@PUT @Path("/{uri}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "changeDocumentCollections: adds/removes Document to/from the specified Collections") public Response changeDocumentCollections(@PathParam("uri") String uri, CollectionParams params) { DocumentManagement docMgr = getDocManager(); try { int cnt = 0; if (params.add) { cnt = docMgr.addDocumentToCollections(uri, params.collections); } else { cnt = docMgr.removeDocumentFromCollections(uri, params.collections); } return Response.ok(cnt).build(); } catch (Exception ex) { logger.error("changeDocumentCollections.error", ex); throw new WebApplicationException(ex, Status.INTERNAL_SERVER_ERROR); //return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ex.getMessage()).build(); } } }
@ManagedOperation(description="Add Document to Collection") @ManagedOperationParameters({ @ManagedOperationParameter(name = "uri", description = "Document identifier"), @ManagedOperationParameter(name = "clnName", description = "Collection name")}) public int addDocumentToCollection(String uri, String clnName) { Collection cln = this.schemaManager.getEntity().getCollection(clnName); if (cln != null) { return docManager.addDocumentToCollections(uri, new String[] {clnName}); } logger.info("addDocumentToCollection; no collection found for name: {}", clnName); return 0; }