]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-2492, CSPACE-2492, CSPACE-2492, CSPACE-2463: Changes to reduce the number...
authorRichard Millet <richard.millet@berkeley.edu>
Fri, 30 Jul 2010 05:37:39 +0000 (05:37 +0000)
committerRichard Millet <richard.millet@berkeley.edu>
Fri, 30 Jul 2010 05:37:39 +0000 (05:37 +0000)
24 files changed:
README.txt
services/IntegrationTests/src/test/java/org/collectionspace/services/ItegrationTests/test/RelationIntegrationTest.java
services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/PerformanceTest.java
services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionServiceTest.java
services/authorization-mgt/import/src/main/java/org/collectionspace/services/authorization/importer/AuthorizationGen.java
services/authorization/jaxb/src/main/resources/permissions.xsd
services/authorization/pstore/src/main/resources/db/mysql/authorization.sql
services/authorization/service/src/main/java/org/collectionspace/services/authorization/AuthZ.java
services/client/src/main/java/org/collectionspace/services/client/AbstractServiceClientImpl.java
services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceClient.java
services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceProxy.java
services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java
services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java
services/common/pom.xml
services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java
services/common/src/main/java/org/collectionspace/services/common/security/SecurityInterceptor.java
services/common/src/main/java/org/collectionspace/services/common/security/SecurityUtils.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteSubItemDocumentModelHandlerImpl.java
services/location/jaxb/.classpath
services/relation/client/pom.xml
services/relation/client/src/main/java/org/collectionspace/services/client/RelationClient.java
services/relation/client/src/main/java/org/collectionspace/services/client/RelationProxy.java
services/relation/service/src/main/java/org/collectionspace/services/relation/NewRelationResource.java

index cdb9fee3e82d68b01a57e31c01d9a349248bb2a8..b4b25d79476d7156e929f151cb5aff3776feae2c 100644 (file)
@@ -1 +1 @@
-This change should only appear in the trunk.  Currently r1624.
\ No newline at end of file
+This change should only appear in the trunk.  Currently r1624.  This is another test of the patching mechanism.
\ No newline at end of file
index 99f2e2c2b0adff090fabf7b75d570f3e934d5e1a..3703c5cfea7da09c11af15d5dbc555f216acff25 100644 (file)
@@ -133,7 +133,8 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
            // Now try to retrieve the Intake record of the CollectionObject.
            //
            String predicate = RelationshipType.COLLECTIONOBJECT_INTAKE.value();
