From: Patrick Schmitz Date: Sat, 12 Feb 2011 00:35:19 +0000 (+0000) Subject: CSPACE-577 - Make the set of fields returned for lists, be configurable in the tenant... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=2ca30355584a58d4e1d7a2b21f357cf76e02070d;p=tmp%2Fjakarta-migration.git CSPACE-577 - Make the set of fields returned for lists, be configurable in the tenant-bindings.xml. Added a new Class CommonList that supports this broadly, and then refactered the new DocHandlerBase to use configuration to build the list results. This is use by a small set of initial services: Blob, Media, Loansin, ObjectExits, and Acquisitions. Updated all the associated xsd files to remove the old results list schemas, updated Resource and DocHandlers, client and procy classes, tests, etc. for each of these 5 services. --- diff --git a/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionClient.java b/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionClient.java index 972716418..f8bd3aef6 100644 --- a/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionClient.java +++ b/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionClient.java @@ -2,7 +2,7 @@ package org.collectionspace.services.client; import javax.ws.rs.core.Response; -import org.collectionspace.services.acquisition.AcquisitionsCommonList; +import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.common.authorityref.AuthorityRefList; import org.jboss.resteasy.client.ProxyFactory; import org.jboss.resteasy.plugins.providers.RegisterBuiltin; @@ -77,7 +77,7 @@ public class AcquisitionClient extends AbstractServiceClientImpl { * @return * @see org.collectionspace.hello.client.IntakeProxy#getIntake() */ - public ClientResponse readList() { + public ClientResponse readList() { return acquisitionProxy.readList(); } diff --git a/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionProxy.java b/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionProxy.java index 2a105603d..6ba5e01a9 100644 --- a/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionProxy.java +++ b/services/acquisition/client/src/main/java/org/collectionspace/services/client/AcquisitionProxy.java @@ -10,7 +10,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; -import org.collectionspace.services.acquisition.AcquisitionsCommonList; +import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.common.authorityref.AuthorityRefList; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; @@ -26,7 +26,7 @@ public interface AcquisitionProxy extends CollectionSpaceProxy { @GET @Produces({"application/xml"}) - ClientResponse readList(); + ClientResponse readList(); //(C)reate @POST diff --git a/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java b/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java index 5863acadd..8213d966f 100644 --- a/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java +++ b/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java @@ -28,16 +28,15 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.client.AcquisitionClient; import org.collectionspace.services.client.CollectionSpaceClient; -import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.acquisition.AcquisitionsCommon; -import org.collectionspace.services.acquisition.AcquisitionsCommonList; import org.collectionspace.services.acquisition.AcquisitionDateList; import org.collectionspace.services.acquisition.AcquisitionFunding; import org.collectionspace.services.acquisition.AcquisitionFundingList; import org.collectionspace.services.acquisition.AcquisitionSourceList; import org.collectionspace.services.acquisition.OwnerList; import org.jboss.resteasy.client.ClientResponse; +import org.collectionspace.services.jaxb.AbstractCommonList; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; @@ -79,7 +78,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { @Override protected AbstractCommonList getAbstractCommonList( ClientResponse response) { - return response.getEntity(AcquisitionsCommonList.class); + return response.getEntity(AbstractCommonList.class); } // --------------------------------------------------------------- @@ -390,8 +389,8 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { // Submit the request to the service and store the response. AcquisitionClient client = new AcquisitionClient(); - ClientResponse res = client.readList(); - AcquisitionsCommonList 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 @@ -406,22 +405,14 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl { // Optionally output additional data about list members for debugging. boolean iterateThroughList = false; if(iterateThroughList && logger.isDebugEnabled()){ - List items = - list.getAcquisitionListItem(); - int i = 0; - for(AcquisitionsCommonList.AcquisitionListItem item : items){ - logger.debug(testName + ": list-item[" + i + "] csid=" + - item.getCsid()); - logger.debug(testName + ": list-item[" + i + "] objectNumber=" + - item.getAcquisitionReferenceNumber()); - logger.debug(testName + ": list-item[" + i + "] acquisitionSource=" + - item.getAcquisitionSource()); - logger.debug(testName + ": list-item[" + i + "] owner=" + - item.getOwner()); - logger.debug(testName + ": list-item[" + i + "] URI=" + - item.getUri()); - i++; - } + List items = + list.getListItem(); + int i = 0; + for(AbstractCommonList.ListItem item : items){ + logger.debug(testName + ": list-item[" + i + "] " + + item.toString()); + i++; + } } } diff --git a/services/acquisition/jaxb/src/main/resources/acquisitions_common.xsd b/services/acquisition/jaxb/src/main/resources/acquisitions_common.xsd index ac8d05288..6fc452e43 100644 --- a/services/acquisition/jaxb/src/main/resources/acquisitions_common.xsd +++ b/services/acquisition/jaxb/src/main/resources/acquisitions_common.xsd @@ -112,34 +112,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/AcquisitionResource.java b/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/AcquisitionResource.java index a8113cf5e..e67b108d5 100644 --- a/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/AcquisitionResource.java +++ b/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/AcquisitionResource.java @@ -55,6 +55,9 @@ import org.collectionspace.services.common.query.IQueryManager; import org.collectionspace.services.common.query.QueryManager; import org.collectionspace.services.common.security.UnauthorizedException; import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler; +import org.collectionspace.services.jaxb.AbstractCommonList; +import org.collectionspace.services.nuxeo.client.java.CommonList; + import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; import org.jboss.resteasy.util.HttpResponseCodes; @@ -223,9 +226,9 @@ public class AcquisitionResource */ @GET @Produces("application/xml") - public AcquisitionsCommonList getAcquisitionList(@Context UriInfo ui, + public CommonList getAcquisitionList(@Context UriInfo ui, @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords) { - AcquisitionsCommonList result = null; + CommonList result = null; MultivaluedMap queryParams = ui.getQueryParameters(); if (keywords != null) { result = searchAcquisitions(queryParams, keywords); @@ -241,13 +244,13 @@ public class AcquisitionResource * * @return the acquisitions list */ - private AcquisitionsCommonList getAcquisitionsList(MultivaluedMap queryParams) { - AcquisitionsCommonList acquisitionObjectList; + private CommonList getAcquisitionsList(MultivaluedMap queryParams) { + CommonList commonList; try { ServiceContext ctx = createServiceContext(queryParams); DocumentHandler handler = createDocumentHandler(ctx); getRepositoryClient(ctx).getFiltered(ctx, handler); - acquisitionObjectList = (AcquisitionsCommonList) handler.getCommonPartList(); + commonList = (CommonList) handler.getCommonPartList(); } catch (UnauthorizedException ue) { Response response = Response.status( Response.Status.UNAUTHORIZED).entity( @@ -262,7 +265,7 @@ public class AcquisitionResource ServiceMessages.LIST_FAILED + e.getMessage()).type("text/plain").build(); throw new WebApplicationException(response); } - return acquisitionObjectList; + return commonList; } /** @@ -373,7 +376,7 @@ public class AcquisitionResource @Path("/search") @Produces("application/xml") @Deprecated - public AcquisitionsCommonList keywordsSearchAcquisitions(@Context UriInfo ui, + public CommonList keywordsSearchAcquisitions(@Context UriInfo ui, @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS) String keywords) { MultivaluedMap queryParams = ui.getQueryParameters(); return searchAcquisitions(queryParams, keywords); @@ -386,10 +389,10 @@ public class AcquisitionResource * * @return the acquisitions common list */ - private AcquisitionsCommonList searchAcquisitions( + private CommonList searchAcquisitions( MultivaluedMap queryParams, String keywords) { - AcquisitionsCommonList acquisitionObjectList; + CommonList commonList; try { ServiceContext ctx = createServiceContext(queryParams); DocumentHandler handler = createDocumentHandler(ctx); @@ -404,7 +407,7 @@ public class AcquisitionResource } } getRepositoryClient(ctx).getFiltered(ctx, handler); - acquisitionObjectList = (AcquisitionsCommonList) handler.getCommonPartList(); + commonList = (CommonList) handler.getCommonPartList(); } catch (UnauthorizedException ue) { Response response = Response.status( Response.Status.UNAUTHORIZED).entity( @@ -419,7 +422,7 @@ public class AcquisitionResource ServiceMessages.SEARCH_FAILED + e.getMessage()).type("text/plain").build(); throw new WebApplicationException(response); } - return acquisitionObjectList; + return commonList; } /** diff --git a/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java b/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java index bc262b11c..f6a2e0245 100644 --- a/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java +++ b/services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java @@ -24,7 +24,6 @@ package org.collectionspace.services.acquisition.nuxeo; import org.collectionspace.services.acquisition.AcquisitionsCommon; -import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; /** AcquisitionDocumentModelHandler @@ -32,6 +31,6 @@ import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; * $LastChangedDate: $ */ public class AcquisitionDocumentModelHandler - extends DocHandlerBase { + extends DocHandlerBase { } diff --git a/services/blob/client/src/main/java/org/collectionspace/services/client/BlobClient.java b/services/blob/client/src/main/java/org/collectionspace/services/client/BlobClient.java index 9c7e20af8..510d30e5f 100644 --- a/services/blob/client/src/main/java/org/collectionspace/services/client/BlobClient.java +++ b/services/blob/client/src/main/java/org/collectionspace/services/client/BlobClient.java @@ -20,8 +20,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; import org.collectionspace.services.common.authorityref.AuthorityRefList; -//import org.collectionspace.services.common.context.ServiceContext; -import org.collectionspace.services.blob.BlobsCommonList; +import org.collectionspace.services.jaxb.AbstractCommonList; import org.jboss.resteasy.client.ProxyFactory; import org.jboss.resteasy.plugins.providers.RegisterBuiltin; @@ -97,7 +96,7 @@ public class BlobClient extends AbstractServiceClientImpl { * @return * @see org.collectionspace.services.client.BlobProxy#getBlob() */ - public ClientResponse readList() { + public ClientResponse readList() { return blobProxy.readList(); } diff --git a/services/blob/client/src/main/java/org/collectionspace/services/client/BlobProxy.java b/services/blob/client/src/main/java/org/collectionspace/services/client/BlobProxy.java index 40797d269..18829d9a0 100644 --- a/services/blob/client/src/main/java/org/collectionspace/services/client/BlobProxy.java +++ b/services/blob/client/src/main/java/org/collectionspace/services/client/BlobProxy.java @@ -11,7 +11,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Response; import org.collectionspace.services.common.authorityref.AuthorityRefList; -import org.collectionspace.services.blob.BlobsCommonList; +import org.collectionspace.services.jaxb.AbstractCommonList; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; @@ -46,7 +46,7 @@ public interface BlobProxy extends CollectionSpaceProxy { // List @GET @Produces({"application/xml"}) - ClientResponse readList(); + ClientResponse readList(); // List Authority References @GET diff --git a/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobServiceTest.java b/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobServiceTest.java index 64249d015..2dea5714d 100644 --- a/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobServiceTest.java +++ b/services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobServiceTest.java @@ -30,7 +30,6 @@ import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.BlobClient; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.blob.BlobsCommon; -import org.collectionspace.services.blob.BlobsCommonList; import org.jboss.resteasy.client.ClientResponse; @@ -62,7 +61,7 @@ public class BlobServiceTest extends AbstractServiceTestImpl { @Override protected AbstractCommonList getAbstractCommonList(ClientResponse response) { - return response.getEntity(BlobsCommonList.class); + return response.getEntity(AbstractCommonList.class); } @Override @@ -109,16 +108,16 @@ public class BlobServiceTest extends AbstractServiceTestImpl { logger.debug(testBanner(testName, CLASS_NAME)); setupReadList(); BlobClient client = new BlobClient(); - ClientResponse res = client.readList(); - BlobsCommonList list = res.getEntity(); + ClientResponse res = client.readList(); + AbstractCommonList list = res.getEntity(); assertStatusCode(res, testName); if (logger.isDebugEnabled()) { - List items = list.getBlobListItem(); + List items = + list.getListItem(); int i = 0; - for (BlobsCommonList.BlobListItem item : items) { - logger.debug(testName + ": list-item[" + i + "] csid=" + item.getCsid()); - logger.debug(testName + ": list-item[" + i + "] blob.name=" + item.getName()); - logger.debug(testName + ": list-item[" + i + "] URI=" + item.getUri()); + for(AbstractCommonList.ListItem item : items){ + logger.debug(testName + ": list-item[" + i + "] " + + item.toString()); i++; } } diff --git a/services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.java b/services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.java index 762935527..bb0fd3444 100644 --- a/services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.java +++ b/services/blob/service/src/main/java/org/collectionspace/services/blob/BlobResource.java @@ -37,7 +37,10 @@ import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.DocumentHandler; import org.collectionspace.services.blob.nuxeo.BlobDocumentModelHandler; //FIXEME: A resource class should not have a dependency on a specific DocumentHandler import org.collectionspace.services.blob.BlobsCommon; -import org.collectionspace.services.blob.BlobsCommonList; +//import org.collectionspace.services.blob.BlobsCommonList; +import org.collectionspace.services.jaxb.AbstractCommonList; +import org.collectionspace.services.nuxeo.client.java.CommonList; +import javax.xml.parsers.ParserConfigurationException; import org.jboss.resteasy.plugins.providers.multipart.InputPart; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; @@ -93,23 +96,23 @@ public class BlobResource extends ResourceBase { //FIXME: Is this method used/needed? @Deprecated - private BlobsCommonList getBlobList(MultivaluedMap queryParams) { - return (BlobsCommonList)getList(queryParams); + private CommonList getBlobList(MultivaluedMap queryParams) { + return (CommonList)getList(queryParams); } @Deprecated - public BlobsCommonList getBlobList(List csidList) { - return (BlobsCommonList) getList(csidList); + public CommonList getBlobList(List csidList) { + return (CommonList) getList(csidList); } @Deprecated - protected BlobsCommonList search(MultivaluedMap queryParams,String keywords) { - return (BlobsCommonList) super.search(queryParams, keywords); + protected CommonList search(MultivaluedMap queryParams,String keywords) { + return (CommonList) super.search(queryParams, keywords); } - private BlobsCommonList getDerivativeList(ServiceContext ctx, + private CommonList getDerivativeList(ServiceContext ctx, String csid) throws Exception { - BlobsCommonList result = null; + CommonList result = null; BlobInput blobInput = new BlobInput(); blobInput.setDerivativeListRequested(true); @@ -267,9 +270,9 @@ public class BlobResource extends ResourceBase { @GET @Path("{csid}/derivatives") @Produces("application/xml") - public BlobsCommonList getDerivatives( + public CommonList getDerivatives( @PathParam("csid") String csid) { - BlobsCommonList result = null; + CommonList result = null; ensureCSID(csid, READ); try { diff --git a/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobDocumentModelHandler.java b/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobDocumentModelHandler.java index e79ae7dd2..8cac45583 100644 --- a/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobDocumentModelHandler.java +++ b/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobDocumentModelHandler.java @@ -24,7 +24,6 @@ package org.collectionspace.services.blob.nuxeo; import org.collectionspace.services.blob.BlobsCommon; -import org.collectionspace.services.blob.BlobsCommonList; import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; import org.collectionspace.services.common.blob.BlobInput; import org.collectionspace.services.common.blob.BlobOutput; @@ -34,6 +33,8 @@ import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.imaging.nuxeo.NuxeoImageUtils; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.jaxb.BlobJAXBSchema; +import org.collectionspace.services.jaxb.AbstractCommonList; +import org.collectionspace.services.nuxeo.client.java.CommonList; import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.repository.RepositoryInstance; @@ -47,7 +48,7 @@ import java.util.List; * The Class BlobDocumentModelHandler. */ public class BlobDocumentModelHandler -extends DocHandlerBase { +extends DocHandlerBase { /** The logger. */ private final Logger logger = LoggerFactory.getLogger(BlobDocumentModelHandler.class); @@ -110,7 +111,7 @@ extends DocHandlerBase { String blobRepositoryId = blobsCommon.getRepositoryId(); //cache the value to pass to the blob retriever if (blobInput.isDerivativeListRequested() == true) { - BlobsCommonList blobsCommonList = NuxeoImageUtils.getBlobDerivatives( + CommonList blobsCommonList = NuxeoImageUtils.getBlobDerivatives( repoSession, blobRepositoryId, getDerivativePathBase(docModel)); // ctx.setProperty(BlobInput.BLOB_DERIVATIVE_LIST_KEY, blobsCommonList); blobInput.setDerivativeList(blobsCommonList); diff --git a/services/common/src/main/cspace/config/services/tenants/collectionspace/tenant-bindings.xml b/services/common/src/main/cspace/config/services/tenants/collectionspace/tenant-bindings.xml index 3691e6248..458ca085c 100644 --- a/services/common/src/main/cspace/config/services/tenants/collectionspace/tenant-bindings.xml +++ b/services/common/src/main/cspace/config/services/tenants/collectionspace/tenant-bindings.xml @@ -172,33 +172,33 @@ org.collectionspace.services.blob.nuxeo.BlobDocumentModelHandler - blobs - blobs - name|mimeType|encoding|length|uri|csid - org.collectionspace.services.blob.BlobsCommonList - org.collectionspace.services.blob.BlobsCommonList$BlobListItem - getBlobListItem - - - setName - name - + blobs + blobs + name|mimeType|encoding|length|uri|csid + org.collectionspace.services.blob.BlobsCommonList + org.collectionspace.services.blob.BlobsCommonList$BlobListItem + getBlobListItem + + + name + name + - setMimeType - mimeType + mimeType + mimeType - setEncoding + encoding encoding - setLength + length length - - + + @@ -273,7 +273,7 @@ authRefvaluer authRefinsurers|insurer authRefconditionCheckersOrAssessors|conditionCheckerOrAssessor - + org.collectionspace.services.loanin.nuxeo.LoaninDocumentModelHandler - loansin - loansin - loanInNumber|lenderList|loanReturnDate|uri|csid - org.collectionspace.services.loanin.LoansinCommonList - org.collectionspace.services.loanin.LoansinCommonList$LoaninListItem - getLoaninListItem - - - setLoanInNumber - loanInNumber - + loansin + loansin + loanInNumber|lenderList|loanReturnDate|uri|csid + org.collectionspace.services.loanin.LoansinCommonList + org.collectionspace.services.loanin.LoansinCommonList$LoaninListItem + getLoaninListItem + + + loanInNumber + loanInNumber + - setLender - lenderGroupList/[0]/lender + lender + lenderGroupList/[0]/lender - setLoanReturnDate + loanReturnDate loanReturnDate @@ -361,12 +361,12 @@ - datePatternMMM dd, yyyy - datePatterndd.MM.yyyy - - localeLanguageen - - + datePatternMMM dd, yyyy + datePatterndd.MM.yyyy + + localeLanguageen + + @@ -486,22 +486,22 @@ org.collectionspace.services.objectexit.nuxeo.ObjectExitDocumentModelHandler - objectexit - objectexit - exitNumber|currentOwner|uri|csid - org.collectionspace.services.objectexit.ObjectexitCommonList - org.collectionspace.services.objectexit.ObjectexitCommonList$ObjectexitListItem - getObjectexitListItem - - - setExitNumber - exitNumber - + objectexit + objectexit + exitNumber|currentOwner|uri|csid + org.collectionspace.services.objectexit.ObjectexitCommonList + org.collectionspace.services.objectexit.ObjectexitCommonList$ObjectexitListItem + getObjectexitListItem + + + exitNumber + exitNumber + - setCurrentOwner - currentOwner + currentOwner + currentOwner - + @@ -558,30 +558,30 @@ org.collectionspace.services.media.nuxeo.MediaDocumentModelHandler - media - media - title|source|filename|identificationNumber|uri|csid - org.collectionspace.services.media.MediaCommonList - org.collectionspace.services.media.MediaCommonList$MediaListItem - getMediaListItem - - - setTitle - title - + media + media + title|source|filename|identificationNumber|uri|csid + org.collectionspace.services.media.MediaCommonList + org.collectionspace.services.media.MediaCommonList$MediaListItem + getMediaListItem + + + title + title + - setSource - source + source + source - setFilename + filename filename - setIdentificationNumber + identificationNumber identificationNumber - - + + @@ -609,7 +609,7 @@ authRefpublisher authRefrightsHolder authRefsubjects|subject - + shortidentifier - + shortidentifier - + org.collectionspace.services.loanin.nuxeo.AcquisitionDocumentModelHandler - acquisition - acquisition - acquisitionReferenceNumber|acquisitionSources|owners|uri|csid - org.collectionspace.services.acquisition.AcquisitionsCommonList - org.collectionspace.services.acquisition.AcquisitionsCommonList$AcquisitionListItem - getAcquisitionListItem - + acquisition + acquisition + acquisitionReferenceNumber|acquisitionSources|owners|uri|csid + org.collectionspace.services.acquisition.AcquisitionsCommonList + org.collectionspace.services.acquisition.AcquisitionsCommonList$AcquisitionListItem + getAcquisitionListItem + + + acquisitionReferenceNumber + acquisitionReferenceNumber + - setAcquisitionReferenceNumber - acquisitionReferenceNumber + acquisitionSource + acquisitionSources/[0] - setAcquisitionSource - acquisitionSources/[0] - - - setOwner + owner owners/[0] @@ -1787,7 +1787,7 @@ - + @@ -1826,9 +1826,8 @@ - + - diff --git a/services/common/src/main/cspace/config/services/tenants/hearstmuseum/tenant-bindings.xml b/services/common/src/main/cspace/config/services/tenants/hearstmuseum/tenant-bindings.xml index 57697856a..7bfb78098 100644 --- a/services/common/src/main/cspace/config/services/tenants/hearstmuseum/tenant-bindings.xml +++ b/services/common/src/main/cspace/config/services/tenants/hearstmuseum/tenant-bindings.xml @@ -179,19 +179,19 @@ getBlobListItem - setName + name name - setMimeType + mimeType mimeType - setEncoding + encoding encoding - setLength + length length @@ -315,15 +315,15 @@ getLoaninListItem - setLoanInNumber + loanInNumber loanInNumber - setLender + lender lenderGroupList/[0]/lender - setLoanReturnDate + loanReturnDate loanReturnDate @@ -457,12 +457,12 @@ getObjectexitListItem - setExitNumber + exitNumber exitNumber - setCurrentOwner + currentOwner currentOwner @@ -530,19 +530,19 @@ getMediaListItem - setTitle + title title - setSource + source source - setFilename + filename filename - setIdentificationNumber + identificationNumber identificationNumber @@ -1204,15 +1204,15 @@ getAcquisitionListItem - setAcquisitionReferenceNumber + acquisitionReferenceNumber acquisitionReferenceNumber - setAcquisitionSource + acquisitionSource acquisitionSources/[0] - setOwner + owner owners/[0] diff --git a/services/common/src/main/java/org/collectionspace/services/common/blob/BlobInput.java b/services/common/src/main/java/org/collectionspace/services/common/blob/BlobInput.java index c0e565895..a7bf2d71e 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/blob/BlobInput.java +++ b/services/common/src/main/java/org/collectionspace/services/common/blob/BlobInput.java @@ -5,7 +5,9 @@ import java.io.InputStream; import javax.servlet.http.HttpServletRequest; -import org.collectionspace.services.blob.BlobsCommonList; +//import org.collectionspace.services.blob.BlobsCommonList; +import org.collectionspace.services.jaxb.AbstractCommonList; +import org.collectionspace.services.nuxeo.client.java.CommonList; import org.collectionspace.services.common.FileUtils; public class BlobInput { @@ -15,7 +17,7 @@ public class BlobInput { private String derivativeTerm; private boolean derivativeListRequested = false; - private BlobsCommonList derivativeList; + private CommonList derivativeList; private boolean contentRequested = false; private InputStream contentStream; @@ -88,11 +90,11 @@ public class BlobInput { this.derivativeListRequested = derivativesRequested; } - public BlobsCommonList getDerivativeList() { + public CommonList getDerivativeList() { return derivativeList; } - public void setDerivativeList(BlobsCommonList derivativeList) { + public void setDerivativeList(CommonList derivativeList) { this.derivativeList = derivativeList; } diff --git a/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoImageUtils.java b/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoImageUtils.java index d7ba33682..67605db5c 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoImageUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoImageUtils.java @@ -112,8 +112,11 @@ import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.DocumentUtils; import org.collectionspace.services.common.FileUtils; import org.collectionspace.services.blob.BlobsCommon; -import org.collectionspace.services.blob.BlobsCommonList; -import org.collectionspace.services.blob.BlobsCommonList.BlobListItem; +//import org.collectionspace.services.blob.BlobsCommonList; +//import org.collectionspace.services.blob.BlobsCommonList.BlobListItem; +import org.collectionspace.services.jaxb.AbstractCommonList; +import org.collectionspace.services.jaxb.BlobJAXBSchema; +import org.collectionspace.services.nuxeo.client.java.CommonList; import org.collectionspace.services.common.blob.BlobOutput; import org.collectionspace.ecm.platform.quote.api.QuoteManager; @@ -190,28 +193,43 @@ public class NuxeoImageUtils { return uri + result + "/" + BlobInput.URI_CONTENT_PATH; } - static private BlobListItem createBlobListItem(Blob blob, String uri) { - BlobListItem result = new BlobListItem(); - - result.setEncoding(blob.getEncoding()); - result.setLength(Long.toString(blob.getLength())); - result.setMimeType(blob.getMimeType()); - result.setName(blob.getFilename()); - result.setUri(getDerivativeUri(uri, blob.getFilename())); - - return result; + static private HashMap createBlobListItem(Blob blob, String uri) { + HashMap item = new HashMap(); + + String value = blob.getEncoding(); + if(value!=null && !value.trim().isEmpty()) { + item.put(BlobJAXBSchema.encoding, value); + } + value = Long.toString(blob.getLength()); + if(value!=null && !value.trim().isEmpty()) { + item.put(BlobJAXBSchema.length, value); + } + value = blob.getMimeType(); + if(value!=null && !value.trim().isEmpty()) { + item.put(BlobJAXBSchema.mimeType, value); + } + value = blob.getFilename(); + if(value!=null && !value.trim().isEmpty()) { + item.put(BlobJAXBSchema.name, value); + } + value = getDerivativeUri(uri, blob.getFilename()); + if(value!=null && !value.trim().isEmpty()) { + item.put(BlobJAXBSchema.uri, value); + } + + return item; } - static public BlobsCommonList getBlobDerivatives(RepositoryInstance repoSession, + static public CommonList getBlobDerivatives(RepositoryInstance repoSession, String repositoryId, String uri) throws Exception { - BlobsCommonList result = new BlobsCommonList(); + CommonList commonList = new CommonList(); IdRef documentRef = new IdRef(repositoryId); DocumentModel documentModel = repoSession.getDocument(documentRef); DocumentBlobHolder docBlobHolder = (DocumentBlobHolder)documentModel.getAdapter(BlobHolder.class); // - // + // FIXME: REM this looks like cruft try { QuoteManager quoteManager = (QuoteManager)Framework.getService(QuoteManager.class); quoteManager.createQuote(documentModel, "Quoted - Comment" + System.currentTimeMillis(), @@ -222,14 +240,14 @@ public class NuxeoImageUtils { // // List docBlobs = docBlobHolder.getBlobs(); - List blobListItems = result.getBlobListItem(); - BlobListItem blobListItem = null; + //List blobListItems = result.getBlobListItem(); + HashMap item = null; for (Blob blob : docBlobs) { - blobListItem = createBlobListItem(blob, uri); - blobListItems.add(blobListItem); + item = createBlobListItem(blob, uri); + commonList.addItem(item); } - return result; + return commonList; } static private BlobsCommon createBlobsCommon(DocumentModel documentModel, Blob nuxeoBlob) { diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/CommonList.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/CommonList.java new file mode 100644 index 000000000..9b807de64 --- /dev/null +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/CommonList.java @@ -0,0 +1,159 @@ +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + + * http://www.collectionspace.org + * http://wiki.collectionspace.org + + * Copyright 2009 University of California at Berkeley + + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + + * You may obtain a copy of the ECL 2.0 License at + + * https://source.collectionspace.org/collection-space/LICENSE.txt + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.collectionspace.services.nuxeo.client.java; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +import org.collectionspace.services.jaxb.AbstractCommonList; + +import org.apache.commons.lang.builder.ToStringBuilder; +import org.jvnet.jaxb2_commons.lang.ToString; +import org.jvnet.jaxb2_commons.lang.builder.JAXBToStringBuilder; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlSeeAlso; + +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; + +/** + * This class allows us to generically represent and marshall a set of list + * results for any object. The base information is provided by the + * AbstractCommonList.xsd and associated class, defining the list header. + * A array of itemInfo objects define the results-specific info, where + * each itemInfo is a map of Strings that represent the fields returned for + * each item. + * + * @author pschmitz + * $LastChangedRevision: $ + * $LastChangedDate: $ + */ +@XmlAccessorType(XmlAccessType.NONE) +// We use the same root as the superclass, so unmarshalling will work (more or less) +@XmlRootElement(name = "abstract-common-list") +public class CommonList extends AbstractCommonList { + + /** The logger. */ + //private final Logger logger = LoggerFactory.getLogger(this.getClass()); + @XmlTransient + private DocumentBuilderFactory factory; + @XmlTransient + private DocumentBuilder parser; + @XmlTransient + private Document doc; + + public CommonList() + throws javax.xml.parsers.ParserConfigurationException { + super(); + factory = DocumentBuilderFactory.newInstance(); + //Get the DocumentBuilder + parser = factory.newDocumentBuilder(); + //Create blank DOM Document + doc = parser.newDocument(); + } + + @XmlTransient + private String fieldKeys[] = null; + + //Add methods to add new items, and to set the fieldKeys. Could make + //them an array of strings rather than arraylist. + + /** + * @return the current set of fieldKeys. + */ + public String[] getFieldKeys() { + return fieldKeys; + } + + /** + * Sets the keys to assume when fetching fields from the itemInfo maps. + * As a side-effect, will build and set super.fieldsReturned. + * This MUST be called before attempting to add items (with addItem). + * + * @param fieldKeys the keys to use + * + */ + public void setFieldsReturned(String[] fieldKeys) { + this.fieldKeys = fieldKeys; + String fieldsImploded = implode(fieldKeys, "|"); + setFieldsReturned(fieldsImploded); + } + + // TODO This should be in common, but then we have mutual dependencies. Sigh. + private String implode(String strings[], String sep) { + String implodedString; + if (strings.length==0) { + implodedString = ""; + } else { + StringBuffer sb = new StringBuffer(); + sb.append(strings[0]); + for (int i=1;i itemInfo) { + if(fieldKeys==null) { + throw new RuntimeException("CommonList.addItem: Cannot add items before fieldKeys are set."); + } + List itemsList = getListItem(); + AbstractCommonList.ListItem listItem = new AbstractCommonList.ListItem(); + itemsList.add(listItem); + List anyList = listItem.getAny(); + for(String key:fieldKeys) { + Element el = doc.createElement(key); + el.setTextContent(itemInfo.get(key)); + anyList.add(el); + } + } + +} + + 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 f53148760..3984b2bb1 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 @@ -25,6 +25,7 @@ package org.collectionspace.services.nuxeo.client.java; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -36,6 +37,7 @@ import org.collectionspace.services.common.service.ServiceBindingType; import org.collectionspace.services.common.context.MultipartServiceContext; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.jaxb.AbstractCommonList; +import org.collectionspace.services.nuxeo.client.java.CommonList; import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; import org.collectionspace.services.nuxeo.util.NuxeoUtils; import org.nuxeo.ecm.core.api.DocumentModel; @@ -44,10 +46,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * This class is generified by the marker types T and TL, - * however, T is expected to map to something like BlobCommon, MediaCommon, ObjectexitCommon, etc., - * whereas TL is expected to map to AbstractCommonList, - * since, for example, BlobCommonList and ObjectexitCommonList descend from AbstractCommonList, + * This class is generified by the marker type T, + * where T is expected to map to something like BlobCommon, MediaCommon, ObjectexitCommon, etc., * and so on for every JAXB-generated schema class. * * User: laramie @@ -55,7 +55,7 @@ import org.slf4j.LoggerFactory; * $LastChangedDate: $ * */ -public abstract class DocHandlerBase extends RemoteDocumentModelHandlerImpl { +public abstract class DocHandlerBase extends RemoteDocumentModelHandlerImpl { /** The logger. */ private final Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -63,8 +63,8 @@ public abstract class DocHandlerBase extends RemoteDocumentModelHandlerIm private AbstractCommonList commonList; @Override - public TL getCommonPartList() { - return (TL)commonList; + public AbstractCommonList getCommonPartList() { + return commonList; } public void setCommonPartList(AbstractCommonList aCommonList) { @@ -128,9 +128,10 @@ public abstract class DocHandlerBase extends RemoteDocumentModelHandlerIm } @Override - public TL extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - String label = getServiceContext().getCommonPartLabel(); - + public AbstractCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { + //String label = getServiceContext().getCommonPartLabel(); + + /* AbstractCommonList commonList = createAbstractCommonListImpl(); extractPagingInfo(((TL)commonList), wrapDoc); commonList.setFieldsReturned(getSummaryFields(commonList)); @@ -142,7 +143,59 @@ public abstract class DocHandlerBase extends RemoteDocumentModelHandlerIm Object item = createItemForCommonList(docModel, label, id); list.add(item); } - return (TL)commonList; + */ + /* Rewrite + * Create the CommonList + * List resultsFields = getListItemsArray(); + * Construct array of strings of resultsFields + * add csid and uri + * Set the fieldNames for CommonList + * For each doc in list: + * Create HashMap of values + * get csid, set csid hashmap value + * get uri, set uri hashmap value + * for (ListResultField field : resultsFields ){ + * get String value from Xpath + * set hashMap value + * AddItem to CommonList + * + */ + String commonSchema = getServiceContext().getCommonPartLabel(); + CommonList commonList = new CommonList(); + extractPagingInfo(commonList, wrapDoc); + List resultsFields = getListItemsArray(); + int nFields = resultsFields.size()+2; + String fields[] = new String[nFields]; + fields[0] = "csid"; + fields[1] = "uri"; + for(int i=2;i iter = wrapDoc.getWrappedObject().iterator(); + HashMap item = new HashMap(); + while(iter.hasNext()){ + DocumentModel docModel = iter.next(); + String id = NuxeoUtils.getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString()); + item.put(fields[0], id); + String uri = getServiceContextPath() + id; + item.put(fields[1], uri); + for (ListResultField field : resultsFields ){ + String schema = field.getSchema(); + if(schema==null || schema.trim().isEmpty()) + schema = commonSchema; + String value = + getXPathStringValue(docModel, schema, field.getXpath()); + if(value!=null && !value.trim().isEmpty()) { + item.put(field.getElement(), value); + } + } + commonList.addItem(item); + item.clear(); + } + + return commonList; } @Override diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/ObjectFactory.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/ObjectFactory.java new file mode 100644 index 000000000..ddbb49700 --- /dev/null +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/ObjectFactory.java @@ -0,0 +1,53 @@ +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + + * http://www.collectionspace.org + * http://wiki.collectionspace.org + + * Copyright 2009 University of California at Berkeley + + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + + * You may obtain a copy of the ECL 2.0 License at + + * https://source.collectionspace.org/collection-space/LICENSE.txt + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.collectionspace.services.nuxeo.client.java; + +import javax.xml.bind.annotation.XmlRegistry; + +/** + * ObjectFactory for CommonList + */ +@XmlRegistry +public class ObjectFactory { + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.collectionspace.services.jaxb + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link tCommonList } + * + */ + public CommonList createCommonList() { + try { + //-System.out.println("CL_ObjectFactory:createAbstractCommonList"); + return new CommonList(); + } catch(Exception e) { + return null; + } + } + +} diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/package-info.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/package-info.java new file mode 100644 index 000000000..272613476 --- /dev/null +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/package-info.java @@ -0,0 +1,3 @@ +// We make the CommonList act like an AbstractCommonList, by setting its namespace +@javax.xml.bind.annotation.XmlSchema(namespace = "http://collectionspace.org/services/jaxb") +package org.collectionspace.services.nuxeo.client.java; diff --git a/services/common/src/main/resources/service.xsd b/services/common/src/main/resources/service.xsd index ab1d0231e..e7fbbb1d3 100644 --- a/services/common/src/main/resources/service.xsd +++ b/services/common/src/main/resources/service.xsd @@ -260,6 +260,8 @@ + + diff --git a/services/jaxb/src/main/resources/AbstractCommonList.xsd b/services/jaxb/src/main/resources/AbstractCommonList.xsd index 790271ae6..59e16d773 100644 --- a/services/jaxb/src/main/resources/AbstractCommonList.xsd +++ b/services/jaxb/src/main/resources/AbstractCommonList.xsd @@ -1,28 +1,26 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/services/jaxb/src/main/resources/blobs_common.xsd b/services/jaxb/src/main/resources/blobs_common.xsd index 74f56be2e..e9ea8e33e 100644 --- a/services/jaxb/src/main/resources/blobs_common.xsd +++ b/services/jaxb/src/main/resources/blobs_common.xsd @@ -43,38 +43,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/services/loanin/client/src/main/java/org/collectionspace/services/client/LoaninClient.java b/services/loanin/client/src/main/java/org/collectionspace/services/client/LoaninClient.java index b4c8d033a..428d9a14f 100644 --- a/services/loanin/client/src/main/java/org/collectionspace/services/client/LoaninClient.java +++ b/services/loanin/client/src/main/java/org/collectionspace/services/client/LoaninClient.java @@ -21,7 +21,7 @@ import javax.ws.rs.core.Response; import org.collectionspace.services.common.authorityref.AuthorityRefList; //import org.collectionspace.services.common.context.ServiceContext; -import org.collectionspace.services.loanin.LoansinCommonList; +import org.collectionspace.services.jaxb.AbstractCommonList; import org.jboss.resteasy.client.ProxyFactory; import org.jboss.resteasy.plugins.providers.RegisterBuiltin; @@ -97,7 +97,7 @@ public class LoaninClient extends AbstractServiceClientImpl { * @return * @see org.collectionspace.services.client.LoaninProxy#getLoanin() */ - public ClientResponse readList() { + public ClientResponse readList() { return loaninProxy.readList(); } diff --git a/services/loanin/client/src/main/java/org/collectionspace/services/client/LoaninProxy.java b/services/loanin/client/src/main/java/org/collectionspace/services/client/LoaninProxy.java index 7f6647e05..d3dd1f885 100644 --- a/services/loanin/client/src/main/java/org/collectionspace/services/client/LoaninProxy.java +++ b/services/loanin/client/src/main/java/org/collectionspace/services/client/LoaninProxy.java @@ -11,7 +11,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Response; import org.collectionspace.services.common.authorityref.AuthorityRefList; -import org.collectionspace.services.loanin.LoansinCommonList; +import org.collectionspace.services.jaxb.AbstractCommonList; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; @@ -46,7 +46,7 @@ public interface LoaninProxy extends CollectionSpaceProxy { // List @GET @Produces({"application/xml"}) - ClientResponse readList(); + ClientResponse readList(); // List Authority References @GET diff --git a/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java b/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java index 44da361ee..924617929 100644 --- a/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java +++ b/services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java @@ -33,7 +33,7 @@ import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.loanin.LenderGroup; import org.collectionspace.services.loanin.LenderGroupList; import org.collectionspace.services.loanin.LoansinCommon; -import org.collectionspace.services.loanin.LoansinCommonList; +//import org.collectionspace.services.loanin.LoansinCommonList; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; @@ -83,7 +83,7 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { @Override protected AbstractCommonList getAbstractCommonList( ClientResponse response) { - return response.getEntity(LoansinCommonList.class); + return response.getEntity(AbstractCommonList.class); } // --------------------------------------------------------------- @@ -380,9 +380,9 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { setupReadList(); // Submit the request to the service and store the response. - LoansinCommonList list = null; + AbstractCommonList list = null; LoaninClient client = new LoaninClient(); - ClientResponse res = client.readList(); + ClientResponse res = client.readList(); try { int statusCode = res.getStatus(); @@ -403,16 +403,12 @@ public class LoaninServiceTest extends AbstractServiceTestImpl { // Optionally output additional data about list members for debugging. boolean iterateThroughList = false; if (iterateThroughList && logger.isDebugEnabled()){ - List items = - list.getLoaninListItem(); + List items = + list.getListItem(); int i = 0; - for(LoansinCommonList.LoaninListItem item : items){ - logger.debug(testName + ": list-item[" + i + "] csid=" + - item.getCsid()); - logger.debug(testName + ": list-item[" + i + "] loanInNumber=" + - item.getLoanInNumber()); - logger.debug(testName + ": list-item[" + i + "] URI=" + - item.getUri()); + for(AbstractCommonList.ListItem item : items){ + logger.debug(testName + ": list-item[" + i + "] " + + item.toString()); i++; } } diff --git a/services/loanin/jaxb/src/main/resources/loansin-common.xsd b/services/loanin/jaxb/src/main/resources/loansin-common.xsd index a5b742ab5..021d22ffc 100644 --- a/services/loanin/jaxb/src/main/resources/loansin-common.xsd +++ b/services/loanin/jaxb/src/main/resources/loansin-common.xsd @@ -71,34 +71,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/services/loanin/service/src/main/java/org/collectionspace/services/loanin/LoaninResource.java b/services/loanin/service/src/main/java/org/collectionspace/services/loanin/LoaninResource.java index 29b1b969c..590539012 100644 --- a/services/loanin/service/src/main/java/org/collectionspace/services/loanin/LoaninResource.java +++ b/services/loanin/service/src/main/java/org/collectionspace/services/loanin/LoaninResource.java @@ -40,6 +40,7 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; +import javax.xml.parsers.ParserConfigurationException; import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl; import org.collectionspace.services.common.ClientType; @@ -58,6 +59,8 @@ import org.collectionspace.services.common.query.IQueryManager; import org.collectionspace.services.common.query.QueryManager; import org.collectionspace.services.common.security.UnauthorizedException; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils; +import org.collectionspace.services.jaxb.AbstractCommonList; +import org.collectionspace.services.nuxeo.client.java.CommonList; import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler; import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; @@ -231,9 +234,9 @@ public class LoaninResource extends */ @GET @Produces("application/xml") - public LoansinCommonList getLoaninList(@Context UriInfo ui, + public AbstractCommonList getLoaninList(@Context UriInfo ui, @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords) { - LoansinCommonList result = null; + AbstractCommonList result = null; MultivaluedMap queryParams = ui.getQueryParameters(); if (keywords != null) { result = searchLoansin(queryParams, keywords); @@ -249,13 +252,13 @@ public class LoaninResource extends * * @return the loanin list */ - private LoansinCommonList getLoaninList(MultivaluedMap queryParams) { - LoansinCommonList loaninObjectList; + private CommonList getLoaninList(MultivaluedMap queryParams) { + CommonList loaninObjectList; try { ServiceContext ctx = createServiceContext(queryParams); DocumentHandler handler = createDocumentHandler(ctx); getRepositoryClient(ctx).getFiltered(ctx, handler); - loaninObjectList = (LoansinCommonList) handler.getCommonPartList(); + loaninObjectList = (CommonList) handler.getCommonPartList(); } catch (UnauthorizedException ue) { Response response = Response.status( Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build(); @@ -320,13 +323,14 @@ public class LoaninResource extends * @return the loanin list */ @Deprecated - public LoansinCommonList getLoaninList(List csidList) { - LoansinCommonList loaninObjectList = new LoansinCommonList(); + public CommonList getLoaninList(List csidList) { + CommonList loaninObjectList; try { + loaninObjectList = new CommonList(); ServiceContext ctx = createServiceContext(); DocumentHandler handler = createDocumentHandler(ctx); getRepositoryClient(ctx).get(ctx, csidList, handler); - loaninObjectList = (LoansinCommonList) handler.getCommonPartList(); + loaninObjectList = (CommonList) handler.getCommonPartList(); } catch (UnauthorizedException ue) { Response response = Response.status( Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build(); @@ -442,10 +446,10 @@ public class LoaninResource extends * * @return the loansin common list */ - private LoansinCommonList searchLoansin( + private CommonList searchLoansin( MultivaluedMap queryParams, String keywords) { - LoansinCommonList loansinObjectList; + CommonList loansinObjectList; try { ServiceContext ctx = createServiceContext(queryParams); DocumentHandler handler = createDocumentHandler(ctx); @@ -460,7 +464,7 @@ public class LoaninResource extends } } getRepositoryClient(ctx).getFiltered(ctx, handler); - loansinObjectList = (LoansinCommonList) handler.getCommonPartList(); + loansinObjectList = (CommonList) handler.getCommonPartList(); } catch (UnauthorizedException ue) { Response response = Response.status( Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build(); diff --git a/services/loanin/service/src/main/java/org/collectionspace/services/loanin/nuxeo/LoaninDocumentModelHandler.java b/services/loanin/service/src/main/java/org/collectionspace/services/loanin/nuxeo/LoaninDocumentModelHandler.java index 4867715d8..d3244a9aa 100644 --- a/services/loanin/service/src/main/java/org/collectionspace/services/loanin/nuxeo/LoaninDocumentModelHandler.java +++ b/services/loanin/service/src/main/java/org/collectionspace/services/loanin/nuxeo/LoaninDocumentModelHandler.java @@ -23,7 +23,6 @@ */ package org.collectionspace.services.loanin.nuxeo; -import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.loanin.LoansinCommon; import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; @@ -32,6 +31,6 @@ import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; * $LastChangedDate$ */ public class LoaninDocumentModelHandler - extends DocHandlerBase { + extends DocHandlerBase { } diff --git a/services/media/client/src/main/java/org/collectionspace/services/client/MediaClient.java b/services/media/client/src/main/java/org/collectionspace/services/client/MediaClient.java index 1c34bec20..be915210a 100644 --- a/services/media/client/src/main/java/org/collectionspace/services/client/MediaClient.java +++ b/services/media/client/src/main/java/org/collectionspace/services/client/MediaClient.java @@ -20,8 +20,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; import org.collectionspace.services.common.authorityref.AuthorityRefList; -//import org.collectionspace.services.common.context.ServiceContext; -import org.collectionspace.services.media.MediaCommonList; +import org.collectionspace.services.jaxb.AbstractCommonList; import org.jboss.resteasy.client.ProxyFactory; import org.jboss.resteasy.plugins.providers.RegisterBuiltin; @@ -97,7 +96,7 @@ public class MediaClient extends AbstractServiceClientImpl { * @return * @see org.collectionspace.services.client.MediaProxy#getMedia() */ - public ClientResponse readList() { + public ClientResponse readList() { return mediaProxy.readList(); } diff --git a/services/media/client/src/main/java/org/collectionspace/services/client/MediaProxy.java b/services/media/client/src/main/java/org/collectionspace/services/client/MediaProxy.java index 2422b764b..2c0291724 100644 --- a/services/media/client/src/main/java/org/collectionspace/services/client/MediaProxy.java +++ b/services/media/client/src/main/java/org/collectionspace/services/client/MediaProxy.java @@ -11,7 +11,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Response; import org.collectionspace.services.common.authorityref.AuthorityRefList; -import org.collectionspace.services.media.MediaCommonList; +import org.collectionspace.services.jaxb.AbstractCommonList; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; @@ -46,7 +46,7 @@ public interface MediaProxy extends CollectionSpaceProxy { // List @GET @Produces({"application/xml"}) - ClientResponse readList(); + ClientResponse readList(); // List Authority References @GET diff --git a/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceTest.java b/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceTest.java index 93dc38a14..e90092e6e 100644 --- a/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceTest.java +++ b/services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceTest.java @@ -30,7 +30,6 @@ import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.MediaClient; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.media.MediaCommon; -import org.collectionspace.services.media.MediaCommonList; import org.jboss.resteasy.client.ClientResponse; @@ -62,7 +61,7 @@ public class MediaServiceTest extends AbstractServiceTestImpl { @Override protected AbstractCommonList getAbstractCommonList(ClientResponse response) { - return response.getEntity(MediaCommonList.class); + return response.getEntity(AbstractCommonList.class); } @Override @@ -109,16 +108,16 @@ public class MediaServiceTest extends AbstractServiceTestImpl { logger.debug(testBanner(testName, CLASS_NAME)); setupReadList(); MediaClient client = new MediaClient(); - ClientResponse res = client.readList(); - MediaCommonList list = res.getEntity(); + ClientResponse res = client.readList(); + AbstractCommonList list = res.getEntity(); assertStatusCode(res, testName); if (logger.isDebugEnabled()) { - List items = list.getMediaListItem(); + List items = + list.getListItem(); int i = 0; - for (MediaCommonList.MediaListItem item : items) { - logger.debug(testName + ": list-item[" + i + "] csid=" + item.getCsid()); - logger.debug(testName + ": list-item[" + i + "] media.title=" + item.getTitle()); - logger.debug(testName + ": list-item[" + i + "] URI=" + item.getUri()); + for(AbstractCommonList.ListItem item : items){ + logger.debug(testName + ": list-item[" + i + "] " + + item.toString()); i++; } } diff --git a/services/media/jaxb/src/main/resources/media_common.xsd b/services/media/jaxb/src/main/resources/media_common.xsd index 2e581577d..7723e76cb 100644 --- a/services/media/jaxb/src/main/resources/media_common.xsd +++ b/services/media/jaxb/src/main/resources/media_common.xsd @@ -98,30 +98,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/services/media/service/src/main/java/org/collectionspace/services/media/MediaResource.java b/services/media/service/src/main/java/org/collectionspace/services/media/MediaResource.java index 97446a576..9cc3e6e06 100644 --- a/services/media/service/src/main/java/org/collectionspace/services/media/MediaResource.java +++ b/services/media/service/src/main/java/org/collectionspace/services/media/MediaResource.java @@ -32,9 +32,9 @@ import org.collectionspace.services.common.blob.BlobUtil; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.DocumentHandler; import org.collectionspace.services.blob.BlobsCommon; -import org.collectionspace.services.blob.BlobsCommonList; import org.collectionspace.services.blob.nuxeo.BlobDocumentModelHandler; import org.collectionspace.services.blob.BlobResource; +import org.collectionspace.services.nuxeo.client.java.CommonList; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; @@ -217,9 +217,9 @@ public class MediaResource extends ResourceBase { @GET @Path("{csid}/blob/derivatives") @Produces("application/xml") - public BlobsCommonList getDerivatives( + public CommonList getDerivatives( @PathParam("csid") String csid) { - BlobsCommonList result = null; + CommonList result = null; try { ensureCSID(csid, READ); diff --git a/services/media/service/src/main/java/org/collectionspace/services/media/nuxeo/MediaDocumentModelHandler.java b/services/media/service/src/main/java/org/collectionspace/services/media/nuxeo/MediaDocumentModelHandler.java index 7b10a27fa..c90614aab 100644 --- a/services/media/service/src/main/java/org/collectionspace/services/media/nuxeo/MediaDocumentModelHandler.java +++ b/services/media/service/src/main/java/org/collectionspace/services/media/nuxeo/MediaDocumentModelHandler.java @@ -40,7 +40,7 @@ import java.util.List; * The Class MediaDocumentModelHandler. */ public class MediaDocumentModelHandler - extends DocHandlerBase { + extends DocHandlerBase { //============================================================================== diff --git a/services/objectexit/client/src/main/java/org/collectionspace/services/client/ObjectExitClient.java b/services/objectexit/client/src/main/java/org/collectionspace/services/client/ObjectExitClient.java index 92d9da95a..8a21594d4 100644 --- a/services/objectexit/client/src/main/java/org/collectionspace/services/client/ObjectExitClient.java +++ b/services/objectexit/client/src/main/java/org/collectionspace/services/client/ObjectExitClient.java @@ -20,8 +20,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; import org.collectionspace.services.common.authorityref.AuthorityRefList; -//import org.collectionspace.services.common.context.ServiceContext; -import org.collectionspace.services.objectexit.ObjectexitCommonList; +import org.collectionspace.services.jaxb.AbstractCommonList; import org.jboss.resteasy.client.ProxyFactory; import org.jboss.resteasy.plugins.providers.RegisterBuiltin; @@ -97,7 +96,7 @@ public class ObjectExitClient extends AbstractServiceClientImpl { * @return * @see org.collectionspace.services.client.ObjectExitProxy#getObjectExit() */ - public ClientResponse readList() { + public ClientResponse readList() { return objectexitProxy.readList(); } diff --git a/services/objectexit/client/src/main/java/org/collectionspace/services/client/ObjectExitProxy.java b/services/objectexit/client/src/main/java/org/collectionspace/services/client/ObjectExitProxy.java index efb8d842f..485f02fa8 100644 --- a/services/objectexit/client/src/main/java/org/collectionspace/services/client/ObjectExitProxy.java +++ b/services/objectexit/client/src/main/java/org/collectionspace/services/client/ObjectExitProxy.java @@ -11,7 +11,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Response; import org.collectionspace.services.common.authorityref.AuthorityRefList; -import org.collectionspace.services.objectexit.ObjectexitCommonList; +import org.collectionspace.services.jaxb.AbstractCommonList; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; @@ -46,7 +46,7 @@ public interface ObjectExitProxy extends CollectionSpaceProxy { // List @GET @Produces({"application/xml"}) - ClientResponse readList(); + ClientResponse readList(); // List Authority References @GET diff --git a/services/objectexit/client/src/test/java/org/collectionspace/services/client/test/ObjectExitServiceTest.java b/services/objectexit/client/src/test/java/org/collectionspace/services/client/test/ObjectExitServiceTest.java index 0aa445ed1..c20aca5cc 100644 --- a/services/objectexit/client/src/test/java/org/collectionspace/services/client/test/ObjectExitServiceTest.java +++ b/services/objectexit/client/src/test/java/org/collectionspace/services/client/test/ObjectExitServiceTest.java @@ -30,7 +30,6 @@ import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.ObjectExitClient; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.objectexit.ObjectexitCommon; -import org.collectionspace.services.objectexit.ObjectexitCommonList; import org.jboss.resteasy.client.ClientResponse; @@ -62,7 +61,7 @@ public class ObjectExitServiceTest extends AbstractServiceTestImpl { @Override protected AbstractCommonList getAbstractCommonList(ClientResponse response) { - return response.getEntity(ObjectexitCommonList.class); + return response.getEntity(AbstractCommonList.class); } @Override @@ -109,16 +108,16 @@ public class ObjectExitServiceTest extends AbstractServiceTestImpl { logger.debug(testBanner(testName, CLASS_NAME)); setupReadList(); ObjectExitClient client = new ObjectExitClient(); - ClientResponse res = client.readList(); - ObjectexitCommonList list = res.getEntity(); + ClientResponse res = client.readList(); + AbstractCommonList list = res.getEntity(); assertStatusCode(res, testName); if (logger.isDebugEnabled()) { - List items = list.getObjectexitListItem(); + List items = + list.getListItem(); int i = 0; - for (ObjectexitCommonList.ObjectexitListItem item : items) { - logger.debug(testName + ": list-item[" + i + "] csid=" + item.getCsid()); - logger.debug(testName + ": list-item[" + i + "] objectExitNumber=" + item.getExitNumber()); - logger.debug(testName + ": list-item[" + i + "] URI=" + item.getUri()); + for(AbstractCommonList.ListItem item : items){ + logger.debug(testName + ": list-item[" + i + "] " + + item.toString()); i++; } } diff --git a/services/objectexit/jaxb/src/main/resources/objectexit_common.xsd b/services/objectexit/jaxb/src/main/resources/objectexit_common.xsd index d6e6f91a5..254e0ee8e 100644 --- a/services/objectexit/jaxb/src/main/resources/objectexit_common.xsd +++ b/services/objectexit/jaxb/src/main/resources/objectexit_common.xsd @@ -59,35 +59,5 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/nuxeo/ObjectExitDocumentModelHandler.java b/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/nuxeo/ObjectExitDocumentModelHandler.java index fded45254..11093d97a 100644 --- a/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/nuxeo/ObjectExitDocumentModelHandler.java +++ b/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/nuxeo/ObjectExitDocumentModelHandler.java @@ -25,9 +25,8 @@ package org.collectionspace.services.objectexit.nuxeo; import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; import org.collectionspace.services.objectexit.ObjectexitCommon; -import org.collectionspace.services.jaxb.AbstractCommonList; public class ObjectExitDocumentModelHandler - extends DocHandlerBase { + extends DocHandlerBase { }