]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5488: Refactoring authority item partial term searches to work in resource...
authorRichard Millet <remillet@berkeley.edu>
Tue, 4 Sep 2012 23:05:08 +0000 (16:05 -0700)
committerRichard Millet <remillet@berkeley.edu>
Tue, 4 Sep 2012 23:05:08 +0000 (16:05 -0700)
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java
services/common/src/main/java/org/collectionspace/services/common/config/ServiceConfigUtils.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 1852ce0f482531810b6127588b233b1c90c9b834..febb685fd4d1673cfcd273e9c3221663a181ff4c 100644 (file)
@@ -652,6 +652,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
      * Most of the authority child classes will/should use this implementation.  However, the Vocabulary service's item schema is
      * different enough that it will have to override this method in it's resource class.
      */
+    @Override
        protected String getOrderByField() {
                String result = null;
 
index be56353ed333a14af6bd6defff7f3eadbe0dedc3..e79d3dc80fad1fd5e69b682311ab28ac701559da 100644 (file)
@@ -26,9 +26,12 @@ package org.collectionspace.services.common.config;
 import java.util.ArrayList;\r
 import java.util.List;\r
 \r
+import org.collectionspace.services.common.context.ServiceContext;\r
+import org.collectionspace.services.common.document.DocumentException;\r
 import org.collectionspace.services.common.document.DocumentHandler;\r
 import org.collectionspace.services.config.RepositoryClientConfigType;\r
 import org.collectionspace.services.config.ServiceConfig;\r
+import org.collectionspace.services.config.service.DocHandlerParams;\r
 import org.collectionspace.services.config.service.ServiceBindingType;\r
 import org.collectionspace.services.config.tenant.TenantBindingType;\r
 import org.collectionspace.services.config.types.PropertyItemType;\r
@@ -44,6 +47,20 @@ public class ServiceConfigUtils {
 \r
     final static Logger logger = LoggerFactory.getLogger(ServiceConfigUtils.class);\r
 \r
+    /*\r
+     * Returns the document handler parameters that were loaded at startup from the\r
+     * tenant bindings config file.\r
+     */\r
+       public static DocHandlerParams.Params getDocHandlerParams(ServiceContext ctx) throws DocumentException {\r
+               ServiceBindingType sb = ctx.getServiceBinding();\r
+               DocHandlerParams dhb = sb.getDocHandlerParams();\r
+               if (dhb != null && dhb.getParams() != null) {\r
+                       return dhb.getParams();\r
+               }\r
+               throw new DocumentException("No DocHandlerParams configured for: "\r
+                               + sb.getName());\r
+       }\r
+       \r
     /**\r
      * Creates the document handler instance.\r
      * \r
index e130ac95cc37a55711bbc6a2e504e768d34145aa..6b8b52c891eec1cf12a67d54d4b8a8ecd3c14657 100644 (file)
@@ -70,6 +70,8 @@ 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 7ac8b2c877e992d78d6ef8bfbb2c32b6d5ac0b19..f4d1f4598f94c04f48db27ac92530452542ab5bf 100644 (file)
@@ -139,6 +139,30 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
     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;
@@ -155,7 +179,6 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
                        
                        result = getStringValue(docModel, schema, field);
                } catch (Exception e) {
-                       // TODO Auto-generated catch block
                        if (logger.isWarnEnabled()) {
                                logger.warn(String.format("Call failed to getRefnameDisplayName() for class %s", this.getClass().getName()));
                        }