]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-834: Service consumer can retreive a list Intake records (if any) associated...
authorRichard Millet <richard.millet@berkeley.edu>
Thu, 11 Feb 2010 03:57:18 +0000 (03:57 +0000)
committerRichard Millet <richard.millet@berkeley.edu>
Thu, 11 Feb 2010 03:57:18 +0000 (03:57 +0000)
services/collectionobject/service/pom.xml
services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java
services/common/src/main/java/org/collectionspace/services/common/relation/RelationListItemJAXBSchema.java
services/common/src/main/java/org/collectionspace/services/common/relation/nuxeo/RelationsUtils.java
services/common/src/main/java/org/collectionspace/services/common/storage/StorageClient.java
services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaStorageClient.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClient.java
services/common/src/main/resources/relations_common.xsd
services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java
services/relation/service/src/main/java/org/collectionspace/services/relation/NewRelationResource.java
services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java

index e4ddeb6194e69059dec96fd884f9df8c3808e93f..e0975c72b8d0fa2f3cc2cf5e6c2bb252d07cad2a 100644 (file)
             <artifactId>org.collectionspace.services.collectionobject.jaxb</artifactId>\r
             <version>1.0</version>\r
         </dependency>\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.intake.jaxb</artifactId>\r
+            <version>1.0</version>\r
+        </dependency>        \r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.intake.service</artifactId>\r
+            <version>1.0</version>\r
+        </dependency>        \r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.relation.service</artifactId>\r
+            <version>1.0</version>\r
+        </dependency>\r
+        \r
         <dependency>\r
             <groupId>org.slf4j</groupId>\r
             <artifactId>slf4j-api</artifactId>\r
             </exclusions>\r
         </dependency>\r
 \r
-        <dependency>\r
+<!--        <dependency>\r
             <groupId>org.restlet</groupId>\r
             <artifactId>org.restlet</artifactId>\r
             <version>1.0.7</version>\r
             <groupId>com.noelios.restlet</groupId>\r
             <artifactId>com.noelios.restlet</artifactId>\r
             <version>1.0.7</version>\r
-        </dependency>\r
+        </dependency> -->\r
 \r
     </dependencies>\r
     \r
index 44e9ae78afcf4abc93abbd0c7b09f2f3d3d85031..189f6612c105b186a10e1a5605f143485833df3c 100644 (file)
  */
 package org.collectionspace.services.collectionobject;
 
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.lang.reflect.Type;
+
 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
@@ -51,19 +56,30 @@ import org.collectionspace.services.common.document.DocumentNotFoundException;
 import org.collectionspace.services.common.document.DocumentHandler;
 import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.security.UnauthorizedException;
+import org.jboss.resteasy.plugins.providers.multipart.InputPart;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
 import org.jboss.resteasy.util.HttpResponseCodes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.collectionspace.services.intake.IntakesCommonList;
+import org.collectionspace.services.intake.IntakeResource;
+
+import org.collectionspace.services.relation.NewRelationResource;
+import org.collectionspace.services.relation.RelationshipType;
+import org.collectionspace.services.relation.RelationsCommonList;
+import org.collectionspace.services.relation.RelationsCommon;
+
+
 @Path("/collectionobjects")
 @Consumes("multipart/mixed")
 @Produces("multipart/mixed")
 public class CollectionObjectResource
         extends AbstractCollectionSpaceResource {
 
-    final private String serviceName = "collectionobjects";
+    static final public String serviceName = "collectionobjects";
     final Logger logger = LoggerFactory.getLogger(CollectionObjectResource.class);
 
     @Override
@@ -276,6 +292,50 @@ public class CollectionObjectResource
 
     }
 
