]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5518: Updated service context setup to support existing hierarchy creation...
authorRichard Millet <remillet@berkeley.edu>
Fri, 7 Sep 2012 20:52:17 +0000 (13:52 -0700)
committerRichard Millet <remillet@berkeley.edu>
Fri, 7 Sep 2012 20:52:17 +0000 (13:52 -0700)
services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml
services/account/service/src/main/java/org/collectionspace/services/account/AccountResource.java
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java
services/common/src/main/java/org/collectionspace/services/common/AbstractCollectionSpaceResourceImpl.java
services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java
services/common/src/main/java/org/collectionspace/services/common/context/MultipartServiceContextFactory.java
services/common/src/main/java/org/collectionspace/services/common/context/MultipartServiceContextImpl.java
services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextFactory.java
services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextImpl.java
services/common/src/main/java/org/collectionspace/services/common/context/ServiceContextFactory.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java

index 1691fe4bf43fa33e1e20784e97d367e9ef67b5c2..10f23e7e6898232b7e6cb836ebbd38f808f34841 100644 (file)
@@ -33,6 +33,9 @@
          File below this line have been ported. -->\r
     <!-- ============================================= -->\r
     \r
+    <run controlFile="collectionobject/collectionobject-hierarchy.xml" testGroup="HierarchicCollectionObject" />\r
+    \r
+    \r
     <run controlFile="./security.xml" testGroup="deleteBug" />\r
     <run controlFile="objectexit/object-exit.xml" testGroup="makeone" />\r
     <run controlFile="objectexit/object-exit.xml" testGroup="checkList" />\r
index 781f391e23c050f36b4bc44a6b8a3b0bea4bf6ee..170e056120b3b541accbbdf9fd20971afb757ae9 100644 (file)
@@ -50,7 +50,6 @@ import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
-import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
index c6176062ef102eef73843ed23d4cffff207bee9a..144500e9d3d2940cbbf635c29d2d12e4c15c3d21 100644 (file)
@@ -376,7 +376,8 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
     @GET
     @Path("{csid}")
     @Override
