]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-4470 Refactor the resourceMap to use the service name rather than the fully...
authorPatrick Schmitz <pschmitz@berkeley.edu>
Mon, 10 Oct 2011 23:47:50 +0000 (23:47 +0000)
committerPatrick Schmitz <pschmitz@berkeley.edu>
Mon, 10 Oct 2011 23:47:50 +0000 (23:47 +0000)
services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java
services/batch/service/pom.xml
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateAndLinkLoanOutBatchJob.java
services/common/src/main/java/org/collectionspace/services/common/ResourceMap.java

index a8d309c629b25f186605291ad64f00b5a5e50507..d99eaff77e34236fc125b13d80cf65998f5f375d 100644 (file)
@@ -132,7 +132,7 @@ public class CollectionSpaceJaxRsApplication extends Application
     
     private void addResourceToMapAndSingletons(ResourceBase resource) {
         singletons.add(resource);
-        resourceMap.put(resource.getClass().getName(), resource);
+        resourceMap.put(resource.getServiceName(), resource);
     }
 
     @Override
index 9c46bc26c299725d9e65a658bba14bab1717bb81..d2748f57be090b8435bbc323e4048f5cdc9be698 100644 (file)
             <artifactId>org.collectionspace.services.batch.client</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.loanout.client</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.relation.client</artifactId>
+            <version>${project.version}</version>
+        </dependency>
         <dependency>
             <groupId>org.collectionspace.services</groupId>
             <artifactId>org.collectionspace.services.batch.jaxb</artifactId>
index 77fdad9b661a7871748aae78a278d2603105a2d0..8df63cddb10dc45e647d990b9a0197e6c7b5a0c1 100644 (file)
@@ -13,6 +13,8 @@ import org.collectionspace.services.common.ResourceMap;
 import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
 import org.collectionspace.services.common.invocable.InvocationContext;
 import org.collectionspace.services.common.invocable.InvocationResults;
+import org.collectionspace.services.client.LoanoutClient;
+import org.collectionspace.services.client.RelationClient;
 
 public class CreateAndLinkLoanOutBatchJob implements BatchInvocable {
 
@@ -131,8 +133,8 @@ public class CreateAndLinkLoanOutBatchJob implements BatchInvocable {
                  +"</ns2:loansout_common></document>";
 
                // First, create the Loanout
-               ResourceBase resource = 
-                       resourceMap.get("org.collectionspace.services.loanout.LoanoutResource");
+               // We fetch the resource class by service name
+               ResourceBase resource = resourceMap.get( LoanoutClient.SERVICE_NAME); 
                Response response = resource.create(null, loanoutPayload);
                if(response.getStatus() != CREATED_STATUS) {
                        completionStatus = STATUS_ERROR;
@@ -158,8 +160,7 @@ public class CreateAndLinkLoanOutBatchJob implements BatchInvocable {
                        +   "<relationshipType>"+RELATION_TYPE+"</relationshipType>"
                        +   "<predicateDisplayName>"+RELATION_PREDICATE_DISP+"</predicateDisplayName>"
                        + "</ns2:relations_common></document>";
-               ResourceBase resource = 
-                       resourceMap.get("org.collectionspace.services.relation.RelationResource");
+               ResourceBase resource = resourceMap.get(RelationClient.SERVICE_NAME);
                Response response = resource.create(null, relationPayload);
                if(response.getStatus() != CREATED_STATUS) {
                        completionStatus = STATUS_ERROR;
index 2f98da3b74865fd2cbb5e007123f910181d03fd6..eecf51c6c9f713329f9e6f97f16c9e9e0a4845f6 100644 (file)
@@ -2,6 +2,9 @@ package org.collectionspace.services.common;
 \r
 import java.util.Map;\r
 \r
+/*\r
+ * Maps service names to Resource instances. Use the Service Client Class to get the service name. \r
+ */\r
 public interface ResourceMap extends Map<String, ResourceBase> {\r
 \r
 }\r