/** * Creates an entry in the group. In a case the group does not exist already it will be * automatically created. * * @param entryStream the input stream corresponding to the content of the registry entry * @param groupName the relative path to the group * @request {code} "entryStream" : the input stream corresponding to the content of the registry * entry {code} Example : {code:xml} <registry * xlinks:href="http://localhost:8080/portal/rest/registry/"> <GroovyScript2RestLoader * xlinks:href="http://localhost:8080/portal/rest/registry/exo:services/GroovyScript2RestLoader"/> * <Audit xlinks:href="http://localhost:8080/portal/rest/registry/exo:services/Audit"/> * </registry> {code} @LevelAPI Experimental */ @POST @Path("/{groupName:.+}") @Consumes(MediaType.APPLICATION_XML) public Response createEntry( InputStream entryStream, @PathParam("groupName") String groupName, @Context UriInfo uriInfo) { SessionProvider sessionProvider = sessionProviderService.getSessionProvider(null); try { RegistryEntry entry = RegistryEntry.parse(entryStream); regService.createEntry(sessionProvider, normalizePath(groupName), entry); URI location = uriInfo.getRequestUriBuilder().path(entry.getName()).build(); return Response.created(location).build(); } catch (IllegalArgumentException e) { LOG.error("Create registry entry failed", e); throw new WebApplicationException(e); } catch (IOException e) { LOG.error("Create registry entry failed", e); throw new WebApplicationException(e); } catch (SAXException e) { LOG.error("Create registry entry failed", e); throw new WebApplicationException(e); } catch (ParserConfigurationException e) { LOG.error("Create registry entry failed", e); throw new WebApplicationException(e); } catch (RepositoryException e) { LOG.error("Create registry entry failed", e); throw new WebApplicationException(e); } }
/** * {@inheritDoc} * * @see net.sf.hajdbc.util.concurrent.Registry#remove(java.lang.Object) */ @Override public void remove(K key) throws E { RegistryEntry entry = this.store.clear(key); if (entry != null) { entry.getValue().stop(); } }
/** * Returns the corresponding registry entry which wraps a node of type "exo:registryEntry" * * @param entryPath The relative path to the registry entry * @response {code} "entryStream" : the output stream corresponding registry entry which wraps a * node of type "exo:registryEntry {code} Example : {code:xml} <Audit * jcr:primaryType="exo:registryEntry"> <adminIdentity jcr:primaryType="nt:unstructured" * value="*:/Platform/Administrators"/> </Audit> {code} @LevelAPI Experimental */ @GET @Path("/{entryPath:.+}") @Produces(MediaType.APPLICATION_XML) public Response getEntry(@PathParam("entryPath") String entryPath) { SessionProvider sessionProvider = sessionProviderService.getSessionProvider(null); try { RegistryEntry entry; entry = regService.getEntry(sessionProvider, normalizePath(entryPath)); return Response.ok(new DOMSource(entry.getDocument())).build(); } catch (PathNotFoundException e) { return Response.status(Response.Status.NOT_FOUND).build(); } catch (RepositoryException e) { LOG.error("Get registry entry failed", e); throw new WebApplicationException(e); } }
/** * {@inheritDoc} * * @see net.sf.hajdbc.util.concurrent.Registry#get(java.lang.Object, java.lang.Object) */ @Override public V get(K key, C context) throws E { RegistryEntry entry = this.store.get(key); if (entry != null) { return entry.getValue(); } V value = this.factory.create(key, context); entry = new RegistryEntry(value); RegistryEntry existing = this.store.setIfAbsent(key, entry); if (existing != null) { return existing.getValue(); } try { value.start(); entry.started(); return value; } catch (Exception e) { this.store.clear(key); try { value.stop(); } catch (Exception re) { this.logger.log(Level.INFO, re); } throw this.exceptionFactory.createException(e); } }