-           ClientResponse<RelationsCommonList> resultResponse = relationClient.readList_SPO(collectionObjectCsid,
+           ClientResponse<RelationsCommonList> resultResponse = relationClient.readList(
+                       collectionObjectCsid,
                        predicate,
                        intakeCsid);
         RelationsCommonList relationList = null;
index c9d6821095f839d1c2180f60c681cd713d2a3447..c48dc167f74c1200737caf272ee74b74589b0de7 100644 (file)
@@ -66,19 +66,20 @@ public class PerformanceTest extends CollectionSpacePerformanceTest {
        // Get clients for the CollectionSpace services
        //
        /** The MA x_ records. */
-       private static int MAX_RECORDS = 1;
+       private static int MAX_RECORDS = 1000;
 
        /**
         * Performance test.
         */
        @Test
        public void performanceTest() {
-//             roundTripOverhead(MAX_RECORDS);
-//             deleteCollectionObjects();
+               roundTripOverhead(10);
+               deleteCollectionObjects();
                String[] coList = this.createCollectionObjects(MAX_RECORDS);
-//             this.searchCollectionObjects(MAX_RECORDS);
-//             this.deleteCollectionObjects(coList);
-//             roundTripOverhead(10);
+               this.searchCollectionObjects(MAX_RECORDS);
+               this.readCollectionObjects(coList);
+               this.deleteCollectionObjects(coList);
+               roundTripOverhead(10);
        }
        
        /**
@@ -173,18 +174,8 @@ public class PerformanceTest extends CollectionSpacePerformanceTest {
         * @return the string
         */
        private String createCollectionObject(CollectionObjectClient collectionObjectClient,
-                       int identifier) {
+                       MultipartOutput multipart) {
                String result = null;
-               //
-               // First create a CollectionObject
-               //
-               CollectionobjectsCommon co = new CollectionobjectsCommon();
-               fillCollectionObject(co, Integer.toString(identifier));
-               
-               // Next, create a part object
-               MultipartOutput multipart = new MultipartOutput();
-               OutputPart commonPart = multipart.addPart(co, MediaType.APPLICATION_XML_TYPE);
-               commonPart.getHeaders().add("label", collectionObjectClient.getCommonPartName());
                // Make the create call and check the response
                ClientResponse<Response> response = collectionObjectClient.create(multipart);
                try {
@@ -213,15 +204,29 @@ public class PerformanceTest extends CollectionSpacePerformanceTest {
        public String[] createCollectionObjects(int numberOfObjects) {
                Random randomGenerator = new Random(System.currentTimeMillis());
                CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
-               String[] coList = new String[numberOfObjects];          
+               String[] coList = new String[numberOfObjects];
+               
+               //
+               // First create a CollectionObject
+               //
+               CollectionobjectsCommon co = new CollectionobjectsCommon();
+               fillCollectionObject(co, Long.toString(System.currentTimeMillis()));
+               
+               // Next, create a part object
+               MultipartOutput multipart = new MultipartOutput();
+               OutputPart commonPart = multipart.addPart(co, MediaType.APPLICATION_XML_TYPE);
+               commonPart.getHeaders().add("label", collectionObjectClient.getCommonPartName());               
                
                int createdObjects = 0;
                try {
                        Date startTime = new Date();
                        for (int i = 0; i < numberOfObjects; i++, createdObjects++) {
-                               coList[i] = createCollectionObject(collectionObjectClient, i + 1);
+                               coList[i] = createCollectionObject(collectionObjectClient, multipart);
                                if (logger.isDebugEnabled() == true) {
-                                       logger.debug("Created CollectionObject #: " + i);
+                                       //
+                                       // Print out a status every 10 operations
+                                       if (i % 10 == 0)
+                                               logger.debug("Created CollectionObject #: " + i);
                                }
                        }
                        Date stopTime = new Date();
@@ -237,7 +242,78 @@ public class PerformanceTest extends CollectionSpacePerformanceTest {
                
                return coList;
        }
+       //
+       //
+       //
+       
+       /**
+        * Delete collection object.
+        *
+        * @param collectionObjectClient the collection object client
+        * @param resourceId the resource id
+        */
+       private void readCollectionObject(CollectionObjectClient collectionObjectClient,
+                       String resourceId) {
+               ClientResponse<Response> res = collectionObjectClient.delete(resourceId);
+               res.releaseConnection();
+       }
+
+       /**
+        * Delete collection objects.
+        *
+        * @param arrayOfObjects the array of objects
+        */
+       public void readCollectionObjects(String[] arrayOfObjects) {
+               CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
+
+               Date startTime = new Date();            
+               for (int i = 0; i < arrayOfObjects.length; i++) {
+                       deleteCollectionObject(collectionObjectClient, arrayOfObjects[i]);
+               }               
+               Date stopTime = new Date();
+               
+               if (logger.isDebugEnabled()) {
+                       System.out.println("Read " + arrayOfObjects.length + " CollectionObjects" +
+                                       " in " + (stopTime.getTime() - startTime.getTime())/1000.0 + " seconds.");
+               }
+       }
+       
+       /**
+        * Delete collection objects.
+        * FIXME: Deletes a page at a time until there are no more CollectionObjects.
+        */
+       public void readCollectionObjects() {
+               CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
+               ClientResponse<AbstractCommonList> response;
+               
+               List<CollectionObjectListItem> coListItems = null;              
+               do {
+                       response = collectionObjectClient.readList(new Long(MAX_RECORDS),
+                                       new Long(0));
+                       try {
+                               CollectionobjectsCommonList commonListElement = 
+                                       (CollectionobjectsCommonList)response.getEntity(CollectionobjectsCommonList.class);
+                               coListItems = commonListElement.getCollectionObjectListItem();
+                       } finally {
+                               response.releaseConnection();
+                       }
+                       
+                       Date startTime = new Date();
+                       for (CollectionObjectListItem i:coListItems) {
+                               readCollectionObject(collectionObjectClient, i.getCsid());
+                       }
+                       Date stopTime = new Date();
+                       
+                       if (logger.isDebugEnabled()) {
+                               System.out.println("Read " + coListItems.size() + " CollectionObjects" +
+                                               " in " + (stopTime.getTime() - startTime.getTime())/1000.0 + " seconds.");
+                       }
+               } while (coListItems.size() > 0);
+       }
        
+       //
+       //
+       //
        /**
         * Delete collection object.
         *
@@ -280,8 +356,8 @@ public class PerformanceTest extends CollectionSpacePerformanceTest {
                
                List<CollectionObjectListItem> coListItems = null;              
                do {
-                       response = collectionObjectClient.readList(Integer.toString(MAX_RECORDS),
-                                       Integer.toString(0));
+                       response = collectionObjectClient.readList(new Long(MAX_RECORDS),
+                                       new Long(0));
                        try {
                                CollectionobjectsCommonList commonListElement = 
                                        (CollectionobjectsCommonList)response.getEntity(CollectionobjectsCommonList.class);
index 880735e1289df78b6a88d7e54840e3f8aa9b2924..0bd3d0147c730e72ad9ef4fff70b9a41b25a5431 100644 (file)
@@ -411,9 +411,10 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-        int EXPECTED_ITEMS = 5; //seeded permissions
+        int EXPECTED_ITEMS = 3; //seeded permissions
+        int actual = list.getPermissions().size();
         if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": received = " + list.getPermissions().size()
+            logger.debug(testName + ": received = " + actual
                     + " expected=" + EXPECTED_ITEMS);
         }
         Assert.assertEquals(EXPECTED_ITEMS, list.getPermissions().size());
index e73f9b913cb49cf88b3c4d444bdf1ae9b8275ad5..d4341270d2b142c3fc88065f0bf79bbbcc51ef3c 100644 (file)
@@ -48,6 +48,7 @@ import org.collectionspace.services.authorization.SubjectType;
 import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;
 import org.collectionspace.services.common.service.ServiceBindingType;
 import org.collectionspace.services.common.tenant.TenantBindingType;
+import org.collectionspace.services.common.security.SecurityUtils;
 
 /**
  * AuthorizationGen generates authorizations (permissions and roles)
@@ -111,21 +112,26 @@ public class AuthorizationGen {
         for (ServiceBindingType sbinding : tbinding.getServiceBindings()) {
 
             //add permissions for the main path
+               String resourceName = sbinding.getName().toLowerCase().trim();
+               if (SecurityUtils.isEntityProxy() == true) {
+                       resourceName = SecurityUtils.getResourceEntity(resourceName);
+               }
             Permission perm = buildAdminPermission(tbinding.getId(),
-                    sbinding.getName().toLowerCase());
+                    resourceName);
             apcList.add(perm);
 
             //add permissions for alternate paths
-            List<String> uriPaths = sbinding.getUriPath();
-            for (String uriPath : uriPaths) {
-                perm = buildAdminPermission(tbinding.getId(),
-                        uriPath.toLowerCase());
-                apcList.add(perm);
+            if (SecurityUtils.isEntityProxy() == false) {
+                   List<String> uriPaths = sbinding.getUriPath();
+                   for (String uriPath : uriPaths) {
+                       perm = buildAdminPermission(tbinding.getId(),
+                               uriPath.toLowerCase());
+                       apcList.add(perm);
+                   }
             }
-
         }
+        
         return apcList;
-
     }
 
     private Permission buildAdminPermission(String tenantId, String resourceName) {
@@ -134,7 +140,7 @@ public class AuthorizationGen {
         perm.setCsid(id);
         perm.setDescription("generated admin permission");
         perm.setCreatedAtItem(new Date());
-        perm.setResourceName(resourceName.toLowerCase());
+        perm.setResourceName(resourceName.toLowerCase().trim());
         perm.setEffect(EffectType.PERMIT);
         perm.setTenantId(tenantId);
         ArrayList<PermissionAction> pas = new ArrayList<PermissionAction>();
@@ -168,20 +174,24 @@ public class AuthorizationGen {
         ArrayList<Permission> apcList = new ArrayList<Permission>();
         TenantBindingType tbinding = tenantBindings.get(tenantId);
         for (ServiceBindingType sbinding : tbinding.getServiceBindings()) {
-
             //add permissions for the main path
+               String resourceName = sbinding.getName().toLowerCase().trim();
+               if (SecurityUtils.isEntityProxy() == true) {
+                       resourceName = SecurityUtils.getResourceEntity(resourceName);
+               }               
             Permission perm = buildReaderPermission(tbinding.getId(),
-                    sbinding.getName().toLowerCase());
+                    resourceName);
             apcList.add(perm);
 
             //add permissions for alternate paths
-            List<String> uriPaths = sbinding.getUriPath();
-            for (String uriPath : uriPaths) {
-                perm = buildReaderPermission(tbinding.getId(),
-                        uriPath.toLowerCase());
-                apcList.add(perm);
+            if (SecurityUtils.isEntityProxy() == false) {
+                   List<String> uriPaths = sbinding.getUriPath();
+                   for (String uriPath : uriPaths) {
+                       perm = buildReaderPermission(tbinding.getId(),
+                               uriPath.toLowerCase());
+                       apcList.add(perm);
+                   }
             }
-
         }
         return apcList;
 
@@ -193,7 +203,7 @@ public class AuthorizationGen {
         perm.setCsid(id);
         perm.setCreatedAtItem(new Date());
         perm.setDescription("generated readonly permission");
-        perm.setResourceName(resourceName.toLowerCase());
+        perm.setResourceName(resourceName.toLowerCase().trim());
         perm.setEffect(EffectType.PERMIT);
         perm.setTenantId(tenantId);
         ArrayList<PermissionAction> pas = new ArrayList<PermissionAction>();
index d0ed3f16157ba5ec7f8f00bd2f3bd726edab64cd..0107371e4286cf4732ff123a0fbd8b17fa808b3b 100644 (file)
@@ -52,6 +52,8 @@
                 no need to give slash at the beginning or end
                 - attributeName could be an attribute of the service schema
                 e.g. otherNumber from collectionobjects_common
+                - actionGroup is label that can be used by a client to "group" sets of actions for operations
+                like searching for permissions by a specific actionGroup label.
                 - action describes the actions that could be taken on given resource (and attribute)
                 - effect describes the effect of the access control for the action
                 performed on the given resource (and attribute)
                     </xs:appinfo>
                 </xs:annotation>
             </xs:element>
+            <xs:element name="actionGroup" type="xs:string" minOccurs="0" maxOccurs="1">
+                <xs:annotation>
+                    <xs:appinfo>
+                        <hj:basic>
+                            <orm:column name="action_group" length="128"  nullable="true"/>
+                        </hj:basic>
+                    </xs:appinfo>
+                </xs:annotation>
+            </xs:element>
             <xs:element name="action" type="permission_action" minOccurs="1" maxOccurs="unbounded"/>
             <xs:element name="effect" type="effect_type" minOccurs="1" maxOccurs="1">
                 <xs:annotation>
index 24c77efb0ad1d28c4b9548180e8f70620f6b7c19..78d80a785e9d594d5bd0a38450f0c61120f03ca8 100644 (file)
@@ -5,7 +5,7 @@ drop table if exists permissions_actions;
 drop table if exists permissions_roles;
 drop table if exists roles;
 create table accounts_roles (HJID bigint not null auto_increment, account_id varchar(128) not null, created_at datetime not null, role_id varchar(128) not null, role_name varchar(255), screen_name varchar(255), user_id varchar(128) not null, primary key (HJID), unique (account_id, role_id));
-create table permissions (csid varchar(128) not null, attribute_name varchar(128), created_at datetime not null, description varchar(255), effect varchar(32) not null, resource_name varchar(128) not null, tenant_id varchar(128) not null, updated_at datetime, primary key (csid));
+create table permissions (csid varchar(128) not null, action_group varchar(128), attribute_name varchar(128), created_at datetime not null, description varchar(255), effect varchar(32) not null, resource_name varchar(128) not null, tenant_id varchar(128) not null, updated_at datetime, primary key (csid));
 create table permissions_actions (HJID bigint not null auto_increment, name varchar(128) not null, ACTIONS_PERMISSION_CSID varchar(128), primary key (HJID));
 create table permissions_roles (HJID bigint not null auto_increment, created_at datetime not null, permission_id varchar(128) not null, permission_resource varchar(255), role_id varchar(128) not null, role_name varchar(255), primary key (HJID), unique (permission_id, role_id));
 create table roles (csid varchar(128) not null, created_at datetime not null, description varchar(255), rolegroup varchar(255), rolename varchar(200) not null, tenant_id varchar(128) not null, updated_at datetime, primary key (csid), unique (rolename, tenant_id));
index a4a416bff6eef2c8802968355d52a31240cf806c..15198681e7694dcca76a1a687cc2212d90a57eab 100644 (file)
@@ -55,7 +55,7 @@ public class AuthZ {
     public final static AuthZ get() {
         return self;
     }
-
+    
     private void setupProvider() {
         String beanConfig = "applicationContext-authorization.xml";
         //system property is only set in test environment
index 3ea1e7e21eb9a676a7a628b2002d5d258303a6a2..b58dc5b41bd6a41623393dda855e125e14c3e87c 100644 (file)
@@ -307,8 +307,8 @@ public abstract class AbstractServiceClientImpl implements
      * .lang.String, java.lang.String)\r
      */\r
     @Override\r
-    public ClientResponse<AbstractCommonList> readList(String pageSize,\r
-            String pageNumber) {\r
+    public ClientResponse<AbstractCommonList> readList(Long pageSize,\r
+               Long pageNumber) {\r
         return getProxy().readList(pageSize, pageNumber);\r
     }\r
 \r
@@ -320,8 +320,8 @@ public abstract class AbstractServiceClientImpl implements
      * .lang.String, java.lang.String)\r
      */\r
     @Override\r
-    public ClientResponse<AbstractCommonList> readList(String sortBy, String pageSize,\r
-            String pageNumber) {\r
+    public ClientResponse<AbstractCommonList> readList(String sortBy, Long pageSize,\r
+            Long pageNumber) {\r
         return getProxy().readList(sortBy, pageSize, pageNumber);\r
     }\r
 \r
index 022380679ab7d812ac65b15a6476e968b9c7e905..8da8cb8e91670ef126ed1fc5329e8f4782848b37 100644 (file)
@@ -149,8 +149,8 @@ public interface CollectionSpaceClient {
      * @return the client response
      */
     public ClientResponse<AbstractCommonList> readList(
-            String pageSize,
-            String pageNumber);
+               Long pageSize,
+               Long pageNumber);
 
     /**
      * Read list.
@@ -162,8 +162,8 @@ public interface CollectionSpaceClient {
      */
     public ClientResponse<AbstractCommonList> readList(
             String sortBy,
-            String pageSize,
-            String pageNumber);
+            Long pageSize,
+            Long pageNumber);
 
     /**
      * Delete.
index f95894ab7b4eaba9ff95f59ce29c70c13b457e44..b9a02d3f227ec7b3b4954349dc0f2a61e0bfa0e6 100644 (file)
@@ -49,11 +49,12 @@ public interface CollectionSpaceProxy {
     @GET\r
     @Produces({"application/xml"})\r
     ClientResponse<AbstractCommonList> readList(\r
-            @QueryParam(IClientQueryParams.PAGE_SIZE_PARAM) String pageSize,\r
-           @QueryParam(IClientQueryParams.START_PAGE_PARAM) String pageNumber);\r
+            @QueryParam(IClientQueryParams.PAGE_SIZE_PARAM) Long pageSize,\r
+           @QueryParam(IClientQueryParams.START_PAGE_PARAM) Long pageNumber);\r
        \r
     /**\r
      * Read list.\r
+     * @param sortBy \r
      *\r
      * @param pageSize the page size\r
      * @param pageNumber the page number\r
@@ -63,6 +64,6 @@ public interface CollectionSpaceProxy {
     @Produces({"application/xml"})\r
     ClientResponse<AbstractCommonList> readList(\r
             @QueryParam(IClientQueryParams.SORT_BY_PARAM) String sortBy,\r
-            @QueryParam(IClientQueryParams.PAGE_SIZE_PARAM) String pageSize,\r
-           @QueryParam(IClientQueryParams.START_PAGE_PARAM) String pageNumber);\r
+            @QueryParam(IClientQueryParams.PAGE_SIZE_PARAM) Long pageSize,\r
+           @QueryParam(IClientQueryParams.START_PAGE_PARAM) Long pageNumber);\r
 }\r
index 1ffe5254263a8afd982f1aff317d2b530afd670c..318841c959e5dc9d1149b5bdea1def46d53a3d35 100644 (file)
@@ -408,7 +408,7 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
                     CollectionSpaceClient client, String sortBy,
                     long pageSize, long pageNumber) throws Exception {
         ClientResponse<AbstractCommonList> response =
-                client.readList(sortBy, Long.toString(pageSize), Long.toString(pageNumber));
+                client.readList(sortBy, pageSize, pageNumber);
         AbstractCommonList result = null;
         try {
             int statusCode = response.getStatus();
index 021879c4d1ca72697237fe661df863dc94cdc3b8..ed39f501a118cb91a56f783f0f6c0f4bd5bf6f6e 100644 (file)
@@ -44,6 +44,7 @@ import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
 import javax.ws.rs.core.MultivaluedMap;
 
+import org.collectionspace.services.common.imaging.nuxeo.NuxeoImageUtils;
 import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
 import org.collectionspace.services.common.authorityref.AuthorityRefList;
 import org.collectionspace.services.common.context.ServiceContextFactory;
@@ -489,6 +490,25 @@ public class CollectionObjectResource
                
                return result;
     }
+    
+    @GET
+    @Path("/picture")
+    @Produces("application/xml")
+    public Response createPictureDocument() {
+       Response result = null;
+       
+               if (logger.isDebugEnabled()) {
+                       logger.debug("------------------------------------------------------------------------------");
+                       logger.debug("Prototype to create a Picture document in Nuxeo");
+                       logger.debug("------------------------------------------------------------------------------");
+                       logger.debug("");
+               }
+               
+               NuxeoImageUtils.createPicture();
+               result = Response.status(HttpResponseCodes.SC_OK).build();
+               
+               return result;
+    }    
 
     /**
      * This method is deprecated.  Use kwSearchCollectionObjects() method instead.
index cdf19397c4b79fa24d3872e861811b4e60466c6f..fed04ab5433a0b36dd60cc5e5064df00a604e794 100644 (file)
             <scope>provided</scope>\r
         </dependency>\r
         <!-- nuxeo -->\r
+           <dependency>\r
+             <groupId>org.nuxeo.ecm.platform</groupId>\r
+             <artifactId>nuxeo-platform-imaging-api</artifactId>\r
+             <version>${nuxeo.version.5.2}</version>\r
+           </dependency>\r
         <dependency>\r
             <groupId>org.nuxeo.common</groupId>\r
             <artifactId>nuxeo-common</artifactId>\r
index b15b3803068354bf501f374706fa3a0e8e6bdb8c..cff812ba5044aaebacefcd17a4fe2dd875f89b4f 100644 (file)
@@ -132,7 +132,6 @@ public class DocumentUtils {
                        
                String s = new String(buff);
                logger.debug(s);
-               System.out.println(s); //FIXME: REM - Remove this when we figure out why the logger.debug() call is not working.
                //
                // Essentially, reset the stream and return it in its original state
                //
@@ -142,19 +141,53 @@ public class DocumentUtils {
        return result;
     }
     
+    /**
+     * Gets the xML schema.
+     *
+     * @param partMeta the part meta
+     * @return the xML schema
+     * @throws Exception the exception
+     */
+    private static File getXMLSchema(ObjectPartType partMeta)
+               throws Exception {
+       final String FILE_SEPARATOR = System.getProperty("file.separator");
+       final String XML_SCHEMA_EXTENSION = ".xsd";
+       final String SCHEMAS_DIR = "schemas";
+       
+       File schemaFile = null;
+       
+       //
+       // Look for an XML Schema (.xsd) file for the incoming part payload
+       //
+       String serverRoot = ServiceMain.getInstance().getServerRootDir();
+       String schemasDir = serverRoot + FILE_SEPARATOR + 
+               SCHEMAS_DIR + FILE_SEPARATOR;           
+       //
+       // Send a warning to the log file if the XML Schema file is missing
+       //
+       String schemaName = schemasDir + partMeta.getLabel() + XML_SCHEMA_EXTENSION;
+       try {
+               schemaFile = new File(schemaName);
+       } catch (Exception e) {
+               if (logger.isWarnEnabled() == true) {
+                       logger.warn("Missing schema file for incoming payload: " + schemaName);
+               }
+       }
+       
+       return schemaFile;
+    }
+    
     /**
      * parseProperties given payload to create XML document. this
      * method also closes given stream after parsing.
      * @param payload stream
      * @param partMeta 
+     * @param validate - whether or not to validate the payload with an XML Schema
      * @return parsed Document
      * @throws Exception
      */
-    public static Document parseDocument(InputStream payload, ObjectPartType partMeta)
+    public static Document parseDocument(InputStream payload, ObjectPartType partMeta, Boolean validate)
             throws Exception {
-       final String FILE_SEPARATOR = System.getProperty("file.separator");
-       final String XML_SCHEMA_EXTENSION = ".xsd";
-       final String SCHEMAS_DIR = "schemas";
        final String JAXP_SCHEMA_SOURCE =
             "http://java.sun.com/xml/jaxp/properties/schemaSource";
        final String JAXP_SCHEMA_LANGUAGE =
@@ -169,23 +202,10 @@ public class DocumentUtils {
                        payload = logByteArrayInputStream((ByteArrayInputStream)payload);
                }
        }       
-       //
-       // Look for an XML Schema (.xsd) file for the incoming part payload
-       //
-       String serverRoot = ServiceMain.getInstance().getServerRootDir();
-       String schemasDir = serverRoot + FILE_SEPARATOR + 
-               SCHEMAS_DIR + FILE_SEPARATOR;           
-       //
-       // Send a warning to the log file if the XML Schema file is missing
-       //
-       String schemaName = schemasDir + partMeta.getLabel() + XML_SCHEMA_EXTENSION;
+       
        File schemaFile = null;
-       try {
-               schemaFile = new File(schemaName);
-       } catch (Exception e) {
-               if (logger.isWarnEnabled() == true) {
-                       logger.warn("Missing schema file for incoming payload: " + schemaName);
-               }
+       if (validate == true) {
+               schemaFile = getXMLSchema(partMeta);
        }
        
        //
@@ -202,13 +222,13 @@ public class DocumentUtils {
             factory.setIgnoringComments(true);
             factory.setIgnoringElementContentWhitespace(true);            
             //
-            // Enable XML validation
+            // Enable XML validation if we found an XML Schema for the payload
             //
-            factory.setNamespaceAware(true);
-            factory.setValidating(true);
             try {
-               factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
                if (schemaFile != null) {
+                    factory.setValidating(true);
+                    factory.setNamespaceAware(true);
+                       factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
                        factory.setAttribute(JAXP_SCHEMA_SOURCE, schemaFile);
                }
             } catch (IllegalArgumentException e) {
@@ -452,10 +472,10 @@ public class DocumentUtils {
         root.setAttribute("xsi:schemaLocation", xc.getSchemaLocation());
         root.setAttribute("xmlns:" + ns, xc.getNamespaceURI());
         document.appendChild(root);
-        
+
         SchemaManager schemaManager = Framework.getLocalService(SchemaManager.class);
         Schema schema = schemaManager.getSchema(partMeta.getLabel());
-
+        
         buildDocument(document, root, objectProps, schema);
         
         return document;
@@ -489,7 +509,7 @@ public class DocumentUtils {
     private static void buildProperty(Document document, Element parent, 
                Field field, Object value) throws IOException {
        Type type = field.getType();
-       //no need to qualify each element name as namespace is already added
+                //no need to qualify each element name as namespace is already added
        String propName = field.getName().getLocalName();
        Element element = document.createElement(propName);
        parent.appendChild(element);
@@ -501,9 +521,9 @@ public class DocumentUtils {
                if (ctype.getName().equals(TypeConstants.CONTENT)) {
                        throw new RuntimeException(
                                        "Unexpected schema type: BLOB for field: "+propName);
-               } else {
+                } else {
                        buildComplex(document, element, ctype, (Map) value);
-               }
+                }
        } else if (type.isListType()) {
                if (value instanceof List) {
                        buildList(document, element, (ListType) type, (List) value);
@@ -514,10 +534,10 @@ public class DocumentUtils {
                        throw new IllegalArgumentException(
                                        "A value of list type is neither list neither array: "
                                        + value);
-               }
-       }
+            }
+        }
     }
-    
+
     private static void buildComplex(Document document, Element element, 
                ComplexType ctype, Map map) throws IOException {
        Iterator<Map.Entry> it = map.entrySet().iterator();
index cd54396ac76de3006d7167b5e2da1360f99ed7df..5010db2ba8c7c391f6311c28bd4ef0090912d8a1 100644 (file)
@@ -28,6 +28,8 @@
 package org.collectionspace.services.common.security;
 
 import java.util.HashMap;
+import java.util.List;
+
 import org.jboss.resteasy.core.ResourceMethod;
 import org.jboss.resteasy.core.ServerResponse;
 import org.jboss.resteasy.spi.interception.PreProcessInterceptor;
@@ -38,6 +40,7 @@ import org.jboss.resteasy.spi.HttpRequest;
 
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.PathSegment;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 import javax.ws.rs.ext.Provider;
@@ -47,6 +50,7 @@ import org.collectionspace.services.authorization.CSpaceResource;
 import org.collectionspace.services.authorization.URIResourceImpl;
 import org.collectionspace.services.common.document.JaxbUtils;
 import org.collectionspace.services.common.storage.jpa.JpaStorageUtils;
+import org.collectionspace.services.common.security.SecurityUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -59,97 +63,118 @@ import org.slf4j.LoggerFactory;
 @Provider
 public class SecurityInterceptor implements PreProcessInterceptor {
 
-    private static final Logger logger = LoggerFactory.getLogger(SecurityInterceptor.class);
-
-    @Override
-    public ServerResponse preProcess(HttpRequest request, ResourceMethod method)
-            throws Failure, WebApplicationException {
-        String httpMethod = request.getHttpMethod();
-        String uriPath = request.getUri().getPath();
-        if (logger.isDebugEnabled()) {
-            logger.debug("received " + httpMethod + " on " + uriPath);
-        }
-        String resName = getResourceName(request.getUri());
-        checkActive();
-        AuthZ authZ = AuthZ.get();
-        CSpaceResource res = new URIResourceImpl(resName, httpMethod);
-        if (!authZ.isAccessAllowed(res)) {
-            logger.error("Access to " + res.getId() + " is NOT allowed to "
-                    + " user=" + AuthN.get().getUserId());
-            Response response = Response.status(
-                    Response.Status.FORBIDDEN).entity(uriPath + " " + httpMethod).type("text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        if (logger.isDebugEnabled()) {
-            logger.debug("Access to " + res.getId() + " is allowed to "
-                    + " user=" + AuthN.get().getUserId() +
-                    " for tenant id=" + AuthN.get().getCurrentTenantName());
-        }
-        return null;
-    }
-
-    /**
-     * checkActive check if account is active
-     * @throws WebApplicationException
-     */
-    private void checkActive() throws WebApplicationException {
-        String userId = AuthN.get().getUserId();
-        String tenantId = AuthN.get().getCurrentTenantId();
-        try {
-            //can't use JAXB here as this runs from the common jar which cannot
-            //depend upon the account service
-            String whereClause = "where userId = :userId";
-            HashMap<String, Object> params = new HashMap<String, Object>();
-            params.put("userId", userId);
-
-            Object account = JpaStorageUtils.getEntity(
-                    "org.collectionspace.services.account.AccountsCommon", whereClause, params);
-            if (account == null) {
-                String msg = "User's account not found, userId=" + userId;
-                Response response = Response.status(
-                        Response.Status.FORBIDDEN).entity(msg).type("text/plain").build();
-                throw new WebApplicationException(response);
-            }
-            Object status = JaxbUtils.getValue(account, "getStatus");
-            if (status != null) {
-                String value = (String) JaxbUtils.getValue(status, "value");
-                if ("INACTIVE".equalsIgnoreCase(value)) {
-                    String msg = "User's account is inactive, userId=" + userId;
-                    Response response = Response.status(
-                            Response.Status.FORBIDDEN).entity(msg).type("text/plain").build();
-                    throw new WebApplicationException(response);
-                }
-            }
-
-        } catch (Exception e) {
-            String msg = "User's account is in invalid state, userId=" + userId;
-            Response response = Response.status(
-                    Response.Status.FORBIDDEN).entity(msg).type("text/plain").build();
-            throw new WebApplicationException(response);
-        }
-    }
-
-    private String getResourceName(UriInfo uriInfo) {
-        String uriPath = uriInfo.getPath();
-        MultivaluedMap<String, String> pathParams = uriInfo.getPathParameters();
-        for (String pathParamName : pathParams.keySet()) {
-            //assumption : path params for csid for any entity has substring csid in name
-            String pathParamValue = pathParams.get(pathParamName).get(0);
-            if ((pathParamName.toLowerCase().indexOf("csid") > -1)) {
-                //replace csids with wildcard
-                uriPath = uriPath.replace(pathParamValue, "*");
-            }
-            if ((pathParamName.toLowerCase().indexOf("predicate") > -1)) {
-                //replace csids with wildcard
-                uriPath = uriPath.replace(pathParamValue, "*");
-            }
-            if (pathParamName.toLowerCase().indexOf("specifier") > -1) {
-                //replace name and specifiers with wildcard
-                uriPath = uriPath.replace("urn:cspace:name(" + pathParamValue
-                        + ")", "*");
-            }
-        }
-        uriPath = uriPath.replace("//", "/");
-        return uriPath;
-    }
+       /** The Constant logger. */
+       private static final Logger logger = LoggerFactory.getLogger(SecurityInterceptor.class);
+
+       /* (non-Javadoc)
+        * @see org.jboss.resteasy.spi.interception.PreProcessInterceptor#preProcess(org.jboss.resteasy.spi.HttpRequest, org.jboss.resteasy.core.ResourceMethod)
+        */
+       @Override
+       public ServerResponse preProcess(HttpRequest request, ResourceMethod method)
+       throws Failure, WebApplicationException {
+               String httpMethod = request.getHttpMethod();
+               String uriPath = request.getUri().getPath();
+               if (logger.isDebugEnabled()) {
+                       logger.debug("received " + httpMethod + " on " + uriPath);
+               }
+               String resName = getResourceName(request.getUri());
+               String resEntity = SecurityUtils.getResourceEntity(resName);
+               
+               //
+               // If the resource entity is acting as a proxy then all sub-resource will map to the resource itself.
+               // This essentially means that the sub-resource inherit all the authz permissions of the entity.
+               //
+               if (SecurityUtils.isEntityProxy() == true) {
+                       resName = resEntity;
+               }
+               
+               checkActive();
+               AuthZ authZ = AuthZ.get();
+               CSpaceResource res = new URIResourceImpl(resName, httpMethod);
+               if (!authZ.isAccessAllowed(res)) {
+                       logger.error("Access to " + res.getId() + " is NOT allowed to "
+                                       + " user=" + AuthN.get().getUserId());
+                       Response response = Response.status(
+                                       Response.Status.FORBIDDEN).entity(uriPath + " " + httpMethod).type("text/plain").build();
+                       throw new WebApplicationException(response);
+               }
+               if (logger.isDebugEnabled()) {
+                       logger.debug("Access to " + res.getId() + " is allowed to "
+                                       + " user=" + AuthN.get().getUserId() +
+                                       " for tenant id=" + AuthN.get().getCurrentTenantName());
+               }
+               return null;
+       }
+
+       /**
+        * checkActive check if account is active
+        * @throws WebApplicationException
+        */
+       private void checkActive() throws WebApplicationException {
+               String userId = AuthN.get().getUserId();
+               String tenantId = AuthN.get().getCurrentTenantId();
+               try {
+                       //can't use JAXB here as this runs from the common jar which cannot
+                       //depend upon the account service
+                       String whereClause = "where userId = :userId";
+                       HashMap<String, Object> params = new HashMap<String, Object>();
+                       params.put("userId", userId);
+
+                       Object account = JpaStorageUtils.getEntity(
+                                       "org.collectionspace.services.account.AccountsCommon", whereClause, params);
+                       if (account == null) {
+                               String msg = "User's account not found, userId=" + userId;
+                               Response response = Response.status(
+                                               Response.Status.FORBIDDEN).entity(msg).type("text/plain").build();
+                               throw new WebApplicationException(response);
+                       }
+                       Object status = JaxbUtils.getValue(account, "getStatus");
+                       if (status != null) {
+                               String value = (String) JaxbUtils.getValue(status, "value");
+                               if ("INACTIVE".equalsIgnoreCase(value)) {
+                                       String msg = "User's account is inactive, userId=" + userId;
+                                       Response response = Response.status(
+                                                       Response.Status.FORBIDDEN).entity(msg).type("text/plain").build();
+                                       throw new WebApplicationException(response);
+                               }
+                       }
+
+               } catch (Exception e) {
+                       String msg = "User's account is in invalid state, userId=" + userId;
+                       Response response = Response.status(
+                                       Response.Status.FORBIDDEN).entity(msg).type("text/plain").build();
+                       throw new WebApplicationException(response);
+               }
+       }
+
+       /**
+        * Gets the resource name.
+        *
+        * @param uriInfo the uri info
+        * @return the resource name
+        */
+       private String getResourceName(UriInfo uriInfo) {
+               String uriPath = uriInfo.getPath();
+
+               MultivaluedMap<String, String> pathParams = uriInfo.getPathParameters();
+               for (String pathParamName : pathParams.keySet()) {
+                       //assumption : path params for csid for any entity has substring csid in name
+                       String pathParamValue = pathParams.get(pathParamName).get(0);
+                       if ((pathParamName.toLowerCase().indexOf("csid") > -1)) {
+                               //replace csids with wildcard
+                               uriPath = uriPath.replace(pathParamValue, "*");
+                       }
+                       if ((pathParamName.toLowerCase().indexOf("predicate") > -1)) {
+                               //replace csids with wildcard
+                               uriPath = uriPath.replace(pathParamValue, "*");
+                       }
+                       if (pathParamName.toLowerCase().indexOf("specifier") > -1) {
+                               //replace name and specifiers with wildcard
+                               uriPath = uriPath.replace("urn:cspace:name(" + pathParamValue
+                                               + ")", "*");
+                       }
+               }
+               uriPath = uriPath.replace("//", "/");
+               return uriPath;
+       }
 }
index de57be1ad758f6bc476c600288765529c12a25da..e1c54840f2b69adc149836920364b2a2054e9890 100644 (file)
  */
 package org.collectionspace.services.common.security;
 
+import java.util.List;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.StringTokenizer;
+
+import javax.ws.rs.core.PathSegment;
+import javax.ws.rs.core.UriInfo;
+
 import org.collectionspace.authentication.AuthN;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -33,6 +41,7 @@ import org.slf4j.LoggerFactory;
 public class SecurityUtils {
 
     private static final Logger logger = LoggerFactory.getLogger(SecurityUtils.class);
+    public static final String URI_PATH_SEPARATOR = "/";
 
     /**
      * createPasswordHash creates password has using configured digest algorithm
@@ -68,6 +77,66 @@ public class SecurityUtils {
         }
     }
 
+       /**
+        * Gets the resource name.
+        *
+        * @param uriInfo the uri info
+        * @return the resource name
+        */
+       public static String getResourceEntity(UriInfo uriInfo) {
+               String result = null;
+               
+               result = getResourceEntity(uriInfo.getPath());
+//             List<PathSegment> pathSegmentList = uriInfo.getPathSegments();
+//             if (pathSegmentList.isEmpty() == false) {
+//                     result = pathSegmentList.get(0).getPath();
+//             }
+               
+               return result;
+       }
+       
+       /**
+        * Gets the resource entity by returning the first segment of the resource path
+        *
+        * @param relativePath the relative path
+        * @return the resource entity
+        * @throws URISyntaxException the uRI syntax exception
+        */
+       public static String getResourceEntity(String relativePath)
+       {
+               String result = "";
+               
+           StringTokenizer strTok = new StringTokenizer(relativePath, URI_PATH_SEPARATOR);
+           String pathSegment = null;
+           while (strTok.hasMoreTokens() == true) {
+               pathSegment = strTok.nextToken();
+               if (pathSegment.equals("*") == true) {
+                       //
+                       // leave the loop if we hit a wildcard character
+                       //
+                       break;
+               }
+               if (result.length() > 0) {
+                       result = result.concat(URI_PATH_SEPARATOR);
+               }
+               result = result.concat(pathSegment);
+           }
+               
+               return result;
+       }
+    
+    /**
+     * Checks if is entity is action as a proxy for all sub-resources.
+     *
+     * @return true, if is entity proxy is acting as a proxy for all sub-resources
+     */
+    public static final boolean isEntityProxy() {
+       //
+       // should be getting this information from  the cspace config settings (tenent bindings file).
+       return true;
+    }
+
+    
     /**
      * isCSpaceAdmin check if authenticated user is a CSpace administrator
      * @param tenantId
index 8785252d83ea728c8808bcd38b61130d6828835f..51b8fc4e64ed6b7eb364f2e57c52f3867108d3fc 100644 (file)
@@ -227,7 +227,8 @@ public abstract class RemoteDocumentModelHandlerImpl<T, TL>
         //check if this is an xml part
         if(part.getMediaType().equals(MediaType.APPLICATION_XML_TYPE)){
             if(payload != null){
-                Document document = DocumentUtils.parseDocument(payload, partMeta);
+                Document document = DocumentUtils.parseDocument(payload, partMeta,
+                               false /*don't validate*/);
                 //TODO: callback to handler if registered to validate the
                 //document
                 Map<String, Object> objectProps = DocumentUtils.parseProperties(document.getFirstChild());
index 9ebc7cd57bc197bd032cb7e6ffe41538064026dc..2b9f88051c3f0f5bbbd68aac139c1102136d4696 100644 (file)
@@ -75,7 +75,8 @@ public abstract class RemoteSubItemDocumentModelHandlerImpl<T, TL> extends
         // and then check that here, so skip other parts.\r
         if(part.getMediaType().equals(MediaType.APPLICATION_XML_TYPE)){\r
             if(payload != null){\r
-                Document document = DocumentUtils.parseDocument(payload, partMeta);\r
+                Document document = DocumentUtils.parseDocument(payload, partMeta,\r
+                               false /*don't validate*/);\r
                 //TODO: callback to handler if registered to validate the\r
                 //document\r
                 Map<String, Object> objectProps = DocumentUtils.parseProperties(document.getFirstChild());\r
index 425cd1620f3d44a6c3d1d8c43488a67552f09765..98a63fe9abaa411b754cc445515a8fed9c780708 100644 (file)
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
 <classpath>\r
        <classpathentry kind="src" output="target/classes" path="src/main/java"/>\r
+       <classpathentry kind="src" path="target/generated-sources/xjc"/>\r
        <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>\r
        <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>\r
        <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>\r
index 34d30174588cc260a5015a8ba44d5f8a68f79145..cce3d0b9098eb8a1e86f76c11b35da1b33f3d099 100644 (file)
             <artifactId>org.collectionspace.services.client</artifactId>\r
             <version>${project.version}</version>\r
         </dependency>\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.common</artifactId>\r
+            <optional>true</optional>\r
+            <version>${project.version}</version>\r
+        </dependency>        \r
         <!-- External dependencies -->\r
         <dependency>\r
             <groupId>org.testng</groupId>\r
index 836bf938214d905058640d663d6335bc749fcf53..4dd699bf71f146d6270b2780700cc49525f54e74 100644 (file)
@@ -102,18 +102,33 @@ public class RelationClient extends AbstractServiceClientImpl {
        }
 
        /**
-        * Read list_ spo.
+        * Read list.
         *
         * @param subjectCsid the subject csid
         * @param predicate the predicate
         * @param objectCsid the object csid
         * @return the client response
         */
-       public ClientResponse<RelationsCommonList> readList_SPO(String subjectCsid,
-                       String predicate, String objectCsid) {
-               return relationProxy.readList_SPO(subjectCsid, predicate, objectCsid);
+       public ClientResponse<RelationsCommonList> readList(String subjectCsid,
+                       String predicate,
+                       String objectCsid) {
+               return relationProxy.readList(subjectCsid, predicate, objectCsid);
        }
 
+//     /**
+//      * Read list_ spo.
+//      *
+//      * @param subjectCsid the subject csid
+//      * @param predicate the predicate
+//      * @param objectCsid the object csid
+//      * @return the client response
+//      */
+//     @Deprecated
+//     public ClientResponse<RelationsCommonList> readList_SPO(String subjectCsid,
+//                     String predicate, String objectCsid) {
+//             return relationProxy.readList_SP0(subjectCsid, predicate, objectCsid);
+//     }
+
        /**
         * Read.
         *
index 352f4f3b808c5a43c446280bb5c4db2e0b97d520..19eaaf1315a75270966473b0a10f8b7da42c4b15 100644 (file)
@@ -11,9 +11,12 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.core.Response;
 
 import org.collectionspace.services.relation.RelationsCommonList;
+import org.collectionspace.services.common.relation.IRelationsManager;
+
 import org.jboss.resteasy.client.ClientResponse;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import javax.ws.rs.QueryParam;
 
 /**
  * @version $Revision:$
@@ -26,13 +29,22 @@ public interface RelationProxy extends CollectionSpaceProxy {
     @GET
     @Produces({"application/xml"})
     ClientResponse<RelationsCommonList> readList();
-
+    
     @GET
     @Produces({"application/xml"})
-    @Path("subject/{subjectCsid}/type/{predicate}/object/{objectCsid}")
-    ClientResponse<RelationsCommonList> readList_SPO(@PathParam("subjectCsid") String subjectCsid,
-            @PathParam("predicate") String predicate,
-            @PathParam("objectCsid") String objectCsid);
+    ClientResponse<RelationsCommonList> readList(
+               @QueryParam(IRelationsManager.SUBJECT_QP) String subjectCsid,
+               @QueryParam(IRelationsManager.PREDICATE_QP) String predicate,
+               @QueryParam(IRelationsManager.OBJECT_QP) String objectCsid);
+    
+//    @GET
+//    @Produces({"application/xml"})
+//    @Path("subject/{subjectCsid}/type/{predicate}/object/{objectCsid}")
+//    @Deprecated
+//    ClientResponse<RelationsCommonList> readList_SPO(
+//             @PathParam("subjectCsid") String subjectCsid,
+//            @PathParam("predicate") String predicate,
+//            @PathParam("objectCsid") String objectCsid);
 
     //(C)reate
     @POST
index 175d52407ea15ce207e6ca7d511f08e6033963c9..a87835b17ca46191f50b6f75f3a8e2fc8749430c 100644 (file)
@@ -34,6 +34,7 @@ import javax.ws.rs.DELETE;
 import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
 import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MultivaluedMap;
@@ -42,6 +43,7 @@ import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
 
 import org.collectionspace.services.common.query.IQueryManager;
+import org.collectionspace.services.common.relation.IRelationsManager;
 import org.collectionspace.services.common.relation.nuxeo.RelationsUtils;
 import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
 import org.collectionspace.services.common.context.ServiceContext;
@@ -200,14 +202,20 @@ public class NewRelationResource extends
         * Gets the relation list.
         * 
         * @param ui the ui
+        * @param subjectCsid 
+        * @param predicate 
+        * @param objectCsid 
         * 
         * @return the relation list
         */
        @GET
        @Produces("application/xml")
-       public RelationsCommonList getRelationList(@Context UriInfo ui) {
+       public RelationsCommonList getRelationList(@Context UriInfo ui,
+                       @QueryParam(IRelationsManager.SUBJECT_QP) String subjectCsid,
+                       @QueryParam(IRelationsManager.PREDICATE_QP) String predicate,
+                       @QueryParam(IRelationsManager.OBJECT_QP) String objectCsid) {
                MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
-               return this.getRelationList(queryParams, null, null, null);
+               return this.getRelationList(queryParams, subjectCsid, predicate, objectCsid);
        }
 
        /**
@@ -498,7 +506,7 @@ public class NewRelationResource extends
                RelationsCommonList relationList = new RelationsCommonList();
                try {
                        ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
-                       DocumentHandler handler = createDocumentHandler(ctx);                   
+                       DocumentHandler handler = createDocumentHandler(ctx);
                        String relationClause = RelationsUtils.buildWhereClause(subjectCsid, predicate, objectCsid);
                        handler.getDocumentFilter().appendWhereClause(relationClause, IQueryManager.SEARCH_QUALIFIER_AND);                      
                        getRepositoryClient(ctx).getFiltered(ctx, handler);