public ZNodeResource(@DefaultValue("") @QueryParam("session") String session, @Context UriInfo ui, @Context HttpServletRequest request ) throws IOException { String contextPath = request.getContextPath(); if (contextPath.equals("")) { contextPath = "/"; } if (session.equals("")) { session = null; } else if (!ZooKeeperService.isConnected(contextPath, session)) { throw new WebApplicationException(Response.status( Response.Status.UNAUTHORIZED).build()); } zk = ZooKeeperService.getClient(contextPath, session); }
@PUT @Produces( { MediaType.APPLICATION_JSON, "application/javascript", MediaType.APPLICATION_XML }) @Consumes(MediaType.APPLICATION_OCTET_STREAM) public Response keepAliveSession(@PathParam("session") String session, @Context UriInfo ui, byte[] data) { if (!ZooKeeperService.isConnected(contextPath, session)) { throwNotFound(session, ui); } ZooKeeperService.resetTimer(contextPath, session); return Response.status(Response.Status.OK).build(); }
@DELETE @Produces( { MediaType.APPLICATION_JSON, "application/javascript", MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM }) public void deleteSession(@PathParam("session") String session, @Context UriInfo ui) { ZooKeeperService.close(contextPath, session); }
public ZNodeResource(@Context UriInfo ui) throws IOException { zk = ZooKeeperService.getClient(ui.getBaseUri().toString()); }