]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6953: Added more SAS tests for hierarchical relationships syncing and also...
authorremillet <remillet@yahoo.com>
Thu, 26 May 2016 17:37:16 +0000 (10:37 -0700)
committerremillet <remillet@yahoo.com>
Thu, 26 May 2016 17:37:16 +0000 (10:37 -0700)
23 files changed:
services/account/client/src/main/java/org/collectionspace/services/client/AccountClient.java
services/account/client/src/main/java/org/collectionspace/services/client/AccountRoleClient.java
services/account/client/src/main/java/org/collectionspace/services/client/TenantClient.java
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java
services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionClient.java
services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/PermissionRoleClient.java
services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/RoleClient.java
services/authorization-mgt/client/src/main/java/org/collectionspace/services/client/RolePermissionClient.java
services/authorization-mgt/import/build.xml
services/client/src/main/java/org/collectionspace/services/client/AbstractPoxServiceClientImpl.java
services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceClient.java
services/client/src/main/java/org/collectionspace/services/client/CollectionSpacePoxClient.java
services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceProxy.java
services/client/src/main/java/org/collectionspace/services/client/RelationClient.java [moved from services/relation/client/src/main/java/org/collectionspace/services/client/RelationClient.java with 100% similarity]
services/client/src/main/java/org/collectionspace/services/client/RelationProxy.java [moved from services/relation/client/src/main/java/org/collectionspace/services/client/RelationProxy.java with 100% similarity]
services/client/src/main/java/org/collectionspace/services/client/TestServiceClient.java
services/client/src/main/java/org/collectionspace/services/client/test/AbstractAuthorityServiceTest.java
services/common/src/main/java/org/collectionspace/services/common/AbstractCollectionSpaceResourceImpl.java
services/common/src/main/java/org/collectionspace/services/common/AbstractMultiPartCollectionSpaceResourceImpl.java
services/common/src/main/java/org/collectionspace/services/common/NuxeoBasedResource.java
services/common/src/main/java/org/collectionspace/services/common/security/SecurityUtils.java
services/id/client/src/main/java/org/collectionspace/services/client/IdClient.java
services/jaxb/src/main/resources/service_description.xsd [new file with mode: 0644]

index 738ff3aa0b2b4bd2b6faa00f3221161687c511ae..b94982bb7d9a3564e0e8ac16991e0ba78231009c 100644 (file)
 package org.collectionspace.services.client;
 
 import javax.ws.rs.core.Response;
+import org.apache.http.HttpStatus;
 
 import org.collectionspace.services.account.AccountsCommon;
 import org.collectionspace.services.account.AccountsCommonList;
+import org.collectionspace.services.description.ServiceDescription;
 
 /**
  * A AccountClient.
@@ -81,6 +83,7 @@ public class AccountClient extends AbstractServiceClientImpl<AccountsCommonList,
      * @return response
      * @see org.collectionspace.hello.client.AccountProxy#readList()
      */
+       @Override
     public Response readList() {
         return getProxy().readList();
     }
@@ -94,6 +97,7 @@ public class AccountClient extends AbstractServiceClientImpl<AccountsCommonList,
      * @return response
      * @see org.collectionspace.hello.client.AccountProxy#getAccount(java.lang.String)
      */
+    @Override
     public Response read(String csid) {
         return getProxy().read(csid);
     }
@@ -104,6 +108,7 @@ public class AccountClient extends AbstractServiceClientImpl<AccountsCommonList,
      * @return response
      * @see org.collectionspace.hello.client.AccountProxy#create(org.collectionspace.services.account.AccountsCommon)
      */
+    @Override
     public Response create(AccountsCommon multipart) {
         return getProxy().create(multipart);
     }
@@ -115,7 +120,23 @@ public class AccountClient extends AbstractServiceClientImpl<AccountsCommonList,
      * @return response
      * @see org.collectionspace.hello.client.AccountProxy#updateAccount(java.lang.Long, org.collectionspace.services.account.AccountsCommon)
      */
+    @Override
     public Response update(String csid, AccountsCommon multipart) {
         return getProxy().update(csid, multipart);
     }
+    
+    /**
+     * 
+     */
+       @Override
+       public ServiceDescription getServiceDescription() {
+               ServiceDescription result = null;
+               
+        Response res = getProxy().getServiceDescription();
+        if (res.getStatus() == HttpStatus.SC_OK) {
+               result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+        }
+        
+        return result;
+       }
 }
index 9360c4ea607458613634a8cedf81e918c3bd57e3..055a57dc809c442505cc38233fb6db23a52c340d 100644 (file)
 package org.collectionspace.services.client;
 
 import javax.ws.rs.core.Response;
+import org.apache.http.HttpStatus;
 
 import org.collectionspace.services.authorization.AccountRole;
+import org.collectionspace.services.description.ServiceDescription;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 
 /**
@@ -86,6 +88,7 @@ public class AccountRoleClient extends AbstractServiceClientImpl<AbstractCommonL
      * @param arcsid the arcsid
      * @return the client response
      */
+    @Override
     public Response read(String csid) {
         return getProxy().read(csid);
     }
@@ -119,6 +122,21 @@ public class AccountRoleClient extends AbstractServiceClientImpl<AbstractCommonL
     public Response delete(String csid, AccountRole accRole) {
         return getProxy().delete(csid, "delete", accRole);
     }