-    public byte[] get( // getAuthority(
+    public byte[] get(
+            @Context Request request,
             @Context UriInfo ui,
             @PathParam("csid") String specifier) {
         PoxPayloadOut result = null;
@@ -607,20 +608,20 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
     public byte[] getAuthorityItem(
             @Context Request request,
             @Context UriInfo ui,
+               @Context ResourceMap resourceMap,            
             @PathParam("csid") String parentspecifier,
             @PathParam("itemcsid") String itemspecifier) {
         PoxPayloadOut result = null;
         try {
-            JaxRsContext jaxRsContext = new JaxRsContext(request, ui);
             MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
             String parentcsid = lookupParentCSID(parentspecifier, "getAuthorityItem(parent)", "GET_ITEM", queryParams);
 
             RemoteServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = null;
-            ctx = (RemoteServiceContext<PoxPayloadIn, PoxPayloadOut>) createServiceContext(getItemServiceName(), queryParams);
+            ctx = (RemoteServiceContext<PoxPayloadIn, PoxPayloadOut>) createServiceContext(getItemServiceName(), resourceMap, ui);
+            
+            JaxRsContext jaxRsContext = new JaxRsContext(request, ui); // REM - Why are we setting this?  Who is using the getter?
             ctx.setJaxRsContext(jaxRsContext);
 
-            ctx.setUriInfo(ui); //ARG!   must pass this or subsequent calls will not have a ui.
-
             // We omit the parentShortId, only needed when doing a create...
             DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createItemDocumentHandler(ctx, parentcsid, null);
 
index ec66b28a20be926dde0ce0803c1bac641f4afdc2..229a198c00e2578193128dd83df9e18298ab1d80 100644 (file)
@@ -159,7 +159,8 @@ public abstract class AbstractCollectionSpaceResourceImpl<IT, OT>
     protected ServiceContext<IT, OT> createServiceContext() throws Exception {         \r
         ServiceContext<IT, OT> ctx = createServiceContext(this.getServiceName(),\r
                        (IT)null, //inputType\r
-                       (MultivaluedMap<String, String>)null, /*queryParams*/\r
+                       null, // The resource map\r
+                       (MultivaluedMap<String, String>)null, // The query params\r
                        this.getCommonPartClass());\r
         return ctx;\r
     }    \r
@@ -176,8 +177,9 @@ public abstract class AbstractCollectionSpaceResourceImpl<IT, OT>
     protected ServiceContext<IT, OT> createServiceContext(String serviceName) throws Exception {       \r
         ServiceContext<IT, OT> ctx = createServiceContext(\r
                        serviceName,\r
-                       (IT)null, /*input*/\r
-                       (MultivaluedMap<String, String>)null, /*queryParams*/\r
+                       (IT)null, // The input part\r
+                       null, // The resource map\r
+                       (MultivaluedMap<String, String>)null, // The queryParams\r
                        (Class<?>)null  /*input type's Class*/);\r
         return ctx;\r
     }\r
@@ -194,7 +196,9 @@ public abstract class AbstractCollectionSpaceResourceImpl<IT, OT>
      */\r
     protected ServiceContext<IT, OT> createServiceContext(String serviceName,\r
                IT input) throws Exception {            \r
-        ServiceContext<IT, OT> ctx = createServiceContext(serviceName, input,\r
+        ServiceContext<IT, OT> ctx = createServiceContext(serviceName,\r
+                       input,\r
+                       null, // The resource map\r
                        (MultivaluedMap<String, String>)null, /*queryParams*/\r
                        (Class<?>)null  /*input type's Class*/);\r
         return ctx;\r
@@ -211,6 +215,7 @@ public abstract class AbstractCollectionSpaceResourceImpl<IT, OT>
                MultivaluedMap<String, String> queryParams) throws Exception {          \r
         ServiceContext<IT, OT> ctx = createServiceContext(serviceName,\r
                        (IT)null,\r
+                       null, // The resource map\r
                        queryParams,\r
                        (Class<?>)null  /*input type's Class*/);\r
         return ctx;\r
@@ -279,13 +284,42 @@ public abstract class AbstractCollectionSpaceResourceImpl<IT, OT>
         return ctx;\r
     }\r
     \r
+    protected ServiceContext<IT, OT> createServiceContext(\r
+               String serviceName,\r
+               ResourceMap resourceMap,\r
+               UriInfo ui) throws Exception {\r
+       ServiceContext<IT, OT> ctx = createServiceContext(\r
+                       serviceName,\r
+                       null, // The input object\r
+                       resourceMap,\r
+                       ui.getQueryParameters(),\r
+                       null /* the class of the input type */);\r
+       ctx.setUriInfo(ui);\r
+       return ctx;\r
+    }\r
+    \r
+    protected ServiceContext<IT, OT> createServiceContext(\r
+               IT input,\r
+               ResourceMap resourceMap,\r
+               UriInfo ui) throws Exception {\r
+       ServiceContext<IT, OT> ctx = createServiceContext(\r
+                       this.getServiceName(),\r
+                       input,\r
+                       resourceMap,\r
+                       ui.getQueryParameters(),\r
+                       null /* the class of the input type */);\r
+       ctx.setUriInfo(ui);\r
+       return ctx;\r
+    }\r
+\r
     protected ServiceContext<IT, OT> createServiceContext(\r
                IT input,\r
                MultivaluedMap<String, String> queryParams) throws Exception {\r
        return createServiceContext(this.getServiceName(),\r
                        input,\r
+                       null, // The resource map\r
                        queryParams,\r
-                       null /* the class of the input type */);\r
+                       null); // The class of the input type.\r
     }\r
     \r
     /**\r
@@ -305,6 +339,7 @@ public abstract class AbstractCollectionSpaceResourceImpl<IT, OT>
                Class<?> theClass) throws Exception {\r
        return createServiceContext(this.getServiceName(),\r
                        input,\r
+                       null, // The resource map\r
                        queryParams,\r
                        theClass);\r
     }\r
@@ -324,17 +359,20 @@ public abstract class AbstractCollectionSpaceResourceImpl<IT, OT>
     private ServiceContext<IT, OT> createServiceContext(\r
                String serviceName,\r
                IT input,\r
+               ResourceMap resourceMap,\r
                MultivaluedMap<String, String> queryParams,\r
                Class<?> theClass) throws Exception {\r
         ServiceContext<IT, OT> ctx = getServiceContextFactory().createServiceContext(\r
                        serviceName,\r
                        input,\r
+                       resourceMap,\r
                        queryParams,\r
                        theClass != null ? theClass.getPackage().getName() : null,\r
                        theClass != null ? theClass.getName() : null);\r
-        if(theClass != null) {\r
+        if (theClass != null) {\r
             ctx.setProperty(ServiceContextProperties.ENTITY_CLASS, theClass);\r
         }\r
+        \r
         return ctx;\r
     }\r
         \r
index 462a8659d5e7ef39ae5604868d3bbf5ea71d5c59..de70114bba2540b14dcf6b4221bc07a30a68d727 100644 (file)
@@ -31,6 +31,8 @@ import org.collectionspace.services.common.api.RefName;
 import org.collectionspace.services.common.api.Tools;\r
 import org.collectionspace.services.common.authorityref.AuthorityRefList;\r
 import org.collectionspace.services.common.config.ServiceConfigUtils;\r
+import org.collectionspace.services.common.context.JaxRsContext;\r
+import org.collectionspace.services.common.context.RemoteServiceContext;\r
 import org.collectionspace.services.common.context.ServiceContext;\r
 import org.collectionspace.services.common.document.DocumentFilter;\r
 import org.collectionspace.services.common.document.DocumentHandler;\r
@@ -89,21 +91,22 @@ public abstract class ResourceBase
     //======================= CREATE ====================================================\r
     \r
     @POST\r
-    public Response create(@Context ResourceMap resourceMap,\r
+    public Response create(\r
+               @Context ResourceMap resourceMap,\r
                @Context UriInfo ui,\r
             String xmlPayload) {\r
         return this.create(null, resourceMap, ui, xmlPayload); \r
     }\r
     \r
     public Response create(ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx, // REM: 8/13/2012 - Some sub-classes will override this method -e.g., MediaResource does.\r
-               @Context ResourceMap resourceMap,\r
-               @Context UriInfo ui,\r
+               ResourceMap resourceMap,\r
+               UriInfo ui,\r
             String xmlPayload) {\r
        Response result = null;\r
        \r
         try {\r
             PoxPayloadIn input = new PoxPayloadIn(xmlPayload);\r
-            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(input, ui.getQueryParameters());\r
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(input, resourceMap, ui);\r
             ctx.setResourceMap(resourceMap);\r
             if (parentCtx != null && parentCtx.getCurrentRepositorySession() != null) {\r
                ctx.setCurrentRepositorySession(parentCtx.getCurrentRepositorySession()); // Reuse the current repo session if one exists\r
@@ -216,13 +219,14 @@ public abstract class ResourceBase
     @GET\r
     @Path("{csid}")\r
     public byte[] get(\r
+            @Context Request request,                  \r
             @Context UriInfo ui,\r
             @PathParam("csid") String csid) {\r
         PoxPayloadOut result = null;\r
         ensureCSID(csid, READ);\r
         try {\r
             MultivaluedMap<String, String> queryParams = ui.getQueryParameters();\r
-            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(queryParams);\r
+            RemoteServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = (RemoteServiceContext<PoxPayloadIn, PoxPayloadOut>) createServiceContext(queryParams);\r
             result = get(csid, ctx);// ==> CALL implementation method, which subclasses may override.\r
             if (result == null) {\r
                 Response response = Response.status(Response.Status.NOT_FOUND).entity(\r
index ba86262068e44e8628f6de074c75f265480b19d0..c98bc8fd909d76c8ee36ffcc7d273aae89987f88 100644 (file)
@@ -27,8 +27,7 @@ import javax.ws.rs.core.MultivaluedMap;
 
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.collectionspace.services.common.ResourceMap;
 
 /**
  *
@@ -79,12 +78,15 @@ public class MultipartServiceContextFactory
      * @see org.collectionspace.services.common.context.ServiceContextFactory#createServiceContext(java.lang.String, java.lang.Object, javax.ws.rs.core.MultivaluedMap)
      */
     @Override
-    public ServiceContext<PoxPayloadIn, PoxPayloadOut> createServiceContext(String serviceName,
-               PoxPayloadIn input, 
+    public ServiceContext<PoxPayloadIn, PoxPayloadOut> createServiceContext(
+               String serviceName,
+               PoxPayloadIn input,
+               ResourceMap resourceMap,
                MultivaluedMap<String, String> queryParams)
                        throws Exception {
        ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = new MultipartServiceContextImpl(serviceName,
                        input,
+                       resourceMap,
                        queryParams);
        return ctx;
     }
@@ -93,11 +95,13 @@ public class MultipartServiceContextFactory
      * @see org.collectionspace.services.common.context.ServiceContextFactory#createServiceContext(java.lang.String, java.lang.Object, javax.ws.rs.core.MultivaluedMap, java.lang.String, java.lang.String)
      */
     @Override
-    public ServiceContext<PoxPayloadIn, PoxPayloadOut> createServiceContext(String serviceName, 
+    public ServiceContext<PoxPayloadIn, PoxPayloadOut> createServiceContext(
+               String serviceName, 
                PoxPayloadIn input,
+               ResourceMap resourceMap,
                MultivaluedMap<String, String> queryParams,
                String documentType,
                String entityName) throws Exception {
-       return this.createServiceContext(serviceName, input, queryParams);
+       return this.createServiceContext(serviceName, input, resourceMap, queryParams);
     }
 }
index 53e1d654d8e2433812b1e56b0729f0490e4de75e..1faa6097c4c8fff7460f813d5716bbb9cc2c2f21 100644 (file)
@@ -33,6 +33,7 @@ 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.common.ResourceMap;
 import org.collectionspace.services.common.security.UnauthorizedException;
 import org.dom4j.DocumentException;
 import org.dom4j.Element;
@@ -91,11 +92,13 @@ public class MultipartServiceContextImpl
      * 
      * @throws UnauthorizedException the unauthorized exception
      */
-    protected MultipartServiceContextImpl(String serviceName,
+    protected MultipartServiceContextImpl(
+               String serviceName,
                PoxPayloadIn theInput,
+               ResourceMap resourceMap,
                MultivaluedMap<String, String> queryParams) 
                        throws DocumentException, UnauthorizedException {
-       super(serviceName, theInput, queryParams);
+       super(serviceName, theInput, resourceMap, queryParams);
        setOutput(new PoxPayloadOut(serviceName));
     }
 
index 570df2274f3679cde0eaacc5260e111bcc4e656c..ac9a4e76ff9a8e8c57f84078a2f54abdaec36c2d 100644 (file)
@@ -28,6 +28,8 @@ package org.collectionspace.services.common.context;
 \r
 import javax.ws.rs.core.MultivaluedMap;\r
 \r
+import org.collectionspace.services.common.ResourceMap;\r
+\r
 \r
 /**\r
  * A factory for creating RemoteServiceContext objects.\r
@@ -78,10 +80,12 @@ public class RemoteServiceContextFactory<IT, OT>
     @Override\r
     public ServiceContext<IT, OT> createServiceContext(\r
                String serviceName,\r
-               IT theInput, \r
+               IT theInput,\r
+               ResourceMap resourceMap,\r
                MultivaluedMap<String, String> queryParams) throws Exception {\r
        ServiceContext<IT, OT> ctx = new RemoteServiceContextImpl<IT, OT>(serviceName,\r
                        theInput,\r
+                       resourceMap,\r
                        queryParams);\r
        \r
         return ctx;\r
@@ -89,13 +93,15 @@ public class RemoteServiceContextFactory<IT, OT>
 \r
     @Override\r
     public ServiceContext<IT, OT> createServiceContext(String serviceName,\r
-               IT input, \r
+               IT input,\r
+               ResourceMap resourceMap,\r
                MultivaluedMap<String, String> queryParams,\r
                String documentType,\r
                String entityName) throws Exception {\r
        ServiceContext<IT, OT> ctx = createServiceContext(\r
                        serviceName,\r
                        input,\r
+                       resourceMap,\r
                        queryParams);\r
         ctx.setDocumentType(documentType); //persistence unit\r
         ctx.setProperty(ServiceContextProperties.ENTITY_NAME, entityName);\r
index 23eee0bfc8c02a5b8d73de19db05bc62ea24bd00..50c1a704c41e11f770a8d163658f55e74f1a30a7 100644 (file)
@@ -98,8 +98,10 @@ public class RemoteServiceContextImpl<IT, OT>
      */
     protected RemoteServiceContextImpl(String serviceName,
                IT theInput,
+               ResourceMap resourceMap,
                MultivaluedMap<String, String> queryParams) throws UnauthorizedException {
         this(serviceName, theInput);
+        this.setResourceMap(resourceMap);
         this.setQueryParams(queryParams);
     }
 
index 49b78493acc1e68909da04efa851787447bd08b2..dcaa909a65bf5f446b3a01d1aae62a988335500a 100644 (file)
@@ -25,6 +25,8 @@ package org.collectionspace.services.common.context;
 
 import javax.ws.rs.core.MultivaluedMap;
 
+import org.collectionspace.services.common.ResourceMap;
+
 /**
  *
  * ServiceContextFactory creates a service context
@@ -66,8 +68,10 @@ public interface ServiceContextFactory<IT, OT> {
      * 
      * @throws Exception the exception
      */
-    public ServiceContext<IT, OT> createServiceContext(String serviceName,
+    public ServiceContext<IT, OT> createServiceContext(
+               String serviceName,
                IT input,
+               ResourceMap resourceMap,                
                MultivaluedMap<String, String> queryParams) throws Exception;    
         
     /**
@@ -86,6 +90,7 @@ public interface ServiceContextFactory<IT, OT> {
     public ServiceContext<IT, OT> createServiceContext(
                String serviceName,
                IT input, 
+               ResourceMap resourceMap,
                MultivaluedMap<String, String> queryParams,
                String documentType,
                String entityName) throws Exception;
index 048b7410f39a3978429a4b892f5c8593bb1ebf15..2412c94aff34ec29979a43799b59cd654e3f3b04 100644 (file)
@@ -332,7 +332,7 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
         String currentServiceName = ctx.getServiceName();
         String workflowSubResource = "/";
         JaxRsContext jaxRsContext = ctx.getJaxRsContext();
-        if (jaxRsContext != null) {
+        if (jaxRsContext != null) { // If not null then we're dealing with an authority item
                String resourceName = SecurityUtils.getResourceName(jaxRsContext.getUriInfo());
                workflowSubResource = workflowSubResource + resourceName + WorkflowClient.SERVICE_PATH + "/";
         } else {
@@ -343,7 +343,7 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
         org.collectionspace.services.authorization.ObjectFactory objectFactory =
                new org.collectionspace.services.authorization.ObjectFactory();
         JAXBElement<AccountPermission> ap = objectFactory.createAccountPermission(accountPermission);
-        PayloadOutputPart accountPermissionPart = new PayloadOutputPart("account_permission", ap);
+        PayloadOutputPart accountPermissionPart = new PayloadOutputPart("account_permission", ap); // REM - "account_permission" should be using a constant and not a literal
         ctx.addOutputPart(accountPermissionPart);
         
         profiler.stop();
@@ -1149,7 +1149,9 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
         List<RelationsCommonList.RelationListItem> childList = null;
         List<RelationsCommonList.RelationListItem> parentList = null;
         DocumentModel docModel = wrapDoc.getWrappedObject();
-               String itemRefName = (String) docModel.getPropertyValue(AuthorityItemJAXBSchema.REF_NAME);
+//             String itemRefName = (String) docModel.getPropertyValue(AuthorityItemJAXBSchema.REF_NAME); cow;
+               String itemRefName = (String) docModel.getProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA,
+                       CollectionSpaceClient.COLLECTIONSPACE_CORE_REFNAME);
 
                ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = getServiceContext();
         //Do magic replacement of ${itemCSID} and fix URI's.