]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5488: More refactoring authority item partial term searches to work in resourc...
authorRichard Millet <richard.millet@berkeley.edu>
Wed, 5 Sep 2012 06:02:22 +0000 (23:02 -0700)
committerRichard Millet <richard.millet@berkeley.edu>
Wed, 5 Sep 2012 06:02:22 +0000 (23:02 -0700)
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java
services/common/src/main/java/org/collectionspace/services/common/AbstractMultiPartCollectionSpaceResourceImpl.java
services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java
services/common/src/main/java/org/collectionspace/services/common/document/AbstractDocumentHandlerImpl.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java

index febb685fd4d1673cfcd273e9c3221663a181ff4c..1493735adc3d1998d724582505e135046435770c 100644 (file)
@@ -653,7 +653,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
      * different enough that it will have to override this method in it's resource class.
      */
     @Override
-       protected String getOrderByField() {
+       protected String getOrderByField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
                String result = null;
 
                result = NuxeoUtils.getPrimaryElPathPropertyName(
@@ -663,7 +663,8 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
                return result;
        }
        
-       protected String getPartialTermMatchField() {
+    @Override
+       protected String getPartialTermMatchField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
                String result = null;
                
                result = NuxeoUtils.getMultiElPathPropertyName(
index 95f067c37ffdba62160ffcd63fd1affd2f9e796d..d7dab54dab947e7caec2514538c7c7c18aabdc99 100644 (file)
@@ -63,7 +63,11 @@ public abstract class AbstractMultiPartCollectionSpaceResourceImpl extends Abstr
     public ServiceContextFactory<PoxPayloadIn, PoxPayloadOut> getServiceContextFactory() {\r
         return MultipartServiceContextFactory.get();\r
     }\r
+    \r
+    abstract protected String getOrderByField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx);    \r
 \r
+       abstract protected String getPartialTermMatchField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx);\r
+    \r
     @Override\r
     public DocumentHandler createDocumentHandler(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) throws Exception {\r
         return createDocumentHandler(ctx, ctx.getCommonPartLabel(), getCommonPartClass());\r
index 8c21ffb1a424b66b4b9de5ff95ac2d4903d538a4..a0c0731f3b6f76d40fbdfc12e73c6e2fba3c4439 100644 (file)
@@ -29,6 +29,7 @@ import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.common.api.RefName;\r
 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.ServiceContext;\r
 import org.collectionspace.services.common.document.DocumentFilter;\r
 import org.collectionspace.services.common.document.DocumentHandler;\r
@@ -37,6 +38,8 @@ import org.collectionspace.services.common.query.QueryManager;
 import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;\r
 import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthRefConfigInfo;\r
 import org.collectionspace.services.config.ClientType;\r
+import org.collectionspace.services.config.service.DocHandlerParams;\r
+import org.collectionspace.services.config.service.ListResultField;\r
 import org.collectionspace.services.jaxb.AbstractCommonList;\r
 import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler;\r
 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;\r
@@ -379,6 +382,50 @@ public abstract class ResourceBase
     }\r
     \r
     //======================== UTILITY : getDocModelForRefName ========================================\r
+\r
+    /*\r
+     * Used get the order by field for list results if one is not specified with an HTTP query param.\r
+     * \r
+     * (non-Javadoc)\r
+     * @see org.collectionspace.services.common.document.AbstractDocumentHandlerImpl#getOrderByField()\r
+     */\r
+    @Override\r
+    protected String getOrderByField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {\r
+       String result = null;\r
+       \r
+       DocHandlerParams.Params params = null;\r
+       try {\r
+                       result = getPartialTermMatchField(ctx);\r
+                       if (result == null) {\r
+                               throw new Exception();\r
+                       }\r
+       } catch (Exception e) {\r
+                       if (logger.isWarnEnabled()) {\r
+                               logger.warn(String.format("Call failed to getOrderByField() for class %s", this.getClass().getName()));\r
+                       }\r
+       }\r
+       \r
+       return result;\r
+    }\r
+\r
+    @Override\r
+       protected String getPartialTermMatchField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {\r
+       String result = null;\r
+       \r
+       DocHandlerParams.Params params = null;\r
+       try {\r
+                       params = ServiceConfigUtils.getDocHandlerParams(ctx);\r
+                       ListResultField field = params.getRefnameDisplayNameField();\r
+                       result = field.getSchema() + ":" + field.getXpath();\r
+       } catch (Exception e) {\r
+                       if (logger.isWarnEnabled()) {\r
+                               logger.warn(String.format("Call failed to getPartialTermMatchField() for class %s", this.getClass().getName()));\r
+                       }\r
+       }\r
+       \r
+       return result;\r
+       }\r
+       \r
     /*\r
      * ResourceBase create and update calls will set the resourceMap into the service context\r
      * for all inheriting resource classes. Just use ServiceContext.getResourceMap() to get\r
@@ -408,4 +455,5 @@ public abstract class ResourceBase
        return getDocModelForAuthorityItem(repoSession, RefName.AuthorityItem.parse(refName));\r
     }\r
 \r
+    \r
 }\r
index 6b8b52c891eec1cf12a67d54d4b8a8ecd3c14657..aba1a6dbc7b926e00c630553a18281d77ff22368 100644 (file)
@@ -69,9 +69,7 @@ public abstract class AbstractDocumentHandlerImpl<T, TL, WT, WTL>
     }
 
     abstract protected String getRefnameDisplayName(DocumentWrapper<WT> docWrapper);
-    
-    abstract protected String getOrderByField();    
-    
+        
     /*
      * Should return a reference name for the wrapper object
      */
index f4d1f4598f94c04f48db27ac92530452542ab5bf..acd520a31b4adfcaf2d6f60a0edb4b9ff1582567 100644 (file)
@@ -50,6 +50,7 @@ import org.collectionspace.services.client.RelationClient;
 import org.collectionspace.services.client.workflow.WorkflowClient;
 import org.collectionspace.services.common.ResourceBase;
 import org.collectionspace.services.common.authorityref.AuthorityRefList;
+import org.collectionspace.services.common.config.ServiceConfigUtils;
 import org.collectionspace.services.common.context.JaxRsContext;
 import org.collectionspace.services.common.context.MultipartServiceContext;
 import org.collectionspace.services.common.context.ServiceBindingUtils;
@@ -119,62 +120,24 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
                     + MultipartServiceContext.class.getName());
         }
     }
