Java 类org.apache.zookeeper.server.jersey.jaxb.ZError 实例源码

项目:fuck_zookeeper    文件:ZNodeResource.java   
@PUT
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public void setZNodeAsOctet(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    zk.setData(path, data, version);
}
项目:fuck_zookeeper    文件:ZNodeResource.java   
@DELETE
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM })
public void deleteZNode(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @Context UriInfo ui) throws InterruptedException, KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    zk.delete(path, version);
}
项目:https-github.com-apache-zookeeper    文件:ZNodeResource.java   
@PUT
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public void setZNodeAsOctet(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    zk.setData(path, data, version);
}
项目:https-github.com-apache-zookeeper    文件:ZNodeResource.java   
@DELETE
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM })
public void deleteZNode(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @Context UriInfo ui) throws InterruptedException, KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    zk.delete(path, version);
}
项目:ZooKeeper    文件:ZNodeResource.java   
@PUT
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public void setZNodeAsOctet(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    zk.setData(path, data, version);
}
项目:ZooKeeper    文件:ZNodeResource.java   
@DELETE
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM })
public void deleteZNode(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @Context UriInfo ui) throws InterruptedException, KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    zk.delete(path, version);
}
项目:StreamProcessingInfrastructure    文件:ZNodeResource.java   
@PUT
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public void setZNodeAsOctet(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    zk.setData(path, data, version);
}
项目:StreamProcessingInfrastructure    文件:ZNodeResource.java   
@DELETE
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM })
public void deleteZNode(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @Context UriInfo ui) throws InterruptedException, KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    zk.delete(path, version);
}
项目:bigstreams    文件:ZNodeResource.java   
@PUT
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public void setZNodeAsOctet(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    zk.setData(path, data, version);
}
项目:bigstreams    文件:ZNodeResource.java   
@DELETE
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM })
public void deleteZNode(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @Context UriInfo ui) throws InterruptedException, KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    zk.delete(path, version);
}
项目:bigstreams    文件:ZNodeResource.java   
@PUT
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public void setZNodeAsOctet(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    zk.setData(path, data, version);
}
项目:bigstreams    文件:ZNodeResource.java   
@DELETE
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM })
public void deleteZNode(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @Context UriInfo ui) throws InterruptedException, KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    zk.delete(path, version);
}
项目:SecureKeeper    文件:ZNodeResource.java   
@PUT
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public void setZNodeAsOctet(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    zk.setData(path, data, version);
}
项目:SecureKeeper    文件:ZNodeResource.java   
@DELETE
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM })
public void deleteZNode(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @Context UriInfo ui) throws InterruptedException, KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    zk.delete(path, version);
}
项目:SecureKeeper    文件:ZNodeResource.java   
@PUT
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public void setZNodeAsOctet(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    zk.setData(path, data, version);
}
项目:SecureKeeper    文件:ZNodeResource.java   
@DELETE
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM })
public void deleteZNode(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @Context UriInfo ui) throws InterruptedException, KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    zk.delete(path, version);
}
项目:StreamBench    文件:ZNodeResource.java   
@PUT
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public void setZNodeAsOctet(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    zk.setData(path, data, version);
}
项目:StreamBench    文件:ZNodeResource.java   
@DELETE
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM })
public void deleteZNode(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @Context UriInfo ui) throws InterruptedException, KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    zk.delete(path, version);
}
项目:LoadBalanced_zk    文件:ZNodeResource.java   
@PUT
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public void setZNodeAsOctet(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    zk.setData(path, data, version);
}
项目:LoadBalanced_zk    文件:ZNodeResource.java   
@DELETE
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM })
public void deleteZNode(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @Context UriInfo ui) throws InterruptedException, KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    zk.delete(path, version);
}
项目:LoadBalanced_zk    文件:ZNodeResource.java   
@PUT
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public void setZNodeAsOctet(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    zk.setData(path, data, version);
}
项目:LoadBalanced_zk    文件:ZNodeResource.java   
@DELETE
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM })
public void deleteZNode(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @Context UriInfo ui) throws InterruptedException, KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    zk.delete(path, version);
}
项目:zookeeper.dsc    文件:ZNodeResource.java   
@DELETE
@Produces({MediaType.APPLICATION_JSON, "application/javascript",
    MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM})
