From: Patrick Schmitz Date: Mon, 10 Oct 2011 23:47:50 +0000 (+0000) Subject: CSPACE-4470 Refactor the resourceMap to use the service name rather than the fully... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=1892c02cc534f1d908f848fea37a740d17e48ada;p=tmp%2Fjakarta-migration.git CSPACE-4470 Refactor the resourceMap to use the service name rather than the fully qualified classname. Cleaner, and makes the map usable in converting refName to CSID. --- diff --git a/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java b/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java index a8d309c62..d99eaff77 100644 --- a/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java +++ b/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java @@ -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 diff --git a/services/batch/service/pom.xml b/services/batch/service/pom.xml index 9c46bc26c..d2748f57b 100644 --- a/services/batch/service/pom.xml +++ b/services/batch/service/pom.xml @@ -29,6 +29,16 @@ org.collectionspace.services.batch.client ${project.version} + + org.collectionspace.services + org.collectionspace.services.loanout.client + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.relation.client + ${project.version} + org.collectionspace.services org.collectionspace.services.batch.jaxb diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateAndLinkLoanOutBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateAndLinkLoanOutBatchJob.java index 77fdad9b6..8df63cddb 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateAndLinkLoanOutBatchJob.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/CreateAndLinkLoanOutBatchJob.java @@ -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 { +""; // 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 { + ""+RELATION_TYPE+"" + ""+RELATION_PREDICATE_DISP+"" + ""; - 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; diff --git a/services/common/src/main/java/org/collectionspace/services/common/ResourceMap.java b/services/common/src/main/java/org/collectionspace/services/common/ResourceMap.java index 2f98da3b7..eecf51c6c 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ResourceMap.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ResourceMap.java @@ -2,6 +2,9 @@ package org.collectionspace.services.common; import java.util.Map; +/* + * Maps service names to Resource instances. Use the Service Client Class to get the service name. + */ public interface ResourceMap extends Map { }