From bb0099e917e2bf2e799596af5956c6b1171c02f3 Mon Sep 17 00:00:00 2001 From: Laramie Crocker Date: Mon, 6 Dec 2010 23:46:45 +0000 Subject: [PATCH] CSPACE-3175 applied objectexit refactoring to blob and media service. Also, refactored ObjectExitDocumentModelHandler, BlobDocumentModelHandler, and MediaDocumentModelHandler to use a new intermediary superclass, DocHandlerBase, which abstracts almost all the work of a DocumentModelHandler up and out of the service. --- .../services/blob/BlobResource.java | 20 --- .../services/blob/nuxeo/BlobConstants.java | 35 ----- .../blob/nuxeo/BlobDocumentModelHandler.java | 145 +++--------------- .../services/common/DocHandlerBase.java | 118 ++++++++++++++ .../services/common/ResourceBase.java | 3 + .../services/media/MediaResource.java | 16 -- .../services/media/nuxeo/MediaConstants.java | 35 ----- .../nuxeo/MediaDocumentModelHandler.java | 140 +++-------------- .../objectexit/ObjectExitResource.java | 20 --- .../objectexit/nuxeo/ObjectExitConstants.java | 35 ----- .../nuxeo/ObjectExitDocumentModelHandler.java | 135 +++------------- 11 files changed, 181 insertions(+), 521 deletions(-) delete mode 100644 services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobConstants.java create mode 100755 services/common/src/main/java/org/collectionspace/services/common/DocHandlerBase.java delete mode 100644 services/media/service/src/main/java/org/collectionspace/services/media/nuxeo/MediaConstants.java delete mode 100644 services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/nuxeo/ObjectExitConstants.java 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 4b56c1585..6eeb42e9a 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 @@ -43,8 +43,6 @@ public class BlobResource extends ResourceBase { return "blob"; }; - //FIXME retrieve client type from configuration - final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType(); @Override protected String getVersionString() { @@ -56,23 +54,5 @@ public class BlobResource extends ResourceBase { public Class getCommonPartClass() { return BlobCommon.class; } - - public Class getResourceClass() { - return this.getClass(); - } - - public BlobCommonList getBlobList(MultivaluedMap queryParams) { - return (BlobCommonList)getList(queryParams); - } - - @Deprecated - public BlobCommonList getBlobList(List csidList) { - return (BlobCommonList) getList(csidList); - } - - protected BlobCommonList search(MultivaluedMap queryParams,String keywords) { - return (BlobCommonList) super.search(queryParams, keywords); - } - } diff --git a/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobConstants.java b/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobConstants.java deleted file mode 100644 index afbe67b61..000000000 --- a/services/blob/service/src/main/java/org/collectionspace/services/blob/nuxeo/BlobConstants.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * 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.blob.nuxeo; - -/** - * BlobConstants specifies constants for the Loans Out service - * - */ -public class BlobConstants { - - public final static String NUXEO_DOCTYPE = "Blob"; - public final static String NUXEO_SCHEMA_NAME = "blob"; - public final static String NUXEO_DC_TITLE = "CollectionSpace-Blob"; -} 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 94b335e40..777955134 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 @@ -27,146 +27,43 @@ import java.util.Iterator; import java.util.List; import org.collectionspace.services.BlobJAXBSchema; -import org.collectionspace.services.common.document.DocumentWrapper; +import org.collectionspace.services.common.DocHandlerBase; import org.collectionspace.services.blob.BlobCommon; import org.collectionspace.services.blob.BlobCommonList; import org.collectionspace.services.blob.BlobCommonList.BlobListItem; import org.collectionspace.services.jaxb.AbstractCommonList; -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; -/** - * The Class BlobDocumentModelHandler. - */ public class BlobDocumentModelHandler - extends RemoteDocumentModelHandlerImpl { - - /** The logger. */ - private final Logger logger = LoggerFactory.getLogger(BlobDocumentModelHandler.class); - - /** The blob. */ - private BlobCommon blob; - - /** The blob list. */ - private BlobCommonList blobList; - - - /** - * Gets the common part. - * - * @return the common part - */ - @Override - public BlobCommon getCommonPart() { - return blob; - } - - /** - * Sets the common part. - * - * @param blob the new common part - */ - @Override - public void setCommonPart(BlobCommon blob) { - this.blob = blob; - } + extends DocHandlerBase { - /** - * Gets the common part list. - * - * @return the common part list - */ - @Override - public BlobCommonList getCommonPartList() { - return blobList; + public final String getNuxeoSchemaName(){ + return "blob"; } - /** - * Sets the common part list. - * - * @param blobList the new common part list - */ - @Override - public void setCommonPartList(BlobCommonList blobList) { - this.blobList = blobList; + public String getSummaryFields(AbstractCommonList commonList){ + return "name|mimeType|encoding|length|uri|csid"; } - /** - * Extract common part. - * - * @param wrapDoc the wrap doc - * @return the blob common - * @throws Exception the exception - */ - @Override - public BlobCommon extractCommonPart(DocumentWrapper wrapDoc) - throws Exception { - throw new UnsupportedOperationException(); + public AbstractCommonList createAbstractCommonListImpl(){ + return new BlobCommonList(); } - /** - * Fill common part. - * - * @param blobObject the blob object - * @param wrapDoc the wrap doc - * @throws Exception the exception - */ - @Override - public void fillCommonPart(BlobCommon blobObject, DocumentWrapper wrapDoc) throws Exception { - throw new UnsupportedOperationException(); - } - - /** - * Extract common part list. - * - * @param wrapDoc the wrap doc - * @return the blob common list - * @throws Exception the exception - */ - @Override - public BlobCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - BlobCommonList coList = extractPagingInfo(new BlobCommonList(), wrapDoc); - AbstractCommonList commonList = (AbstractCommonList) coList; - commonList.setFieldsReturned("name|mimeType|encoding|length|csid"); - - - List list = coList.getBlobListItem(); - Iterator iter = wrapDoc.getWrappedObject().iterator(); - while(iter.hasNext()){ - DocumentModel docModel = iter.next(); - BlobListItem item = new BlobListItem(); - - String label = getServiceContext().getCommonPartLabel(); - item.setEncoding((String) docModel.getProperty(label, BlobJAXBSchema.encoding)); - item.setMimeType((String) docModel.getProperty(label, BlobJAXBSchema.mimeType)); - String theData = (String) docModel.getProperty(label, BlobJAXBSchema.data); - item.setName((String) docModel.getProperty(label, BlobJAXBSchema.name)); - item.setLength((String) docModel.getProperty(label, BlobJAXBSchema.length)); - - - String id = NuxeoUtils.extractId(docModel.getPathAsString()); - item.setUri(getServiceContextPath() + id); - item.setCsid(id); - list.add(item); - } - - return coList; + public List createItemsList(AbstractCommonList commonList){ + List list = ((BlobCommonList)commonList).getBlobListItem(); + return list; } - /** - * Gets the q property. - * - * @param prop the prop - * @return the q property - */ - @Override - public String getQProperty(String prop) { - return BlobConstants.NUXEO_SCHEMA_NAME + ":" + prop; + public Object createItemForCommonList(DocumentModel docModel, String label, String id) throws Exception { + BlobListItem item = new BlobListItem(); + item.setEncoding((String) docModel.getProperty(label, BlobJAXBSchema.encoding)); + item.setMimeType((String) docModel.getProperty(label, BlobJAXBSchema.mimeType)); + //String theData = (String) docModel.getProperty(label, BlobJAXBSchema.data); + item.setName((String) docModel.getProperty(label, BlobJAXBSchema.name)); + item.setLength((String) docModel.getProperty(label, BlobJAXBSchema.length)); + item.setUri(getServiceContextPath() + id); + item.setCsid(id); + return item; } - } diff --git a/services/common/src/main/java/org/collectionspace/services/common/DocHandlerBase.java b/services/common/src/main/java/org/collectionspace/services/common/DocHandlerBase.java new file mode 100755 index 000000000..e2afaefa7 --- /dev/null +++ b/services/common/src/main/java/org/collectionspace/services/common/DocHandlerBase.java @@ -0,0 +1,118 @@ +/** + * 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.common; + +import java.util.Iterator; +import java.util.List; + +import org.collectionspace.services.common.document.DocumentWrapper; +import org.collectionspace.services.jaxb.AbstractCommonList; +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; + +/** + * User: laramie + * $LastChangedRevision: $ + * $LastChangedDate: $ + */ +public abstract class DocHandlerBase + extends RemoteDocumentModelHandlerImpl { + + /** The logger. */ + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private AbstractCommonList commonList; + + @Override + public TL getCommonPartList() { + return (TL)commonList; + } + + public void setCommonPartList(AbstractCommonList aCommonList) { + this.commonList = aCommonList; + } + + private T commonPart; + + @Override + public T getCommonPart() { + return (T)commonPart; + } + + public void setCommonPart(T commonPart) { + this.commonPart = commonPart; + } + + public abstract String getNuxeoSchemaName(); + + public abstract String getSummaryFields(AbstractCommonList commonList); + + public abstract AbstractCommonList createAbstractCommonListImpl(); + + public abstract List createItemsList(AbstractCommonList commonList ); + + /** DocHandlerBase calls this method with the CSID as id */ + public abstract Object createItemForCommonList(DocumentModel docModel, String label, String id) throws Exception; + + @Override + public T extractCommonPart(DocumentWrapper wrapDoc) throws Exception { + throw new UnsupportedOperationException(); + } + + public void fillCommonPart(T objectexitObject, DocumentWrapper wrapDoc) throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public TL extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { + String label = getServiceContext().getCommonPartLabel(); + + AbstractCommonList commonList = createAbstractCommonListImpl(); + //ObjectexitCommonList oeList = (ObjectexitCommonList)extractPagingInfo(commonList, wrapDoc); + extractPagingInfo(((TL)commonList), wrapDoc); + commonList.setFieldsReturned(getSummaryFields(commonList)); + List list = createItemsList(commonList); + Iterator iter = wrapDoc.getWrappedObject().iterator(); + while(iter.hasNext()){ + DocumentModel docModel = iter.next(); + String id = NuxeoUtils.extractId(docModel.getPathAsString()); + Object item = createItemForCommonList(docModel, label, id); + list.add(item); + } + return (TL)commonList; + } + + @Override + public String getQProperty(String prop) { + return getNuxeoSchemaName() + ":" + prop; + } + + + +} + diff --git a/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java b/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java index 6193df815..7bea31e78 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java @@ -36,6 +36,9 @@ extends AbstractMultiPartCollectionSpaceResourceImpl { public static final String DELETE = "delete"; public static final String LIST = "list"; + //FIXME retrieve client type from configuration + final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType(); + public void ensureCSID(String csid, String crudType) throws WebApplicationException { if (logger.isDebugEnabled()) { logger.debug(crudType+" for "+getClass().getName()+" with csid=" + csid); 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 408af9628..f392b4888 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 @@ -57,22 +57,6 @@ public class MediaResource extends ResourceBase { return MediaCommon.class; } - public Class getResourceClass() { - return this.getClass(); - } - - public MediaCommonList getMediaList(MultivaluedMap queryParams) { - return (MediaCommonList)getList(queryParams); - } - - @Deprecated - public MediaCommonList getMediaList(List csidList) { - return (MediaCommonList) getList(csidList); - } - - protected MediaCommonList search(MultivaluedMap queryParams,String keywords) { - return (MediaCommonList) super.search(queryParams, keywords); - } } diff --git a/services/media/service/src/main/java/org/collectionspace/services/media/nuxeo/MediaConstants.java b/services/media/service/src/main/java/org/collectionspace/services/media/nuxeo/MediaConstants.java deleted file mode 100644 index 41f18d8bc..000000000 --- a/services/media/service/src/main/java/org/collectionspace/services/media/nuxeo/MediaConstants.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * 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.media.nuxeo; - -/** - * MediaConstants specifies constants for the Loans Out service - * - */ -public class MediaConstants { - - public final static String NUXEO_DOCTYPE = "Media"; - public final static String NUXEO_SCHEMA_NAME = "media"; - public final static String NUXEO_DC_TITLE = "CollectionSpace-Media"; -} 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 e089455e6..3f3edeb81 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 @@ -23,148 +23,48 @@ */ package org.collectionspace.services.media.nuxeo; -import java.util.Iterator; import java.util.List; import org.collectionspace.services.MediaJAXBSchema; -import org.collectionspace.services.common.document.DocumentWrapper; +import org.collectionspace.services.common.DocHandlerBase; import org.collectionspace.services.media.MediaCommon; import org.collectionspace.services.media.MediaCommonList; import org.collectionspace.services.media.MediaCommonList.MediaListItem; import org.collectionspace.services.jaxb.AbstractCommonList; -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; /** * The Class MediaDocumentModelHandler. */ public class MediaDocumentModelHandler - extends RemoteDocumentModelHandlerImpl { + extends DocHandlerBase { - /** The logger. */ - private final Logger logger = LoggerFactory.getLogger(MediaDocumentModelHandler.class); - - /** The media. */ - private MediaCommon media; - - /** The media list. */ - private MediaCommonList mediaList; - - - /** - * Gets the common part. - * - * @return the common part - */ - @Override - public MediaCommon getCommonPart() { - return media; - } - - /** - * Sets the common part. - * - * @param media the new common part - */ - @Override - public void setCommonPart(MediaCommon media) { - this.media = media; - } - - /** - * Gets the common part list. - * - * @return the common part list - */ - @Override - public MediaCommonList getCommonPartList() { - return mediaList; + public final String getNuxeoSchemaName(){ + return "media"; } - /** - * Sets the common part list. - * - * @param mediaList the new common part list - */ - @Override - public void setCommonPartList(MediaCommonList mediaList) { - this.mediaList = mediaList; + public String getSummaryFields(AbstractCommonList commonList){ + return "title|source|filename|identificationNumber|uri|csid"; } - /** - * Extract common part. - * - * @param wrapDoc the wrap doc - * @return the media common - * @throws Exception the exception - */ - @Override - public MediaCommon extractCommonPart(DocumentWrapper wrapDoc) - throws Exception { - throw new UnsupportedOperationException(); + public AbstractCommonList createAbstractCommonListImpl(){ + return new MediaCommonList(); } - /** - * Fill common part. - * - * @param mediaObject the media object - * @param wrapDoc the wrap doc - * @throws Exception the exception - */ - @Override - public void fillCommonPart(MediaCommon mediaObject, DocumentWrapper wrapDoc) throws Exception { - throw new UnsupportedOperationException(); - } - - /** - * Extract common part list. - * - * @param wrapDoc the wrap doc - * @return the media common list - * @throws Exception the exception - */ - @Override - public MediaCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - MediaCommonList coList = extractPagingInfo(new MediaCommonList(), wrapDoc); - AbstractCommonList commonList = (AbstractCommonList) coList; - //CSPACE-3209 don't use all fields. commonList.setFieldsReturned("currentOwner|depositor|exitDate|exitMethod|exitNote|exitNumber|exitReason|packingNote|uri|csid"); - commonList.setFieldsReturned("exitNumber|currentOwner|uri|csid"); //CSPACE-3209 now do this - List list = coList.getMediaListItem(); - Iterator iter = wrapDoc.getWrappedObject().iterator(); - while(iter.hasNext()){ - DocumentModel docModel = iter.next(); - MediaListItem item = new MediaListItem(); - - String label = getServiceContext().getCommonPartLabel(); - - item.setTitle((String) docModel.getProperty(label, MediaJAXBSchema.title)); - item.setSource((String) docModel.getProperty(label, MediaJAXBSchema.source)); - item.setFilename((String) docModel.getProperty(label, MediaJAXBSchema.filename)); - item.setIdentificationNumber((String) docModel.getProperty(label, MediaJAXBSchema.identificationNumber)); - - String id = NuxeoUtils.extractId(docModel.getPathAsString()); - item.setUri(getServiceContextPath() + id); - item.setCsid(id); - list.add(item); - } - - return coList; + public List createItemsList(AbstractCommonList commonList){ + List list = ((MediaCommonList)commonList).getMediaListItem(); + return list; } - /** - * Gets the q property. - * - * @param prop the prop - * @return the q property - */ - @Override - public String getQProperty(String prop) { - return MediaConstants.NUXEO_SCHEMA_NAME + ":" + prop; + public Object createItemForCommonList(DocumentModel docModel, String label, String id) throws Exception { + MediaListItem item = new MediaListItem(); + item.setTitle((String) docModel.getProperty(label, MediaJAXBSchema.title)); + item.setSource((String) docModel.getProperty(label, MediaJAXBSchema.source)); + item.setFilename((String) docModel.getProperty(label, MediaJAXBSchema.filename)); + item.setIdentificationNumber((String) docModel.getProperty(label, MediaJAXBSchema.identificationNumber)); + item.setUri(getServiceContextPath() + id); + item.setCsid(id); + return item; } - } diff --git a/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/ObjectExitResource.java b/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/ObjectExitResource.java index e80196442..0b5d8a1ba 100644 --- a/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/ObjectExitResource.java +++ b/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/ObjectExitResource.java @@ -54,25 +54,5 @@ public class ObjectExitResource extends ResourceBase { public Class getCommonPartClass() { return ObjectexitCommon.class; } - /* - public Class getResourceClass() { - return this.getClass(); - } - - public ObjectexitCommonList getObjectexitList(MultivaluedMap queryParams) { - return (ObjectexitCommonList)getList(queryParams); - } - - @Deprecated - public ObjectexitCommonList getObjectexitList(List csidList) { - return (ObjectexitCommonList) getList(csidList); - } - - protected ObjectexitCommonList search(MultivaluedMap queryParams,String keywords) { - return (ObjectexitCommonList) super.search(queryParams, keywords); - } - */ - - } diff --git a/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/nuxeo/ObjectExitConstants.java b/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/nuxeo/ObjectExitConstants.java deleted file mode 100644 index 2ddc216dd..000000000 --- a/services/objectexit/service/src/main/java/org/collectionspace/services/objectexit/nuxeo/ObjectExitConstants.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * 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.objectexit.nuxeo; - -/** - * ObjectExitConstants specifies constants for the Loans Out service - * - */ -public class ObjectExitConstants { - - public final static String NUXEO_DOCTYPE = "ObjectExit"; - public final static String NUXEO_SCHEMA_NAME = "objectexit"; - public final static String NUXEO_DC_TITLE = "CollectionSpace-ObjectExit"; -} 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 d63987af9..f4185d262 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 @@ -23,145 +23,48 @@ */ package org.collectionspace.services.objectexit.nuxeo; -import java.util.Iterator; import java.util.List; import org.collectionspace.services.ObjectexitJAXBSchema; -import org.collectionspace.services.common.document.DocumentWrapper; +import org.collectionspace.services.common.DocHandlerBase; import org.collectionspace.services.objectexit.ObjectexitCommon; import org.collectionspace.services.objectexit.ObjectexitCommonList; import org.collectionspace.services.objectexit.ObjectexitCommonList.ObjectexitListItem; import org.collectionspace.services.jaxb.AbstractCommonList; -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; /** * The Class ObjectExitDocumentModelHandler. */ public class ObjectExitDocumentModelHandler - extends RemoteDocumentModelHandlerImpl { + extends DocHandlerBase { - /** The logger. */ - private final Logger logger = LoggerFactory.getLogger(ObjectExitDocumentModelHandler.class); - - /** The objectexit. */ - private ObjectexitCommon objectexit; - - /** The objectexit list. */ - private ObjectexitCommonList objectexitList; - - - /** - * Gets the common part. - * - * @return the common part - */ - @Override - public ObjectexitCommon getCommonPart() { - return objectexit; + public final String getNuxeoSchemaName(){ + return "objectexit"; } - /** - * Sets the common part. - * - * @param objectexit the new common part - */ @Override - public void setCommonPart(ObjectexitCommon objectexit) { - this.objectexit = objectexit; + public String getSummaryFields(AbstractCommonList commonList){ + return "exitNumber|currentOwner|uri|csid"; } - /** - * Gets the common part list. - * - * @return the common part list - */ - @Override - public ObjectexitCommonList getCommonPartList() { - return objectexitList; + public AbstractCommonList createAbstractCommonListImpl(){ + return new ObjectexitCommonList(); } - /** - * Sets the common part list. - * - * @param objectexitList the new common part list - */ - @Override - public void setCommonPartList(ObjectexitCommonList objectexitList) { - this.objectexitList = objectexitList; + public List createItemsList(AbstractCommonList commonList){ + //actually means getObjectexitListItems(), plural -- it's a list, but element is named singular, so JAXB generates like so. + List list = ((ObjectexitCommonList)commonList).getObjectexitListItem(); //List list = oeList.getObjectexitListItem(); + return list; } - /** - * Extract common part. - * - * @param wrapDoc the wrap doc - * @return the objectexit common - * @throws Exception the exception - */ - @Override - public ObjectexitCommon extractCommonPart(DocumentWrapper wrapDoc) - throws Exception { - throw new UnsupportedOperationException(); - } - - /** - * Fill common part. - * - * @param objectexitObject the objectexit object - * @param wrapDoc the wrap doc - * @throws Exception the exception - */ - @Override - public void fillCommonPart(ObjectexitCommon objectexitObject, DocumentWrapper wrapDoc) throws Exception { - throw new UnsupportedOperationException(); - } - - /** - * Extract common part list. - * - * @param wrapDoc the wrap doc - * @return the objectexit common list - * @throws Exception the exception - */ - @Override - public ObjectexitCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { - ObjectexitCommonList coList = extractPagingInfo(new ObjectexitCommonList(), wrapDoc); - AbstractCommonList commonList = (AbstractCommonList) coList; - //CSPACE-3209 don't use all fields. commonList.setFieldsReturned("currentOwner|depositor|exitDate|exitMethod|exitNote|exitNumber|exitReason|packingNote|uri|csid"); - commonList.setFieldsReturned("exitNumber|currentOwner|uri|csid"); //CSPACE-3209 now do this - List list = coList.getObjectexitListItem(); - Iterator iter = wrapDoc.getWrappedObject().iterator(); - while(iter.hasNext()){ - DocumentModel docModel = iter.next(); - ObjectexitListItem ilistItem = new ObjectexitListItem(); - - String label = getServiceContext().getCommonPartLabel(); - ilistItem.setExitNumber((String) docModel.getProperty(label, ObjectexitJAXBSchema.OBJECT_EXIT_NUMBER)); - //CSPACE-3209 ilistItem.setExitDate((String) docModel.getProperty(label, ObjectexitJAXBSchema.OBJECT_EXIT_DATE)); - ilistItem.setCurrentOwner((String) docModel.getProperty(label, ObjectexitJAXBSchema.OBJECT_EXIT_CURRENT_OWNER)); //CSPACE-3209 - String id = NuxeoUtils.extractId(docModel.getPathAsString()); - ilistItem.setUri(getServiceContextPath() + id); - ilistItem.setCsid(id); - list.add(ilistItem); - } - - return coList; - } - - /** - * Gets the q property. - * - * @param prop the prop - * @return the q property - */ - @Override - public String getQProperty(String prop) { - return ObjectExitConstants.NUXEO_SCHEMA_NAME + ":" + prop; + public Object createItemForCommonList(DocumentModel docModel, String label, String id) throws Exception { + ObjectexitListItem item = new ObjectexitListItem(); + item.setExitNumber((String) docModel.getProperty(label, ObjectexitJAXBSchema.OBJECT_EXIT_NUMBER)); + item.setCurrentOwner((String) docModel.getProperty(label, ObjectexitJAXBSchema.OBJECT_EXIT_CURRENT_OWNER)); + item.setUri(getServiceContextPath() + id); + item.setCsid(id); + return item; } - } -- 2.47.3