+    
+    /**
+     * 
+     */
+       @Override
+       public ServiceDescription getServiceDescription() {
+               ServiceDescription result = null;
+               
+        Response res = getProxy().getServiceDescription();
+        if (res.getStatus() == HttpStatus.SC_OK) {
+               result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+        }
+        
+        return result;
+       }
 
     /*
      * Not supported.
index 254a901967260627c53c10676e5f6bccb51af8f2..1dcee1967e213695094999fda8a95cbdb46cca9a 100644 (file)
@@ -28,8 +28,10 @@ package org.collectionspace.services.client;
 
 import javax.ws.rs.core.Response;
 
+import org.apache.http.HttpStatus;
 import org.collectionspace.services.account.Tenant;
 import org.collectionspace.services.account.TenantsList;
+import org.collectionspace.services.description.ServiceDescription;
 
 /**
  * A TenantClient.
@@ -68,6 +70,7 @@ public class TenantClient extends AbstractServiceClientImpl<TenantsList, Tenant,
      * @return response
      * @see org.collectionspace.hello.client.TenantProxy#readList()
      */
+       @Override
     public Response readList() {
         return getProxy().readList();
     }
@@ -81,6 +84,7 @@ public class TenantClient extends AbstractServiceClientImpl<TenantsList, Tenant,
      * @return response
      * @see org.collectionspace.hello.client.TenantProxy#getTenant(java.lang.String)
      */
+    @Override
     public Response read(String id) {
         return getProxy().read(id);
     }
@@ -91,6 +95,7 @@ public class TenantClient extends AbstractServiceClientImpl<TenantsList, Tenant,
      * @return response
      * @see org.collectionspace.hello.client.TenantProxy#create(org.collectionspace.services.account.Tenant)
      */
+    @Override
     public Response create(Tenant multipart) {
         return getProxy().create(multipart);
     }
@@ -102,7 +107,20 @@ public class TenantClient extends AbstractServiceClientImpl<TenantsList, Tenant,
      * @return response
      * @see org.collectionspace.hello.client.TenantProxy#updateTenant(java.lang.Long, org.collectionspace.services.account.Tenant)
      */
+    @Override
     public Response update(String id, Tenant multipart) {
         return getProxy().update(id, multipart);
     }
+    
+       @Override
+       public ServiceDescription getServiceDescription() {
+               ServiceDescription result = null;
+               
+        Response res = getProxy().getServiceDescription();
+        if (res.getStatus() == HttpStatus.SC_OK) {
+               result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+        }
+        
+        return result;
+       }
 }
index 48607fc71bb0c2445f709dceb937c5c1cfe523a5..c8611215f2d49b84db62606a6944c3cb4118c07c 100644 (file)
@@ -89,6 +89,7 @@ import org.collectionspace.services.workflow.WorkflowCommon;
 import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthorityItemSpecifier;
 import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.SpecifierForm;
 import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier;
+import org.collectionspace.services.description.ServiceDescription;
 import org.jboss.resteasy.util.HttpResponseCodes;
 import org.nuxeo.ecm.core.api.DocumentModel;
 import org.nuxeo.ecm.core.api.DocumentModelList;
@@ -1422,5 +1423,15 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
                 uriRegistryEntriesMap.putAll(getUriRegistryEntries(tenantId, getItemDocType(tenantId), UriTemplateFactory.ITEM));
         }
         return uriRegistryEntriesMap;
-    }  
+    }
+    
+    /**
+     * 
+     */
+    public ServiceDescription getDescription(ServiceContext ctx) {
+       ServiceDescription result = super.getDescription(ctx);
+       result.setSubresourceDocumentType(this.getItemDocType(ctx.getTenantId()));
+       return result;
+    }    
+    
 }
index 97ee6de56d2f520bacb887e623a09d847749b374..61e89d44d3793e8b6dde3601bc688ffeb1c285e8 100644 (file)
@@ -28,8 +28,10 @@ package org.collectionspace.services.client;
 
 import javax.ws.rs.core.Response;
 
+import org.apache.http.HttpStatus;
 import org.collectionspace.services.authorization.perms.Permission;
 import org.collectionspace.services.authorization.perms.PermissionsList;
+import org.collectionspace.services.description.ServiceDescription;
 
 /**
  * A PermissionClient.
@@ -76,6 +78,7 @@ public class PermissionClient extends AbstractServiceClientImpl<PermissionsList,
      * @return
      * @see org.collectionspace.hello.client.PermissionProxy#readList()
      */
+       @Override
     public Response readList() {
         return getProxy().readList();
 
@@ -91,6 +94,7 @@ public class PermissionClient extends AbstractServiceClientImpl<PermissionsList,
      * @return
      * @see org.collectionspace.hello.client.PermissionProxy#getAccount(java.lang.String)
      */
+    @Override
     public Response read(String csid) {
         return getProxy().read(csid);
     }
@@ -100,6 +104,7 @@ public class PermissionClient extends AbstractServiceClientImpl<PermissionsList,
      * @return
      * @see org.collectionspace.hello.client.PermissionProxy#create(org.collectionspace.services.permission.Permission)
      */
+    @Override
     public Response create(Permission permission) {
         return getProxy().create(permission);
     }
@@ -110,7 +115,20 @@ public class PermissionClient extends AbstractServiceClientImpl<PermissionsList,
      * @return
      * @see org.collectionspace.hello.client.PermissionProxy#updateAccount(java.lang.Long, org.collectionspace.services.permission.Permission)
      */
+    @Override
     public Response update(String csid, Permission permission) {
         return getProxy().update(csid, permission);
     }
+    
+       @Override
+       public ServiceDescription getServiceDescription() {
+               ServiceDescription result = null;
+               
+        Response res = getProxy().getServiceDescription();
+        if (res.getStatus() == HttpStatus.SC_OK) {
+               result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+        }
+        
+        return result;
+       }
 }
