From 3619a920960a270cd22838d10b468ab7b6a5ed08 Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Fri, 4 May 2012 09:51:14 -0700 Subject: [PATCH] CSPACE-5130: Fixing bug in override methods of VocabularyItemDocumentModelHandler --- .../common/vocabulary/AuthorityResource.java | 2 +- .../AuthorityItemDocumentModelHandler.java | 30 ++++++++++++------- .../test/AbstractAuthorityServiceTest.java | 2 +- .../client/VocabularyClientUtils.java | 4 +-- .../vocabulary/VocabularyItemJAXBSchema.java | 1 + .../vocabulary/VocabularyResource.java | 2 +- .../VocabularyItemDocumentModelHandler.java | 20 ++++++++----- 7 files changed, 39 insertions(+), 22 deletions(-) diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java index 0fe7c37d7..632600c48 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java @@ -422,7 +422,7 @@ public abstract class AuthorityResource */ @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 queryParams = ui.getQueryParameters(); ServiceContext ctx = createServiceContext(queryParams); diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java index 7d894f58c..8ba40877c 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java @@ -141,9 +141,9 @@ public abstract class AuthorityItemDocumentModelHandler } /* - * 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 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 getListItemsArray() throws DocumentException { List list = super.getListItemsArray(); @@ -185,7 +198,7 @@ public abstract class AuthorityItemDocumentModelHandler } ListResultField field; if (!hasDisplayName) { - field = getListResultField(); + field = getListResultsDisplayNameField(); list.add(field); } if (!hasShortId) { @@ -201,10 +214,7 @@ public abstract class AuthorityItemDocumentModelHandler 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 // 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 //============================= END TODO refactor ========================== public String getItemTermInfoGroupXPathBase() { - return this.authorityItemTermGroupXPathBase; + return authorityItemTermGroupXPathBase; } public void setItemTermInfoGroupXPathBase(String itemTermInfoGroupXPathBase) { - this.authorityItemTermGroupXPathBase = itemTermInfoGroupXPathBase; + authorityItemTermGroupXPathBase = itemTermInfoGroupXPathBase; } protected String getAuthorityItemCommonSchemaName() { diff --git a/services/client/src/main/java/org/collectionspace/services/client/test/AbstractAuthorityServiceTest.java b/services/client/src/main/java/org/collectionspace/services/client/test/AbstractAuthorityServiceTest.java index 5bdf85193..3d3ff6001 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/test/AbstractAuthorityServiceTest.java +++ b/services/client/src/main/java/org/collectionspace/services/client/test/AbstractAuthorityServiceTest.java @@ -340,7 +340,6 @@ public abstract class AbstractAuthorityServiceTest items = list.getListItem(); int nItemsReturned = items.size(); long nItemsTotal = list.getTotalItems(); diff --git a/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClientUtils.java b/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClientUtils.java index 7bbc5c2ce..5c4930645 100644 --- a/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClientUtils.java +++ b/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClientUtils.java @@ -74,7 +74,7 @@ public class VocabularyClientUtils { if(logger.isDebugEnabled()){ logger.debug("Import: Create Item: \""+itemMap.get(AuthorityItemJAXBSchema.SHORT_IDENTIFIER) - +"\" in personAuthority: \"" + vcsid +"\""); + +"\" in vocabularyAuthority: \"" + vcsid +"\""); } PoxPayloadOut multipart = createVocabularyItemInstance(null, //vocabularyRefName, itemMap, client.getItemCommonPartName()); @@ -89,7 +89,7 @@ public class VocabularyClientUtils { } if(statusCode != EXPECTED_STATUS_CODE) { throw new RuntimeException("Unexpected Status when creating Item: \""+itemMap.get(AuthorityItemJAXBSchema.DISPLAY_NAME) - + "\" in personAuthority: \"" + vcsid /*vocabularyRefName*/ + "\", Status:" + statusCode); + + "\" in vocabularyAuthority: \"" + vcsid /*vocabularyRefName*/ + "\", Status:" + statusCode); } return extractId(res); diff --git a/services/vocabulary/jaxb/src/main/java/org/collectionspace/services/vocabulary/VocabularyItemJAXBSchema.java b/services/vocabulary/jaxb/src/main/java/org/collectionspace/services/vocabulary/VocabularyItemJAXBSchema.java index c6192ee66..7ca5aaea0 100644 --- a/services/vocabulary/jaxb/src/main/java/org/collectionspace/services/vocabulary/VocabularyItemJAXBSchema.java +++ b/services/vocabulary/jaxb/src/main/java/org/collectionspace/services/vocabulary/VocabularyItemJAXBSchema.java @@ -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 diff --git a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java index c2f448da2..f471deff3 100644 --- a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java +++ b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java @@ -91,6 +91,6 @@ public class VocabularyResource extends */ @Override public String getItemTermInfoGroupXPathBase() { - throw new UnsupportedOperationException("operation not relevant for AccountDocumentHandler"); + return null; } } diff --git a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java index dcd7f2bf6..13605c9b1 100644 --- a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java +++ b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java @@ -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; + } + } -- 2.47.3