2 * This document is a part of the source code and related artifacts
3 * for CollectionSpace, an open source collections management system
4 * for museums and related institutions:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright 2009 University of California at Berkeley
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
16 * https://source.collectionspace.org/collection-space/LICENSE.txt
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
24 package org.collectionspace.services.organization;
26 import java.util.List;
28 import javax.ws.rs.Consumes;
29 import javax.ws.rs.DELETE;
30 import javax.ws.rs.GET;
31 import javax.ws.rs.POST;
32 import javax.ws.rs.PUT;
33 import javax.ws.rs.Path;
34 import javax.ws.rs.PathParam;
35 import javax.ws.rs.Produces;
36 import javax.ws.rs.QueryParam;
37 import javax.ws.rs.WebApplicationException;
38 import javax.ws.rs.core.Context;
39 import javax.ws.rs.core.MultivaluedMap;
40 import javax.ws.rs.core.Response;
41 import javax.ws.rs.core.UriBuilder;
42 import javax.ws.rs.core.UriInfo;
44 import org.collectionspace.services.OrgAuthorityJAXBSchema;
45 import org.collectionspace.services.OrganizationJAXBSchema;
46 import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
47 import org.collectionspace.services.common.ClientType;
48 import org.collectionspace.services.common.ServiceMain;
49 import org.collectionspace.services.common.authorityref.AuthorityRefDocList;
50 import org.collectionspace.services.common.authorityref.AuthorityRefList;
51 //import org.collectionspace.services.common.context.MultipartServiceContext;
52 //import org.collectionspace.services.common.context.MultipartServiceContextFactory;
53 import org.collectionspace.services.common.context.MultipartServiceContextImpl;
54 //import org.collectionspace.services.common.context.MultipartServiceContextFactory;
55 import org.collectionspace.services.common.context.ServiceBindingUtils;
56 import org.collectionspace.services.common.context.ServiceContext;
57 import org.collectionspace.services.common.document.BadRequestException;
58 import org.collectionspace.services.common.document.DocumentFilter;
59 import org.collectionspace.services.common.document.DocumentHandler;
60 import org.collectionspace.services.common.document.DocumentNotFoundException;
61 import org.collectionspace.services.common.document.DocumentWrapper;
62 import org.collectionspace.services.common.query.IQueryManager;
63 import org.collectionspace.services.common.repository.RepositoryClient;
64 import org.collectionspace.services.contact.ContactResource;
65 import org.collectionspace.services.contact.ContactsCommon;
66 import org.collectionspace.services.contact.ContactsCommonList;
67 import org.collectionspace.services.contact.ContactJAXBSchema;
68 import org.collectionspace.services.contact.nuxeo.ContactDocumentModelHandler;
69 import org.collectionspace.services.common.security.UnauthorizedException;
70 import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
71 import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
72 import org.collectionspace.services.organization.nuxeo.OrganizationDocumentModelHandler;
73 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
74 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
75 import org.jboss.resteasy.util.HttpResponseCodes;
76 import org.nuxeo.ecm.core.api.DocumentModel;
77 import org.slf4j.Logger;
78 import org.slf4j.LoggerFactory;
81 * The Class OrgAuthorityResource.
83 @Path("/orgauthorities")
84 @Consumes("multipart/mixed")
85 @Produces("multipart/mixed")
86 public class OrgAuthorityResource extends
87 AbstractMultiPartCollectionSpaceResourceImpl {
89 /** The Constant orgAuthorityServiceName. */
90 private final static String orgAuthorityServiceName = "orgauthorities";
92 /** The Constant organizationServiceName. */
93 private final static String organizationServiceName = "organizations";
96 final Logger logger = LoggerFactory.getLogger(OrgAuthorityResource.class);
97 //FIXME retrieve client type from configuration
98 /** The Constant CLIENT_TYPE. */
99 final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType();
101 /** The contact resource. */
102 private ContactResource contactResource = new ContactResource();
105 * Instantiates a new org authority resource.
107 public OrgAuthorityResource() {
112 * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString()
115 protected String getVersionString() {
116 /** The last change revision. */
117 final String lastChangeRevision = "$LastChangedRevision$";
118 return lastChangeRevision;
122 * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName()
125 public String getServiceName() {
126 return orgAuthorityServiceName;
130 * @see org.collectionspace.services.common.CollectionSpaceResource#getCommonPartClass()
133 public Class<OrgauthoritiesCommon> getCommonPartClass() {
134 return OrgauthoritiesCommon.class;
138 * Gets the item service name.
140 * @return the item service name
142 public String getItemServiceName() {
143 return organizationServiceName;
147 * Gets the contact service name.
149 * @return the contact service name
151 public String getContactServiceName() {
152 return contactResource.getServiceName();
156 * Creates the item document handler.
159 * @param inAuthority the in authority
161 * @return the document handler
163 * @throws Exception the exception
165 private DocumentHandler createItemDocumentHandler(
166 ServiceContext<MultipartInput, MultipartOutput> ctx,
167 String inAuthority) throws Exception {
168 OrganizationDocumentModelHandler docHandler = (OrganizationDocumentModelHandler)createDocumentHandler(
170 ctx.getCommonPartLabel(getItemServiceName()),
171 OrganizationsCommon.class);
172 docHandler.setInAuthority(inAuthority);
178 * Creates the contact document handler.
181 * @param inAuthority the in authority
182 * @param inItem the in item
184 * @return the document handler
186 * @throws Exception the exception
188 private DocumentHandler createContactDocumentHandler(
189 ServiceContext<MultipartInput, MultipartOutput> ctx, String inAuthority,
190 String inItem) throws Exception {
192 ContactDocumentModelHandler docHandler = (ContactDocumentModelHandler)createDocumentHandler(
194 ctx.getCommonPartLabel(getContactServiceName()),
195 ContactsCommon.class);
196 docHandler.setInAuthority(inAuthority);
197 docHandler.setInItem(inItem);
203 * Creates the org authority.
205 * @param input the input
207 * @return the response
210 public Response createOrgAuthority(MultipartInput input) {
212 ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(input);
213 DocumentHandler handler = createDocumentHandler(ctx);
214 String csid = getRepositoryClient(ctx).create(ctx, handler);
215 UriBuilder path = UriBuilder.fromResource(OrgAuthorityResource.class);
216 path.path("" + csid);
217 Response response = Response.created(path.build()).build();
219 } catch (BadRequestException bre) {
220 Response response = Response.status(
221 Response.Status.BAD_REQUEST).entity("Create failed reason " + bre.getErrorReason()).type("text/plain").build();
222 throw new WebApplicationException(response);
223 } catch (UnauthorizedException ue) {
224 Response response = Response.status(
225 Response.Status.UNAUTHORIZED).entity("Create failed reason " + ue.getErrorReason()).type("text/plain").build();
226 throw new WebApplicationException(response);
227 } catch (Exception e) {
228 if (logger.isDebugEnabled()) {
229 logger.debug("Caught exception in createOrgAuthority", e);
231 Response response = Response.status(
232 Response.Status.INTERNAL_SERVER_ERROR).entity("Create failed").type("text/plain").build();
233 throw new WebApplicationException(response);
238 * Gets the org authority by name.
240 * @param specifier the specifier
242 * @return the org authority by name
245 @Path("urn:cspace:name({specifier})")
246 public MultipartOutput getOrgAuthorityByName(@PathParam("specifier") String specifier) {
247 if (specifier == null) {
248 logger.error("getOrgAuthority: missing name!");
249 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
250 "get failed on OrgAuthority (missing specifier)").type(
251 "text/plain").build();
252 throw new WebApplicationException(response);
255 OrgAuthorityJAXBSchema.ORGAUTHORITIES_COMMON+
256 ":"+OrgAuthorityJAXBSchema.DISPLAY_NAME+
258 // We only get a single doc - if there are multiple,
259 // it is an error in use.
261 if (logger.isDebugEnabled()) {
262 logger.debug("getOrgAuthority with name=" + specifier);
264 MultipartOutput result = null;
266 ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
267 DocumentHandler handler = createDocumentHandler(ctx);
268 DocumentFilter myFilter = new DocumentFilter(whereClause, 0, 1);
269 handler.setDocumentFilter(myFilter);
270 getRepositoryClient(ctx).get(ctx, handler);
271 result = (MultipartOutput) ctx.getOutput();
272 } catch (UnauthorizedException ue) {
273 Response response = Response.status(
274 Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build();
275 throw new WebApplicationException(response);
276 } catch (DocumentNotFoundException dnfe) {
277 if (logger.isDebugEnabled()) {
278 logger.debug("getOrgAuthority", dnfe);
280 Response response = Response.status(Response.Status.NOT_FOUND).entity(
281 "Get failed on OrgAuthority spec=" + specifier).type(
282 "text/plain").build();
283 throw new WebApplicationException(response);
284 } catch (Exception e) {
285 if (logger.isDebugEnabled()) {
286 logger.debug("getOrgAuthority", e);
288 Response response = Response.status(
289 Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
290 throw new WebApplicationException(response);
292 if (result == null) {
293 Response response = Response.status(Response.Status.NOT_FOUND).entity(
294 "Get failed, the requested OrgAuthority spec:" + specifier + ": was not found.").type(
295 "text/plain").build();
296 throw new WebApplicationException(response);
302 * Gets the entities referencing this Organization instance. The service type
303 * can be passed as a query param "type", and must match a configured type
304 * for the service bindings. If not set, the type defaults to
305 * ServiceBindingUtils.SERVICE_TYPE_PROCEDURE.
308 * @param csid the parent csid
309 * @param itemcsid the person csid
312 * @return the info for the referencing objects
315 @Path("{csid}/items/{itemcsid}/refObjs")
316 @Produces("application/xml")
317 public AuthorityRefDocList getReferencingObjects(
318 @PathParam("csid") String parentcsid,
319 @PathParam("itemcsid") String itemcsid,
320 @Context UriInfo ui) {
321 AuthorityRefDocList authRefDocList = null;
322 if (logger.isDebugEnabled()) {
323 logger.debug("getReferencingObjects with parentcsid="
324 + parentcsid + " and itemcsid=" + itemcsid);
326 if (parentcsid == null || "".equals(parentcsid)
327 || itemcsid == null || "".equals(itemcsid)) {
328 logger.error("getPerson: missing parentcsid or itemcsid!");
329 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
330 "get failed on Person with parentcsid="
331 + parentcsid + " and itemcsid=" + itemcsid).type(
332 "text/plain").build();
333 throw new WebApplicationException(response);
336 // Note that we have to create the service context for the Items, not the main service
337 MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
338 ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(), queryParams);
339 DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
340 RepositoryClient repoClient = getRepositoryClient(ctx);
341 DocumentFilter myFilter = handler.getDocumentFilter();
342 String serviceType = ServiceBindingUtils.SERVICE_TYPE_PROCEDURE;
343 List<String> list = queryParams.remove(ServiceBindingUtils.SERVICE_TYPE_PROP);
345 serviceType = list.get(0);
347 DocumentWrapper<DocumentModel> docWrapper = repoClient.getDoc(ctx, itemcsid);
348 DocumentModel docModel = docWrapper.getWrappedObject();
349 String refName = (String)docModel.getPropertyValue(OrganizationJAXBSchema.REF_NAME);
351 authRefDocList = RefNameServiceUtils.getAuthorityRefDocs(ctx,
355 myFilter.getPageSize(), myFilter.getStartPage(), true );
356 } catch (UnauthorizedException ue) {
357 Response response = Response.status(
358 Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build();
359 throw new WebApplicationException(response);
360 } catch (DocumentNotFoundException dnfe) {
361 if (logger.isDebugEnabled()) {
362 logger.debug("getReferencingObjects", dnfe);
364 Response response = Response.status(Response.Status.NOT_FOUND).entity(
365 "GetReferencingObjects failed with parentcsid="
366 + parentcsid + " and itemcsid=" + itemcsid).type(
367 "text/plain").build();
368 throw new WebApplicationException(response);
369 } catch (Exception e) { // Includes DocumentException
370 if (logger.isDebugEnabled()) {
371 logger.debug("GetReferencingObjects", e);
373 Response response = Response.status(
374 Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
375 throw new WebApplicationException(response);
377 if (authRefDocList == null) {
378 Response response = Response.status(Response.Status.NOT_FOUND).entity(
379 "Get failed, the requested Person CSID:" + itemcsid + ": was not found.").type(
380 "text/plain").build();
381 throw new WebApplicationException(response);
383 return authRefDocList;
388 * Gets the org authority.
390 * @param csid the csid
392 * @return the org authority
396 public MultipartOutput getOrgAuthority(@PathParam("csid") String csid) {
398 logger.error("getOrgAuthority: missing csid!");
399 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
400 "get failed on OrgAuthority csid=" + csid).type(
401 "text/plain").build();
402 throw new WebApplicationException(response);
404 if (logger.isDebugEnabled()) {
405 logger.debug("getOrgAuthority with path(id)=" + csid);
407 MultipartOutput result = null;
409 ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
410 DocumentHandler handler = createDocumentHandler(ctx);
411 getRepositoryClient(ctx).get(ctx, csid, handler);
412 result = (MultipartOutput) ctx.getOutput();
413 } catch (UnauthorizedException ue) {
414 Response response = Response.status(
415 Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build();
416 throw new WebApplicationException(response);
417 } catch (DocumentNotFoundException dnfe) {
418 if (logger.isDebugEnabled()) {
419 logger.debug("getOrgAuthority", dnfe);
421 Response response = Response.status(Response.Status.NOT_FOUND).entity(
422 "Get failed on OrgAuthority csid=" + csid).type(
423 "text/plain").build();
424 throw new WebApplicationException(response);
425 } catch (Exception e) {
426 if (logger.isDebugEnabled()) {
427 logger.debug("getOrgAuthority", e);
429 Response response = Response.status(
430 Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
431 throw new WebApplicationException(response);
433 if (result == null) {
434 Response response = Response.status(Response.Status.NOT_FOUND).entity(
435 "Get failed, the requested OrgAuthority CSID:" + csid + ": was not found.").type(
436 "text/plain").build();
437 throw new WebApplicationException(response);
443 * Gets the org authority list.
447 * @return the org authority list
450 @Produces("application/xml")
451 public OrgauthoritiesCommonList getOrgAuthorityList(@Context UriInfo ui) {
452 OrgauthoritiesCommonList orgAuthorityObjectList = new OrgauthoritiesCommonList();
454 MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
455 ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
456 DocumentHandler handler = createDocumentHandler(ctx);
457 DocumentFilter myFilter = handler.getDocumentFilter();
458 String nameQ = queryParams.getFirst("refName");
460 myFilter.setWhereClause("orgauthorities_common:refName='" + nameQ + "'");
462 getRepositoryClient(ctx).getFiltered(ctx, handler);
463 orgAuthorityObjectList = (OrgauthoritiesCommonList) handler.getCommonPartList();
464 } catch (UnauthorizedException ue) {
465 Response response = Response.status(
466 Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
467 throw new WebApplicationException(response);
468 } catch (Exception e) {
469 if (logger.isDebugEnabled()) {
470 logger.debug("Caught exception in getOrgAuthorityList", e);
472 Response response = Response.status(
473 Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
474 throw new WebApplicationException(response);
476 return orgAuthorityObjectList;
480 * Update org authority.
482 * @param csid the csid
483 * @param theUpdate the the update
485 * @return the multipart output
489 public MultipartOutput updateOrgAuthority(
490 @PathParam("csid") String csid,
491 MultipartInput theUpdate) {
492 if (logger.isDebugEnabled()) {
493 logger.debug("updateOrgAuthority with csid=" + csid);
495 if (csid == null || "".equals(csid)) {
496 logger.error("updateOrgAuthority: missing csid!");
497 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
498 "update failed on OrgAuthority csid=" + csid).type(
499 "text/plain").build();
500 throw new WebApplicationException(response);
502 MultipartOutput result = null;
504 ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(theUpdate);
505 DocumentHandler handler = createDocumentHandler(ctx);
506 getRepositoryClient(ctx).update(ctx, csid, handler);
507 result = (MultipartOutput) ctx.getOutput();
508 } catch (BadRequestException bre) {
509 Response response = Response.status(
510 Response.Status.BAD_REQUEST).entity("Create failed reason " + bre.getErrorReason()).type("text/plain").build();
511 throw new WebApplicationException(response);
512 } catch (UnauthorizedException ue) {
513 Response response = Response.status(
514 Response.Status.UNAUTHORIZED).entity("Update failed reason " + ue.getErrorReason()).type("text/plain").build();
515 throw new WebApplicationException(response);
516 } catch (DocumentNotFoundException dnfe) {
517 if (logger.isDebugEnabled()) {
518 logger.debug("caught exception in updateOrgAuthority", dnfe);
520 Response response = Response.status(Response.Status.NOT_FOUND).entity(
521 "Update failed on OrgAuthority csid=" + csid).type(
522 "text/plain").build();
523 throw new WebApplicationException(response);
524 } catch (Exception e) {
525 Response response = Response.status(
526 Response.Status.INTERNAL_SERVER_ERROR).entity("Update failed").type("text/plain").build();
527 throw new WebApplicationException(response);
533 * Delete org authority.
535 * @param csid the csid
537 * @return the response
541 public Response deleteOrgAuthority(@PathParam("csid") String csid) {
543 if (logger.isDebugEnabled()) {
544 logger.debug("deleteOrgAuthority with csid=" + csid);
546 if (csid == null || "".equals(csid)) {
547 logger.error("deleteOrgAuthority: missing csid!");
548 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
549 "delete failed on OrgAuthority csid=" + csid).type(
550 "text/plain").build();
551 throw new WebApplicationException(response);
554 ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
555 getRepositoryClient(ctx).delete(ctx, csid);
556 return Response.status(HttpResponseCodes.SC_OK).build();
557 } catch (UnauthorizedException ue) {
558 Response response = Response.status(
559 Response.Status.UNAUTHORIZED).entity("Delete failed reason " + ue.getErrorReason()).type("text/plain").build();
560 throw new WebApplicationException(response);
561 } catch (DocumentNotFoundException dnfe) {
562 if (logger.isDebugEnabled()) {
563 logger.debug("caught exception in deleteOrgAuthority", dnfe);
565 Response response = Response.status(Response.Status.NOT_FOUND).entity(
566 "Delete failed on OrgAuthority csid=" + csid).type(
567 "text/plain").build();
568 throw new WebApplicationException(response);
569 } catch (Exception e) {
570 Response response = Response.status(
571 Response.Status.INTERNAL_SERVER_ERROR).entity("Delete failed").type("text/plain").build();
572 throw new WebApplicationException(response);
576 /*************************************************************************
577 * Organization parts - this is a sub-resource of OrgAuthority
580 * @return org response
581 *************************************************************************/
583 @Path("{csid}/items")
584 public Response createOrganization(@PathParam("csid") String parentcsid, MultipartInput input) {
586 ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(),
588 DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
589 String itemcsid = getRepositoryClient(ctx).create(ctx, handler);
590 UriBuilder path = UriBuilder.fromResource(OrgAuthorityResource.class);
591 path.path(parentcsid + "/items/" + itemcsid);
592 Response response = Response.created(path.build()).build();
594 } catch (BadRequestException bre) {
595 Response response = Response.status(
596 Response.Status.BAD_REQUEST).entity("Create failed reason " + bre.getErrorReason()).type("text/plain").build();
597 throw new WebApplicationException(response);
598 } catch (UnauthorizedException ue) {
599 Response response = Response.status(
600 Response.Status.UNAUTHORIZED).entity("Create failed reason " + ue.getErrorReason()).type("text/plain").build();
601 throw new WebApplicationException(response);
602 } catch (Exception e) {
603 if (logger.isDebugEnabled()) {
604 logger.debug("Caught exception in createOrganization", e);
606 Response response = Response.status(
607 Response.Status.INTERNAL_SERVER_ERROR).entity("Create failed").type("text/plain").build();
608 throw new WebApplicationException(response);
613 * Gets the organization.
616 * @param csid The organization authority (parent) CSID.
617 * @param itemcsid The organization item CSID.
619 * @return the organization.
622 @Path("{csid}/items/{itemcsid}")
623 public MultipartOutput getOrganization(
624 @PathParam("csid") String parentcsid,
625 @PathParam("itemcsid") String itemcsid) {
626 if (logger.isDebugEnabled()) {
627 logger.debug("getOrganization with parentcsid=" + parentcsid + " and itemcsid=" + itemcsid);
629 if (parentcsid == null || "".equals(parentcsid)) {
630 logger.error("getOrganization: missing csid!");
631 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
632 "get failed on Organization csid=" + parentcsid).type(
633 "text/plain").build();
634 throw new WebApplicationException(response);
636 if (itemcsid == null || "".equals(itemcsid)) {
637 logger.error("getOrganization: missing itemcsid!");
638 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
639 "get failed on Organization itemcsid=" + itemcsid).type(
640 "text/plain").build();
641 throw new WebApplicationException(response);
643 MultipartOutput result = null;
645 // Note that we have to create the service context for the Items, not the main service
646 ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName());
647 DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
648 getRepositoryClient(ctx).get(ctx, itemcsid, handler);
649 // TODO should we assert that the item is in the passed orgAuthority?
650 result = (MultipartOutput) ctx.getOutput();
651 } catch (UnauthorizedException ue) {
652 Response response = Response.status(
653 Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build();
654 throw new WebApplicationException(response);
655 } catch (DocumentNotFoundException dnfe) {
656 if (logger.isDebugEnabled()) {
657 logger.debug("getOrganization", dnfe);
659 Response response = Response.status(Response.Status.NOT_FOUND).entity(
660 "Get failed on Organization csid=" + itemcsid).type(
661 "text/plain").build();
662 throw new WebApplicationException(response);
663 } catch (Exception e) {
664 if (logger.isDebugEnabled()) {
665 logger.debug("getOrganization", e);
667 Response response = Response.status(
668 Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
669 throw new WebApplicationException(response);
671 if (result == null) {
672 Response response = Response.status(Response.Status.NOT_FOUND).entity(
673 "Get failed, the requested Organization CSID:" + itemcsid + ": was not found.").type(
674 "text/plain").build();
675 throw new WebApplicationException(response);
681 * Gets the authority refs for an Organization item.
684 * @param csid The organization authority (parent) CSID.
685 * @param itemcsid The organization item CSID.
688 * @return the authority refs for the Organization item.
691 @Path("{csid}/items/{itemcsid}/authorityrefs")
692 @Produces("application/xml")
693 public AuthorityRefList getOrganizationAuthorityRefs(
694 @PathParam("csid") String parentcsid,
695 @PathParam("itemcsid") String itemcsid,
696 @Context UriInfo ui) {
697 AuthorityRefList authRefList = null;
699 MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
700 ServiceContext<MultipartInput, MultipartOutput> ctx =
701 createServiceContext(getItemServiceName(), queryParams);
702 RemoteDocumentModelHandlerImpl handler =
703 (RemoteDocumentModelHandlerImpl) createItemDocumentHandler(ctx, parentcsid);
704 DocumentWrapper<DocumentModel> docWrapper =
705 getRepositoryClient(ctx).getDoc(ctx, itemcsid);
706 List<String> authRefFields =
707 ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(
708 ServiceBindingUtils.AUTH_REF_PROP, ServiceBindingUtils.QUALIFIED_PROP_NAMES);
709 authRefList = handler.getAuthorityRefs(docWrapper, authRefFields);
710 } catch (UnauthorizedException ue) {
711 Response response = Response.status(
712 Response.Status.UNAUTHORIZED).entity("Failed to retrieve authority references: reason " + ue.getErrorReason()).type("text/plain").build();
713 throw new WebApplicationException(response);
714 } catch (Exception e) {
715 if (logger.isDebugEnabled()) {
716 logger.debug("Caught exception in getAuthorityRefs", e);
718 Response response = Response.status(
719 Response.Status.INTERNAL_SERVER_ERROR).entity("Failed to retrieve authority references").type("text/plain").build();
720 throw new WebApplicationException(response);
726 * Gets the organization list.
728 * @param parentcsid the parentcsid
729 * @param partialTerm the partial term
732 * @return the organization list
735 @Path("{csid}/items")
736 @Produces("application/xml")
737 public OrganizationsCommonList getOrganizationList(
738 @PathParam("csid") String parentcsid,
739 @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
740 @Context UriInfo ui) {
741 OrganizationsCommonList organizationObjectList = new OrganizationsCommonList();
743 MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
744 // Note that docType defaults to the ServiceName, so we're fine with that.
745 ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(),
747 DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
748 DocumentFilter myFilter = handler.getDocumentFilter(); //new DocumentFilter();
749 myFilter.setWhereClause(OrganizationJAXBSchema.ORGANIZATIONS_COMMON +
750 ":" + OrganizationJAXBSchema.IN_AUTHORITY + "=" +
751 "'" + parentcsid + "'");
753 // AND organizations_common:displayName LIKE '%partialTerm%'
754 if (partialTerm != null && !partialTerm.isEmpty()) {
755 String ptClause = OrganizationJAXBSchema.ORGANIZATIONS_COMMON +
756 ":" + OrganizationJAXBSchema.DISPLAY_NAME +
757 " LIKE " + "'%" + partialTerm + "%'";
758 myFilter.appendWhereClause(ptClause, IQueryManager.SEARCH_QUALIFIER_AND);
760 getRepositoryClient(ctx).getFiltered(ctx, handler);
761 organizationObjectList = (OrganizationsCommonList) handler.getCommonPartList();
762 } catch (UnauthorizedException ue) {
763 Response response = Response.status(
764 Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
765 throw new WebApplicationException(response);
766 } catch (Exception e) {
767 if (logger.isDebugEnabled()) {
768 logger.debug("Caught exception in getOrganizationList", e);
770 Response response = Response.status(
771 Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
772 throw new WebApplicationException(response);
774 return organizationObjectList;
778 * Gets the organization list by auth name.
780 * @param parentSpecifier the parent specifier
781 * @param partialTerm the partial term
784 * @return the organization list by auth name
787 @Path("urn:cspace:name({specifier})/items")
788 @Produces("application/xml")
789 public OrganizationsCommonList getOrganizationListByAuthName(
790 @PathParam("specifier") String parentSpecifier,
791 @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
792 @Context UriInfo ui) {
793 OrganizationsCommonList personObjectList = new OrganizationsCommonList();
795 MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
797 OrgAuthorityJAXBSchema.ORGAUTHORITIES_COMMON+
798 ":" + OrgAuthorityJAXBSchema.DISPLAY_NAME+
799 "='" + parentSpecifier+"'";
800 // Need to get an Authority by name
801 ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
802 String parentcsid = getRepositoryClient(ctx).findDocCSID(ctx, whereClause);
804 ctx = createServiceContext(getItemServiceName(), queryParams);
805 DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
806 DocumentFilter myFilter = handler.getDocumentFilter();// new DocumentFilter();
808 // Add the where clause "organizations_common:inAuthority='" + parentcsid + "'"
809 myFilter.setWhereClause(OrganizationJAXBSchema.ORGANIZATIONS_COMMON + ":" +
810 OrganizationJAXBSchema.IN_AUTHORITY + "='" + parentcsid + "'");
812 // AND organizations_common:displayName LIKE '%partialTerm%'
813 if (partialTerm != null && !partialTerm.isEmpty()) {
814 String ptClause = OrganizationJAXBSchema.ORGANIZATIONS_COMMON + ":" +
815 OrganizationJAXBSchema.DISPLAY_NAME +
817 "'%" + partialTerm + "%'";
818 myFilter.appendWhereClause(ptClause, IQueryManager.SEARCH_QUALIFIER_AND);
820 getRepositoryClient(ctx).getFiltered(ctx, handler);
821 personObjectList = (OrganizationsCommonList) handler.getCommonPartList();
822 } catch (UnauthorizedException ue) {
823 Response response = Response.status(
824 Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
825 throw new WebApplicationException(response);
826 } catch (Exception e) {
827 if (logger.isDebugEnabled()) {
828 logger.debug("Caught exception in getOrganizationListByAuthName", e);
830 Response response = Response.status(
831 Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
832 throw new WebApplicationException(response);
834 return personObjectList;
838 * Update organization.
840 * @param parentcsid the parentcsid
841 * @param itemcsid the itemcsid
842 * @param theUpdate the the update
844 * @return the multipart output
847 @Path("{csid}/items/{itemcsid}")
848 public MultipartOutput updateOrganization(
849 @PathParam("csid") String parentcsid,
850 @PathParam("itemcsid") String itemcsid,
851 MultipartInput theUpdate) {
852 if (logger.isDebugEnabled()) {
853 logger.debug("updateOrganization with parentcsid=" + parentcsid + " and itemcsid=" + itemcsid);
855 if (parentcsid == null || "".equals(parentcsid)) {
856 logger.error("updateOrganization: missing csid!");
857 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
858 "update failed on Organization parentcsid=" + parentcsid).type(
859 "text/plain").build();
860 throw new WebApplicationException(response);
862 if (itemcsid == null || "".equals(itemcsid)) {
863 logger.error("updateOrganization: missing itemcsid!");
864 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
865 "update failed on Organization=" + itemcsid).type(
866 "text/plain").build();
867 throw new WebApplicationException(response);
869 MultipartOutput result = null;
871 // Note that we have to create the service context for the Items, not the main service
872 ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(),
874 DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
875 getRepositoryClient(ctx).update(ctx, itemcsid, handler);
876 result = (MultipartOutput) ctx.getOutput();
877 } catch (BadRequestException bre) {
878 Response response = Response.status(
879 Response.Status.BAD_REQUEST).entity("Create failed reason " + bre.getErrorReason()).type("text/plain").build();
880 throw new WebApplicationException(response);
881 } catch (UnauthorizedException ue) {
882 Response response = Response.status(
883 Response.Status.UNAUTHORIZED).entity("Update failed reason " + ue.getErrorReason()).type("text/plain").build();
884 throw new WebApplicationException(response);
885 } catch (DocumentNotFoundException dnfe) {
886 if (logger.isDebugEnabled()) {
887 logger.debug("caught exception in updateOrganization", dnfe);
889 Response response = Response.status(Response.Status.NOT_FOUND).entity(
890 "Update failed on Organization csid=" + itemcsid).type(
891 "text/plain").build();
892 throw new WebApplicationException(response);
893 } catch (Exception e) {
894 Response response = Response.status(
895 Response.Status.INTERNAL_SERVER_ERROR).entity("Update failed").type("text/plain").build();
896 throw new WebApplicationException(response);
902 * Delete organization.
904 * @param parentcsid the parentcsid
905 * @param itemcsid the itemcsid
907 * @return the response
910 @Path("{csid}/items/{itemcsid}")
911 public Response deleteOrganization(
912 @PathParam("csid") String parentcsid,
913 @PathParam("itemcsid") String itemcsid) {
914 if (logger.isDebugEnabled()) {
915 logger.debug("deleteOrganization with parentcsid=" + parentcsid + " and itemcsid=" + itemcsid);
917 if (parentcsid == null || "".equals(parentcsid)) {
918 logger.error("deleteOrganization: missing csid!");
919 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
920 "delete failed on Organization parentcsid=" + parentcsid).type(
921 "text/plain").build();
922 throw new WebApplicationException(response);
924 if (itemcsid == null || "".equals(itemcsid)) {
925 logger.error("deleteOrganization: missing itemcsid!");
926 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
927 "delete failed on Organization=" + itemcsid).type(
928 "text/plain").build();
929 throw new WebApplicationException(response);
932 // Note that we have to create the service context for the Items, not the main service
933 ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName());
934 getRepositoryClient(ctx).delete(ctx, itemcsid);
935 return Response.status(HttpResponseCodes.SC_OK).build();
936 } catch (UnauthorizedException ue) {
937 Response response = Response.status(
938 Response.Status.UNAUTHORIZED).entity("Delete failed reason " + ue.getErrorReason()).type("text/plain").build();
939 throw new WebApplicationException(response);
940 } catch (DocumentNotFoundException dnfe) {
941 if (logger.isDebugEnabled()) {
942 logger.debug("caught exception in deleteOrganization", dnfe);
944 Response response = Response.status(Response.Status.NOT_FOUND).entity(
945 "Delete failed on Organization itemcsid=" + itemcsid).type(
946 "text/plain").build();
947 throw new WebApplicationException(response);
948 } catch (Exception e) {
949 Response response = Response.status(
950 Response.Status.INTERNAL_SERVER_ERROR).entity("Delete failed").type("text/plain").build();
951 throw new WebApplicationException(response);
956 /*************************************************************************
957 * Contact parts - this is a sub-resource of Organization (or "item")
962 *************************************************************************/
964 @Path("{parentcsid}/items/{itemcsid}/contacts")
965 public Response createContact(
966 @PathParam("parentcsid") String parentcsid,
967 @PathParam("itemcsid") String itemcsid,
968 MultipartInput input) {
970 // Note that we have to create the service context and document
971 // handler for the Contact service, not the main service.
972 ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getContactServiceName(), input);
973 DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
974 String csid = getRepositoryClient(ctx).create(ctx, handler);
975 UriBuilder path = UriBuilder.fromResource(OrgAuthorityResource.class);
976 path.path("" + parentcsid + "/items/" + itemcsid + "/contacts/" + csid);
977 Response response = Response.created(path.build()).build();
979 } catch (BadRequestException bre) {
980 Response response = Response.status(
981 Response.Status.BAD_REQUEST).entity("Create failed reason " + bre.getErrorReason()).type("text/plain").build();
982 throw new WebApplicationException(response);
983 } catch (UnauthorizedException ue) {
984 Response response = Response.status(
985 Response.Status.UNAUTHORIZED).entity("Create failed reason " + ue.getErrorReason()).type("text/plain").build();
986 throw new WebApplicationException(response);
987 } catch (Exception e) {
988 if (logger.isDebugEnabled()) {
989 logger.debug("Caught exception in createContact", e);
991 Response response = Response.status(
992 Response.Status.INTERNAL_SERVER_ERROR)
993 .entity("Attempt to create Contact failed.")
994 .type("text/plain").build();
995 throw new WebApplicationException(response);
1001 * Gets the contact list.
1003 * @param parentcsid the parentcsid
1004 * @param itemcsid the itemcsid
1007 * @return the contact list
1010 @Produces({"application/xml"})
1011 @Path("{parentcsid}/items/{itemcsid}/contacts/")
1012 public ContactsCommonList getContactList(
1013 @PathParam("parentcsid") String parentcsid,
1014 @PathParam("itemcsid") String itemcsid,
1015 @Context UriInfo ui) {
1016 ContactsCommonList contactObjectList = new ContactsCommonList();
1018 MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
1019 ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getContactServiceName(),
1021 DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
1022 DocumentFilter myFilter = handler.getDocumentFilter(); //new DocumentFilter();
1023 myFilter.setWhereClause(ContactJAXBSchema.CONTACTS_COMMON + ":" +
1024 ContactJAXBSchema.IN_AUTHORITY +
1025 "='" + parentcsid + "'" +
1026 IQueryManager.SEARCH_QUALIFIER_AND +
1027 ContactJAXBSchema.CONTACTS_COMMON + ":" +
1028 ContactJAXBSchema.IN_ITEM +
1029 "='" + itemcsid + "'" +
1030 IQueryManager.SEARCH_QUALIFIER_AND +
1032 getRepositoryClient(ctx).getFiltered(ctx, handler);
1033 contactObjectList = (ContactsCommonList) handler.getCommonPartList();
1034 } catch (UnauthorizedException ue) {
1035 Response response = Response.status(
1036 Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
1037 throw new WebApplicationException(response);
1038 } catch (Exception e) {
1039 if (logger.isDebugEnabled()) {
1040 logger.debug("Caught exception in getContactsList", e);
1042 Response response = Response.status(
1043 Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
1044 throw new WebApplicationException(response);
1046 return contactObjectList;
1052 * @param parentcsid the parentcsid
1053 * @param itemcsid the itemcsid
1054 * @param csid the csid
1056 * @return the contact
1059 @Path("{parentcsid}/items/{itemcsid}/contacts/{csid}")
1060 public MultipartOutput getContact(
1061 @PathParam("parentcsid") String parentcsid,
1062 @PathParam("itemcsid") String itemcsid,
1063 @PathParam("csid") String csid) {
1064 MultipartOutput result = null;
1065 if (logger.isDebugEnabled()) {
1066 logger.debug("getContact with parentCsid=" + parentcsid +
1067 " itemcsid=" + itemcsid + " csid=" + csid);
1070 // Note that we have to create the service context and document
1071 // handler for the Contact service, not the main service.
1072 ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getContactServiceName());
1073 DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
1074 getRepositoryClient(ctx).get(ctx, csid, handler);
1075 result = (MultipartOutput) ctx.getOutput();
1076 } catch (UnauthorizedException ue) {
1077 Response response = Response.status(
1078 Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build();
1079 throw new WebApplicationException(response);
1080 } catch (DocumentNotFoundException dnfe) {
1081 if (logger.isDebugEnabled()) {
1082 logger.debug("getContact", dnfe);
1084 Response response = Response.status(Response.Status.NOT_FOUND)
1085 .entity("Get failed, the requested Contact CSID:" + csid + ": was not found.")
1086 .type("text/plain").build();
1087 throw new WebApplicationException(response);
1088 } catch (Exception e) {
1089 if (logger.isDebugEnabled()) {
1090 logger.debug("getContact", e);
1092 Response response = Response.status(Response.Status.INTERNAL_SERVER_ERROR)
1093 .entity("Get contact failed")
1094 .type("text/plain").build();
1095 throw new WebApplicationException(response);
1097 if (result == null) {
1098 Response response = Response.status(Response.Status.NOT_FOUND)
1099 .entity("Get failed, the requested Contact CSID:" + csid + ": was not found.")
1100 .type("text/plain").build();
1101 throw new WebApplicationException(response);
1110 * @param parentcsid the parentcsid
1111 * @param itemcsid the itemcsid
1112 * @param csid the csid
1113 * @param theUpdate the the update
1115 * @return the multipart output
1118 @Path("{parentcsid}/items/{itemcsid}/contacts/{csid}")
1119 public MultipartOutput updateContact(
1120 @PathParam("parentcsid") String parentcsid,
1121 @PathParam("itemcsid") String itemcsid,
1122 @PathParam("csid") String csid,
1123 MultipartInput theUpdate) {
1124 if (logger.isDebugEnabled()) {
1125 logger.debug("updateContact with parentcsid=" + parentcsid +
1126 " itemcsid=" + itemcsid + " csid=" + csid);
1128 if (parentcsid == null || parentcsid.trim().isEmpty()) {
1129 logger.error("updateContact: missing csid!");
1130 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
1131 "update failed on Contact parentcsid=" + parentcsid).type(
1132 "text/plain").build();
1133 throw new WebApplicationException(response);
1135 if (itemcsid == null || itemcsid.trim().isEmpty()) {
1136 logger.error("updateContact: missing itemcsid!");
1137 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
1138 "update failed on Contact=" + itemcsid).type(
1139 "text/plain").build();
1140 throw new WebApplicationException(response);
1142 if (csid == null || csid.trim().isEmpty()) {
1143 logger.error("updateContact: missing csid!");
1144 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
1145 "update failed on Contact=" + csid).type(
1146 "text/plain").build();
1147 throw new WebApplicationException(response);
1149 MultipartOutput result = null;
1151 // Note that we have to create the service context and document
1152 // handler for the Contact service, not the main service.
1153 ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getContactServiceName(), theUpdate);
1154 DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid);
1155 getRepositoryClient(ctx).update(ctx, csid, handler);
1156 result = (MultipartOutput) ctx.getOutput();
1157 } catch (BadRequestException bre) {
1158 Response response = Response.status(
1159 Response.Status.BAD_REQUEST).entity("Create failed reason " + bre.getErrorReason()).type("text/plain").build();
1160 throw new WebApplicationException(response);
1161 } catch (UnauthorizedException ue) {
1162 Response response = Response.status(
1163 Response.Status.UNAUTHORIZED).entity("Update failed reason " + ue.getErrorReason()).type("text/plain").build();
1164 throw new WebApplicationException(response);
1165 } catch (DocumentNotFoundException dnfe) {
1166 if (logger.isDebugEnabled()) {
1167 logger.debug("caught exception in updateContact", dnfe);
1169 Response response = Response.status(Response.Status.NOT_FOUND).entity(
1170 "Update failed on Contact csid=" + itemcsid).type(
1171 "text/plain").build();
1172 throw new WebApplicationException(response);
1173 } catch (Exception e) {
1174 Response response = Response.status(
1175 Response.Status.INTERNAL_SERVER_ERROR).entity("Update failed").type("text/plain").build();
1176 throw new WebApplicationException(response);
1184 * @param parentcsid the parentcsid
1185 * @param itemcsid the itemcsid
1186 * @param csid the csid
1188 * @return the response
1191 @Path("{parentcsid}/items/{itemcsid}/contacts/{csid}")
1192 public Response deleteContact(
1193 @PathParam("parentcsid") String parentcsid,
1194 @PathParam("itemcsid") String itemcsid,
1195 @PathParam("csid") String csid) {
1196 if (logger.isDebugEnabled()) {
1197 logger.debug("deleteContact with parentCsid=" + parentcsid +
1198 " itemcsid=" + itemcsid + " csid=" + csid);
1200 if (parentcsid == null || parentcsid.trim().isEmpty()) {
1201 logger.error("deleteContact: missing parentcsid!");
1202 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
1203 "delete contact failed on parentcsid=" + parentcsid).type(
1204 "text/plain").build();
1205 throw new WebApplicationException(response);
1207 if (itemcsid == null || itemcsid.trim().isEmpty()) {
1208 logger.error("deleteContact: missing itemcsid!");
1209 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
1210 "delete contact failed on itemcsid=" + itemcsid).type(
1211 "text/plain").build();
1212 throw new WebApplicationException(response);
1214 if (csid == null || csid.trim().isEmpty()) {
1215 logger.error("deleteContact: missing csid!");
1216 Response response = Response.status(Response.Status.BAD_REQUEST).entity(
1217 "delete contact failed on csid=" + csid).type(
1218 "text/plain").build();
1219 throw new WebApplicationException(response);
1222 // Note that we have to create the service context for the
1223 // Contact service, not the main service.
1224 ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getContactServiceName());
1225 getRepositoryClient(ctx).delete(ctx, csid);
1226 return Response.status(HttpResponseCodes.SC_OK).build();
1227 } catch (UnauthorizedException ue) {
1228 Response response = Response.status(
1229 Response.Status.UNAUTHORIZED).entity("Delete failed reason " + ue.getErrorReason()).type("text/plain").build();
1230 throw new WebApplicationException(response);
1231 } catch (DocumentNotFoundException dnfe) {
1232 if (logger.isDebugEnabled()) {
1233 logger.debug("Caught exception in deleteContact", dnfe);
1235 Response response = Response.status(Response.Status.NOT_FOUND)
1236 .entity("Delete failed, the requested Contact CSID:" + csid + ": was not found.")
1237 .type("text/plain").build();
1238 throw new WebApplicationException(response);
1239 } catch (Exception e) {
1240 Response response = Response.status(
1241 Response.Status.INTERNAL_SERVER_ERROR).entity("Delete failed").type("text/plain").build();
1242 throw new WebApplicationException(response);