]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5130: Fixing bug in override methods of VocabularyItemDocumentModelHandler
authorRichard Millet <remillet@berkeley.edu>
Fri, 4 May 2012 16:51:14 +0000 (09:51 -0700)
committerRichard Millet <remillet@berkeley.edu>
Fri, 4 May 2012 16:51:14 +0000 (09:51 -0700)
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java
services/client/src/main/java/org/collectionspace/services/client/test/AbstractAuthorityServiceTest.java
services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClientUtils.java
services/vocabulary/jaxb/src/main/java/org/collectionspace/services/vocabulary/VocabularyItemJAXBSchema.java
services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java
services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java

index 0fe7c37d7a0e30341c233c37a115939ecc409e71..632600c48e99ca05ad7aae7d68ec0c6d5d330701 100644 (file)
@@ -422,7 +422,7 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
      */
     @GET
     @Produces("application/xml")
-    public AbstractCommonList getAuthorityList(@Context UriInfo ui) {
+    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);
index 7d894f58c533d7382ec0022130a5e96f842afebc..8ba40877c9a3348ba4f137947dd0dceb4a0a029d 100644 (file)
@@ -141,9 +141,9 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
     }
 
     /*
-     * Note that the Vocabulary service's item-documentmodel-handler will override this method.
+     * Note: the Vocabulary service's VocabularyItemDocumentModelHandler class overrides this method.
      */
-    protected ListResultField getListResultField() {
+    protected ListResultField getListResultsDisplayNameField() {
        ListResultField result = new ListResultField();
        // Per CSPACE-5132, the name of this element remains 'displayName'
         // for backwards compatibility, although its value is obtained
@@ -159,6 +159,19 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
        return result;
     }
     
+    /*
+     * Note: the Vocabulary service's VocabularyItemDocumentModelHandler class overrides this method.
+     */    
+    protected ListResultField getListResultsTermStatusField() {
+       ListResultField result = new ListResultField();
+        
+       result.setElement(AuthorityItemJAXBSchema.TERM_STATUS);
+       result.setXpath(NuxeoUtils.getPrimaryXPathPropertyName(
+                authorityItemCommonSchemaName, getItemTermInfoGroupXPathBase(), AuthorityItemJAXBSchema.TERM_STATUS));
+
+        return result;
+    }    
+    
     @Override
     public List<ListResultField> getListItemsArray() throws DocumentException {
         List<ListResultField> list = super.getListItemsArray();
@@ -185,7 +198,7 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
         }
         ListResultField field;
         if (!hasDisplayName) {
-               field = getListResultField();
+               field = getListResultsDisplayNameField();
             list.add(field);
         }
         if (!hasShortId) {
@@ -201,10 +214,7 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
             list.add(field);
         }
         if (!hasTermStatus) {
-            field = new ListResultField();
-            field.setElement(AuthorityItemJAXBSchema.TERM_STATUS);
-            field.setXpath(NuxeoUtils.getPrimaryXPathPropertyName(
-                    authorityItemCommonSchemaName, getItemTermInfoGroupXPathBase(), AuthorityItemJAXBSchema.TERM_STATUS));
+            field = getListResultsTermStatusField();
             list.add(field);
         }
         
@@ -256,7 +266,7 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
 
         // Now, check the new display and handle the refname update.
         String newDisplayName = (String) getPrimaryDisplayName(wrapDoc.getWrappedObject(), authorityItemCommonSchemaName,
-                this.authorityItemTermGroupXPathBase,
+                authorityItemTermGroupXPathBase,
                 AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
         if (newDisplayName != null && !newDisplayName.equals(oldDisplayNameOnUpdate)) {
             // Need to update the refName, and then fix all references.
@@ -1123,11 +1133,11 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
     //============================= END TODO refactor ==========================
 
     public String getItemTermInfoGroupXPathBase() {
-        return this.authorityItemTermGroupXPathBase;
+        return authorityItemTermGroupXPathBase;
     }
         
     public void setItemTermInfoGroupXPathBase(String itemTermInfoGroupXPathBase) {
-        this.authorityItemTermGroupXPathBase = itemTermInfoGroupXPathBase;
+        authorityItemTermGroupXPathBase = itemTermInfoGroupXPathBase;
     }
     
     protected String getAuthorityItemCommonSchemaName() {
index 5bdf85193c3aac8b47791181911e08c529cb56f9..3d3ff6001acfe0d065ad30b7391c9a808ace626b 100644 (file)
@@ -340,7 +340,6 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
         } else {\r
             Assert.fail("Internal Error: readItemList both vcsid and shortId are null!");\r
         }\r
-        AbstractCommonList list = res.getEntity();\r
         int statusCode = res.getStatus();\r
 \r
         // Check the status code of the response: does it match\r
@@ -352,6 +351,7 @@ public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHOR
                 invalidStatusCodeMessage(testRequestType, statusCode));\r
         Assert.assertEquals(statusCode, testExpectedStatusCode);\r
 \r
+        AbstractCommonList list = res.getEntity();\r
         List<AbstractCommonList.ListItem> items = list.getListItem();\r
         int nItemsReturned = items.size();\r
         long nItemsTotal = list.getTotalItems();\r
index 7bbc5c2cee0315208077cf42134017d1a372a126..5c4930645647d3aabf94d08db356d3dfc7592462 100644 (file)
@@ -74,7 +74,7 @@ public class VocabularyClientUtils {
 \r
        if(logger.isDebugEnabled()){\r
                logger.debug("Import: Create Item: \""+itemMap.get(AuthorityItemJAXBSchema.SHORT_IDENTIFIER)\r
-                               +"\" in personAuthority: \"" + vcsid +"\"");\r
+                               +"\" in vocabularyAuthority: \"" + vcsid +"\"");\r
        }\r
        PoxPayloadOut multipart = createVocabularyItemInstance(null, //vocabularyRefName,\r
                                itemMap, client.getItemCommonPartName());\r
@@ -89,7 +89,7 @@ public class VocabularyClientUtils {
        }\r
        if(statusCode != EXPECTED_STATUS_CODE) {\r
                throw new RuntimeException("Unexpected Status when creating Item: \""+itemMap.get(AuthorityItemJAXBSchema.DISPLAY_NAME)\r
-                               + "\" in personAuthority: \"" + vcsid /*vocabularyRefName*/ + "\", Status:" + statusCode);\r
+                               + "\" in vocabularyAuthority: \"" + vcsid /*vocabularyRefName*/ + "\", Status:" + statusCode);\r
        }\r
 \r
        return extractId(res);\r
index c6192ee6689c2c0fd4a0c37766977afac7b1a7f2..7ca5aaea0ef36ac03ae793bccfd85f4b0cb3855d 100644 (file)
@@ -2,4 +2,5 @@ package org.collectionspace.services.vocabulary;
 
 public interface VocabularyItemJAXBSchema {
     final static String DISPLAY_NAME = "displayName";
+    final static String TERM_STATUS = "termStatus";
 }
\ No newline at end of file
index c2f448da2d39b0ae0b947b85e2a73326ba9420c9..f471deff3a20d70c5fbf79e035ecc69091e777fa 100644 (file)
@@ -91,6 +91,6 @@ public class VocabularyResource extends
         */
        @Override
        public String getItemTermInfoGroupXPathBase() {
-               throw new UnsupportedOperationException("operation not relevant for AccountDocumentHandler");
+               return null;
        }
 }