index 826416686482265be03a7373f531d92084ebde20..96d8d367dd10056dee16728e0c6863904c3d8822 100644 (file)
@@ -28,7 +28,9 @@ package org.collectionspace.services.client;
 
 import javax.ws.rs.core.Response;
 
+import org.apache.http.HttpStatus;
 import org.collectionspace.services.authorization.PermissionRole;
+import org.collectionspace.services.description.ServiceDescription;
 
 /**
  * A PermissionRoleClient.
@@ -87,6 +89,7 @@ public class PermissionRoleClient extends AbstractServiceClientImpl<PermissionRo
      * @return the client response
      * @see
      */
+    @Override
     public Response read(String csid) {
         return getProxy().read(csid);
     }
@@ -129,4 +132,16 @@ public class PermissionRoleClient extends AbstractServiceClientImpl<PermissionRo
        public Response readList() {
                throw new UnsupportedOperationException(); //method not supported nor needed
        }
+       
+       @Override
+       public ServiceDescription getServiceDescription() {
+               ServiceDescription result = null;
+               
+        Response res = getProxy().getServiceDescription();
+        if (res.getStatus() == HttpStatus.SC_OK) {
+               result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+        }
+        
+        return result;
+       }
 }
index ce0bab70633307b03f99d2c1cc4911e0279cda2a..edf0562e5f1e19e94fc1ae8c4535c11734c5c218 100644 (file)
@@ -30,9 +30,13 @@ import javax.ws.rs.core.Response;
 
 
 
+
+
+import org.apache.http.HttpStatus;
 import org.collectionspace.services.authorization.AccountRole;
 import org.collectionspace.services.authorization.Role;
 import org.collectionspace.services.authorization.RolesList;
+import org.collectionspace.services.description.ServiceDescription;
 
 /**
  * A RoleClient.
@@ -108,4 +112,16 @@ public class RoleClient extends AbstractServiceClientImpl<RolesList, Role, Role,
        public Class<RoleProxy> getProxyClass() {
                return RoleProxy.class;
        }
+
+       @Override
+       public ServiceDescription getServiceDescription() {
+               ServiceDescription result = null;
+               
+        Response res = getProxy().getServiceDescription();
+        if (res.getStatus() == HttpStatus.SC_OK) {
+               result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+        }
+        
+        return result;
+       }
 }
index 958aa8e54a01826c2492d28000f4c8a15ef82f67..6759755569ac53f708aabfcb07c19e9d62b59e34 100644 (file)
@@ -28,7 +28,9 @@ package org.collectionspace.services.client;
 
 import javax.ws.rs.core.Response;
 
+import org.apache.http.HttpStatus;
 import org.collectionspace.services.authorization.PermissionRole;
+import org.collectionspace.services.description.ServiceDescription;
 
 // TODO: Auto-generated Javadoc
 /**
@@ -128,4 +130,16 @@ public class RolePermissionClient extends AbstractServiceClientImpl<PermissionRo
        public Response readList() {
                throw new UnsupportedOperationException(); //method not supported nor needed
        }
+       
+       @Override
+       public ServiceDescription getServiceDescription() {
+               ServiceDescription result = null;
+               
+        Response res = getProxy().getServiceDescription();
+        if (res.getStatus() == HttpStatus.SC_OK) {
+               result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+        }
+        
+        return result;
+       }
 }
index 0ea7137cf877b8a319917feb93bcaed9ebb9344a..8617b4308b1f078d98eb5cd39b7657b33f21da62 100644 (file)
     <target name="import-windows" if="osfamily-windows" depends="setup_hibernate.cfg">
         <exec executable="cmd" failonerror="true">
             <arg value="/c" />
-            <arg value="mvn.bat" /> <!-- To debug, change command here to be 'mvnDebug.bat' -->
+            <arg value=" .bat" /> <!-- To debug, change command here to be 'mvnDebug.bat' -->
             <arg value="exec:java" />
             <arg value="-f" />
             <arg value="${basedir}/pom.xml" />
index 3d3151f6c523de2a987691348aa013daf11a03bc..99fb6101a89cd5ad751ef54c394649cad500a8cf 100644 (file)
@@ -2,8 +2,9 @@ package org.collectionspace.services.client;
 
 import javax.ws.rs.core.Response;
 
-import org.jboss.resteasy.client.ClientResponse;
 import org.testng.Assert;
+import org.apache.http.HttpStatus;
+import org.collectionspace.services.description.ServiceDescription;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 
 /*
@@ -22,6 +23,18 @@ public abstract class AbstractPoxServiceClientImpl<CLT extends AbstractCommonLis
                super();
        }
 
+       @Override
+       public ServiceDescription getServiceDescription() {
+               ServiceDescription result = null;
+               
+        Response res = getProxy().getServiceDescription();
+        if (res.getStatus() == HttpStatus.SC_OK) {
+               result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+        }
+        
+        return result;
+       }
+       
        @Override
        public Response create(PoxPayloadOut xmlPayload) {
         return getProxy().create(xmlPayload.getBytes());
index e56deba46d3cd87edea4d65d41eac1b19d7ec8d2..fa495f3d36aa6a00af669a06ab91af7a4f6e1cdb 100644 (file)
@@ -26,8 +26,7 @@ package org.collectionspace.services.client;
 import javax.ws.rs.core.Response;
 
 import org.apache.commons.httpclient.HttpClient;
-import org.jboss.resteasy.client.ClientResponse;
-import org.collectionspace.services.common.authorityref.AuthorityRefList;
+import org.collectionspace.services.description.ServiceDescription;
 
 /**
  *     LT - List Type
@@ -72,6 +71,9 @@ public interface CollectionSpaceClient<CLT, REQUEST_TYPE, RESPONSE_TYPE, P exten
     public static final String URL_PROPERTY = "cspace.url";
     public static final String USER_PROPERTY = "cspace.user";
     public static final String TENANT_PROPERTY = "cspace.tenant";
+    
+    // JAX-RS path for getting service description meta information
+       public static final String SERVICE_DESCRIPTION_PATH = "description";
 
     /**
      * Gets the proxy.
@@ -182,6 +184,8 @@ public interface CollectionSpaceClient<CLT, REQUEST_TYPE, RESPONSE_TYPE, P exten
      * Common proxied service calls
      */
 