-
-    /*
-     * Returns the document handler parameters that were loaded at startup from the
-     * tenant bindings config file.
-     */
-       public DocHandlerParams.Params getDocHandlerParams() throws DocumentException {
-               MultipartServiceContext sc = (MultipartServiceContext) getServiceContext();
-               ServiceBindingType sb = sc.getServiceBinding();
-               DocHandlerParams dhb = sb.getDocHandlerParams();
-               if (dhb != null && dhb.getParams() != null) {
-                       return dhb.getParams();
-               }
-               throw new DocumentException("No DocHandlerParams configured for: "
-                               + sb.getName());
-       }
     
     @Override
     protected String getRefnameDisplayName(DocumentWrapper<DocumentModel> docWrapper) {
        return getRefnameDisplayName(docWrapper.getWrappedObject());
     }
-    
-    /*
-     * Used get the order by field for list results if one is not specified with an HTTP query param.
-     * 
-     * (non-Javadoc)
-     * @see org.collectionspace.services.common.document.AbstractDocumentHandlerImpl#getOrderByField()
-     */
-    @Override
-    protected String getOrderByField() {
-       String result = null;
        
-       DocHandlerParams.Params params = null;
-       try {
-                       params = getDocHandlerParams();
-                       ListResultField field = params.getRefnameDisplayNameField();
-                       result = field.getSchema() + ":" + field.getXpath();
-       } catch (Exception e) {
-                       if (logger.isWarnEnabled()) {
-                               logger.warn(String.format("Call failed to getOrderByField() for class %s", this.getClass().getName()));
-                       }
-       }
-       
-       return result;
-    }
-       
        private String getRefnameDisplayName(DocumentModel docModel) { // Look in the tenant bindings to see what field should be our display name for our refname value
                String result = null;
+               ServiceContext ctx = this.getServiceContext();
                
        DocHandlerParams.Params params = null;
        try {
-                       params = getDocHandlerParams();
+                       params = ServiceConfigUtils.getDocHandlerParams(ctx);
                        ListResultField field = params.getRefnameDisplayNameField();
                        
                        String schema = field.getSchema();
                        if (schema == null || schema.trim().isEmpty()) {
-                               schema = getServiceContext().getCommonPartLabel();
+                               schema = ctx.getCommonPartLabel();
                        }
                        
                        result = getStringValue(docModel, schema, field);