+    @GET
+    @Path("{csid}/intakes")
+    @Produces("application/xml")
+    public IntakesCommonList getIntakesCommonList(@Context UriInfo ui,
+               @PathParam("csid") String csid) {
+        IntakesCommonList result = null;       
+        
+        try {
+               //
+               // Find all the intake-related relation records.
+               //
+               String subjectCsid = csid;
+               String predicate = RelationshipType.COLLECTIONOBJECT_INTAKE.value();
+               String objectCsid = null;
+               NewRelationResource relationResource = new NewRelationResource();               
+               RelationsCommonList relationsCommonList = relationResource.getRelationList(subjectCsid, predicate, objectCsid);
+               
+               //
+               // Create an array of Intake csid's
+               //
+               List<RelationsCommonList.RelationListItem> relationsListItems = relationsCommonList.getRelationListItem();
+               List<String> intakeCsidList = new ArrayList<String>();
+            for (RelationsCommonList.RelationListItem relationsListItem : relationsListItems) {
+               intakeCsidList.add(relationsListItem.getObjectCsid());
+               }
+            
+            //
+            // Get a response list for the Intake records from the Intake resource
+            //
+               IntakeResource intakeResource = new IntakeResource();
+               result = intakeResource.getIntakeList(intakeCsidList);
+        } catch (Exception e) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Caught exception in getIntakeList", e);
+            }
+            Response response = Response.status(
+                    Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        
+        return result;
+    }    
+
+    //FIXME: Replace this "search" resource with a keyword "kw" query parameter
     @GET
     @Path("/search")
     @Produces("application/xml")
@@ -314,4 +374,5 @@ public class CollectionObjectResource
         }
         return collectionObjectList;
     }
+        
 }
index 733ae2d5b53bb12a37c24034bcdad21bd4ae1f2a..db7fa908b82eec117ca6cea25e291113e4967c47 100644 (file)
@@ -37,6 +37,9 @@ public interface RelationListItemJAXBSchema {
        /** The Constant CSID. */\r
        final static String CSID = "csid";\r
        \r
+       final static String SUBJECT_CSID = "subjectCsid";\r
+       final static String OBJECT_CSID = "objectCsid";\r
+       \r
        /** The Constant URI. */\r
        final static String URI = "url";\r
 }\r
index ebf47e26ef272fc61cc65191e9e9b21993c87166..af2cabd6c1e079c9a1515b0cd16ed03a15987f79 100644 (file)
@@ -26,9 +26,12 @@ package org.collectionspace.services.common.relation.nuxeo;
 import java.util.Iterator;
 import java.util.List;
 
+import org.collectionspace.services.common.relation.RelationListItemJAXBSchema;
 import org.collectionspace.services.common.relation.RelationJAXBSchema;
 import org.collectionspace.services.common.document.DocumentException;
 import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.common.context.ServiceContext;
+
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.collectionspace.services.relation.RelationsCommonList;
 import org.collectionspace.services.relation.RelationsCommonList.RelationListItem;