+    public ServiceDescription getServiceDescription();
+    
        public Response create(REQUEST_TYPE payload);
        
        public Response read(String csid);
index e7830f39215bb7ca8ccc0391cae3bd55492a9406..c3d3223cba38846af7ec923cd8b771bcfbd7211c 100644 (file)
@@ -25,5 +25,5 @@ public interface CollectionSpacePoxClient<LT extends AbstractCommonList, P exten
 
     public Response keywordSearchIncludeDeleted(String keywords, Boolean includeDeleted);
     
-    public Response advancedSearchIncludeDeleted(String whereClause, Boolean includeDeleted);
+    public Response advancedSearchIncludeDeleted(String whereClause, Boolean includeDeleted);    
 }
index e3d48c2f0620c61cfcf75b4e40cdfa94c7dc0124..6c90c4c128fd62dc13ec34c0ce1cc3f1014328fb 100644 (file)
@@ -37,9 +37,6 @@ import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Response;
 
 import org.collectionspace.services.client.workflow.WorkflowClient;
-import org.collectionspace.services.common.authorityref.AuthorityRefList;
-
-import org.jboss.resteasy.client.ClientResponse;
 
 /**
  * The Interface CollectionSpaceProxy.
@@ -69,7 +66,16 @@ public interface CollectionSpaceProxy<CLT> {
     @Consumes({"application/xml"})    
     @Path("{csid}" + WorkflowClient.SERVICE_PATH + "/" + "{transition}")
     Response updateWorkflowWithTransition(@PathParam("csid") String csid, @PathParam("transition") String transition);
-    
+
+    /**
+     * Return a payload of meta info about the service
+     * @return
+     */
+    @GET
+    @Produces({"application/xml"})
+    @Path("/" + CollectionSpaceClient.SERVICE_DESCRIPTION_PATH)
+       public Response getServiceDescription();
+
     /*
      * (R)read List operations
      */
index 58060dc2a3c2894f6b8d321cab9598886af0b305..a575c393882bcb12bb91e6e1ac9e62b93533a87d 100644 (file)
@@ -24,6 +24,8 @@ package org.collectionspace.services.client;
 
 import javax.ws.rs.core.Response;
 
+import org.apache.http.HttpStatus;
+import org.collectionspace.services.description.ServiceDescription;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 
 /**
@@ -74,5 +76,17 @@ public final class TestServiceClient extends AbstractServiceClientImpl<AbstractC
        @Override
        public Response readList() {
         throw new UnsupportedOperationException();
-       } 
+       }
+       
+       @Override
+       public ServiceDescription getServiceDescription() {
+               ServiceDescription result = null;
+               
+        Response res = getProxy().getServiceDescription();
+        if (res.getStatus() == HttpStatus.SC_OK) {
+               result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+        }
+        
+        return result;
+       }
 }
index 99a5acad7fae986ce0ffa73d5f4d81e5f54c291c..de18d234c7eabec58b526befdc59dbc2b32986af 100644 (file)
@@ -1,25 +1,28 @@
 package org.collectionspace.services.client.test;
 
-import java.lang.reflect.Array;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import javax.ws.rs.core.Response;
+import org.apache.http.HttpStatus;
 
 import org.collectionspace.services.client.AbstractCommonListUtils;
 import org.collectionspace.services.client.AuthorityClient;
-import org.collectionspace.services.client.AuthorityClientImpl;
-import org.collectionspace.services.client.AuthorityProxy;
 import org.collectionspace.services.client.CollectionSpaceClient;
 import org.collectionspace.services.client.PayloadInputPart;
 import org.collectionspace.services.client.PayloadOutputPart;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.client.RelationClient;
 import org.collectionspace.services.client.XmlTools;
 import org.collectionspace.services.client.workflow.WorkflowClient;
+import org.collectionspace.services.description.ServiceDescription;
 import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.relation.RelationsCommon;
+import org.collectionspace.services.relation.RelationshipType;
+
 import org.dom4j.Document;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -47,10 +50,12 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
        protected String knownAuthorityWithItemsIdentifier = null;
        
        protected static final String SAS_IDENTIFIER = "SAS";
+       protected static final String SAS_WITH_RELATIONS = "_RELATIONS_"; 
+
+       private static final int SAS_ITEMLIST_SIZE = 5;
 
-       private static final int SAS_ITEMLIST_SIZE = 5; 
        protected String knownSASAuthorityResourceId = null;
-       protected String knownSASAuthorityResourceIdentifier = null;
+       protected String knownSASAuthorityResourceShortId = null;
        protected List<String> knownSASItemIdentifiersList = new ArrayList<String>();
        protected String knownSASItemResourceId = null;
        protected HashMap<String, String> allSASResourceItemIdsCreated = new HashMap<String, String>(); /* itemURN, parentURN */;