index dcd7f2bf6f641ebfa7b92abfc596b37ffb233657..13605c9b1220718e23f073130e5d54564231b21a 100644 (file)
@@ -28,9 +28,8 @@ import org.collectionspace.services.common.context.ServiceBindingUtils;
 import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
 import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
 import org.collectionspace.services.config.service.ListResultField;
-import org.collectionspace.services.nuxeo.util.NuxeoUtils;
+import org.collectionspace.services.vocabulary.VocabularyItemJAXBSchema;
 import org.collectionspace.services.vocabulary.VocabularyitemsCommon;
-import org.nuxeo.ecm.core.api.ClientException;
 import org.nuxeo.ecm.core.api.DocumentModel;
 
 /**
@@ -79,7 +78,7 @@ public class VocabularyItemDocumentModelHandler
                String result = null;
 
                try {
-                       result = (String) docModel.getProperty(schema, AuthorityItemJAXBSchema.DISPLAY_NAME);
+                       result = (String) docModel.getProperty(schema, VocabularyItemJAXBSchema.DISPLAY_NAME);
                } catch (Exception e) {
                        throw new RuntimeException("Unknown problem retrieving property {"
                                        + schema + ":" + fieldName + "}." + e.getLocalizedMessage());
@@ -92,16 +91,23 @@ public class VocabularyItemDocumentModelHandler
      * Because the Vocabulary service's item schema is not standard, we need to override this method.
      */
     @Override
-       protected ListResultField getListResultField() {
+       protected ListResultField getListResultsDisplayNameField() {
                ListResultField result = new ListResultField();
 
                result.setElement(AuthorityItemJAXBSchema.DISPLAY_NAME);
-               result.setXpath(NuxeoUtils.getPrimaryXPathPropertyName(this.getAuthorityItemCommonSchemaName(),
-                               getItemTermInfoGroupXPathBase(),
-                               AuthorityItemJAXBSchema.TERM_DISPLAY_NAME));
+               result.setXpath(AuthorityItemJAXBSchema.DISPLAY_NAME);
 
                return result;
        }
     
+    protected ListResultField getListResultsTermStatusField() {
+               ListResultField result = new ListResultField();
+
+               result.setElement(VocabularyItemJAXBSchema.DISPLAY_NAME);
+               result.setXpath(VocabularyItemJAXBSchema.TERM_STATUS);
+
+               return result;
+    }    
+    
 }