]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5518: Updating ServiceContext factory methods to accept a UriInfo rather than...
authorRichard Millet <remillet@berkeley.edu>
Fri, 7 Sep 2012 23:42:17 +0000 (16:42 -0700)
committerRichard Millet <remillet@berkeley.edu>
Fri, 7 Sep 2012 23:42:17 +0000 (16:42 -0700)
services/IntegrationTests/src/test/resources/test-data/xmlreplay/collectionobject/collectionobject-hierarchy.xml
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java
services/batch/service/src/main/java/org/collectionspace/services/batch/BatchResource.java
services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.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/document/Hierarchy.java
services/common/src/main/java/org/collectionspace/services/common/relation/RelationResource.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java
services/report/service/src/main/java/org/collectionspace/services/report/ReportResource.java
services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/ServiceGroupResource.java

index 23d9212da6d1eb2e9ff5010ff35bef1a91a0906a..1b47e4e088713a1fdae1c45164534db819c9199d 100644 (file)
@@ -1,5 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <xmlReplay>
+
+    <testGroup ID="HierarchicCollectionObject" autoDeletePOSTS="false">
     
     <testGroup ID="CreateCollectionObjects"> <!-- autoDeletePOSTS="true" -->
         
index 144500e9d3d2940cbbf635c29d2d12e4c15c3d21..c8f304b5a143ba53f141017d5ada79cc7b8af263 100644 (file)
@@ -425,7 +425,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
     public AbstractCommonList getAuthorityList(@Context UriInfo ui) { //FIXME - REM 5/3/2012 - This is not reachable from the JAX-RS dispatcher.  Instead the equivalent method in ResourceBase is getting called.
         try {
             MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
-            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(queryParams);
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(ui);
             DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
             DocumentFilter myFilter = handler.getDocumentFilter();
             // Need to make the default sort order for authority items
@@ -919,7 +919,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
             // All items in dive can look at their child uri's to get uri.  So we calculate the very first one.  We could also do a GET and look at the common part uri field, but why...?
             String calledUri = ui.getPath();
             String uri = "/" + calledUri.substring(0, (calledUri.length() - ("/" + hierarchy).length()));
-            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName());
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), ui);
             ctx.setUriInfo(ui);
             String direction = ui.getQueryParameters().getFirst(Hierarchy.directionQP);
             if (Tools.notBlank(direction) && Hierarchy.direction_parents.equals(direction)) {
index b064cb1471155f3ebe3f9012de12b5cd4aee56c2..f0aee5427e07111ec68dc4b64c9b9bbd235a3e2a 100644 (file)
@@ -113,17 +113,17 @@ public class BatchResource extends ResourceBase {
                        @Context UriInfo ui) {
         AbstractCommonList list;
         if (docType != null && !docType.isEmpty() && mode != null && !mode.isEmpty()) {
-            list = batchSearch(ui.getQueryParameters(), docType, mode);
+            list = batchSearch(ui, docType, mode);
         } else {
             list = getList(ui);
         }
         return list;
        }
 
-    private AbstractCommonList batchSearch(MultivaluedMap<String, String> queryParams
+    private AbstractCommonList batchSearch(UriInfo ui
                                                                                String docType, String mode) {
         try {
-            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(queryParams);
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(ui);
             DocumentHandler handler = createDocumentHandler(ctx);
             // perform a search by docType and invocation mode
             DocumentFilter documentFilter = handler.getDocumentFilter();
index 19e43f1ed1b8c64e71a013354cccb9fea989c34a..091b3a6f4ad6c34dc4e86443d8c9cc126f71bcd5 100644 (file)
@@ -79,12 +79,6 @@ public class BlobResource extends ResourceBase {
        return BlobsCommon.class;
     }
 
-    //FIXME: Is this method used/needed?
-    @Deprecated
-    private CommonList getBlobList(MultivaluedMap<String, String> queryParams) {
-        return (CommonList)getList(queryParams);
-    }
-
     @Deprecated
     public CommonList getBlobList(List<String> csidList) {
         return (CommonList) getList(csidList);
index 229a198c00e2578193128dd83df9e18298ab1d80..ed5cd247c7a302e109bac43769f81b5bf83cae3d 100644 (file)
@@ -184,6 +184,17 @@ public abstract class AbstractCollectionSpaceResourceImpl<IT, OT>
         return ctx;\r
     }\r
     \r
+    protected ServiceContext<IT, OT> createServiceContext(String serviceName, UriInfo ui) throws Exception {           \r
+        ServiceContext<IT, OT> ctx = createServiceContext(\r
+                       serviceName,\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
+        ctx.setUriInfo(ui);\r
+        return ctx;\r
+    }    \r
+    \r
     /**\r
      * Creates the service context.\r
      * \r
@@ -221,35 +232,16 @@ public abstract class AbstractCollectionSpaceResourceImpl<IT, OT>
         return ctx;\r
     }    \r
 \r
-    /**\r
-     * Creates the service context.\r
-     * \r
-     * @param queryParams the query params\r
-     * \r
-     * @return the service context< i t, o t>\r
-     * \r
-     * @throws Exception the exception\r
-     */\r
-    protected ServiceContext<IT, OT> createServiceContext(MultivaluedMap<String, String> queryParams) throws Exception {\r
-        ServiceContext<IT, OT> ctx = createServiceContext(\r
-                       (IT)null, /*input*/\r
-                       queryParams,\r
-                       (Class<?>)null  /*input type's Class*/);\r
-        return ctx;\r
-    }\r
-\r
     protected ServiceContext<IT, OT> createServiceContext(UriInfo ui) throws Exception {\r
         MultivaluedMap<String, String> queryParams = ui.getQueryParameters();\r
         ServiceContext<IT, OT> ctx = createServiceContext(\r
                        (IT)null, /*input*/\r
                        queryParams,\r
                        (Class<?>)null  /*input type's Class*/);\r
+        ctx.setUriInfo(ui);\r
         return ctx;\r
     }\r
 \r
-\r
-\r
-        \r
     /**\r
      * Creates the service context.\r
      * \r
index de70114bba2540b14dcf6b4221bc07a30a68d727..3cf450ea554f0e03368b633c3d3ef70188f900d8 100644 (file)
@@ -225,8 +225,7 @@ public abstract class ResourceBase
         PoxPayloadOut result = null;\r
         ensureCSID(csid, READ);\r
         try {\r
-            MultivaluedMap<String, String> queryParams = ui.getQueryParameters();\r
-            RemoteServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = (RemoteServiceContext<PoxPayloadIn, PoxPayloadOut>) createServiceContext(queryParams);\r
+            RemoteServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = (RemoteServiceContext<PoxPayloadIn, PoxPayloadOut>) createServiceContext(ui);\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
@@ -285,9 +284,9 @@ public abstract class ResourceBase
     //======================= GET without csid. List, search, etc. =====================================\r
     @GET\r
     public AbstractCommonList getList(@Context UriInfo ui) {\r
-        MultivaluedMap<String, String> queryParams = ui.getQueryParameters();\r
         AbstractCommonList list = null;\r
         \r
+        MultivaluedMap<String, String> queryParams = ui.getQueryParameters();\r
         if (isGetAllRequest(queryParams) == false) {\r
             String orderBy = queryParams.getFirst(IClientQueryParams.ORDER_BY_PARAM);\r
             String keywords = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_KW);\r
@@ -295,15 +294,15 @@ public abstract class ResourceBase
             String partialTerm = queryParams.getFirst(IQueryManager.SEARCH_TYPE_PARTIALTERM);\r
             list = search(queryParams, orderBy, keywords, advancedSearch, partialTerm);\r
         } else {\r
-            list = getList(queryParams);\r
+            list = getCommonList(ui);\r
         }\r
         \r
         return list;\r
     }\r
     \r
-    protected AbstractCommonList getList(MultivaluedMap<String, String> queryParams) {\r
+    protected AbstractCommonList getCommonList(UriInfo ui) {\r
         try {\r
-            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(queryParams);\r
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(ui);\r
             DocumentHandler handler = createDocumentHandler(ctx);\r
             getRepositoryClient(ctx).getFiltered(ctx, handler);\r
             AbstractCommonList list = (AbstractCommonList) handler.getCommonPartList();\r
@@ -325,7 +324,7 @@ public abstract class ResourceBase
     protected AbstractCommonList search(\r
                ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,\r
                DocumentHandler handler, \r
-               MultivaluedMap<String, String> queryParams,\r
+               UriInfo ui,\r
                String orderBy,\r
                String keywords,\r
                String advancedSearch,\r
@@ -375,7 +374,7 @@ public abstract class ResourceBase
     }\r
 \r
     private AbstractCommonList search(\r
-               MultivaluedMap<String, String> queryParams,\r
+               UriInfo ui,\r
                String orderBy,\r
                String keywords,\r
                String advancedSearch,\r
@@ -384,9 +383,9 @@ public abstract class ResourceBase
 \r
        ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx;\r
        try {\r
-               ctx = createServiceContext(queryParams);\r
+               ctx = createServiceContext(ui);\r
                DocumentHandler handler = createDocumentHandler(ctx);\r
-               result = search(ctx, handler, queryParams, orderBy, keywords, advancedSearch, partialTerm);\r
+               result = search(ctx, handler, ui, orderBy, keywords, advancedSearch, partialTerm);\r
        } catch (Exception e) {\r
                throw bigReThrow(e, ServiceMessages.SEARCH_FAILED);\r
        }\r
@@ -416,8 +415,7 @@ public abstract class ResourceBase
             @Context UriInfo ui) {\r
         AuthorityRefList authRefList = null;\r
         try {\r
-            MultivaluedMap<String, String> queryParams = ui.getQueryParameters();\r
-            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(queryParams);\r
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(ui);\r
             DocumentModelHandler<PoxPayloadIn, PoxPayloadOut> handler = (DocumentModelHandler<PoxPayloadIn, PoxPayloadOut>) createDocumentHandler(ctx);\r
             List<AuthRefConfigInfo> authRefsInfo = RefNameServiceUtils.getConfiguredAuthorityRefs(ctx);\r
             authRefList = handler.getAuthorityRefs(csid, authRefsInfo);\r
index 51606afcfdf941c5c607ca4baf16640f375501d5..621857f21ef0b6b9b0c6dca37273844059ded584 100644 (file)
@@ -63,7 +63,7 @@ public class Hierarchy {
     }
 
     private static String dive(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String itemcsid, String uri, boolean lookupFirstName) {
-        MultivaluedMap<String, String> queryParams = ctx.getUriInfo().getQueryParameters();
+        MultivaluedMap<String, String> queryParams = ctx.getQueryParams();
         //Run getList() once as sent to get childListOuter:
         queryParams.putSingle(IRelationsManager.PREDICATE_QP, RelationshipType.HAS_BROADER.value());
         queryParams.putSingle(IRelationsManager.SUBJECT_QP, null);
@@ -122,7 +122,7 @@ public class Hierarchy {
     }
     
     private static SurfaceResultStruct surface(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String itemcsid, String uri, boolean first) {
-        MultivaluedMap<String, String> queryParams = ctx.getUriInfo().getQueryParameters();
+        MultivaluedMap<String, String> queryParams = ctx.getQueryParams();
         //Run getList() once as sent to get parentListOuter:
         queryParams.putSingle(IRelationsManager.PREDICATE_QP, RelationshipType.HAS_BROADER.value());
         queryParams.putSingle(IRelationsManager.SUBJECT_QP, itemcsid);
index 4baaea1d13aec634e453af9b88c01c0af15aad64..02d3d8b7b3ed6b16cabfd4e22a59bfef6b3f651b 100644 (file)
@@ -84,29 +84,26 @@ public class RelationResource extends ResourceBase {
        }
        
        private RelationsCommonList getList(ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx, UriInfo uriInfo) {
-               if (parentCtx != null) {
-                       uriInfo = parentCtx.getUriInfo(); //Override the input param and use the parent context's UriInfo
-               }
                MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();
-
+               
                String subjectCsid = queryParams.getFirst(IRelationsManager.SUBJECT_QP);
                String subjectType = queryParams.getFirst(IRelationsManager.SUBJECT_TYPE_QP);
                String predicate = queryParams.getFirst(IRelationsManager.PREDICATE_QP);
                String objectCsid = queryParams.getFirst(IRelationsManager.OBJECT_QP);
                String objectType = queryParams.getFirst(IRelationsManager.OBJECT_TYPE_QP);
 
-               return this.getRelationList(parentCtx, queryParams, subjectCsid, subjectType, predicate, objectCsid, objectType);
+               return this.getRelationList(parentCtx, uriInfo, subjectCsid, subjectType, predicate, objectCsid, objectType);
        }
 
     private RelationsCommonList getRelationList(
                ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx,
-               MultivaluedMap<String, String> queryParams,
+               UriInfo uriInfo,
                String subjectCsid, String subjectType,
                String predicate,
                String objectCsid,
                String objectType) throws WebApplicationException {
         try {
-            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(queryParams);
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(uriInfo);
             if (parentCtx != null) { // If the parent context has an open repository session then use it
                ctx.setCurrentRepositorySession(parentCtx.getCurrentRepositorySession());
             }
@@ -117,7 +114,7 @@ public class RelationResource extends ResourceBase {
             //
             // Handle keyword clause
             //
-            String keywords = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_KW);            
+            String keywords = uriInfo.getQueryParameters().getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_KW);            
             if (keywords != null && keywords.isEmpty() == false) {
                String keywordClause = QueryManager.createWhereClauseFromKeywords(keywords);
                handler.getDocumentFilter().appendWhereClause(keywordClause, IQueryManager.SEARCH_QUALIFIER_AND);
index 2412c94aff34ec29979a43799b59cd654e3f3b04..187b11588e3df1adc4027451377e785e4e31daf7 100644 (file)
@@ -208,10 +208,10 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
                            }
                     }
                 } catch (Throwable t){
-                    logger.error("Unable to addOutputPart: "+partLabel
-                                               +" in serviceContextPath: "+this.getServiceContextPath()
-                                               +" with URI: "+this.getServiceContext().getUriInfo().getPath()
-                                               +" error: "+t);
+                    logger.error("Unable to addOutputPart: " + partLabel
+                                               + " in serviceContextPath: "+this.getServiceContextPath()
+                                               + " with URI: " + this.getServiceContext().getUriInfo().getPath()
+                                               + " error: " + t);
                 }
                }
         } else {
index a3c71844dbd71987907cf4484c471a6b62e81671..1f8dda5c4975407bc8677d015fa790d1b5f9e421 100644 (file)
@@ -48,8 +48,10 @@ import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 
 @Path(ReportClient.SERVICE_PATH)
 @Consumes("application/xml")
@@ -83,9 +85,10 @@ public class ReportResource extends ResourceBase {
     }
     
     @Override
-    protected AbstractCommonList getList(MultivaluedMap<String, String> queryParams) {
+    protected AbstractCommonList getCommonList(UriInfo ui) {
         try {
-            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(queryParams);
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(ui);
+            MultivaluedMap<String, String> queryParams = ctx.getQueryParams();
             DocumentHandler handler = createDocumentHandler(ctx);
             String docType = queryParams.getFirst(IQueryManager.SEARCH_TYPE_DOCTYPE);
             String mode = queryParams.getFirst(IQueryManager.SEARCH_TYPE_INVOCATION_MODE);
@@ -135,16 +138,18 @@ public class ReportResource extends ResourceBase {
     @Path("{csid}/output")
     @Produces("application/pdf")
     public Response invokeReport(
+               @Context UriInfo ui,                    
             @PathParam("csid") String csid) {
        InvocationContext invContext = new InvocationContext();
        invContext.setMode(Invocable.INVOCATION_MODE_NO_CONTEXT);
-       return invokeReport(csid, invContext);
+       return invokeReport(ui, csid, invContext);
     }
     
     @POST
     @Path("{csid}")
     @Produces("application/pdf")
     public Response invokeReport(
+               @Context UriInfo ui,
                @PathParam("csid") String csid,
                InvocationContext invContext) {
         if (csid == null || "".equals(csid)) {
index 42f33c34596017ac1352b592dc019c60e95c73b8..8caa93dce9d8d7de87a62672b25bb24f710d3e4b 100644 (file)
@@ -222,9 +222,7 @@ public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl {
         ensureCSID(serviceGroupName, ResourceBase.READ);
         AbstractCommonList list = null;
         try {
-            MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
-            String keywords = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_KW);
-            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(queryParams);
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(ui);
                ServiceGroupDocumentModelHandler handler = (ServiceGroupDocumentModelHandler)
                                                createDocumentHandler(ctx);
                ArrayList<String> groupsList = null;  
@@ -235,6 +233,8 @@ public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl {
                        groupsList.add(serviceGroupName);
                }
                // set up a keyword search
+            MultivaluedMap<String, String> queryParams = ctx.getQueryParams();
+            String keywords = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_KW);
                if (keywords != null && !keywords.isEmpty()) {
                    String whereClause = QueryManager.createWhereClauseFromKeywords(keywords);
                    if(Tools.isEmpty(whereClause)) {