@@ -61,6 +66,9 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
     protected int nItemsToCreateInList = 5;
     protected String TEST_SHORTID = "johnWayneActor";
 
+       protected String knownSASAuthorityResourceWithRelationsId = null;
+       protected String knownSASAuthorityResourceWithRelationsShortId = null;
+
     /*
      * Abstract methods that subclasses must override/implement
      */
@@ -136,10 +144,17 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
      * @return
      */
        protected String getSASAuthorityIdentifier() {
-               // TODO Auto-generated method stub
                return this.getKnowResourceIdentifier() + SAS_IDENTIFIER;
        }
     
+    /**
+     * 
+     * @return
+     */
+       protected String getSASAuthorityWithRelationsIdentifier() {
+               return this.getKnowResourceIdentifier() + SAS_WITH_RELATIONS + SAS_IDENTIFIER;
+       }
+    
        /**
         * 
         * @param shortId
@@ -334,7 +349,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
         //
        String localAuthorityId = null;
         try {
-                       localAuthorityId = createResource(client, testName, knownSASAuthorityResourceIdentifier, false);
+                       localAuthorityId = createResource(client, testName, knownSASAuthorityResourceShortId, false);
                } catch (Exception e) {
                        Assert.assertNotNull(localAuthorityId);
                }
@@ -343,7 +358,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
        // Now we can try to sync the SAS authority with the local one we just created.
        //
         setupSync();
-       Response response = client.syncByName(knownSASAuthorityResourceIdentifier); // Notice we're using the Short ID (short ID is the same on the local and SAS)
+       Response response = client.syncByName(knownSASAuthorityResourceShortId); // Notice we're using the Short ID (short ID is the same on the local and SAS)
         try {
                int statusCode = response.getStatus();
                Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
@@ -357,7 +372,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
         // Check to see if the parent authority (local) is in the "Replicated" state.
         //
         setupRead();
-       response = client.readByName(knownSASAuthorityResourceIdentifier); // Notice we're using the Short ID (short ID is the same on the local and SAS)
+       response = client.readByName(knownSASAuthorityResourceShortId); // Notice we're using the Short ID (short ID is the same on the local and SAS)
         try {
                int statusCode = response.getStatus();
                Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
@@ -391,7 +406,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
 
         // Submit the request to the service and store the response.
         Response res = null;
-        res = client.readItemListForNamedAuthority(knownSASAuthorityResourceIdentifier, null, null);
+        res = client.readItemListForNamedAuthority(knownSASAuthorityResourceShortId, null, null);
 
         try {
                int statusCode = res.getStatus();
@@ -414,7 +429,9 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
                            + nItemsToCreateInList + " items; got: " + nItemsReturned + " of: " + nItemsTotal);
                }
                Assert.assertEquals(nItemsTotal, SAS_ITEMLIST_SIZE);
-       
+               //
+               // Verify that each of our local items has a corresponding remote item
+               //
                        for (AbstractCommonList.ListItem item : items) {
                                String shortId = AbstractCommonListUtils.ListItemGetElementValue(
                                                item, AuthorityClient.SHORT_IDENTIFIER);
@@ -463,7 +480,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
         try {
                String newID = createResource(getSASClientInstance(), testName, getSASAuthorityIdentifier(), true);
                knownSASAuthorityResourceId = newID;
-               knownSASAuthorityResourceIdentifier = getShortId(getSASClientInstance(), knownSASAuthorityResourceId);
+               knownSASAuthorityResourceShortId = getShortId(getSASClientInstance(), knownSASAuthorityResourceId);
             if (logger.isDebugEnabled()) {
                String.format("Created SAS authority '%s' with CSID=%s.", getSASAuthorityIdentifier(), newID);
             }
@@ -471,6 +488,65 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
                logger.info(String.format("Failed to create SAS authority '%s'.", getSASAuthorityIdentifier()));
         }
     }
+    
+    @Test(dataProvider = "testName", dependsOnMethods = {"deleteLocalItemWithSync", "CRUDTests"})
+    public void createSASAuthorityWithRelations(String testName) {
+        //
+        // First check to see if the authority supports synchronization.
+        //
+       AuthorityClient client = (AuthorityClient) getClientInstance();
+       if (client.supportsSync() == false) {
+               return; // Exit the test since this authority doesn't support synchronization
+       }
+       
+        // Perform setup.
+        setupCreate();
+        //
+        // Create a new authority on the remote server
+        //
+        try {
+               String newID = createResource(getSASClientInstance(), testName, getSASAuthorityWithRelationsIdentifier(), true);
+               knownSASAuthorityResourceWithRelationsId = newID;
+               knownSASAuthorityResourceWithRelationsShortId = getShortId(getSASClientInstance(), knownSASAuthorityResourceWithRelationsId);
+        } catch (Exception e) {
+               logger.info(String.format("Failed to create SAS authority with relations '%s'.", getSASAuthorityWithRelationsIdentifier()));
+        }
+        //
+        // Add three items to the remote authority
+        //
+        String continentShortId = "Continent" + System.currentTimeMillis() + Math.abs(random.nextInt()); // short ID needs to be unique
+        String continentCSID = createItemInAuthority(getSASClientInstance(), knownSASAuthorityResourceWithRelationsId, continentShortId);
+        this.allSASResourceItemIdsCreated.put(this.getUrnIdentifier(continentShortId), getUrnIdentifier(getSASAuthorityWithRelationsIdentifier()));
+        
+        String countryShortId = "Country" + System.currentTimeMillis() + Math.abs(random.nextInt()); // short ID needs to be unique
+        String countryCSID = createItemInAuthority(getSASClientInstance(), knownSASAuthorityResourceWithRelationsId, countryShortId);
+        this.allSASResourceItemIdsCreated.put(this.getUrnIdentifier(countryShortId), getUrnIdentifier(getSASAuthorityWithRelationsIdentifier()));
+
+        String cityShortId = "City" + System.currentTimeMillis() + Math.abs(random.nextInt()); // short ID needs to be unique
+        String cityCSID = createItemInAuthority(getSASClientInstance(), knownSASAuthorityResourceWithRelationsId, cityShortId);
+        this.allSASResourceItemIdsCreated.put(this.getUrnIdentifier(cityShortId), getUrnIdentifier(getSASAuthorityWithRelationsIdentifier()));
+        //
+        // Create a set of hierarchical relationships between the items
+        //
+        ServiceDescription serviceDescription = client.getServiceDescription();
+        final String authorityItemDocumentType = serviceDescription == null ? "unknown" : serviceDescription.getSubresourceDocumentType();
+        
+        RelationsCommon relationCommon = new RelationsCommon();
+        relationCommon.setSubjectCsid(countryCSID);
+        relationCommon.setSubjectDocumentType(authorityItemDocumentType);
+        relationCommon.setObjectCsid(continentCSID);
+        relationCommon.setObjectDocumentType(authorityItemDocumentType);
+        relationCommon.setRelationshipType(RelationshipType.HAS_BROADER.value());
+        relationCommon.setPredicateDisplayName(RelationshipType.HAS_BROADER.value());
+        
+        RelationClient relationClient = new RelationClient(CollectionSpaceClient.SAS_CLIENT_PROPERTIES_FILENAME); // Get a Relation service client to the SAS
+        PoxPayloadOut payloadOut = relationClient.createRequestTypeInstance(relationCommon);
+        Response res = relationClient.create(payloadOut);
+        if (res.getStatus() != HttpStatus.SC_CREATED) {
+               logger.error("Could not create Relationship.");
+        }
+
+}
 
     /**
      * SAS - Create an item in the SAS authority on the SAS server.
@@ -509,7 +585,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
                // the *local* authority after we perform a sync operation.  We need to keep track
                // of the URN (not the CSID) since the CSIDs will differ on the SAS vs local.
                //
-               this.allSASResourceItemIdsCreated.put(this.getUrnIdentifier(shortId), getUrnIdentifier(getSASAuthorityIdentifier()));
+               this.allSASResourceItemIdsCreated.put(this.getUrnIdentifier(shortId), getUrnIdentifier(knownSASAuthorityResourceShortId));
         }
         
     }
@@ -890,7 +966,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
 
         // Delete an item from the SAS server
         AuthorityClient sasClient = (AuthorityClient) this.getSASClientInstance();
-        Response res = sasClient.deleteNamedItemInNamedAuthority(knownSASAuthorityResourceIdentifier, knownSASItemIdentifiersList.get(itemIndexToDelete));
+        Response res = sasClient.deleteNamedItemInNamedAuthority(knownSASAuthorityResourceShortId, knownSASItemIdentifiersList.get(itemIndexToDelete));
         try {
                Assert.assertEquals(res.getStatus(), testExpectedStatusCode);   
         } finally {
@@ -901,7 +977,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
         // to the SAS takes place locally after the sync -i.e., the local item should be deleted as well.
         setupSync();
         AuthorityClient localClient = (AuthorityClient) this.getClientInstance();
-       Response response = localClient.syncByName(knownSASAuthorityResourceIdentifier); // Notice we're using the Short ID (short ID is the same on the local and SAS)
+       Response response = localClient.syncByName(knownSASAuthorityResourceShortId); // Notice we're using the Short ID (short ID is the same on the local and SAS)
         try {
                int statusCode = response.getStatus();
                Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), invalidStatusCodeMessage(testRequestType, statusCode));
@@ -912,7 +988,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
         
         // Verify that the local item has been deleted.
         setupReadNonExistent();
-        res = localClient.readNamedItemInNamedAuthority(knownSASAuthorityResourceIdentifier, knownSASItemIdentifiersList.get(itemIndexToDelete));
+        res = localClient.readNamedItemInNamedAuthority(knownSASAuthorityResourceShortId, knownSASItemIdentifiersList.get(itemIndexToDelete));
         try {
                Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
                knownSASItemIdentifiersList.remove(0); // remove it from our known set now that we've deleted it
@@ -943,7 +1019,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
         // Retrieve the contents of a shared authority item that we're going to update.
         AUTHORITY_ITEM_TYPE sasAuthorityItem = null;
         AuthorityClient sasClient = (AuthorityClient) this.getSASClientInstance();
-        Response res = sasClient.readNamedItemInNamedAuthority(knownSASAuthorityResourceIdentifier, knownSASItemIdentifiersList.get(0));
+        Response res = sasClient.readNamedItemInNamedAuthority(knownSASAuthorityResourceShortId, knownSASItemIdentifiersList.get(0));
         try {
                if (logger.isDebugEnabled()) {
                    logger.debug(testName + ": read status = " + res.getStatus());
@@ -961,7 +1037,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
 
         // Submit the updated authority item and check the response.
         PoxPayloadOut output = this.createItemRequestTypeInstance(theUpdate);
-        res = sasClient.updateNamedItemInNamedAuthority(knownSASAuthorityResourceIdentifier, knownSASItemIdentifiersList.get(0), output);
+        res = sasClient.updateNamedItemInNamedAuthority(knownSASAuthorityResourceShortId, knownSASItemIdentifiersList.get(0), output);
         AUTHORITY_ITEM_TYPE updatedSASAuthorityItem = null;
         try {
                int statusCode = res.getStatus();
@@ -987,7 +1063,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
         // to the SAS item appears locally after the sync
         setupSync();
         AuthorityClient localClient = (AuthorityClient) this.getClientInstance();
-       Response response = localClient.syncByName(knownSASAuthorityResourceIdentifier); // Notice we're using the Short ID (short ID is the same on the local and SAS)
+       Response response = localClient.syncByName(knownSASAuthorityResourceShortId); // Notice we're using the Short ID (short ID is the same on the local and SAS)
         try {
                int statusCode = response.getStatus();
                Assert.assertTrue(testRequestType.isValidStatusCode(statusCode), invalidStatusCodeMessage(testRequestType, statusCode));
@@ -997,7 +1073,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
         }        
         
         setupRead();
-        res = localClient.readNamedItemInNamedAuthority(knownSASAuthorityResourceIdentifier, knownSASItemIdentifiersList.get(0));
+        res = localClient.readNamedItemInNamedAuthority(knownSASAuthorityResourceShortId, knownSASItemIdentifiersList.get(0));
         try {
                Assert.assertEquals(res.getStatus(), testExpectedStatusCode);
                AUTHORITY_ITEM_TYPE syncedAuthorityItem = extractItemCommonPartValue(res);
index 6ca439eba5c13facca8714b17179e949f9c4caac..893c4e0be253cded5e9d5aff562e4bf5d5df80e8 100644 (file)
@@ -23,7 +23,6 @@
  */
 package org.collectionspace.services.common;
 