public void deleteZNode(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @Context UriInfo ui)
    throws InterruptedException, KeeperException
{
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(),
                        path + " bad version " + versionParam)).build());
    }

    zk.delete(path, version);
}
项目:zookeeper-pkg    文件:ZNodeResource.java   
@PUT
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public void setZNodeAsOctet(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    zk.setData(path, data, version);
}
项目:zookeeper-pkg    文件:ZNodeResource.java   
@DELETE
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM })
public void deleteZNode(@PathParam("path") String path,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @Context UriInfo ui) throws InterruptedException, KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    zk.delete(path, version);
}
项目:fuck_zookeeper    文件:SessionsResource.java   
private static void throwNotFound(String session, UriInfo ui)
        throws WebApplicationException {
    throw new WebApplicationException(Response.status(
            Response.Status.NOT_FOUND).entity(
            new ZError(ui.getRequestUri().toString(), session
                    + " not found")).build());
}
项目:fuck_zookeeper    文件:ZNodeResource.java   
@PUT
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML })
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public Response setZNode(
        @PathParam("path") String path,
        @QueryParam("callback") String callback,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("base64") @QueryParam("dataformat") String dataformat,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    Stat stat = zk.setData(path, data, version);

    ZStat zstat = new ZStat(path, ui.getAbsolutePath().toString(), null,
            null, stat.getCzxid(), stat.getMzxid(), stat.getCtime(), stat
                    .getMtime(), stat.getVersion(), stat.getCversion(),
            stat.getAversion(), stat.getEphemeralOwner(), stat
                    .getDataLength(), stat.getNumChildren(), stat
                    .getPzxid());

    return Response.status(Response.Status.OK).entity(
            new JSONWithPadding(zstat, callback)).build();
}
项目:fuck_zookeeper    文件:ZNodeResource.java   
private static void throwNotFound(String path, UriInfo ui)
        throws WebApplicationException {
    throw new WebApplicationException(Response.status(
            Response.Status.NOT_FOUND).entity(
            new ZError(ui.getRequestUri().toString(), path + " not found"))
            .build());
}
项目:fuck_zookeeper    文件:ZErrorWriter.java   
public void writeTo(ZError t, Class<?> type, Type genericType,
        Annotation[] annotations, MediaType mediaType,
        MultivaluedMap<String, Object> httpHeaders,
        OutputStream os)
    throws IOException, WebApplicationException
{
    PrintStream p = new PrintStream(os);
    p.print("Request " + t.request + " failed due to " + t.message);
    p.flush();
}
项目:fuck_zookeeper    文件:RuntimeExceptionMapper.java   
public Response toResponse(RuntimeException e) {
    // don't try to handle jersey exceptions ourselves
    if (e instanceof WebApplicationException) { 
        WebApplicationException ie =(WebApplicationException) e; 
        return ie.getResponse(); 
    } 

    return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
            new ZError(ui.getRequestUri().toString(),
                    "Error processing request due to " + e
                    )).build();
}
项目:https-github.com-apache-zookeeper    文件:SessionsResource.java   
private static void throwNotFound(String session, UriInfo ui)
        throws WebApplicationException {
    throw new WebApplicationException(Response.status(
            Response.Status.NOT_FOUND).entity(
            new ZError(ui.getRequestUri().toString(), session
                    + " not found")).build());
}
项目:https-github.com-apache-zookeeper    文件:ZNodeResource.java   
@PUT
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML })
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public Response setZNode(
        @PathParam("path") String path,
        @QueryParam("callback") String callback,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("base64") @QueryParam("dataformat") String dataformat,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    Stat stat = zk.setData(path, data, version);

    ZStat zstat = new ZStat(path, ui.getAbsolutePath().toString(), null,
            null, stat.getCzxid(), stat.getMzxid(), stat.getCtime(), stat
                    .getMtime(), stat.getVersion(), stat.getCversion(),
            stat.getAversion(), stat.getEphemeralOwner(), stat
                    .getDataLength(), stat.getNumChildren(), stat
                    .getPzxid());

    return Response.status(Response.Status.OK).entity(
            new JSONWithPadding(zstat, callback)).build();
}
项目:https-github.com-apache-zookeeper    文件:ZNodeResource.java   
private static void throwNotFound(String path, UriInfo ui)
        throws WebApplicationException {
    throw new WebApplicationException(Response.status(
            Response.Status.NOT_FOUND).entity(
            new ZError(ui.getRequestUri().toString(), path + " not found"))
            .build());
}
项目:https-github.com-apache-zookeeper    文件:ZErrorWriter.java   
public void writeTo(ZError t, Class<?> type, Type genericType,
        Annotation[] annotations, MediaType mediaType,
        MultivaluedMap<String, Object> httpHeaders,
        OutputStream os)
    throws IOException, WebApplicationException
{
    PrintStream p = new PrintStream(os);
    p.print("Request " + t.request + " failed due to " + t.message);
    p.flush();
}
项目:https-github.com-apache-zookeeper    文件:RuntimeExceptionMapper.java   
public Response toResponse(RuntimeException e) {
    // don't try to handle jersey exceptions ourselves
    if (e instanceof WebApplicationException) { 
        WebApplicationException ie =(WebApplicationException) e; 
        return ie.getResponse(); 
    } 

    return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
            new ZError(ui.getRequestUri().toString(),
                    "Error processing request due to " + e
                    )).build();
}
项目:ZooKeeper    文件:SessionsResource.java   
private static void throwNotFound(String session, UriInfo ui)
        throws WebApplicationException {
    throw new WebApplicationException(Response.status(
            Response.Status.NOT_FOUND).entity(
            new ZError(ui.getRequestUri().toString(), session
                    + " not found")).build());
}
项目:ZooKeeper    文件:ZNodeResource.java   
@PUT
@Produces( { MediaType.APPLICATION_JSON, "application/javascript",
        MediaType.APPLICATION_XML })
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public Response setZNode(
        @PathParam("path") String path,
        @QueryParam("callback") String callback,
        @DefaultValue("-1") @QueryParam("version") String versionParam,
        @DefaultValue("base64") @QueryParam("dataformat") String dataformat,
        @DefaultValue("false") @QueryParam("null") String setNull,
        @Context UriInfo ui, byte[] data) throws InterruptedException,
        KeeperException {
    ensurePathNotNull(path);

    int version;
    try {
        version = Integer.parseInt(versionParam);
    } catch (NumberFormatException e) {
        throw new WebApplicationException(Response.status(
                Response.Status.BAD_REQUEST).entity(
                new ZError(ui.getRequestUri().toString(), path
                        + " bad version " + versionParam)).build());
    }

    if (setNull.equals("true")) {
        data = null;
    }

    Stat stat = zk.setData(path, data, version);

    ZStat zstat = new ZStat(path, ui.getAbsolutePath().toString(), null,
            null, stat.getCzxid(), stat.getMzxid(), stat.getCtime(), stat
                    .getMtime(), stat.getVersion(), stat.getCversion(),
            stat.getAversion(), stat.getEphemeralOwner(), stat
                    .getDataLength(), stat.getNumChildren(), stat
                    .getPzxid());

    return Response.status(Response.Status.OK).entity(
            new JSONWithPadding(zstat, callback)).build();
}
项目:ZooKeeper    文件:ZNodeResource.java   
private static void throwNotFound(String path, UriInfo ui)
        throws WebApplicationException {
    throw new WebApplicationException(Response.status(
            Response.Status.NOT_FOUND).entity(
            new ZError(ui.getRequestUri().toString(), path + " not found"))
            .build());
}
项目:ZooKeeper    文件:ZErrorWriter.java   
public void writeTo(ZError t, Class<?> type, Type genericType,
        Annotation[] annotations, MediaType mediaType,
        MultivaluedMap<String, Object> httpHeaders,
        OutputStream os)
    throws IOException, WebApplicationException
{
    PrintStream p = new PrintStream(os);
    p.print("Request " + t.request + " failed due to " + t.message);
    p.flush();
}
项目:ZooKeeper    文件:RuntimeExceptionMapper.java   
public Response toResponse(RuntimeException e) {
    // don't try to handle jersey exceptions ourselves
    if (e instanceof WebApplicationException) { 
        WebApplicationException ie =(WebApplicationException) e; 
        return ie.getResponse(); 
    } 

    return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
            new ZError(ui.getRequestUri().toString(),
                    "Error processing request due to " + e
                    )).build();
}