@@ -47,7 +50,7 @@ public class RelationsUtils {
 
     private static final Logger logger = LoggerFactory.getLogger(RelationsUtils.class);
 
-    public static RelationsCommonList extractCommonPartList(DocumentWrapper wrapDoc,
+    public static RelationsCommonList extractCommonPartList(ServiceContext ctx, DocumentWrapper wrapDoc,
             String serviceContextPath)
             throws Exception {
         DocumentModelList docList = (DocumentModelList) wrapDoc.getWrappedObject();
@@ -60,18 +63,23 @@ public class RelationsUtils {
         Iterator<DocumentModel> iter = docList.iterator();
         while (iter.hasNext()) {
             DocumentModel docModel = iter.next();
-            RelationListItem relationListItem = getRelationListItem(docModel,
+            RelationListItem relationListItem = getRelationListItem(ctx, docModel,
                     serviceContextPath);
             list.add(relationListItem);
         }
         return relList;
     }
 
-    public static RelationListItem getRelationListItem(DocumentModel docModel,
+    public static RelationListItem getRelationListItem(ServiceContext ctx, DocumentModel docModel,
             String serviceContextPath) throws Exception {
         RelationListItem relationListItem = new RelationListItem();
         String id = NuxeoUtils.extractId(docModel.getPathAsString());
         relationListItem.setCsid(id);
+        relationListItem.setSubjectCsid((String) docModel.getProperty(ctx.getCommonPartLabel(),
+                       RelationJAXBSchema.DOCUMENT_ID_1));
+        relationListItem.setObjectCsid((String) docModel.getProperty(ctx.getCommonPartLabel(),
+                       RelationJAXBSchema.DOCUMENT_ID_2));
+        
         relationListItem.setUri(serviceContextPath + id);
         return relationListItem;
     }
index 63474c34da4775691c75d782d26c99c310146481..3e34f29c87d318d30f377c524bfcf7eabcac83d5 100644 (file)
@@ -17,6 +17,8 @@
  */
 package org.collectionspace.services.common.storage;
 
+import java.util.List;
+
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.BadRequestException;
 import org.collectionspace.services.common.document.DocumentException;
@@ -58,6 +60,19 @@ public interface StorageClient {
      */
     void get(ServiceContext ctx, String id, DocumentHandler handler) throws DocumentNotFoundException, DocumentException;
 
+    /**
+     * Gets the.
+     * 
+     * @param ctx the ctx
+     * @param csidList the csid list
+     * @param handler the handler
+     * 
+     * @throws DocumentNotFoundException the document not found exception
+     * @throws DocumentException the document exception
+     */
+    void get(ServiceContext ctx, List<String> csidList, DocumentHandler handler)
+               throws DocumentNotFoundException, DocumentException;
+    
     /**
      * getAll get all entitys for an entity service from the persistence store
      * @param ctx service context under which this method is invoked
index 9e71d811cf4224c52f895c7b201168cfc46aa4d4..7e8495f4d0c5233ecb64a7ddcd7fe35a0671a864 100644 (file)
@@ -48,12 +48,21 @@ import org.slf4j.LoggerFactory;
  */
 public class JpaStorageClient implements StorageClient {
 
+    /** The logger. */
     private final Logger logger = LoggerFactory.getLogger(JpaStorageClient.class);
+    
+    /** The Constant CS_PERSISTENCE_UNIT. */
     protected final static String CS_PERSISTENCE_UNIT = "org.collectionspace.services";
 
+    /**
+     * Instantiates a new jpa storage client.
+     */
     public JpaStorageClient() {
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.common.storage.StorageClient#create(org.collectionspace.services.common.context.ServiceContext, org.collectionspace.services.common.document.DocumentHandler)
+     */
     @Override
     public String create(ServiceContext ctx,
             DocumentHandler handler) throws BadRequestException,
@@ -100,6 +109,17 @@ public class JpaStorageClient implements StorageClient {
 
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.common.storage.StorageClient#get(org.collectionspace.services.common.context.ServiceContext, java.util.List, org.collectionspace.services.common.document.DocumentHandler)
+     */
+    public void get(ServiceContext ctx, List<String> csidList, DocumentHandler handler)
+               throws DocumentNotFoundException, DocumentException {
+        throw new UnsupportedOperationException();
+    }
+    
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.common.storage.StorageClient#get(org.collectionspace.services.common.context.ServiceContext, java.lang.String, org.collectionspace.services.common.document.DocumentHandler)
+     */
     @Override
     public void get(ServiceContext ctx, String id, DocumentHandler handler)
             throws DocumentNotFoundException, DocumentException {
@@ -173,12 +193,18 @@ public class JpaStorageClient implements StorageClient {
         }
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.common.storage.StorageClient#getAll(org.collectionspace.services.common.context.ServiceContext, org.collectionspace.services.common.document.DocumentHandler)
+     */
     @Override
     public void getAll(ServiceContext ctx, DocumentHandler handler)
             throws DocumentNotFoundException, DocumentException {
         throw new UnsupportedOperationException("use getFiltered instead");
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.common.storage.StorageClient#getFiltered(org.collectionspace.services.common.context.ServiceContext, org.collectionspace.services.common.document.DocumentHandler)
+     */
     @Override
     public void getFiltered(ServiceContext ctx, DocumentHandler handler)
             throws DocumentNotFoundException, DocumentException {
@@ -243,6 +269,9 @@ public class JpaStorageClient implements StorageClient {
         }
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.common.storage.StorageClient#update(org.collectionspace.services.common.context.ServiceContext, java.lang.String, org.collectionspace.services.common.document.DocumentHandler)
+     */
     @Override
     public void update(ServiceContext ctx, String id, DocumentHandler handler)
             throws BadRequestException, DocumentNotFoundException,
@@ -293,6 +322,9 @@ public class JpaStorageClient implements StorageClient {
         }
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.common.storage.StorageClient#delete(org.collectionspace.services.common.context.ServiceContext, java.lang.String)
+     */
     @Override
     public void delete(ServiceContext ctx, String id)
             throws DocumentNotFoundException,
@@ -349,16 +381,33 @@ public class JpaStorageClient implements StorageClient {
         }
     }
 
+    /**
+     * Gets the entity manager factory.
+     * 
+     * @return the entity manager factory
+     */
     protected EntityManagerFactory getEntityManagerFactory() {
         return getEntityManagerFactory(CS_PERSISTENCE_UNIT);
     }
 
+    /**
+     * Gets the entity manager factory.
+     * 
+     * @param persistenceUnit the persistence unit
+     * 
+     * @return the entity manager factory
+     */
     protected EntityManagerFactory getEntityManagerFactory(
             String persistenceUnit) {
         return Persistence.createEntityManagerFactory(persistenceUnit);
 
     }
 
+    /**
+     * Release entity manager factory.
+     * 
+     * @param emf the emf
+     */
     protected void releaseEntityManagerFactory(EntityManagerFactory emf) {
         if (emf != null) {
             emf.close();
@@ -428,6 +477,14 @@ public class JpaStorageClient implements StorageClient {
         return r;
     }
 
+    /**
+     * Sets the csid.
+     * 
+     * @param o the o
+     * @param csid the csid
+     * 
+     * @throws Exception the exception
+     */
     protected void setCsid(Object o, String csid) throws Exception {
         //verify csid
         String id = (String) getValue(o, "getCsid");
@@ -446,6 +503,13 @@ public class JpaStorageClient implements StorageClient {
         setValue(o, "setCsid", java.lang.String.class, csid);
     }
 
+    /**
+     * Gets the entity name.
+     * 
+     * @param ctx the ctx
+     * 
+     * @return the entity name
+     */
     protected String getEntityName(ServiceContext ctx) {
         Object o = ctx.getProperty("entity-name");
         if (o == null) {
index 27f475394dacab08a01ae331f0dd46630bc90579..01f9ab81d3d547b8695c2ed37c0732c44a9da6a2 100644 (file)
@@ -18,6 +18,7 @@
 package org.collectionspace.services.nuxeo.client.java;
 
 import java.util.UUID;
+import java.util.List;
 
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.document.BadRequestException;
@@ -34,6 +35,7 @@ import org.nuxeo.common.utils.IdUtils;
 import org.nuxeo.ecm.core.api.ClientException;
 import org.nuxeo.ecm.core.api.DocumentModel;
 import org.nuxeo.ecm.core.api.DocumentModelList;
+import org.nuxeo.ecm.core.api.impl.DocumentModelListImpl;
 import org.nuxeo.ecm.core.api.DocumentRef;
 import org.nuxeo.ecm.core.api.IdRef;
 import org.nuxeo.ecm.core.api.PathRef;
@@ -121,7 +123,7 @@ public class RepositoryJavaClient implements RepositoryClient {
         }
 
     }
-
+    
     /**
      * get document from the Nuxeo repository
      * @param ctx service context under which this method is invoked
@@ -175,6 +177,46 @@ public class RepositoryJavaClient implements RepositoryClient {
         }
     }
 
+    @Override
+    public void get(ServiceContext ctx, List<String> csidList, DocumentHandler handler)
+               throws DocumentNotFoundException, DocumentException {
+        if (handler == null) {
+            throw new IllegalArgumentException(
+                    "RepositoryJavaClient.getAll: handler is missing");
+        }
+
+        RepositoryInstance repoSession = null;
+
+        try {
+            handler.prepare(Action.GET_ALL);
+            repoSession = getRepositorySession();
+            DocumentModelList docModelList = new DocumentModelListImpl();
+            //FIXME: Should be using NuxeoUtils.createPathRef for security reasons
+            for (String csid : csidList) {
+                DocumentRef docRef = NuxeoUtils.createPathRef(ctx, csid);
+                DocumentModel docModel = repoSession.getDocument(docRef);
+                docModelList.add(docModel);
+            }
+
+            //set reposession to handle the document
+            ((DocumentModelHandler) handler).setRepositorySession(repoSession);
+            DocumentWrapper<DocumentModelList> wrapDoc = new DocumentWrapperImpl<DocumentModelList>(docModelList);
+            handler.handle(Action.GET_ALL, wrapDoc);
+            handler.complete(Action.GET_ALL, wrapDoc);
+        } catch (DocumentException de) {
+            throw de;
+        } catch (Exception e) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Caught exception ", e);
+            }
+            throw new DocumentException(e);
+        } finally {
+            if (repoSession != null) {
+                releaseRepositorySession(repoSession);
+            }
+        }
+    }
+    
     /**
      * getAll get all documents for an entity entity service from the Nuxeo
      * repository
index d0415d480654bbeb98cb7e6ccb3fe8c660a72651..9ab41ebc629a49e71b002bf180e01dbe454f5ae1 100644 (file)
@@ -55,6 +55,8 @@
                             <!-- uri to retrive collection object details -->\r
                             <xs:element name="uri" type="xs:anyURI" minOccurs="1"/>\r
                             <xs:element name="csid" type="xs:string" minOccurs="1"/>\r
+                            <xs:element name="subjectCsid" type="xs:string" minOccurs="1"/>\r
+                            <xs:element name="objectCsid" type="xs:string" minOccurs="1"/>\r
                         </xs:sequence>\r
                     </xs:complexType>\r
                 </xs:element>\r
index d437fb00237e467c46d0e333bf6f817898daab73..40714aae8708d7d1dc515a2364d8b5fd545efe26 100644 (file)
@@ -23,6 +23,7 @@
  */
 package org.collectionspace.services.intake;
 
+import java.util.List;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
@@ -193,6 +194,35 @@ public class IntakeResource extends AbstractCollectionSpaceResource {
         return intakeObjectList;
     }
 
+    /**
+     * Gets the intake list.
+     * 
+     * @param csidList the csid list
+     * 
+     * @return the intake list
+     */
+    public IntakesCommonList getIntakeList(List<String> csidList) {
+        IntakesCommonList intakeObjectList = new IntakesCommonList();
+        try {
+            ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+            DocumentHandler handler = createDocumentHandler(ctx);
+            getRepositoryClient(ctx).get(ctx, csidList, handler);
+            intakeObjectList = (IntakesCommonList) handler.getCommonPartList();
+        } catch (UnauthorizedException ue) {
+            Response response = Response.status(
+                    Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (Exception e) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Caught exception in getIntakeList", e);
+            }
+            Response response = Response.status(
+                    Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        return intakeObjectList;
+    }
+    
     @PUT
     @Path("{csid}")
     public MultipartOutput updateIntake(
index 6763ff0bb25f3f5fc4f8652d30b5d648810b7e94..1dc04fc0d9bea23453af82cb10685343962d9ac9 100644 (file)
@@ -42,7 +42,6 @@ import javax.ws.rs.core.Response;
 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;
@@ -57,315 +56,468 @@ import org.jboss.resteasy.util.HttpResponseCodes;
 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;
+       }
 }
index 550546515e322d8e69d93d4aae4c40c526ff4dfc..5b6bb5658e40f43efe5881822c1185c7e10c5aed 100644 (file)
@@ -127,7 +127,7 @@ public class RelationDocumentModelHandler
             DocumentModel docModel = iter.next();
             if(RelationsUtils.isQueryMatch(docModel, subjectCsid,
                     predicate, objectCsid) == true){
-                RelationListItem relListItem = RelationsUtils.getRelationListItem(
+                RelationListItem relListItem = RelationsUtils.getRelationListItem(getServiceContext(),
                         docModel, getServiceContextPath());
                 itemList.add(relListItem);
             }