-import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -31,13 +30,16 @@ import java.util.Map;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
+import org.collectionspace.services.client.CollectionSpaceClient;
 import org.collectionspace.services.common.CSWebApplicationException;
 import org.collectionspace.services.common.api.Tools;
 import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;
+import org.collectionspace.services.common.context.MultipartServiceContext;
 import org.collectionspace.services.common.context.ServiceContext;
 import org.collectionspace.services.common.context.ServiceContextProperties;
 import org.collectionspace.services.common.document.BadRequestException;
@@ -51,10 +53,8 @@ import org.collectionspace.services.common.security.UnauthorizedException;
 import org.collectionspace.services.common.storage.StorageClient;
 import org.collectionspace.services.common.storage.jpa.JpaStorageClientImpl;
 import org.collectionspace.services.config.service.ServiceBindingType;
-import org.jboss.resteasy.core.ResourceMethodInvoker;
-//import org.jboss.resteasy.core.ResourceMethod;
+import org.collectionspace.services.description.ServiceDescription;
 import org.jboss.resteasy.spi.HttpRequest;
-import org.jboss.resteasy.spi.metadata.ResourceMethod;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -409,6 +409,41 @@ public abstract class AbstractCollectionSpaceResourceImpl<IT, OT>
        
        return result;
     }
