import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
-
import org.collectionspace.services.common.AbstractCollectionSpaceResource;
import org.collectionspace.services.common.context.MultipartServiceContext;
import org.collectionspace.services.common.context.MultipartServiceContextFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * The Class NewRelationResource.
+ */
@Path("/relations")
@Consumes("multipart/mixed")
@Produces("multipart/mixed")
public class NewRelationResource extends AbstractCollectionSpaceResource {
- public final static String serviceName = "relations";
- final Logger logger = LoggerFactory.getLogger(NewRelationResource.class);
+ /** The Constant serviceName. */
+ public final static String serviceName = "relations";
+
+ /** The logger. */
+ final Logger logger = LoggerFactory.getLogger(NewRelationResource.class);
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResource#getVersionString()
+ */
+ @Override
+ protected String getVersionString() {
+ /** The last change revision. */
+ final String lastChangeRevision = "$LastChangedRevision$";
+ return lastChangeRevision;
+ }
- @Override
- protected String getVersionString() {
- /** The last change revision. */
- final String lastChangeRevision = "$LastChangedRevision$";
- return lastChangeRevision;
- }
-
- @Override
- public String getServiceName() {
- return serviceName;
- }
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResource#getServiceName()
+ */
+ @Override
+ public String getServiceName() {
+ return serviceName;
+ }
- @Override
- public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
- DocumentHandler docHandler = ctx.getDocumentHandler();
- if (ctx.getInput() != null) {
- Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), RelationsCommon.class);
- if (obj != null) {
- docHandler.setCommonPart((RelationsCommon) obj);
- }
- }
- return docHandler;
- }
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResource#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext)
+ */
+ @Override
+ public DocumentHandler createDocumentHandler(ServiceContext ctx)
+ throws Exception {
+ DocumentHandler docHandler = ctx.getDocumentHandler();
+ if (ctx.getInput() != null) {
+ Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx
+ .getCommonPartLabel(), RelationsCommon.class);
+ if (obj != null) {
+ docHandler.setCommonPart((RelationsCommon) obj);
+ }
+ }
+ return docHandler;
+ }
- @POST
- public Response createRelation(MultipartInput input) {
+ /**
+ * Creates the relation.
+ *
+ * @param input the input
+ *
+ * @return the response
+ */
+ @POST
+ public Response createRelation(MultipartInput input) {
- try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getServiceName());
- DocumentHandler handler = createDocumentHandler(ctx);
- String csid = getRepositoryClient(ctx).create(ctx, handler);
- UriBuilder path = UriBuilder.fromResource(NewRelationResource.class);
- path.path("" + csid);
- Response response = Response.created(path.build()).build();
- return response;
- } catch (UnauthorizedException ue) {
- Response response = Response.status(
- Response.Status.UNAUTHORIZED).entity("Create failed reason " + ue.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (Exception e) {
- if (logger.isDebugEnabled()) {
- logger.debug("Caught exception in createRelation", e);
- }
- Response response = Response.status(
- Response.Status.INTERNAL_SERVER_ERROR).entity(
- "Create failed").type("text/plain").build();
- throw new WebApplicationException(response);
- }
- }
+ try {
+ ServiceContext ctx = MultipartServiceContextFactory.get()
+ .createServiceContext(input, getServiceName());
+ DocumentHandler handler = createDocumentHandler(ctx);
+ String csid = getRepositoryClient(ctx).create(ctx, handler);
+ UriBuilder path = UriBuilder
+ .fromResource(NewRelationResource.class);
+ path.path("" + csid);
+ Response response = Response.created(path.build()).build();
+ return response;
+ } catch (UnauthorizedException ue) {
+ Response response = Response.status(Response.Status.UNAUTHORIZED)
+ .entity("Create failed reason " + ue.getErrorReason())
+ .type("text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Caught exception in createRelation", e);
+ }
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity(
+ "Create failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ }
+
+ /**
+ * Gets the relation.
+ *
+ * @param csid the csid
+ *
+ * @return the relation
+ */
+ @GET
+ @Path("{csid}")
+ public MultipartOutput getRelation(@PathParam("csid") String csid) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("getRelation with csid=" + csid);
+ }
+ if (csid == null || "".equals(csid)) {
+ logger.error("getRelation: missing csid!");
+ Response response = Response.status(Response.Status.BAD_REQUEST)
+ .entity("get failed on Relation csid=" + csid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ MultipartOutput result = null;
+ try {
+ ServiceContext ctx = MultipartServiceContextFactory.get()
+ .createServiceContext(null, getServiceName());
+ DocumentHandler handler = createDocumentHandler(ctx);
+ getRepositoryClient(ctx).get(ctx, csid, handler);
+ result = (MultipartOutput) ctx.getOutput();
+ } catch (UnauthorizedException ue) {
+ Response response = Response.status(Response.Status.UNAUTHORIZED)
+ .entity("Get failed reason " + ue.getErrorReason()).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (DocumentNotFoundException dnfe) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("getRelation", dnfe);
+ }
+ Response response = Response.status(Response.Status.NOT_FOUND)
+ .entity("Get failed on Relation csid=" + csid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("getRelation", e);
+ }
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed")
+ .type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
- @GET
- @Path("{csid}")
- public MultipartOutput getRelation(@PathParam("csid") String csid) {
- if (logger.isDebugEnabled()) {
- logger.debug("getRelation with csid=" + csid);
- }
- if (csid == null || "".equals(csid)) {
- logger.error("getRelation: missing csid!");
- Response response = Response.status(Response.Status.BAD_REQUEST).entity("get failed on Relation csid=" + csid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- }
- MultipartOutput result = null;
- try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
- DocumentHandler handler = createDocumentHandler(ctx);
- getRepositoryClient(ctx).get(ctx, csid, handler);
- result = (MultipartOutput) ctx.getOutput();
- } catch (UnauthorizedException ue) {
- Response response = Response.status(
- Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (DocumentNotFoundException dnfe) {
- if (logger.isDebugEnabled()) {
- logger.debug("getRelation", dnfe);
- }
- Response response = Response.status(Response.Status.NOT_FOUND).entity("Get failed on Relation csid=" + csid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- } catch (Exception e) {
- if (logger.isDebugEnabled()) {
- logger.debug("getRelation", e);
- }
- Response response = Response.status(
- Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
- throw new WebApplicationException(response);
- }
+ if (result == null) {
+ Response response = Response.status(Response.Status.NOT_FOUND)
+ .entity(
+ "Get failed, the requested Relation CSID:" + csid
+ + ": was not found.").type("text/plain")
+ .build();
+ throw new WebApplicationException(response);
+ }
+ return result;
+ }
- if (result == null) {
- Response response = Response.status(Response.Status.NOT_FOUND).entity(
- "Get failed, the requested Relation CSID:" + csid + ": was not found.").type("text/plain").build();
- throw new WebApplicationException(response);
- }
- return result;
- }
+ /*
+ * BEGIN OF GET LIST
+ */
+ /**
+ * Gets the relation list.
+ *
+ * @param ui the ui
+ *
+ * @return the relation list
+ */
+ @GET
+ @Produces("application/xml")
+ public RelationsCommonList getRelationList(@Context UriInfo ui) {
+ return this.getRelationList(null, null, null);
+ }
- /*
- * BEGIN OF GET LIST
- */
- @GET
- @Produces("application/xml")
- public RelationsCommonList getRelationList(@Context UriInfo ui) {
- return this.getRelationList(null, null, null);
- }
+ /**
+ * Gets the relation list_ s.
+ *
+ * @param ui the ui
+ * @param subjectCsid the subject csid
+ *
+ * @return the relation list_ s
+ */
+ @GET
+ @Path("subject/{subjectCsid}")
+ @Produces("application/xml")
+ public RelationsCommonList getRelationList_S(@Context UriInfo ui,
+ @PathParam("subjectCsid") String subjectCsid) {
+ return this.getRelationList(subjectCsid, null, null);
+ }
- @GET
- @Path("subject/{subjectCsid}")
- @Produces("application/xml")
- public RelationsCommonList getRelationList_S(@Context UriInfo ui,
- @PathParam("subjectCsid") String subjectCsid) {
- return this.getRelationList(subjectCsid, null, null);
- }
+ /**
+ * Gets the relation list_ p.
+ *
+ * @param ui the ui
+ * @param predicate the predicate
+ *
+ * @return the relation list_ p
+ */
+ @GET
+ @Path("type/{predicate}")
+ @Produces("application/xml")
+ public RelationsCommonList getRelationList_P(@Context UriInfo ui,
+ @PathParam("predicate") String predicate) {
+ return this.getRelationList(null, predicate, null);
+ }
- @GET
- @Path("type/{predicate}")
- @Produces("application/xml")
- public RelationsCommonList getRelationList_P(@Context UriInfo ui,
- @PathParam("predicate") String predicate) {
- return this.getRelationList(null, predicate, null);
- }
+ /**
+ * Gets the relation list_ o.
+ *
+ * @param ui the ui
+ * @param objectCsid the object csid
+ *
+ * @return the relation list_ o
+ */
+ @GET
+ @Path("object/{objectCsid}")
+ @Produces("application/xml")
+ public RelationsCommonList getRelationList_O(@Context UriInfo ui,
+ @PathParam("objectCsid") String objectCsid) {
+ return this.getRelationList(null, null, objectCsid);
+ }
- @GET
- @Path("object/{objectCsid}")
- @Produces("application/xml")
- public RelationsCommonList getRelationList_O(@Context UriInfo ui,
- @PathParam("objectCsid") String objectCsid) {
- return this.getRelationList(null, null, objectCsid);
- }
+ /**
+ * Gets the relation list_ ps.
+ *
+ * @param ui the ui
+ * @param predicate the predicate
+ * @param subjectCsid the subject csid
+ *
+ * @return the relation list_ ps
+ */
+ @GET
+ @Path("type/{predicate}/subject/{subjectCsid}")
+ @Produces("application/xml")
+ public RelationsCommonList getRelationList_PS(@Context UriInfo ui,
+ @PathParam("predicate") String predicate,
+ @PathParam("subjectCsid") String subjectCsid) {
+ return this.getRelationList(subjectCsid, predicate, null);
+ }
- @GET
- @Path("type/{predicate}/subject/{subjectCsid}")
- @Produces("application/xml")
- public RelationsCommonList getRelationList_PS(@Context UriInfo ui,
- @PathParam("predicate") String predicate,
- @PathParam("subjectCsid") String subjectCsid) {
- return this.getRelationList(subjectCsid, predicate, null);
- }
+ /**
+ * Gets the relation list_ sp.
+ *
+ * @param ui the ui
+ * @param subjectCsid the subject csid
+ * @param predicate the predicate
+ *
+ * @return the relation list_ sp
+ */
+ @GET
+ @Path("subject/{subjectCsid}/type/{predicate}")
+ @Produces("application/xml")
+ public RelationsCommonList getRelationList_SP(@Context UriInfo ui,
+ @PathParam("subjectCsid") String subjectCsid,
+ @PathParam("predicate") String predicate) {
+ return this.getRelationList(subjectCsid, predicate, null);
+ }
- @GET
- @Path("subject/{subjectCsid}/type/{predicate}")
- @Produces("application/xml")
- public RelationsCommonList getRelationList_SP(@Context UriInfo ui,
- @PathParam("subjectCsid") String subjectCsid,
- @PathParam("predicate") String predicate) {
- return this.getRelationList(subjectCsid, predicate, null);
- }
+ /**
+ * Gets the relation list_ po.
+ *
+ * @param ui the ui
+ * @param predicate the predicate
+ * @param objectCsid the object csid
+ *
+ * @return the relation list_ po
+ */
+ @GET
+ @Path("type/{predicate}/object/{objectCsid}")
+ @Produces("application/xml")
+ public RelationsCommonList getRelationList_PO(@Context UriInfo ui,
+ @PathParam("predicate") String predicate,
+ @PathParam("objectCsid") String objectCsid) {
+ return this.getRelationList(null, predicate, objectCsid);
+ }
- @GET
- @Path("type/{predicate}/object/{objectCsid}")
- @Produces("application/xml")
- public RelationsCommonList getRelationList_PO(@Context UriInfo ui,
- @PathParam("predicate") String predicate,
- @PathParam("objectCsid") String objectCsid) {
- return this.getRelationList(null, predicate, objectCsid);
- }
+ /**
+ * Gets the relation list_ op.
+ *
+ * @param ui the ui
+ * @param objectCsid the object csid
+ * @param predicate the predicate
+ *
+ * @return the relation list_ op
+ */
+ @GET
+ @Path("object/{objectCsid}/type/{predicate}")
+ @Produces("application/xml")
+ public RelationsCommonList getRelationList_OP(@Context UriInfo ui,
+ @PathParam("objectCsid") String objectCsid,
+ @PathParam("predicate") String predicate) {
+ return this.getRelationList(null, predicate, objectCsid);
+ }
- @GET
- @Path("object/{objectCsid}/type/{predicate}")
- @Produces("application/xml")
- public RelationsCommonList getRelationList_OP(@Context UriInfo ui,
- @PathParam("objectCsid") String objectCsid,
- @PathParam("predicate") String predicate) {
- return this.getRelationList(null, predicate, objectCsid);
- }
+ /**
+ * Gets the relation list_ pso.
+ *
+ * @param ui the ui
+ * @param predicate the predicate
+ * @param subjectCsid the subject csid
+ * @param objectCsid the object csid
+ *
+ * @return the relation list_ pso
+ */
+ @GET
+ @Path("type/{predicate}/subject/{subjectCsid}/object/{objectCsid}")
+ @Produces("application/xml")
+ public RelationsCommonList getRelationList_PSO(@Context UriInfo ui,
+ @PathParam("predicate") String predicate,
+ @PathParam("subjectCsid") String subjectCsid,
+ @PathParam("objectCsid") String objectCsid) {
+ return this.getRelationList(subjectCsid, predicate, objectCsid);
+ }
- @GET
- @Path("type/{predicate}/subject/{subjectCsid}/object/{objectCsid}")
- @Produces("application/xml")
- public RelationsCommonList getRelationList_PSO(@Context UriInfo ui,
- @PathParam("predicate") String predicate,
- @PathParam("subjectCsid") String subjectCsid,
- @PathParam("objectCsid") String objectCsid) {
- return this.getRelationList(subjectCsid, predicate, objectCsid);
- }
+ /**
+ * Gets the relation list_ spo.
+ *
+ * @param ui the ui
+ * @param subjectCsid the subject csid
+ * @param predicate the predicate
+ * @param objectCsid the object csid
+ *
+ * @return the relation list_ spo
+ */
+ @GET
+ @Path("subject/{subjectCsid}/type/{predicate}/object/{objectCsid}")
+ @Produces("application/xml")
+ public RelationsCommonList getRelationList_SPO(@Context UriInfo ui,
+ @PathParam("subjectCsid") String subjectCsid,
+ @PathParam("predicate") String predicate,
+ @PathParam("objectCsid") String objectCsid) {
+ return this.getRelationList(subjectCsid, predicate, objectCsid);
+ }
- @GET
- @Path("subject/{subjectCsid}/type/{predicate}/object/{objectCsid}")
- @Produces("application/xml")
- public RelationsCommonList getRelationList_SPO(@Context UriInfo ui,
- @PathParam("subjectCsid") String subjectCsid,
- @PathParam("predicate") String predicate,
- @PathParam("objectCsid") String objectCsid) {
- return this.getRelationList(subjectCsid, predicate, objectCsid);
- }
- /*
- * END OF GET LIST
- */
+ /*
+ * END OF GET LIST
+ */
- @PUT
- @Path("{csid}")
- public MultipartOutput updateRelation(@PathParam("csid") String csid,
- MultipartInput theUpdate) {
- if (logger.isDebugEnabled()) {
- logger.debug("updateRelation with csid=" + csid);
- }
- if (csid == null || "".equals(csid)) {
- logger.error("updateRelation: missing csid!");
- Response response = Response.status(Response.Status.BAD_REQUEST).entity("update failed on Relation csid=" + csid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- }
- MultipartOutput result = null;
- try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(theUpdate, getServiceName());
- DocumentHandler handler = createDocumentHandler(ctx);
- getRepositoryClient(ctx).update(ctx, csid, handler);
- result = (MultipartOutput) ctx.getOutput();
- } catch (UnauthorizedException ue) {
- Response response = Response.status(
- Response.Status.UNAUTHORIZED).entity("Update failed reason " + ue.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (DocumentNotFoundException dnfe) {
- if (logger.isDebugEnabled()) {
- logger.debug("caugth exception in updateRelation", dnfe);
- }
- Response response = Response.status(Response.Status.NOT_FOUND).entity("Update failed on Relation csid=" + csid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- } catch (Exception e) {
- Response response = Response.status(
- Response.Status.INTERNAL_SERVER_ERROR).entity(
- "Update failed").type("text/plain").build();
- throw new WebApplicationException(response);
- }
- return result;
- }
+ /**
+ * Update relation.
+ *
+ * @param csid the csid
+ * @param theUpdate the the update
+ *
+ * @return the multipart output
+ */
+ @PUT
+ @Path("{csid}")
+ public MultipartOutput updateRelation(@PathParam("csid") String csid,
+ MultipartInput theUpdate) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("updateRelation with csid=" + csid);
+ }
+ if (csid == null || "".equals(csid)) {
+ logger.error("updateRelation: missing csid!");
+ Response response = Response.status(Response.Status.BAD_REQUEST)
+ .entity("update failed on Relation csid=" + csid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ MultipartOutput result = null;
+ try {
+ ServiceContext ctx = MultipartServiceContextFactory.get()
+ .createServiceContext(theUpdate, getServiceName());
+ DocumentHandler handler = createDocumentHandler(ctx);
+ getRepositoryClient(ctx).update(ctx, csid, handler);
+ result = (MultipartOutput) ctx.getOutput();
+ } catch (UnauthorizedException ue) {
+ Response response = Response.status(Response.Status.UNAUTHORIZED)
+ .entity("Update failed reason " + ue.getErrorReason())
+ .type("text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (DocumentNotFoundException dnfe) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("caugth exception in updateRelation", dnfe);
+ }
+ Response response = Response.status(Response.Status.NOT_FOUND)
+ .entity("Update failed on Relation csid=" + csid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity(
+ "Update failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ return result;
+ }
- @DELETE
- @Path("{csid}")
- public Response deleteRelation(@PathParam("csid") String csid) {
+ /**
+ * Delete relation.
+ *
+ * @param csid the csid
+ *
+ * @return the response
+ */
+ @DELETE
+ @Path("{csid}")
+ public Response deleteRelation(@PathParam("csid") String csid) {
- if (logger.isDebugEnabled()) {
- logger.debug("deleteRelation with csid=" + csid);
- }
- if (csid == null || "".equals(csid)) {
- logger.error("deleteRelation: missing csid!");
- Response response = Response.status(Response.Status.BAD_REQUEST).entity("delete failed on Relation csid=" + csid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- }
- try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
- getRepositoryClient(ctx).delete(ctx, csid);
- return Response.status(HttpResponseCodes.SC_OK).build();
- } catch (UnauthorizedException ue) {
- Response response = Response.status(
- Response.Status.UNAUTHORIZED).entity("Delete failed reason " + ue.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (DocumentNotFoundException dnfe) {
- if (logger.isDebugEnabled()) {
- logger.debug("caught exception in deleteRelation", dnfe);
- }
- Response response = Response.status(Response.Status.NOT_FOUND).entity("Delete failed on Relation csid=" + csid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- } catch (Exception e) {
- Response response = Response.status(
- Response.Status.INTERNAL_SERVER_ERROR).entity(
- "Delete failed").type("text/plain").build();
- throw new WebApplicationException(response);
- }
+ if (logger.isDebugEnabled()) {
+ logger.debug("deleteRelation with csid=" + csid);
+ }
+ if (csid == null || "".equals(csid)) {
+ logger.error("deleteRelation: missing csid!");
+ Response response = Response.status(Response.Status.BAD_REQUEST)
+ .entity("delete failed on Relation csid=" + csid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ try {
+ ServiceContext ctx = MultipartServiceContextFactory.get()
+ .createServiceContext(null, getServiceName());
+ getRepositoryClient(ctx).delete(ctx, csid);
+ return Response.status(HttpResponseCodes.SC_OK).build();
+ } catch (UnauthorizedException ue) {
+ Response response = Response.status(Response.Status.UNAUTHORIZED)
+ .entity("Delete failed reason " + ue.getErrorReason())
+ .type("text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (DocumentNotFoundException dnfe) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("caught exception in deleteRelation", dnfe);
+ }
+ Response response = Response.status(Response.Status.NOT_FOUND)
+ .entity("Delete failed on Relation csid=" + csid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity(
+ "Delete failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
- }
+ }
- /*
- * Private Methods
- */
- /**
- * Gets the relation list request.
- *
- * @return the relation list request
- *
- * @throws WebApplicationException the web application exception
- */
- private RelationsCommonList getRelationList(String subjectCsid,
- String predicate,
- String objectCsid)
- throws WebApplicationException {
- RelationsCommonList relationList = new RelationsCommonList();
- try {
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
- DocumentHandler handler = createDocumentHandler(ctx);
- Map propsFromPath = handler.getProperties();
- propsFromPath.put(IRelationsManager.SUBJECT, subjectCsid);
- propsFromPath.put(IRelationsManager.PREDICATE, predicate);
- propsFromPath.put(IRelationsManager.OBJECT, objectCsid);
- getRepositoryClient(ctx).getAll(ctx, handler);
- relationList = (RelationsCommonList) handler.getCommonPartList();
- } catch (UnauthorizedException ue) {
- Response response = Response.status(
- Response.Status.UNAUTHORIZED).entity("Get relations failed reason " + ue.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (Exception e) {
- if (logger.isDebugEnabled()) {
- logger.debug("Caught exception in getRelationList", e);
- }
- Response response = Response.status(
- Response.Status.INTERNAL_SERVER_ERROR).entity(
- "Index failed").type("text/plain").build();
- throw new WebApplicationException(response);
- }
- return relationList;
- }
+ /**
+ * Gets the relation list request.
+ *
+ * @return the relation list request
+ *
+ * @throws WebApplicationException
+ * the web application exception
+ */
+ public RelationsCommonList getRelationList(String subjectCsid,
+ String predicate, String objectCsid) throws WebApplicationException {
+ RelationsCommonList relationList = new RelationsCommonList();
+ try {
+ ServiceContext ctx = MultipartServiceContextFactory.get()
+ .createServiceContext(null, getServiceName());
+ DocumentHandler handler = createDocumentHandler(ctx);
+ Map propsFromPath = handler.getProperties();
+ propsFromPath.put(IRelationsManager.SUBJECT, subjectCsid);
+ propsFromPath.put(IRelationsManager.PREDICATE, predicate);
+ propsFromPath.put(IRelationsManager.OBJECT, objectCsid);
+ getRepositoryClient(ctx).getAll(ctx, handler);
+ relationList = (RelationsCommonList) handler.getCommonPartList();
+ } catch (UnauthorizedException ue) {
+ Response response = Response.status(Response.Status.UNAUTHORIZED)
+ .entity(
+ "Get relations failed reason "
+ + ue.getErrorReason()).type("text/plain")
+ .build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Caught exception in getRelationList", e);
+ }
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity(
+ "Index failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ return relationList;
+ }
}