From: Patrick Schmitz Date: Wed, 27 Jul 2011 20:25:28 +0000 (+0000) Subject: CSPACE-3332, CSPACE-3784, CSPACE-4257 Updated Vocabulary and Authority classes to... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=0ba4a3f7e85a269b89df9555ec81ab893a060d3b;p=tmp%2Fjakarta-migration.git CSPACE-3332, CSPACE-3784, CSPACE-4257 Updated Vocabulary and Authority classes to use shared subclasses for AbstractCommonList support. Most of the work was in the Authority base classes for resources and docmodelhandlers. Also cleaned up a few things with taxonomy service. Checking to follow will update the app config for same. --- diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/res/GetVocabularyItems.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/res/GetVocabularyItems.res.xml index f8c787427..fe7ab95e3 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/res/GetVocabularyItems.res.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/vocabulary/res/GetVocabularyItems.res.xml @@ -1,4 +1,4 @@ - + - - /taxonomyauthorities/*/workflow/ - /taxonomyauthorities/*/items/*/workflow/ + + /taxonomyauthority/*/workflow/ + /taxonomyauthority/*/items/*/workflow/ default-domain org.collectionspace.services.taxonomy.nuxeo.TaxonomyAuthorityDocumentModelHandler @@ -1526,6 +1542,10 @@ shortIdentifier shortIdentifier + + refName + refName + diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java index cbafe1030..e8d9366f9 100755 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocHandlerBase.java @@ -186,7 +186,7 @@ public abstract class DocHandlerBase extends RemoteDocumentModelHandlerImpl> - extends AuthorityClient { +public interface AuthorityWithContactsClient

+ extends AuthorityClient

{ /** * Creates the contact. * diff --git a/services/contact/client/src/main/java/org/collectionspace/services/client/AuthorityWithContactsClientImpl.java b/services/contact/client/src/main/java/org/collectionspace/services/client/AuthorityWithContactsClientImpl.java index b802db06a..092ffb1d4 100644 --- a/services/contact/client/src/main/java/org/collectionspace/services/client/AuthorityWithContactsClientImpl.java +++ b/services/contact/client/src/main/java/org/collectionspace/services/client/AuthorityWithContactsClientImpl.java @@ -11,9 +11,9 @@ import org.collectionspace.services.jaxb.AbstractCommonList; * ILT - Authority item list type * P - Proxy type */ -public abstract class AuthorityWithContactsClientImpl> - extends AuthorityClientImpl - implements AuthorityWithContactsClient { +public abstract class AuthorityWithContactsClientImpl

+ extends AuthorityClientImpl

+ implements AuthorityWithContactsClient

{ @Override public ClientResponse createContact(String parentcsid, diff --git a/services/contact/client/src/main/java/org/collectionspace/services/client/AuthorityWithContactsProxy.java b/services/contact/client/src/main/java/org/collectionspace/services/client/AuthorityWithContactsProxy.java index 4ec77fb20..8b57e3ae9 100644 --- a/services/contact/client/src/main/java/org/collectionspace/services/client/AuthorityWithContactsProxy.java +++ b/services/contact/client/src/main/java/org/collectionspace/services/client/AuthorityWithContactsProxy.java @@ -10,14 +10,13 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Response; import org.collectionspace.services.contact.ContactsCommonList; -import org.collectionspace.services.jaxb.AbstractCommonList; import org.jboss.resteasy.client.ClientResponse; /* * ILT = Item list type * LT = List type */ -public interface AuthorityWithContactsProxy extends AuthorityProxy { +public interface AuthorityWithContactsProxy extends AuthorityProxy { @GET @Produces({"application/xml"}) @Path("/{parentcsid}/items/{itemcsid}/contacts/") diff --git a/services/contact/service/src/main/java/org/collectionspace/services/contact/AuthorityResourceWithContacts.java b/services/contact/service/src/main/java/org/collectionspace/services/contact/AuthorityResourceWithContacts.java index 7b6813225..949299df5 100644 --- a/services/contact/service/src/main/java/org/collectionspace/services/contact/AuthorityResourceWithContacts.java +++ b/services/contact/service/src/main/java/org/collectionspace/services/contact/AuthorityResourceWithContacts.java @@ -23,8 +23,6 @@ */ package org.collectionspace.services.contact; -//import java.util.List; - import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -33,7 +31,6 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -//import javax.ws.rs.QueryParam; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Context; import javax.ws.rs.core.MultivaluedMap; @@ -45,37 +42,15 @@ import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.vocabulary.AuthorityResource; -//import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; -//import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema; -//import org.collectionspace.services.common.vocabulary.AuthorityResource.Specifier; -//import org.collectionspace.services.common.vocabulary.AuthorityResource.SpecifierForm; -//import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler; -//import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl; -//import org.collectionspace.services.common.ClientType; -//import org.collectionspace.services.common.ServiceMain; -//import org.collectionspace.services.common.authorityref.AuthorityRefDocList; -//import org.collectionspace.services.common.authorityref.AuthorityRefList; -//import org.collectionspace.services.common.context.MultipartServiceContextImpl; -//import org.collectionspace.services.common.context.ServiceBindingUtils; import org.collectionspace.services.common.context.ServiceContext; -import org.collectionspace.services.common.document.BadRequestException; import org.collectionspace.services.common.document.DocumentFilter; import org.collectionspace.services.common.document.DocumentHandler; -import org.collectionspace.services.common.document.DocumentNotFoundException; -//import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.contact.ContactResource; import org.collectionspace.services.contact.ContactsCommon; import org.collectionspace.services.contact.ContactsCommonList; import org.collectionspace.services.contact.ContactJAXBSchema; import org.collectionspace.services.contact.nuxeo.ContactDocumentModelHandler; -//import org.collectionspace.services.common.repository.RepositoryClient; -import org.collectionspace.services.common.security.UnauthorizedException; -//import org.collectionspace.services.common.query.IQueryManager; -//import org.collectionspace.services.common.query.QueryManager; -//import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; -//import org.jboss.remoting.samples.chat.exceptions.InvalidArgumentException; import org.jboss.resteasy.util.HttpResponseCodes; -//import org.nuxeo.ecm.core.api.DocumentModel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -84,8 +59,8 @@ import org.slf4j.LoggerFactory; */ @Consumes("application/xml") @Produces("application/xml") -public abstract class AuthorityResourceWithContacts extends //FIXME: REM - Why is this resource in this package instead of somewhere in 'common'? - AuthorityResource { +public abstract class AuthorityResourceWithContacts extends //FIXME: REM - Why is this resource in this package instead of somewhere in 'common'? + AuthorityResource { private ContactResource contactResource = new ContactResource(); // Warning: ContactResource is a singleton. diff --git a/services/location/client/src/main/java/org/collectionspace/services/client/LocationAuthorityClient.java b/services/location/client/src/main/java/org/collectionspace/services/client/LocationAuthorityClient.java index ba2636870..c102107de 100644 --- a/services/location/client/src/main/java/org/collectionspace/services/client/LocationAuthorityClient.java +++ b/services/location/client/src/main/java/org/collectionspace/services/client/LocationAuthorityClient.java @@ -26,26 +26,10 @@ */ package org.collectionspace.services.client; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.Response; - -//import org.collectionspace.services.common.authorityref.AuthorityRefList; -import org.collectionspace.services.common.authorityref.AuthorityRefDocList; -import org.collectionspace.services.contact.ContactsCommonList; -import org.collectionspace.services.location.LocationauthoritiesCommonList; -import org.collectionspace.services.location.LocationsCommonList; -import org.collectionspace.services.client.LocationAuthorityProxy; - -import org.jboss.resteasy.client.ClientResponse; -import org.jboss.resteasy.client.ProxyFactory; -import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor; -import org.jboss.resteasy.plugins.providers.RegisterBuiltin; -import org.jboss.resteasy.spi.ResteasyProviderFactory; - /** * The Class LocationAuthorityClient. */ -public class LocationAuthorityClient extends AuthorityClientImpl { +public class LocationAuthorityClient extends AuthorityClientImpl { public static final String SERVICE_NAME = "locationauthorities"; public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT; @@ -82,16 +66,4 @@ public class LocationAuthorityClient extends AuthorityClientImpl getProxyClass() { return LocationAuthorityProxy.class; } - - /* - * Proxied service calls. - */ - - /** - * @return list - * @see org.collectionspace.services.client.LocationAuthorityProxy#readList() - */ - public ClientResponse readList() { - return getProxy().readList(); - } } diff --git a/services/location/client/src/main/java/org/collectionspace/services/client/LocationAuthorityProxy.java b/services/location/client/src/main/java/org/collectionspace/services/client/LocationAuthorityProxy.java index 81168dcb6..0eae00b76 100644 --- a/services/location/client/src/main/java/org/collectionspace/services/client/LocationAuthorityProxy.java +++ b/services/location/client/src/main/java/org/collectionspace/services/client/LocationAuthorityProxy.java @@ -1,16 +1,8 @@ package org.collectionspace.services.client; -import org.jboss.resteasy.client.ClientResponse; import javax.ws.rs.Consumes; -import javax.ws.rs.GET; import javax.ws.rs.Path; -import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; - -import org.collectionspace.services.client.workflow.WorkflowClient; -import org.collectionspace.services.location.LocationauthoritiesCommonList; -import org.collectionspace.services.location.LocationsCommonList; /** * @version $Revision:$ @@ -20,48 +12,5 @@ import org.collectionspace.services.location.LocationsCommonList; @Path(LocationAuthorityClient.SERVICE_PATH + "/") @Produces("application/xml") @Consumes("application/xml") -public interface LocationAuthorityProxy extends AuthorityProxy { - - // List Locationauthorities - @GET - ClientResponse readList(); - - /* - * List results that must be overridden for the RESTEasy proxy generation to work correctly. - */ - - // List Items matching a partial term or keywords. - @Override - @GET - @Produces({"application/xml"}) - @Path("/{csid}/items/") - ClientResponse readItemList( - @PathParam("csid") String vcsid, - @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); - - // List Items for a named authority matching a partial term or keywords. - @Override - @GET - @Produces({"application/xml"}) - @Path("/urn:cspace:name({specifier})/items/") - ClientResponse readItemListForNamedAuthority( - @PathParam("specifier") String specifier, - @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); - - @Override - @GET - @Produces({"application/xml"}) - ClientResponse readIncludeDeleted( - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); - - @Override - @GET - @Produces({"application/xml"}) - ClientResponse keywordSearchIncludeDeleted( - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); +public interface LocationAuthorityProxy extends AuthorityProxy { } diff --git a/services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java b/services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java index aa9def8c6..5083f02eb 100644 --- a/services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java +++ b/services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java @@ -35,15 +35,14 @@ import org.collectionspace.services.client.ContactClientUtils; import org.collectionspace.services.client.PayloadOutputPart; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; +import org.collectionspace.services.common.AbstractCommonListUtils; import org.collectionspace.services.contact.ContactsCommon; import org.collectionspace.services.contact.ContactsCommonList; import org.collectionspace.services.client.LocationAuthorityClient; import org.collectionspace.services.client.LocationAuthorityClientUtils; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.location.LocationauthoritiesCommon; -import org.collectionspace.services.location.LocationauthoritiesCommonList; import org.collectionspace.services.location.LocationsCommon; -import org.collectionspace.services.location.LocationsCommonList; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -68,6 +67,8 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI /** The logger. */ private final String CLASS_NAME = LocationAuthorityServiceTest.class.getName(); private final Logger logger = LoggerFactory.getLogger(LocationAuthorityServiceTest.class); + private final String REFNAME = "refName"; + private final String DISPLAYNAME = "displayName"; @Override public String getServicePathComponent() { @@ -145,15 +146,6 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI return new LocationAuthorityClient(); } - /* (non-Javadoc) - * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse) - */ - @Override - protected AbstractCommonList getAbstractCommonList( - ClientResponse response) { - return response.getEntity(LocationsCommonList.class); - } - @Override protected PoxPayloadOut createInstance(String identifier) { LocationAuthorityClient client = new LocationAuthorityClient(); @@ -769,9 +761,9 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI // Submit the request to the service and store the response. LocationAuthorityClient client = new LocationAuthorityClient(); - ClientResponse res = client.readList(); + ClientResponse res = client.readList(); try { - LocationauthoritiesCommonList list = res.getEntity(); + AbstractCommonList list = res.getEntity(); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -784,22 +776,8 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); // Optionally output additional data about list members for debugging. - boolean iterateThroughList = false; - if (iterateThroughList && logger.isDebugEnabled()) { - List items = - list.getLocationauthorityListItem(); - int i = 0; - for (LocationauthoritiesCommonList.LocationauthorityListItem item : items) { - String csid = item.getCsid(); - logger.debug(testName + ": list-item[" + i + "] csid=" + - csid); - logger.debug(testName + ": list-item[" + i + "] displayName=" + - item.getDisplayName()); - logger.debug(testName + ": list-item[" + i + "] URI=" + - item.getUri()); - readItemList(csid, null); - i++; - } + if(logger.isTraceEnabled()){ + AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName); } } finally { res.releaseConnection(); @@ -845,7 +823,7 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI // Submit the request to the service and store the response. LocationAuthorityClient client = new LocationAuthorityClient(); - ClientResponse res = null; + ClientResponse res = null; if(vcsid!= null) { res = client.readItemList(vcsid, null, null); } else if(shortId!= null) { @@ -854,7 +832,7 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI Assert.fail("readItemList passed null csid and name!"); } try { - LocationsCommonList list = res.getEntity(); + AbstractCommonList list = res.getEntity(); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -866,8 +844,8 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - List items = - list.getLocationListItem(); + List items = + list.getListItem(); int nItemsReturned = items.size(); // There will be one item created, associated with a // known parent resource, by the createItem test. @@ -882,24 +860,17 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI } Assert.assertEquals(nItemsReturned, nExpectedItems); - int i = 0; - for (LocationsCommonList.LocationListItem item : items) { - Assert.assertTrue((null != item.getRefName()), "Item refName is null!"); - Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!"); - // Optionally output additional data about list members for debugging. - boolean showDetails = true; - if (showDetails && logger.isDebugEnabled()) { - logger.debug(" " + testName + ": list-item[" + i + "] csid=" + - item.getCsid()); - logger.debug(" " + testName + ": list-item[" + i + "] refName=" + - item.getRefName()); - logger.debug(" " + testName + ": list-item[" + i + "] displayName=" + - item.getDisplayName()); - logger.debug(" " + testName + ": list-item[" + i + "] URI=" + - item.getUri()); - } - i++; - } + for (AbstractCommonList.ListItem item : items) { + String value = + AbstractCommonListUtils.ListItemGetElementValue(item, REFNAME); + Assert.assertTrue((null != value), "Item refName is null!"); + value = + AbstractCommonListUtils.ListItemGetElementValue(item, DISPLAYNAME); + Assert.assertTrue((null != value), "Item displayName is null!"); + } + if(logger.isTraceEnabled()){ + AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName); + } } finally { res.releaseConnection(); } diff --git a/services/location/jaxb/src/main/resources/location_common.xsd b/services/location/jaxb/src/main/resources/location_common.xsd index 3131b7102..a6f77b668 100644 --- a/services/location/jaxb/src/main/resources/location_common.xsd +++ b/services/location/jaxb/src/main/resources/location_common.xsd @@ -55,43 +55,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/services/location/jaxb/src/main/resources/locationauthority_common.xsd b/services/location/jaxb/src/main/resources/locationauthority_common.xsd index 107df3e0c..13278e966 100644 --- a/services/location/jaxb/src/main/resources/locationauthority_common.xsd +++ b/services/location/jaxb/src/main/resources/locationauthority_common.xsd @@ -45,46 +45,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/services/location/service/src/main/java/org/collectionspace/services/location/LocationAuthorityResource.java b/services/location/service/src/main/java/org/collectionspace/services/location/LocationAuthorityResource.java index 419289977..fe20ed786 100644 --- a/services/location/service/src/main/java/org/collectionspace/services/location/LocationAuthorityResource.java +++ b/services/location/service/src/main/java/org/collectionspace/services/location/LocationAuthorityResource.java @@ -37,8 +37,8 @@ import javax.ws.rs.Produces; @Consumes("application/xml") @Produces("application/xml") public class LocationAuthorityResource - extends AuthorityResource { + extends AuthorityResource { private final static String locationAuthorityServiceName = "locationauthorities"; private final static String LOCATIONAUTHORITIES_COMMON = "locationauthorities_common"; diff --git a/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationAuthorityDocumentModelHandler.java b/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationAuthorityDocumentModelHandler.java index 5caaf628d..62371f6ab 100644 --- a/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationAuthorityDocumentModelHandler.java +++ b/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationAuthorityDocumentModelHandler.java @@ -23,25 +23,8 @@ */ package org.collectionspace.services.location.nuxeo; -import java.util.Iterator; -import java.util.List; - -import org.collectionspace.services.common.document.DocumentHandler.Action; -import org.collectionspace.services.common.document.DocumentFilter; -import org.collectionspace.services.common.document.DocumentWrapper; -import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler; -import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.location.LocationauthoritiesCommon; -import org.collectionspace.services.location.LocationauthoritiesCommonList; -import org.collectionspace.services.location.LocationauthoritiesCommonList.LocationauthorityListItem; - -import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; -import org.collectionspace.services.nuxeo.util.NuxeoUtils; -import org.nuxeo.ecm.core.api.DocumentModel; -import org.nuxeo.ecm.core.api.DocumentModelList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * LocationAuthorityDocumentModelHandler @@ -50,7 +33,7 @@ import org.slf4j.LoggerFactory; * $LastChangedDate: $ */ public class LocationAuthorityDocumentModelHandler - extends AuthorityDocumentModelHandler { + extends AuthorityDocumentModelHandler { /** * Common part schema label @@ -61,38 +44,6 @@ public class LocationAuthorityDocumentModelHandler super(COMMON_PART_LABEL); } - @Override - public LocationauthoritiesCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - LocationauthoritiesCommonList coList = extractPagingInfo(new LocationauthoritiesCommonList(), - wrapDoc); - AbstractCommonList commonList = (AbstractCommonList) coList; - commonList.setFieldsReturned("displayName|refName|shortIdentifier|vocabType|uri|csid"); - - //FIXME: iterating over a long list of documents is not a long term - //strategy...need to change to more efficient iterating in future - List list = coList.getLocationauthorityListItem(); - String label = getServiceContext().getCommonPartLabel(); - Iterator iter = wrapDoc.getWrappedObject().iterator(); - while(iter.hasNext()){ - DocumentModel docModel = iter.next(); - LocationauthorityListItem ilistItem = new LocationauthorityListItem(); - ilistItem.setDisplayName((String) docModel.getProperty(label, - AuthorityJAXBSchema.DISPLAY_NAME)); - ilistItem.setRefName((String) docModel.getProperty(label, - AuthorityJAXBSchema.REF_NAME)); - ilistItem.setShortIdentifier((String) docModel.getProperty(label, - AuthorityJAXBSchema.SHORT_IDENTIFIER)); - ilistItem.setVocabType((String) docModel.getProperty(label, - AuthorityJAXBSchema.VOCAB_TYPE)); - String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString()); - ilistItem.setUri(getServiceContextPath() + id); - ilistItem.setCsid(id); - list.add(ilistItem); - } - - return coList; - } - /** * getQProperty converts the given property to qualified schema property * @param prop diff --git a/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationDocumentModelHandler.java b/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationDocumentModelHandler.java index 93f7634ae..2f0c03268 100644 --- a/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationDocumentModelHandler.java +++ b/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationDocumentModelHandler.java @@ -23,29 +23,12 @@ */ package org.collectionspace.services.location.nuxeo; -import java.util.Iterator; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - import org.collectionspace.services.LocationJAXBSchema; import org.collectionspace.services.client.LocationAuthorityClient; -import org.collectionspace.services.common.document.DocumentFilter; import org.collectionspace.services.common.document.DocumentWrapper; -import org.collectionspace.services.common.service.ObjectPartType; -import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema; import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler; -import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; -import org.collectionspace.services.nuxeo.util.NuxeoUtils; -import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.location.LocationsCommon; -import org.collectionspace.services.location.LocationsCommonList; -import org.collectionspace.services.location.LocationsCommonList.LocationListItem; import org.nuxeo.ecm.core.api.DocumentModel; -import org.nuxeo.ecm.core.api.DocumentModelList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * LocationDocumentModelHandler @@ -58,10 +41,8 @@ import org.slf4j.LoggerFactory; * */ public class LocationDocumentModelHandler - extends AuthorityItemDocumentModelHandler { + extends AuthorityItemDocumentModelHandler { - /** The logger. */ - private final Logger logger = LoggerFactory.getLogger(LocationDocumentModelHandler.class); /** * Common part schema label */ @@ -145,38 +126,6 @@ public class LocationDocumentModelHandler return newStr.toString(); } - /* (non-Javadoc) - * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper) - */ - @Override - public LocationsCommonList extractCommonPartList( - DocumentWrapper wrapDoc) throws Exception { - LocationsCommonList coList = extractPagingInfo(new LocationsCommonList(), wrapDoc); - AbstractCommonList commonList = (AbstractCommonList) coList; - commonList.setFieldsReturned("displayName|refName|shortIdentifier|uri|csid"); - List list = coList.getLocationListItem(); - Iterator iter = wrapDoc.getWrappedObject().iterator(); - String commonPartLabel = getServiceContext().getCommonPartLabel( - "locations"); - while (iter.hasNext()) { - DocumentModel docModel = iter.next(); - LocationListItem ilistItem = new LocationListItem(); - ilistItem.setDisplayName((String) docModel.getProperty( - commonPartLabel, AuthorityItemJAXBSchema.DISPLAY_NAME)); - ilistItem.setShortIdentifier((String) docModel.getProperty(commonPartLabel, - AuthorityItemJAXBSchema.SHORT_IDENTIFIER)); - ilistItem.setRefName((String) docModel.getProperty(commonPartLabel, - AuthorityItemJAXBSchema.REF_NAME)); - String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString()); - ilistItem.setUri("/locationauthorities/" + inAuthority + "/items/" - + id); - ilistItem.setCsid(id); - list.add(ilistItem); - } - - return coList; - } - /** * getQProperty converts the given property to qualified schema property * @param prop diff --git a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClient.java b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClient.java index 8c086c694..56b375bc3 100644 --- a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClient.java +++ b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClient.java @@ -25,15 +25,11 @@ * https://source.collectionspace.org/collection-space/LICENSE.txt */ package org.collectionspace.services.client; -import org.jboss.resteasy.client.ClientResponse; - -import org.collectionspace.services.organization.OrgauthoritiesCommonList; -import org.collectionspace.services.organization.OrganizationsCommonList; /** * The Class OrgAuthorityClient. */ -public class OrgAuthorityClient extends AuthorityWithContactsClientImpl { +public class OrgAuthorityClient extends AuthorityWithContactsClientImpl { public static final String SERVICE_NAME = "orgauthorities"; public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT; @@ -70,17 +66,4 @@ public class OrgAuthorityClient extends AuthorityWithContactsClientImpl readList() { - return getProxy().readList(); - } } diff --git a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityProxy.java b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityProxy.java index 43731b6d7..ddf9e901b 100644 --- a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityProxy.java +++ b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityProxy.java @@ -1,66 +1,13 @@ package org.collectionspace.services.client; import javax.ws.rs.Consumes; -import javax.ws.rs.GET; import javax.ws.rs.Path; -import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; - -import org.collectionspace.services.organization.OrgauthoritiesCommonList; -import org.collectionspace.services.organization.OrganizationsCommonList; -import org.collectionspace.services.client.workflow.WorkflowClient; - -import org.jboss.resteasy.client.ClientResponse; - /** * @version $Revision$ */ @Path(OrgAuthorityClient.SERVICE_PATH + "/") @Produces({"application/xml"}) @Consumes({"application/xml"}) -public interface OrgAuthorityProxy extends AuthorityWithContactsProxy { - // List OrgAuthorities - @GET - ClientResponse readList(); - - @Override - @GET - @Produces({"application/xml"}) - ClientResponse readIncludeDeleted( - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); - - @Override - @GET - @Produces({"application/xml"}) - ClientResponse keywordSearchIncludeDeleted( - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); - - - /* - * List results that must be overridden for the RESTEasy proxy generation to work correctly. - */ - - // List Items matching a partial term or keywords. - @Override - @GET - @Produces({"application/xml"}) - @Path("/{csid}/items/") - ClientResponse readItemList( - @PathParam("csid") String vcsid, - @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); - - // List Items for a named authority matching a partial term or keywords. - @Override - @GET - @Produces({"application/xml"}) - @Path("/urn:cspace:name({specifier})/items/") - ClientResponse readItemListForNamedAuthority( - @PathParam("specifier") String specifier, - @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); +public interface OrgAuthorityProxy extends AuthorityWithContactsProxy { } diff --git a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java index 346bb6425..dcb5a1336 100644 --- a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java +++ b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java @@ -30,16 +30,14 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.collectionspace.services.OrganizationJAXBSchema; -import org.collectionspace.services.PersonJAXBSchema; import org.collectionspace.services.client.AuthorityClient; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.ContactClient; import org.collectionspace.services.client.ContactClientUtils; import org.collectionspace.services.client.PayloadOutputPart; -import org.collectionspace.services.client.PersonAuthorityClient; -import org.collectionspace.services.client.PersonAuthorityClientUtils; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; +import org.collectionspace.services.common.AbstractCommonListUtils; import org.collectionspace.services.contact.ContactsCommon; import org.collectionspace.services.contact.ContactsCommonList; import org.collectionspace.services.client.OrgAuthorityClient; @@ -48,9 +46,7 @@ import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.organization.MainBodyGroup; import org.collectionspace.services.organization.MainBodyGroupList; import org.collectionspace.services.organization.OrgauthoritiesCommon; -import org.collectionspace.services.organization.OrgauthoritiesCommonList; import org.collectionspace.services.organization.OrganizationsCommon; -import org.collectionspace.services.organization.OrganizationsCommonList; import org.jboss.resteasy.client.ClientResponse; @@ -72,6 +68,8 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME: /** The logger. */ private final String CLASS_NAME = OrgAuthorityServiceTest.class.getName(); private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); + private final String REFNAME = "refName"; + private final String DISPLAYNAME = "displayName"; @Override public String getServicePathComponent() { @@ -130,15 +128,6 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME: return new OrgAuthorityClient(); } - /* (non-Javadoc) - * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse) - */ - @Override - protected AbstractCommonList getAbstractCommonList( - ClientResponse response) { - return response.getEntity(OrganizationsCommonList.class); - } - // --------------------------------------------------------------- // CRUD tests : CREATE tests // --------------------------------------------------------------- @@ -1095,9 +1084,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME: // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); - ClientResponse res = client.readList(); + ClientResponse res = client.readList(); try { - OrgauthoritiesCommonList list = res.getEntity(); + AbstractCommonList list = res.getEntity(); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -1110,22 +1099,8 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME: Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); // Optionally output additional data about list members for debugging. - boolean iterateThroughList = false; - if (iterateThroughList && logger.isDebugEnabled()) { - List items = - list.getOrgauthorityListItem(); - int i = 0; - for (OrgauthoritiesCommonList.OrgauthorityListItem item : items) { - String csid = item.getCsid(); - logger.debug(testName + ": list-item[" + i + "] csid=" + - csid); - logger.debug(testName + ": list-item[" + i + "] displayName=" + - item.getDisplayName()); - logger.debug(testName + ": list-item[" + i + "] URI=" + - item.getUri()); - readItemList(csid, null); - i++; - } + if(logger.isTraceEnabled()){ + AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName); } } finally { res.releaseConnection(); @@ -1166,7 +1141,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME: // Submit the request to the service and store the response. OrgAuthorityClient client = new OrgAuthorityClient(); - ClientResponse res = null; + ClientResponse res = null; if(vcsid!= null) { res = client.readItemList(vcsid, null, null); } else if(name!= null) { @@ -1175,7 +1150,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME: Assert.fail("readItemList passed null csid and name!"); } try { - OrganizationsCommonList list = res.getEntity(); + AbstractCommonList list = res.getEntity(); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -1187,8 +1162,8 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME: invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - List items = - list.getOrganizationListItem(); + List items = + list.getListItem(); int nItemsReturned = items.size(); // There will be one item created, associated with a // known parent resource, by the createItem test. @@ -1203,24 +1178,17 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME: } Assert.assertEquals(nItemsReturned, nExpectedItems); - int i = 0; - for (OrganizationsCommonList.OrganizationListItem item : items) { - Assert.assertTrue((null != item.getRefName()), "Item refName is null!"); - Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!"); - // Optionally output additional data about list members for debugging. - boolean showDetails = true; - if (showDetails && logger.isDebugEnabled()) { - logger.debug(" " + testName + ": list-item[" + i + "] csid=" + - item.getCsid()); - logger.debug(" " + testName + ": list-item[" + i + "] refName=" + - item.getRefName()); - logger.debug(" " + testName + ": list-item[" + i + "] displayName=" + - item.getDisplayName()); - logger.debug(" " + testName + ": list-item[" + i + "] URI=" + - item.getUri()); - } - i++; - } + for (AbstractCommonList.ListItem item : items) { + String value = + AbstractCommonListUtils.ListItemGetElementValue(item, REFNAME); + Assert.assertTrue((null != value), "Item refName is null!"); + value = + AbstractCommonListUtils.ListItemGetElementValue(item, DISPLAYNAME); + Assert.assertTrue((null != value), "Item displayName is null!"); + } + if(logger.isTraceEnabled()){ + AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName); + } } finally { res.releaseConnection(); } diff --git a/services/organization/jaxb/src/main/resources/organization_common.xsd b/services/organization/jaxb/src/main/resources/organization_common.xsd index 60d378431..946afd0eb 100644 --- a/services/organization/jaxb/src/main/resources/organization_common.xsd +++ b/services/organization/jaxb/src/main/resources/organization_common.xsd @@ -88,43 +88,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/services/organization/jaxb/src/main/resources/orgauthority_common.xsd b/services/organization/jaxb/src/main/resources/orgauthority_common.xsd index edc7a21cc..5c7ff8070 100644 --- a/services/organization/jaxb/src/main/resources/orgauthority_common.xsd +++ b/services/organization/jaxb/src/main/resources/orgauthority_common.xsd @@ -44,45 +44,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/OrgAuthorityResource.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/OrgAuthorityResource.java index 5376b6150..b1fe8c8fc 100644 --- a/services/organization/service/src/main/java/org/collectionspace/services/organization/OrgAuthorityResource.java +++ b/services/organization/service/src/main/java/org/collectionspace/services/organization/OrgAuthorityResource.java @@ -37,8 +37,7 @@ import javax.ws.rs.Produces; @Consumes("application/xml") @Produces("application/xml") public class OrgAuthorityResource extends - AuthorityResourceWithContacts { + AuthorityResourceWithContacts { private final static String orgAuthorityServiceName = OrgAuthorityClient.SERVICE_NAME; private final static String ORGAUTHORITIES_COMMON = "orgauthorities_common"; diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java index 849ccd916..42a878740 100644 --- a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java +++ b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java @@ -23,22 +23,8 @@ */ package org.collectionspace.services.organization.nuxeo; -import java.util.Iterator; -import java.util.List; - -import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; -import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.organization.OrgauthoritiesCommon; -import org.collectionspace.services.organization.OrgauthoritiesCommonList; -import org.collectionspace.services.organization.OrgauthoritiesCommonList.OrgauthorityListItem; - import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler; -import org.collectionspace.services.jaxb.AbstractCommonList; -import org.collectionspace.services.nuxeo.util.NuxeoUtils; -import org.nuxeo.ecm.core.api.DocumentModel; -import org.nuxeo.ecm.core.api.DocumentModelList; -//import org.slf4j.Logger; -//import org.slf4j.LoggerFactory; /** * OrgAuthorityDocumentModelHandler @@ -47,7 +33,7 @@ import org.nuxeo.ecm.core.api.DocumentModelList; * $LastChangedDate$ */ public class OrgAuthorityDocumentModelHandler - extends AuthorityDocumentModelHandler { + extends AuthorityDocumentModelHandler { /** * Common part schema label @@ -58,37 +44,6 @@ public class OrgAuthorityDocumentModelHandler super(COMMON_PART_LABEL); } - /* (non-Javadoc) - * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper) - */ - @Override - public OrgauthoritiesCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - OrgauthoritiesCommonList coList = this.extractPagingInfo(new OrgauthoritiesCommonList(), wrapDoc); - AbstractCommonList commonList = (AbstractCommonList) coList; - commonList.setFieldsReturned("displayName|refName|shortIdentifier|vocabType|uri|csid"); - List list = coList.getOrgauthorityListItem(); - Iterator iter = wrapDoc.getWrappedObject().iterator(); - String label = getServiceContext().getCommonPartLabel(); - while(iter.hasNext()){ - DocumentModel docModel = iter.next(); - OrgauthorityListItem ilistItem = new OrgauthorityListItem(); - ilistItem.setDisplayName((String) docModel.getProperty(label, - AuthorityJAXBSchema.DISPLAY_NAME)); - ilistItem.setRefName((String) docModel.getProperty(label, - AuthorityJAXBSchema.REF_NAME)); - ilistItem.setShortIdentifier((String) docModel.getProperty(label, - AuthorityJAXBSchema.SHORT_IDENTIFIER)); - ilistItem.setVocabType((String) docModel.getProperty(label, - AuthorityJAXBSchema.VOCAB_TYPE)); - String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString()); - ilistItem.setUri(getServiceContextPath() + id); - ilistItem.setCsid(id); - list.add(ilistItem); - } - - return coList; - } - /** * getQProperty converts the given property to qualified schema property * @param prop diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java index fa42403fb..e95ff1bc3 100644 --- a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java +++ b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java @@ -23,22 +23,12 @@ */ package org.collectionspace.services.organization.nuxeo; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - import org.collectionspace.services.client.OrgAuthorityClient; import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler; import org.collectionspace.services.OrganizationJAXBSchema; import org.collectionspace.services.common.document.DocumentWrapper; -import org.collectionspace.services.common.service.ObjectPartType; -import org.collectionspace.services.jaxb.AbstractCommonList; -import org.collectionspace.services.nuxeo.util.NuxeoUtils; import org.collectionspace.services.organization.OrganizationsCommon; -import org.collectionspace.services.organization.OrganizationsCommonList; -import org.collectionspace.services.organization.OrganizationsCommonList.OrganizationListItem; import org.nuxeo.ecm.core.api.DocumentModel; -import org.nuxeo.ecm.core.api.DocumentModelList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,7 +39,7 @@ import org.slf4j.LoggerFactory; * $LastChangedDate$ */ public class OrganizationDocumentModelHandler - extends AuthorityItemDocumentModelHandler { + extends AuthorityItemDocumentModelHandler { /** The logger. */ private final Logger logger = LoggerFactory.getLogger(OrganizationDocumentModelHandler.class); @@ -152,36 +142,6 @@ public class OrganizationDocumentModelHandler return newStr.toString(); } - /* (non-Javadoc) - * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper) - */ - @Override - public OrganizationsCommonList extractCommonPartList(DocumentWrapper wrapDoc) - throws Exception { - OrganizationsCommonList coList = this.extractPagingInfo(new OrganizationsCommonList(), wrapDoc); - AbstractCommonList commonList = (AbstractCommonList) coList; - commonList.setFieldsReturned("displayName|refName|shortIdentifier|uri|csid"); - List list = coList.getOrganizationListItem(); - Iterator iter = wrapDoc.getWrappedObject().iterator(); - String commonPartLabel = getServiceContext().getCommonPartLabel("organizations"); - while(iter.hasNext()){ - DocumentModel docModel = iter.next(); - OrganizationListItem ilistItem = new OrganizationListItem(); - ilistItem.setDisplayName((String) - docModel.getProperty(commonPartLabel,OrganizationJAXBSchema.DISPLAY_NAME )); - ilistItem.setShortIdentifier((String) docModel.getProperty(commonPartLabel, - OrganizationJAXBSchema.SHORT_IDENTIFIER)); - ilistItem.setRefName((String) - docModel.getProperty(commonPartLabel, OrganizationJAXBSchema.REF_NAME)); - String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString()); - ilistItem.setUri("/orgauthorities/" + this.inAuthority + "/items/" + id); - ilistItem.setCsid(id); - list.add(ilistItem); - } - - return coList; - } - /** * getQProperty converts the given property to qualified schema property * @param prop diff --git a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClient.java b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClient.java index 6fab05612..fe728bfd8 100644 --- a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClient.java +++ b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClient.java @@ -26,17 +26,10 @@ */ package org.collectionspace.services.client; -//import javax.ws.rs.PathParam; -import org.jboss.resteasy.client.ClientResponse; - -import org.collectionspace.services.person.PersonauthoritiesCommonList; -import org.collectionspace.services.person.PersonsCommonList; -import org.collectionspace.services.client.PersonAuthorityProxy; - /** * The Class PersonAuthorityClient. */ -public class PersonAuthorityClient extends AuthorityWithContactsClientImpl { +public class PersonAuthorityClient extends AuthorityWithContactsClientImpl { public static final String SERVICE_NAME = "personauthorities"; public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT; @@ -78,12 +71,4 @@ public class PersonAuthorityClient extends AuthorityWithContactsClientImpl getProxyClass() { return PersonAuthorityProxy.class; } - - /* - * Proxied service call methods - */ - - public ClientResponse readList() { - return getProxy().readList(); - } } diff --git a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityProxy.java b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityProxy.java index e39cdf1e4..b348057c6 100644 --- a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityProxy.java +++ b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityProxy.java @@ -1,17 +1,8 @@ package org.collectionspace.services.client; import javax.ws.rs.Consumes; -import javax.ws.rs.GET; import javax.ws.rs.Path; -import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; - -import org.collectionspace.services.person.PersonauthoritiesCommonList; -import org.collectionspace.services.person.PersonsCommonList; -import org.collectionspace.services.client.workflow.WorkflowClient; - -import org.jboss.resteasy.client.ClientResponse; /** * @version $Revision:$ @@ -19,48 +10,6 @@ import org.jboss.resteasy.client.ClientResponse; @Path(PersonAuthorityClient.SERVICE_PATH + "/") @Produces({"application/xml"}) @Consumes({"application/xml"}) -public interface PersonAuthorityProxy extends AuthorityWithContactsProxy { - - // List Personauthorities - @GET - ClientResponse readList(); +public interface PersonAuthorityProxy extends AuthorityWithContactsProxy { - @Override - @GET - @Produces({"application/xml"}) - ClientResponse readIncludeDeleted( - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); - - @Override - @GET - @Produces({"application/xml"}) - ClientResponse keywordSearchIncludeDeleted( - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); - - /* - * List results that must be overridden for the RESTEasy proxy generation to work correctly. - */ - - // List Items matching a partial term or keywords. - @Override - @GET - @Produces({"application/xml"}) - @Path("/{csid}/items/") - ClientResponse readItemList( - @PathParam("csid") String vcsid, - @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); - - // List Items for a named authority matching a partial term or keywords. - @Override - @GET - @Produces({"application/xml"}) - @Path("/urn:cspace:name({specifier})/items/") - ClientResponse readItemListForNamedAuthority( - @PathParam("specifier") String specifier, - @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); } diff --git a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java index 9948d5202..c6f38395f 100644 --- a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java +++ b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java @@ -38,7 +38,6 @@ import org.collectionspace.services.client.PersonAuthorityClient; import org.collectionspace.services.client.PersonAuthorityClientUtils; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.jaxb.AbstractCommonList; -import org.collectionspace.services.person.PersonsCommonList; import org.jboss.resteasy.client.ClientResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -160,7 +159,7 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { @Override protected AbstractCommonList getAbstractCommonList( ClientResponse response) { - return response.getEntity(PersonsCommonList.class); + return response.getEntity(AbstractCommonList.class); } private String getPartialTermCommon() { @@ -496,13 +495,13 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); - ClientResponse res = null; + ClientResponse res = null; if (authorityCsid != null) { res = client.readItemList(authorityCsid, partialTerm, keywords); } else { Assert.fail("readItemListByPartialTerm passed null csid!"); } - PersonsCommonList list = null; + AbstractCommonList list = null; try { int statusCode = res.getStatus(); @@ -520,7 +519,7 @@ public class PersonAuthoritySearchTest extends BaseServiceTest { res.releaseConnection(); } - List items = list.getPersonListItem(); + List items = list.getListItem(); int nItemsReturned = items.size(); return nItemsReturned; diff --git a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServicePerfTest.java b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServicePerfTest.java index 3fd836440..e960c8581 100644 --- a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServicePerfTest.java +++ b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServicePerfTest.java @@ -34,7 +34,6 @@ import org.collectionspace.services.client.PersonAuthorityClient; import org.collectionspace.services.client.PersonAuthorityClientUtils; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.jaxb.AbstractCommonList; -import org.collectionspace.services.person.PersonsCommonList; import org.jboss.resteasy.client.ClientResponse; import org.slf4j.Logger; @@ -117,7 +116,7 @@ public class PersonAuthorityServicePerfTest extends BaseServiceTest { @Override protected AbstractCommonList getAbstractCommonList( ClientResponse response) { - return response.getEntity(PersonsCommonList.class); + return response.getEntity(AbstractCommonList.class); } @BeforeClass @@ -308,13 +307,13 @@ public class PersonAuthorityServicePerfTest extends BaseServiceTest { // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); - ClientResponse res = null; + ClientResponse res = null; if (authorityCsid != null) { res = client.readItemList(authorityCsid, partialTerm, keywords); } else { Assert.fail(testName+" passed null csid!"); } - PersonsCommonList list = null; + AbstractCommonList list = null; try { int statusCode = res.getStatus(); Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -326,7 +325,7 @@ public class PersonAuthorityServicePerfTest extends BaseServiceTest { res.releaseConnection(); } - List items = list.getPersonListItem(); + List items = list.getListItem(); return (int)list.getTotalItems(); } // --------------------------------------------------------------- diff --git a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java index 9e02ccb70..fd653102a 100644 --- a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java +++ b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java @@ -38,7 +38,7 @@ import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.client.ContactClient; import org.collectionspace.services.client.ContactClientUtils; -import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema; +import org.collectionspace.services.common.AbstractCommonListUtils; import org.collectionspace.services.contact.ContactsCommon; import org.collectionspace.services.contact.ContactsCommonList; @@ -46,9 +46,7 @@ import org.collectionspace.services.client.PersonAuthorityClient; import org.collectionspace.services.client.PersonAuthorityClientUtils; import org.collectionspace.services.PersonJAXBSchema; import org.collectionspace.services.person.PersonauthoritiesCommon; -import org.collectionspace.services.person.PersonauthoritiesCommonList; import org.collectionspace.services.person.PersonsCommon; -import org.collectionspace.services.person.PersonsCommonList; import org.jboss.resteasy.client.ClientResponse; //import org.jboss.resteasy.plugins.providers.multipart.OutputPart; @@ -70,6 +68,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM /** The logger. */ private final String CLASS_NAME = PersonAuthorityServiceTest.class.getName(); private final Logger logger = LoggerFactory.getLogger(CLASS_NAME); + private final String REFNAME = "refName"; + private final String DISPLAYNAME = "displayName"; @Override public String getServicePathComponent() { @@ -145,15 +145,6 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM return new PersonAuthorityClient(); } - /* (non-Javadoc) - * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse) - */ - @Override - protected AbstractCommonList getAbstractCommonList( - ClientResponse response) { - return response.getEntity(PersonsCommonList.class); - } - // --------------------------------------------------------------- // CRUD tests : CREATE tests // --------------------------------------------------------------- @@ -1316,8 +1307,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); - PersonauthoritiesCommonList list = null; - ClientResponse res = client.readList(); + AbstractCommonList list = null; + ClientResponse res = client.readList(); try { int statusCode = res.getStatus(); @@ -1336,22 +1327,9 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM } // Optionally output additional data about list members for debugging. - boolean iterateThroughList = false; - if (iterateThroughList && logger.isDebugEnabled()) { - List items = - list.getPersonauthorityListItem(); - int i = 0; - for (PersonauthoritiesCommonList.PersonauthorityListItem item : items) { - String csid = item.getCsid(); - logger.debug(testName + ": list-item[" + i + "] csid=" + - csid); - logger.debug(testName + ": list-item[" + i + "] displayName=" + - item.getDisplayName()); - logger.debug(testName + ": list-item[" + i + "] URI=" + - item.getUri()); - readItemList(csid, null, testName); - i++; - } + // Optionally output additional data about list members for debugging. + if(logger.isTraceEnabled()){ + AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName); } } @@ -1386,7 +1364,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM // Submit the request to the service and store the response. PersonAuthorityClient client = new PersonAuthorityClient(); - ClientResponse res = null; + ClientResponse res = null; if (vcsid!= null) { res = client.readItemList(vcsid, null, null); } else if (name!= null) { @@ -1394,7 +1372,7 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM } else { Assert.fail("readItemList passed null csid and name!"); } - PersonsCommonList list = null; + AbstractCommonList list = null; try { int statusCode = res.getStatus(); @@ -1412,8 +1390,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM res.releaseConnection(); } - List items = - list.getPersonListItem(); + List items = + list.getListItem(); int nItemsReturned = items.size(); // There will be one item created, associated with a // known parent resource, by the createItem test. @@ -1428,23 +1406,16 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM } Assert.assertEquals(nItemsReturned, nExpectedItems); - int i = 0; - for (PersonsCommonList.PersonListItem item : items) { - Assert.assertTrue((null != item.getRefName()), "Item refName is null!"); - Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!"); - // Optionally output additional data about list members for debugging. - boolean showDetails = true; - if (showDetails && logger.isDebugEnabled()) { - logger.debug(" " + testName + ": list-item[" + i + "] csid=" + - item.getCsid()); - logger.debug(" " + testName + ": list-item[" + i + "] refName=" + - item.getRefName()); - logger.debug(" " + testName + ": list-item[" + i + "] displayName=" + - item.getDisplayName()); - logger.debug(" " + testName + ": list-item[" + i + "] URI=" + - item.getUri()); - } - i++; + for (AbstractCommonList.ListItem item : items) { + String value = + AbstractCommonListUtils.ListItemGetElementValue(item, REFNAME); + Assert.assertTrue((null != value), "Item refName is null!"); + value = + AbstractCommonListUtils.ListItemGetElementValue(item, DISPLAYNAME); + Assert.assertTrue((null != value), "Item displayName is null!"); + } + if(logger.isTraceEnabled()){ + AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName); } } diff --git a/services/person/jaxb/src/main/resources/person_common.xsd b/services/person/jaxb/src/main/resources/person_common.xsd index 5a932a812..df0c9c16b 100644 --- a/services/person/jaxb/src/main/resources/person_common.xsd +++ b/services/person/jaxb/src/main/resources/person_common.xsd @@ -89,43 +89,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/services/person/jaxb/src/main/resources/personauthority_common.xsd b/services/person/jaxb/src/main/resources/personauthority_common.xsd index 7e942a027..375b0821a 100644 --- a/services/person/jaxb/src/main/resources/personauthority_common.xsd +++ b/services/person/jaxb/src/main/resources/personauthority_common.xsd @@ -45,46 +45,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/services/person/service/src/main/java/org/collectionspace/services/person/PersonAuthorityResource.java b/services/person/service/src/main/java/org/collectionspace/services/person/PersonAuthorityResource.java index 3b32b060e..c8227d917 100644 --- a/services/person/service/src/main/java/org/collectionspace/services/person/PersonAuthorityResource.java +++ b/services/person/service/src/main/java/org/collectionspace/services/person/PersonAuthorityResource.java @@ -37,8 +37,7 @@ import javax.ws.rs.Produces; @Consumes("application/xml") @Produces("application/xml") public class PersonAuthorityResource extends - AuthorityResourceWithContacts { + AuthorityResourceWithContacts { final Logger logger = LoggerFactory.getLogger(PersonAuthorityResource.class); diff --git a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java index be7e69928..3a15f1bfd 100644 --- a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java +++ b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java @@ -23,23 +23,9 @@ */ package org.collectionspace.services.person.nuxeo; -import java.util.Iterator; -import java.util.List; - -import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; -import org.collectionspace.services.common.document.DocumentWrapper; -import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.person.PersonauthoritiesCommon; -import org.collectionspace.services.person.PersonauthoritiesCommonList; -import org.collectionspace.services.person.PersonauthoritiesCommonList.PersonauthorityListItem; import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler; -import org.collectionspace.services.nuxeo.util.NuxeoUtils; -import org.nuxeo.ecm.core.api.DocumentModel; -import org.nuxeo.ecm.core.api.DocumentModelList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * PersonAuthorityDocumentModelHandler * @@ -47,7 +33,7 @@ import org.slf4j.LoggerFactory; * $LastChangedDate: $ */ public class PersonAuthorityDocumentModelHandler - extends AuthorityDocumentModelHandler { + extends AuthorityDocumentModelHandler { /** * Common part schema label @@ -58,38 +44,6 @@ public class PersonAuthorityDocumentModelHandler super(COMMON_PART_LABEL); } - @Override - public PersonauthoritiesCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - PersonauthoritiesCommonList coList = extractPagingInfo(new PersonauthoritiesCommonList(), - wrapDoc); - AbstractCommonList commonList = (AbstractCommonList) coList; - commonList.setFieldsReturned("displayName|refName|shortIdentifier|vocabType|uri|csid"); - - //FIXME: iterating over a long list of documents is not a long term - //strategy...need to change to more efficient iterating in future - List list = coList.getPersonauthorityListItem(); - Iterator iter = wrapDoc.getWrappedObject().iterator(); - String label = getServiceContext().getCommonPartLabel(); - while(iter.hasNext()){ - DocumentModel docModel = iter.next(); - PersonauthorityListItem ilistItem = new PersonauthorityListItem(); - ilistItem.setDisplayName((String) docModel.getProperty(label, - AuthorityJAXBSchema.DISPLAY_NAME)); - ilistItem.setRefName((String) docModel.getProperty(label, - AuthorityJAXBSchema.REF_NAME)); - ilistItem.setShortIdentifier((String) docModel.getProperty(label, - AuthorityJAXBSchema.SHORT_IDENTIFIER)); - ilistItem.setVocabType((String) docModel.getProperty(label, - AuthorityJAXBSchema.VOCAB_TYPE)); - String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString()); - ilistItem.setUri(getServiceContextPath() + id); - ilistItem.setCsid(id); - list.add(ilistItem); - } - - return coList; - } - /** * getQProperty converts the given property to qualified schema property * @param prop diff --git a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java index f29ee1618..a3e076a47 100644 --- a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java +++ b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java @@ -23,7 +23,6 @@ */ package org.collectionspace.services.person.nuxeo; -import java.util.Iterator; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -33,17 +32,8 @@ import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumen import org.collectionspace.services.PersonJAXBSchema; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.service.ObjectPartType; -import org.collectionspace.services.nuxeo.util.NuxeoUtils; -import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.person.PersonsCommon; -import org.collectionspace.services.person.PersonsCommonList; -import org.collectionspace.services.person.PersonsCommonList.PersonListItem; - import org.nuxeo.ecm.core.api.DocumentModel; -import org.nuxeo.ecm.core.api.DocumentModelList; - -//import org.slf4j.Logger; -//import org.slf4j.LoggerFactory; /** * PersonDocumentModelHandler @@ -56,7 +46,7 @@ import org.nuxeo.ecm.core.api.DocumentModelList; * */ public class PersonDocumentModelHandler - extends AuthorityItemDocumentModelHandler { + extends AuthorityItemDocumentModelHandler { /** The logger. */ //private final Logger logger = LoggerFactory.getLogger(PersonDocumentModelHandler.class); @@ -209,38 +199,6 @@ public class PersonDocumentModelHandler return unQObjectProperties; } - /* (non-Javadoc) - * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper) - */ - @Override - public PersonsCommonList extractCommonPartList( - DocumentWrapper wrapDoc) throws Exception { - PersonsCommonList coList = extractPagingInfo(new PersonsCommonList(), wrapDoc); - AbstractCommonList commonList = (AbstractCommonList) coList; - commonList.setFieldsReturned("displayName|refName|shortIdentifier|uri|csid"); - List list = coList.getPersonListItem(); - Iterator iter = wrapDoc.getWrappedObject().iterator(); - String commonPartLabel = getServiceContext().getCommonPartLabel( - "persons"); - while (iter.hasNext()) { - DocumentModel docModel = iter.next(); - PersonListItem ilistItem = new PersonListItem(); - ilistItem.setDisplayName((String) docModel.getProperty( - commonPartLabel, PersonJAXBSchema.DISPLAY_NAME)); - ilistItem.setShortIdentifier((String) docModel.getProperty(commonPartLabel, - PersonJAXBSchema.SHORT_IDENTIFIER)); - ilistItem.setRefName((String) docModel.getProperty(commonPartLabel, - PersonJAXBSchema.REF_NAME)); - String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString()); - ilistItem.setUri("/personauthorities/" + inAuthority + "/items/" - + id); - ilistItem.setCsid(id); - list.add(ilistItem); - } - - return coList; - } - /** * getQProperty converts the given property to qualified schema property * @param prop diff --git a/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityClient.java b/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityClient.java index 5f6897b5b..90cc6f74e 100644 --- a/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityClient.java +++ b/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityClient.java @@ -26,30 +26,15 @@ */ package org.collectionspace.services.client; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.Response; - -//import org.collectionspace.services.common.authorityref.AuthorityRefList; -import org.collectionspace.services.common.authorityref.AuthorityRefDocList; -import org.collectionspace.services.taxonomy.TaxonomyauthorityCommonList; -import org.collectionspace.services.taxonomy.TaxonCommonList; -import org.collectionspace.services.client.TaxonomyAuthorityProxy; - -import org.jboss.resteasy.client.ClientResponse; -import org.jboss.resteasy.client.ProxyFactory; -import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor; -import org.jboss.resteasy.plugins.providers.RegisterBuiltin; -import org.jboss.resteasy.spi.ResteasyProviderFactory; - /** * The Class TaxonomyAuthorityClient. */ -public class TaxonomyAuthorityClient extends AuthorityClientImpl { +public class TaxonomyAuthorityClient extends AuthorityClientImpl { - public static final String SERVICE_NAME = "taxonomyauthorities"; + public static final String SERVICE_NAME = "taxonomyauthority"; public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT; - public static final String SERVICE_PAYLOAD_NAME = "taxonomyauthority"; + public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME; // // Subitem constants // @@ -73,11 +58,6 @@ public class TaxonomyAuthorityClient extends AuthorityClientImpl getProxyClass() { return TaxonomyAuthorityProxy.class; } - - /* - * Proxied service calls. - */ - /** - * @return list - * @see org.collectionspace.services.client.TaxonomyAuthorityProxy#readList() - */ - public ClientResponse readList() { - return getProxy().readList(); - } } diff --git a/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityProxy.java b/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityProxy.java index aa8aadc2a..4b94035ea 100644 --- a/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityProxy.java +++ b/services/taxonomy/client/src/main/java/org/collectionspace/services/client/TaxonomyAuthorityProxy.java @@ -1,16 +1,8 @@ package org.collectionspace.services.client; -import org.jboss.resteasy.client.ClientResponse; import javax.ws.rs.Consumes; -import javax.ws.rs.GET; import javax.ws.rs.Path; -import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; - -import org.collectionspace.services.client.workflow.WorkflowClient; -import org.collectionspace.services.taxonomy.TaxonomyauthorityCommonList; -import org.collectionspace.services.taxonomy.TaxonCommonList; /** * @version $Revision$ @@ -20,48 +12,5 @@ import org.collectionspace.services.taxonomy.TaxonCommonList; @Path(TaxonomyAuthorityClient.SERVICE_PATH + "/") @Produces("application/xml") @Consumes("application/xml") -public interface TaxonomyAuthorityProxy extends AuthorityProxy { - - // List Taxonomyauthority - @GET - ClientResponse readList(); - - /* - * List results that must be overridden for the RESTEasy proxy generation to work correctly. - */ - - // List Items matching a partial term or keywords. - @Override - @GET - @Produces({"application/xml"}) - @Path("/{csid}/items/") - ClientResponse readItemList( - @PathParam("csid") String vcsid, - @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); - - // List Items for a named authority matching a partial term or keywords. - @Override - @GET - @Produces({"application/xml"}) - @Path("/urn:cspace:name({specifier})/items/") - ClientResponse readItemListForNamedAuthority( - @PathParam("specifier") String specifier, - @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); - - @Override - @GET - @Produces({"application/xml"}) - ClientResponse readIncludeDeleted( - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); - - @Override - @GET - @Produces({"application/xml"}) - ClientResponse keywordSearchIncludeDeleted( - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); +public interface TaxonomyAuthorityProxy extends AuthorityProxy { } diff --git a/services/taxonomy/client/src/test/java/org/collectionspace/services/client/test/TaxonomyAuthorityServiceTest.java b/services/taxonomy/client/src/test/java/org/collectionspace/services/client/test/TaxonomyAuthorityServiceTest.java index 6d24897fe..314e5f11a 100644 --- a/services/taxonomy/client/src/test/java/org/collectionspace/services/client/test/TaxonomyAuthorityServiceTest.java +++ b/services/taxonomy/client/src/test/java/org/collectionspace/services/client/test/TaxonomyAuthorityServiceTest.java @@ -35,14 +35,13 @@ import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.client.TaxonomyAuthorityClient; import org.collectionspace.services.client.TaxonomyAuthorityClientUtils; +import org.collectionspace.services.common.AbstractCommonListUtils; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.taxonomy.TaxonAuthorGroup; import org.collectionspace.services.taxonomy.TaxonAuthorGroupList; import org.collectionspace.services.taxonomy.TaxonCitationList; import org.collectionspace.services.taxonomy.TaxonomyauthorityCommon; -import org.collectionspace.services.taxonomy.TaxonomyauthorityCommonList; import org.collectionspace.services.taxonomy.TaxonCommon; -import org.collectionspace.services.taxonomy.TaxonCommonList; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -67,6 +66,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI /** The logger. */ private final String CLASS_NAME = TaxonomyAuthorityServiceTest.class.getName(); private final Logger logger = LoggerFactory.getLogger(TaxonomyAuthorityServiceTest.class); + private final String REFNAME = "refName"; + private final String DISPLAYNAME = "displayName"; @Override public String getServicePathComponent() { @@ -131,15 +132,6 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI return new TaxonomyAuthorityClient(); } - /* (non-Javadoc) - * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse) - */ - @Override - protected AbstractCommonList getAbstractCommonList( - ClientResponse response) { - return response.getEntity(TaxonCommonList.class); - } - @Override protected PoxPayloadOut createInstance(String identifier) { TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); @@ -775,9 +767,9 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI // Submit the request to the service and store the response. TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); - ClientResponse res = client.readList(); + ClientResponse res = client.readList(); try { - TaxonomyauthorityCommonList list = res.getEntity(); + AbstractCommonList list = res.getEntity(); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -790,22 +782,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); // Optionally output additional data about list members for debugging. - boolean iterateThroughList = false; - if (iterateThroughList && logger.isDebugEnabled()) { - List items = - list.getTaxonomyauthorityListItem(); - int i = 0; - for (TaxonomyauthorityCommonList.TaxonomyauthorityListItem item : items) { - String csid = item.getCsid(); - logger.debug(testName + ": list-item[" + i + "] csid=" - + csid); - logger.debug(testName + ": list-item[" + i + "] displayName=" - + item.getDisplayName()); - logger.debug(testName + ": list-item[" + i + "] URI=" - + item.getUri()); - readItemList(csid, null); - i++; - } + if(logger.isTraceEnabled()){ + AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName); } } finally { res.releaseConnection(); @@ -851,7 +829,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI // Submit the request to the service and store the response. TaxonomyAuthorityClient client = new TaxonomyAuthorityClient(); - ClientResponse res = null; + ClientResponse res = null; if (vcsid != null) { res = client.readItemList(vcsid, null, null); } else if (shortId != null) { @@ -860,7 +838,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI Assert.fail("readItemList passed null csid and name!"); } try { - TaxonCommonList list = res.getEntity(); + AbstractCommonList list = res.getEntity(); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -872,8 +850,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - List items = - list.getTaxonListItem(); + List items = + list.getListItem(); int nItemsReturned = items.size(); // There will be one item created, associated with a // known parent resource, by the createItem test. @@ -888,23 +866,16 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI } Assert.assertEquals(nItemsReturned, nExpectedItems); - int i = 0; - for (TaxonCommonList.TaxonListItem item : items) { - Assert.assertTrue((null != item.getRefName()), "Item refName is null!"); - Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!"); - // Optionally output additional data about list members for debugging. - boolean showDetails = true; - if (showDetails && logger.isDebugEnabled()) { - logger.debug(" " + testName + ": list-item[" + i + "] csid=" - + item.getCsid()); - logger.debug(" " + testName + ": list-item[" + i + "] refName=" - + item.getRefName()); - logger.debug(" " + testName + ": list-item[" + i + "] displayName=" - + item.getDisplayName()); - logger.debug(" " + testName + ": list-item[" + i + "] URI=" - + item.getUri()); - } - i++; + for (AbstractCommonList.ListItem item : items) { + String value = + AbstractCommonListUtils.ListItemGetElementValue(item, REFNAME); + Assert.assertTrue((null != value), "Item refName is null!"); + value = + AbstractCommonListUtils.ListItemGetElementValue(item, DISPLAYNAME); + Assert.assertTrue((null != value), "Item displayName is null!"); + } + if(logger.isTraceEnabled()){ + AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName); } } finally { res.releaseConnection(); diff --git a/services/taxonomy/jaxb/src/main/resources/taxon_common.xsd b/services/taxonomy/jaxb/src/main/resources/taxon_common.xsd index e435812c8..126d94a1a 100644 --- a/services/taxonomy/jaxb/src/main/resources/taxon_common.xsd +++ b/services/taxonomy/jaxb/src/main/resources/taxon_common.xsd @@ -68,43 +68,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/services/taxonomy/jaxb/src/main/resources/taxonomyauthority_common.xsd b/services/taxonomy/jaxb/src/main/resources/taxonomyauthority_common.xsd index 36d879813..c2afec0cf 100644 --- a/services/taxonomy/jaxb/src/main/resources/taxonomyauthority_common.xsd +++ b/services/taxonomy/jaxb/src/main/resources/taxonomyauthority_common.xsd @@ -45,46 +45,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/TaxonomyAuthorityResource.java b/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/TaxonomyAuthorityResource.java index 6b3e31e29..886c8cf3f 100644 --- a/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/TaxonomyAuthorityResource.java +++ b/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/TaxonomyAuthorityResource.java @@ -37,9 +37,9 @@ import javax.ws.rs.Produces; @Consumes("application/xml") @Produces("application/xml") public class TaxonomyAuthorityResource - extends AuthorityResource { + extends AuthorityResource { - private final static String taxonomyAuthorityServiceName = "taxonomyauthorities"; + private final static String taxonomyAuthorityServiceName = "taxonomyauthority"; private final static String TAXONOMYAUTHORITY_COMMON = "taxonomyauthority_common"; private final static String taxonomyItemServiceName = "taxon"; private final static String TAXONOMYITEM_COMMON = "taxon_common"; diff --git a/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonDocumentModelHandler.java b/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonDocumentModelHandler.java index b92471560..95b1688f4 100644 --- a/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonDocumentModelHandler.java +++ b/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonDocumentModelHandler.java @@ -23,29 +23,11 @@ */ package org.collectionspace.services.taxonomy.nuxeo; -import java.util.Iterator; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - import org.collectionspace.services.TaxonJAXBSchema; -import org.collectionspace.services.client.TaxonomyAuthorityClient; -import org.collectionspace.services.common.document.DocumentFilter; import org.collectionspace.services.common.document.DocumentWrapper; -import org.collectionspace.services.common.service.ObjectPartType; -import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema; import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler; -import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; -import org.collectionspace.services.nuxeo.util.NuxeoUtils; -import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.taxonomy.TaxonCommon; -import org.collectionspace.services.taxonomy.TaxonCommonList; -import org.collectionspace.services.taxonomy.TaxonCommonList.TaxonListItem; import org.nuxeo.ecm.core.api.DocumentModel; -import org.nuxeo.ecm.core.api.DocumentModelList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * TaxonomyDocumentModelHandler @@ -58,10 +40,8 @@ import org.slf4j.LoggerFactory; * */ public class TaxonDocumentModelHandler - extends AuthorityItemDocumentModelHandler { + extends AuthorityItemDocumentModelHandler { - /** The logger. */ - private final Logger logger = LoggerFactory.getLogger(TaxonDocumentModelHandler.class); /** * Common part schema label */ @@ -138,37 +118,6 @@ public class TaxonDocumentModelHandler return newStr.toString(); } - /* (non-Javadoc) - * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper) - */ - @Override - public TaxonCommonList extractCommonPartList( - DocumentWrapper wrapDoc) throws Exception { - TaxonCommonList coList = extractPagingInfo(new TaxonCommonList(), wrapDoc); - AbstractCommonList commonList = (AbstractCommonList) coList; - commonList.setFieldsReturned("displayName|refName|shortIdentifier|uri|csid"); - List list = coList.getTaxonListItem(); - Iterator iter = wrapDoc.getWrappedObject().iterator(); - String commonPartLabel = getServiceContext().getCommonPartLabel("taxon"); - while (iter.hasNext()) { - DocumentModel docModel = iter.next(); - TaxonListItem ilistItem = new TaxonListItem(); - ilistItem.setDisplayName((String) docModel.getProperty( - commonPartLabel, AuthorityItemJAXBSchema.DISPLAY_NAME)); - ilistItem.setShortIdentifier((String) docModel.getProperty(commonPartLabel, - AuthorityItemJAXBSchema.SHORT_IDENTIFIER)); - ilistItem.setRefName((String) docModel.getProperty(commonPartLabel, - AuthorityItemJAXBSchema.REF_NAME)); - String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString()); - ilistItem.setUri("/taxonomyauthorities/" + inAuthority + "/items/" - + id); - ilistItem.setCsid(id); - list.add(ilistItem); - } - - return coList; - } - /** * getQProperty converts the given property to qualified schema property * @param prop diff --git a/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonomyAuthorityDocumentModelHandler.java b/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonomyAuthorityDocumentModelHandler.java index 8bb95b744..554f0b285 100644 --- a/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonomyAuthorityDocumentModelHandler.java +++ b/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonomyAuthorityDocumentModelHandler.java @@ -23,25 +23,8 @@ */ package org.collectionspace.services.taxonomy.nuxeo; -import java.util.Iterator; -import java.util.List; - -import org.collectionspace.services.common.document.DocumentHandler.Action; -import org.collectionspace.services.common.document.DocumentFilter; -import org.collectionspace.services.common.document.DocumentWrapper; -import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler; -import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.taxonomy.TaxonomyauthorityCommon; -import org.collectionspace.services.taxonomy.TaxonomyauthorityCommonList; -import org.collectionspace.services.taxonomy.TaxonomyauthorityCommonList.TaxonomyauthorityListItem; - -import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; -import org.collectionspace.services.nuxeo.util.NuxeoUtils; -import org.nuxeo.ecm.core.api.DocumentModel; -import org.nuxeo.ecm.core.api.DocumentModelList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * TaxonomyAuthorityDocumentModelHandler @@ -50,7 +33,7 @@ import org.slf4j.LoggerFactory; * $LastChangedDate$ */ public class TaxonomyAuthorityDocumentModelHandler - extends AuthorityDocumentModelHandler { + extends AuthorityDocumentModelHandler { /** * Common part schema label @@ -65,54 +48,5 @@ public class TaxonomyAuthorityDocumentModelHandler return COMMON_PART_LABEL; } - @Override - public TaxonomyauthorityCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - TaxonomyauthorityCommonList coList = extractPagingInfo(new TaxonomyauthorityCommonList(), - wrapDoc); - AbstractCommonList commonList = (AbstractCommonList) coList; - commonList.setFieldsReturned("displayName|refName|shortIdentifier|vocabType|uri|csid"); - - //FIXME: iterating over a long list of documents is not a long term - //strategy...need to change to more efficient iterating in future - List list = coList.getTaxonomyauthorityListItem(); - // FIXME: This workaround - for the discrepancy between plural service - // name / path ("taxonomyauthorities") and singular common part name - // ("taxonomyauthority ... _common") in this service might be handled - // in a cleaner way than below. Absent this workaround, values of fields - // (other than URI and CSID) could not be obtained via the document model. - // Perhaps this will be moot when we switch to the model of Person, et al., - // where SERVICE_PAYLOAD_NAME can be distinct from SERVICE_NAME. - // String label = getServiceContext().getCommonPartLabel(); - String label = getCommonPartLabel(); - Iterator iter = wrapDoc.getWrappedObject().iterator(); - while(iter.hasNext()){ - DocumentModel docModel = iter.next(); - TaxonomyauthorityListItem ilistItem = new TaxonomyauthorityListItem(); - ilistItem.setDisplayName((String) docModel.getProperty(label, - AuthorityJAXBSchema.DISPLAY_NAME)); - ilistItem.setRefName((String) docModel.getProperty(label, - AuthorityJAXBSchema.REF_NAME)); - ilistItem.setShortIdentifier((String) docModel.getProperty(label, - AuthorityJAXBSchema.SHORT_IDENTIFIER)); - ilistItem.setVocabType((String) docModel.getProperty(label, - AuthorityJAXBSchema.VOCAB_TYPE)); - String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString()); - ilistItem.setUri(getServiceContextPath() + id); - ilistItem.setCsid(id); - list.add(ilistItem); - } - - return coList; - } - - /** - * getQProperty converts the given property to qualified schema property - * @param prop - * @return - */ - @Override - public String getQProperty(String prop) { - return TaxonomyAuthorityConstants.NUXEO_SCHEMA_NAME + ":" + prop; - } } diff --git a/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClient.java b/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClient.java index d8646d5b9..54d87bfb9 100644 --- a/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClient.java +++ b/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClient.java @@ -26,16 +26,10 @@ */ package org.collectionspace.services.client; -import org.jboss.resteasy.client.ClientResponse; - -import org.collectionspace.services.vocabulary.VocabulariesCommonList; -import org.collectionspace.services.vocabulary.VocabularyitemsCommonList; -import org.collectionspace.services.client.VocabularyProxy; - /** * The Class VocabularyClient. */ -public class VocabularyClient extends AuthorityClientImpl { +public class VocabularyClient extends AuthorityClientImpl { public static final String SERVICE_NAME = "vocabularies"; public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT; @@ -79,17 +73,4 @@ public class VocabularyClient extends AuthorityClientImpl readList() { - return getProxy().readList(); - } } diff --git a/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyProxy.java b/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyProxy.java index c6b082d07..7c4bbc3c5 100644 --- a/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyProxy.java +++ b/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyProxy.java @@ -1,17 +1,8 @@ package org.collectionspace.services.client; import javax.ws.rs.Consumes; -import javax.ws.rs.GET; import javax.ws.rs.Path; -import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; - -import org.collectionspace.services.vocabulary.VocabulariesCommonList; -import org.collectionspace.services.vocabulary.VocabularyitemsCommonList; -import org.collectionspace.services.client.workflow.WorkflowClient; - -import org.jboss.resteasy.client.ClientResponse; /** * @version $Revision:$ @@ -19,48 +10,6 @@ import org.jboss.resteasy.client.ClientResponse; @Path("/" + VocabularyClient.SERVICE_PATH_COMPONENT + "/") @Produces({"application/xml"}) @Consumes({"application/xml"}) -public interface VocabularyProxy extends AuthorityProxy { - // List Vocabularies - @GET - @Produces({"application/xml"}) - ClientResponse readList(); - - @Override - @GET - @Produces({"application/xml"}) - ClientResponse readIncludeDeleted( - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); - - @Override - @GET - @Produces({"application/xml"}) - ClientResponse keywordSearchIncludeDeleted( - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); - - /* - * List results that must be overridden for the RESTEasy proxy generation to work correctly. - */ - - // List Items matching a partial term or keywords. - @Override - @GET - @Produces({"application/xml"}) - @Path("/{csid}/items/") - ClientResponse readItemList( - @PathParam("csid") String vcsid, - @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); +public interface VocabularyProxy extends AuthorityProxy { - // List Items for a named authority matching a partial term or keywords. - @Override - @GET - @Produces({"application/xml"}) - @Path("/urn:cspace:name({specifier})/items/") - ClientResponse readItemListForNamedAuthority( - @PathParam("specifier") String specifier, - @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); } diff --git a/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java b/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java index a2615ab6b..fb103e585 100644 --- a/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java +++ b/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java @@ -30,6 +30,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.collectionspace.services.client.AuthorityClient; +import org.collectionspace.services.common.AbstractCommonListUtils; import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.PayloadOutputPart; @@ -39,9 +40,7 @@ import org.collectionspace.services.client.VocabularyClient; import org.collectionspace.services.client.VocabularyClientUtils; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.vocabulary.VocabulariesCommon; -import org.collectionspace.services.vocabulary.VocabulariesCommonList; import org.collectionspace.services.vocabulary.VocabularyitemsCommon; -import org.collectionspace.services.vocabulary.VocabularyitemsCommonList; import org.jboss.resteasy.client.ClientResponse; import org.slf4j.Logger; @@ -91,15 +90,6 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { return new VocabularyClient(); } - /* (non-Javadoc) - * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse) - */ - @Override - protected AbstractCommonList getAbstractCommonList( - ClientResponse response) { - return response.getEntity(VocabulariesCommonList.class); - } - @Override protected PoxPayloadOut createInstance(String identifier) { VocabularyClient client = new VocabularyClient(); @@ -663,8 +653,8 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. VocabularyClient client = new VocabularyClient(); - ClientResponse res = client.readList(); - VocabulariesCommonList list = res.getEntity(); + ClientResponse res = client.readList(); + AbstractCommonList list = res.getEntity(); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -677,22 +667,8 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); // Optionally output additional data about list members for debugging. - boolean iterateThroughList = false; - if (iterateThroughList && logger.isDebugEnabled()) { - List items = - list.getVocabularyListItem(); - int i = 0; - for (VocabulariesCommonList.VocabularyListItem item : items) { - String csid = item.getCsid(); - logger.debug(testName + ": list-item[" + i + "] csid=" - + csid); - logger.debug(testName + ": list-item[" + i + "] displayName=" - + item.getDisplayName()); - logger.debug(testName + ": list-item[" + i + "] URI=" - + item.getUri()); - readItemListInt(csid, null, "readList"); - i++; - } + if(logger.isTraceEnabled()){ + AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName); } } @@ -715,7 +691,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. VocabularyClient client = new VocabularyClient(); - ClientResponse res = null; + ClientResponse res = null; if (vcsid != null) { res = client.readItemList(vcsid, null, null); } else if (shortId != null) { @@ -723,7 +699,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { } else { Assert.fail("Internal Error: readItemList both vcsid and shortId are null!"); } - VocabularyitemsCommonList list = res.getEntity(); + AbstractCommonList list = res.getEntity(); int statusCode = res.getStatus(); // Check the status code of the response: does it match @@ -735,8 +711,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - List items = - list.getVocabularyitemListItem(); + List items = list.getListItem(); int nItemsReturned = items.size(); long nItemsTotal = list.getTotalItems(); if (logger.isDebugEnabled()) { @@ -745,20 +720,8 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { } Assert.assertEquals(nItemsTotal, nItemsToCreateInList); - // Optionally output additional data about list members for debugging. - boolean iterateThroughList = true; - if (iterateThroughList && logger.isDebugEnabled()) { - logger.debug(" " + testName + ": checking items"); - int i = 0; - for (VocabularyitemsCommonList.VocabularyitemListItem item : items) { - logger.debug(" " + testName + ": list-item[" + i + "] csid=" - + item.getCsid()); - logger.debug(" " + testName + ": list-item[" + i + "] displayName=" - + item.getDisplayName()); - logger.debug(" " + testName + ": list-item[" + i + "] URI=" - + item.getUri()); - i++; - } + if(logger.isTraceEnabled()){ + AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName); } } diff --git a/services/vocabulary/jaxb/src/main/resources/vocabulary_common.xsd b/services/vocabulary/jaxb/src/main/resources/vocabulary_common.xsd index 4e17b1c0e..c362b5a8c 100644 --- a/services/vocabulary/jaxb/src/main/resources/vocabulary_common.xsd +++ b/services/vocabulary/jaxb/src/main/resources/vocabulary_common.xsd @@ -44,46 +44,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/services/vocabulary/jaxb/src/main/resources/vocabularyitem_common.xsd b/services/vocabulary/jaxb/src/main/resources/vocabularyitem_common.xsd index 27727365f..fcde9d3c8 100644 --- a/services/vocabulary/jaxb/src/main/resources/vocabularyitem_common.xsd +++ b/services/vocabulary/jaxb/src/main/resources/vocabularyitem_common.xsd @@ -33,46 +33,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 d9e07a5f4..91fdbaef3 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 @@ -33,8 +33,7 @@ import javax.ws.rs.Path; @Path("/" + VocabularyClient.SERVICE_PATH_COMPONENT) public class VocabularyResource extends - AuthorityResource { + AuthorityResource { private final static String vocabularyServiceName = VocabularyClient.SERVICE_PATH_COMPONENT; diff --git a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java index b5609dc02..ae145b1d5 100644 --- a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java +++ b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java @@ -23,22 +23,8 @@ */ package org.collectionspace.services.vocabulary.nuxeo; -import java.util.Iterator; -import java.util.List; - -import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler; -import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.vocabulary.VocabulariesCommon; -import org.collectionspace.services.vocabulary.VocabulariesCommonList; -import org.collectionspace.services.vocabulary.VocabulariesCommonList.VocabularyListItem; - -import org.collectionspace.services.nuxeo.util.NuxeoUtils; -import org.collectionspace.services.jaxb.AbstractCommonList; -import org.nuxeo.ecm.core.api.DocumentModel; -import org.nuxeo.ecm.core.api.DocumentModelList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * VocabularyDocumentModelHandler @@ -47,7 +33,7 @@ import org.slf4j.LoggerFactory; * $LastChangedDate: $ */ public class VocabularyDocumentModelHandler - extends AuthorityDocumentModelHandler { + extends AuthorityDocumentModelHandler { /** * Common part schema label @@ -57,38 +43,6 @@ public class VocabularyDocumentModelHandler public VocabularyDocumentModelHandler() { super(COMMON_PART_LABEL); } - - /* (non-Javadoc) - * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper) - */ - @Override - public VocabulariesCommonList extractCommonPartList( - DocumentWrapper wrapDoc) throws Exception { - String label = getServiceContext().getCommonPartLabel(); - VocabulariesCommonList coList = extractPagingInfo(new VocabulariesCommonList(), wrapDoc); - AbstractCommonList commonList = (AbstractCommonList) coList; - commonList.setFieldsReturned("displayName|refName|shortIdentifier|vocabType|uri|csid"); - List list = coList.getVocabularyListItem(); - Iterator iter = wrapDoc.getWrappedObject().iterator(); - while(iter.hasNext()){ - DocumentModel docModel = iter.next(); - VocabularyListItem ilistItem = new VocabularyListItem(); - ilistItem.setDisplayName((String) docModel.getProperty(label, - AuthorityJAXBSchema.DISPLAY_NAME)); - ilistItem.setRefName((String) docModel.getProperty(label, - AuthorityJAXBSchema.REF_NAME)); - ilistItem.setShortIdentifier((String) docModel.getProperty(label, - AuthorityJAXBSchema.SHORT_IDENTIFIER)); - ilistItem.setVocabType((String) docModel.getProperty(label, - AuthorityJAXBSchema.VOCAB_TYPE)); - String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString()); - ilistItem.setUri(getServiceContextPath() + id); - ilistItem.setCsid(id); - list.add(ilistItem); - } - - return coList; - } /** * getQProperty converts the given property to qualified schema property 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 54683b208..66e04b602 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 @@ -23,22 +23,9 @@ */ package org.collectionspace.services.vocabulary.nuxeo; -import java.util.Iterator; -import java.util.List; - import org.collectionspace.services.client.VocabularyClient; -import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema; -import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler; -import org.collectionspace.services.nuxeo.util.NuxeoUtils; -import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.vocabulary.VocabularyitemsCommon; -import org.collectionspace.services.vocabulary.VocabularyitemsCommonList; -import org.collectionspace.services.vocabulary.VocabularyitemsCommonList.VocabularyitemListItem; -import org.nuxeo.ecm.core.api.DocumentModel; -import org.nuxeo.ecm.core.api.DocumentModelList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * VocabularyItemDocumentModelHandler @@ -47,10 +34,8 @@ import org.slf4j.LoggerFactory; * $LastChangedDate: $ */ public class VocabularyItemDocumentModelHandler - extends AuthorityItemDocumentModelHandler { + extends AuthorityItemDocumentModelHandler { - private final Logger logger = LoggerFactory.getLogger(VocabularyItemDocumentModelHandler.class); - private static final String COMMON_PART_LABEL = "vocabularyitems_common"; public VocabularyItemDocumentModelHandler() { @@ -61,38 +46,7 @@ public class VocabularyItemDocumentModelHandler public String getAuthorityServicePath(){ return VocabularyClient.SERVICE_PATH_COMPONENT; // CSPACE-3932 } - - @Override - public VocabularyitemsCommonList extractCommonPartList( - DocumentWrapper wrapDoc) throws Exception { - VocabularyitemsCommonList coList = extractPagingInfo(new VocabularyitemsCommonList(), wrapDoc); - AbstractCommonList commonList = (AbstractCommonList) coList; - commonList.setFieldsReturned("displayName|refName|shortIdentifier|order|uri|csid"); - - List list = coList.getVocabularyitemListItem(); - Iterator iter = wrapDoc.getWrappedObject().iterator(); - String commonPartLabel = getServiceContext().getCommonPartLabel("vocabularyItems"); - while (iter.hasNext()) { - DocumentModel docModel = iter.next(); - VocabularyitemListItem ilistItem = new VocabularyitemListItem(); - ilistItem.setDisplayName((String) docModel.getProperty(commonPartLabel, - AuthorityItemJAXBSchema.DISPLAY_NAME)); - ilistItem.setShortIdentifier((String) docModel.getProperty(commonPartLabel, - AuthorityItemJAXBSchema.SHORT_IDENTIFIER)); - ilistItem.setRefName((String) docModel.getProperty(commonPartLabel, - AuthorityItemJAXBSchema.REF_NAME)); - ilistItem.setOrder((String) docModel.getProperty(commonPartLabel, - AuthorityItemJAXBSchema.ORDER)); - String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString()); - ilistItem.setUri("/vocabularies/" + inAuthority + "/items/" + id); - ilistItem.setCsid(id); - list.add(ilistItem); - } - - return coList; - } - /** * getQProperty converts the given property to qualified schema property * @param prop