+    
+    /*
+     * Get the service description
+     */
+    @GET
+    @Path(CollectionSpaceClient.SERVICE_DESCRIPTION_PATH)
+    public ServiceDescription getDescription(@Context UriInfo uriInfo) {
+       ServiceDescription result = null;
+
+       ServiceContext  ctx = null;
+        try {
+            ctx = createServiceContext(uriInfo);
+            result = getDescription(ctx);
+        } catch (Exception e) {
+               String errMsg = String.format("Request to get service description information for the '%s' service failed.",
+                               this.getServiceContextFactory());
+            throw bigReThrow(e, errMsg);
+        }
+        
+        return result;
+    }
+    
+    /**
+     * Each resource can override this method if they need to.
+     * 
+     * @param ctx
+     * @return
+     */
+    public ServiceDescription getDescription(ServiceContext ctx) {
+       ServiceDescription result = new ServiceDescription();
+       
+       result.setDocumentType(getDocType(ctx.getTenantId()));
+       
+       return result;
+    }    
 
     public void checkResult(Object resultToCheck, String csid, String serviceMessage) throws CSWebApplicationException {
         if (resultToCheck == null) {
index f3020da179f84e8394235116c11c209da77dd7db..03e9ccfadd18e2b297bf2f88809d1b92e3fd6693 100644 (file)
@@ -50,6 +50,7 @@ import org.collectionspace.services.common.workflow.service.nuxeo.WorkflowDocume
 import org.collectionspace.services.lifecycle.Lifecycle;
 import org.collectionspace.services.lifecycle.TransitionDef;
 import org.collectionspace.services.workflow.WorkflowCommon;
+
 import org.dom4j.DocumentException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -137,9 +138,11 @@ public abstract class AbstractMultiPartCollectionSpaceResourceImpl extends Abstr
 
         return docHandler;
     }
-
-    /*
-     * JAX-RS Annotated methods
+    
+    /**
+     * Get the workflow lifecycle description of a resource
+     * @param uriInfo
+     * @return
      */
     @GET
     @Path(WorkflowClient.SERVICE_PATH)
@@ -163,11 +166,7 @@ public abstract class AbstractMultiPartCollectionSpaceResourceImpl extends Abstr
         
         return result;
     }
-    
-    /*
-     * JAX-RS Annotated methods
-     */
-    
+        
     /*
      * We should change this method.  The RepositoryClient (from call to getRepositoryClient) should support a call getWorkflowTransition() instead.
      */    
index 97c1f71de30998c6d94b5964c32fb83a09ebbb4f..899c5fc5cd84b66dd9746d023c39958f8f80f48a 100644 (file)
@@ -23,9 +23,7 @@
  */
 package org.collectionspace.services.common;
 
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import javax.ws.rs.*;
 import javax.ws.rs.core.*;
@@ -38,10 +36,8 @@ import org.collectionspace.services.common.api.RefName;
 import org.collectionspace.services.common.api.Tools;
 import org.collectionspace.services.common.authorityref.AuthorityRefList;
 import org.collectionspace.services.common.config.ServiceConfigUtils;
-import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;
 import org.collectionspace.services.common.context.RemoteServiceContext;
 import org.collectionspace.services.common.context.ServiceContext;
-import org.collectionspace.services.common.document.DocumentException;
 import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.document.DocumentHandler;
 import org.collectionspace.services.common.document.DocumentNotFoundException;
@@ -51,7 +47,7 @@ import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthRe
 import org.collectionspace.services.config.ClientType;
 import org.collectionspace.services.config.service.DocHandlerParams;
 import org.collectionspace.services.config.service.ListResultField;
-import org.collectionspace.services.config.service.ServiceBindingType;
+import org.collectionspace.services.description.ServiceDescription;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
@@ -591,6 +587,15 @@ public abstract class NuxeoBasedResource
        
        return result;
        }
+    
+    @Override
+    public ServiceDescription getDescription(ServiceContext ctx) {
+       ServiceDescription result = new ServiceDescription();
+       
+       result.setDocumentType(getDocType(ctx.getTenantId()));
+       
+       return result;
+    }
        
     /*
      * ResourceBase create and update calls will set the resourceMap into the service context
index a5c49bfc406156119da766cff7bbd472dea6f10c..1c4e6f25fcc1af35c7478772231586a0a2b01061 100644 (file)
@@ -32,6 +32,7 @@ import java.util.StringTokenizer;
 import org.collectionspace.services.authorization.AuthZ;
 import org.collectionspace.services.authorization.CSpaceResource;
 import org.collectionspace.services.authorization.URIResourceImpl;
+import org.collectionspace.services.client.CollectionSpaceClient;
 import org.collectionspace.services.client.index.IndexClient;
 import org.collectionspace.services.client.workflow.WorkflowClient;
 import org.collectionspace.services.config.service.ServiceBindingType;
@@ -237,7 +238,8 @@ public class SecurityUtils {
            String pathSegment = null;
            while (strTok.hasMoreTokens() == true) {
                pathSegment = strTok.nextToken();
-               if (pathSegment.equals("*") == true || pathSegment.equals("index") == true) {
+               if (pathSegment.equals("*") || 
+                               pathSegment.equals("index") || pathSegment.equals(CollectionSpaceClient.SERVICE_DESCRIPTION_PATH)) {  // Strip off subresource paths since they inherit their parent's permissions
                        //
                        // leave the loop if we hit a wildcard character or the "index" subresource
                        //
index 22400023fd27c09392944671c220fad4188aa0b4..a40e512c79e32091536155b87aff26d646ce8c43 100644 (file)
@@ -2,6 +2,9 @@ package org.collectionspace.services.client;
 
 import javax.ws.rs.core.Response;
 
+import org.apache.http.HttpStatus;
+import org.collectionspace.services.description.ServiceDescription;
+
 /**
  * IDClient.
  *
@@ -44,14 +47,17 @@ public class IdClient extends AbstractServiceClientImpl<String, String, String,
     
     // Operations on ID Generators
     
+    @Override
     public Response create(String xmlPayload) {
         return getProxy().create(xmlPayload);
     }
 
+    @Override
     public Response read(String csid) {
         return getProxy().read(csid);
     }
     
+    @Override
     public Response readList() {
         return getProxy().readList();
     }
@@ -69,5 +75,18 @@ public class IdClient extends AbstractServiceClientImpl<String, String, String,
 
        @Override
        public Response update(String csid, String payload) {
-               throw new UnsupportedOperationException("ID client does not support an update operation.");     }
+               throw new UnsupportedOperationException("ID client does not support an update operation.");
+       }
+       
+       @Override
+       public ServiceDescription getServiceDescription() {
+               ServiceDescription result = null;
+               
+        Response res = getProxy().getServiceDescription();
+        if (res.getStatus() == HttpStatus.SC_OK) {
+               result = (ServiceDescription) res.readEntity(ServiceDescription.class);
+        }
+        
+        return result;
+       }
 }
diff --git a/services/jaxb/src/main/resources/service_description.xsd b/services/jaxb/src/main/resources/service_description.xsd
new file mode 100644 (file)
index 0000000..c586bb3
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+    Service Description Schema (XSD)
+    
+    Entity  : ServiceDescription
+    Used for: JAXB binding between XML and Java objects
+-->
+
+<xs:schema 
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+  jaxb:version="1.0" elementFormDefault="unqualified"
+  xmlns:ns="http://collectionspace.org/services/description"
+  xmlns="http://collectionspace.org/services/description"
+  targetNamespace="http://collectionspace.org/services/description"
+  version="0.1">
+<!--
+    Avoid XmlRootElement nightmare:
+    See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
+-->    
+    <!-- ServiceDescription -->
+    <xs:element name="service_description">
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element name="documentType" type="xs:string"/>
+                <xs:element name="subresourceDocumentType" type="xs:string"/>
+                <xs:element name="serviceVersion" type="xs:string"/>
+            </xs:sequence>
+        </xs:complexType>
+    </xs:element>    
+</xs:schema>
+