2 * This document is a part of the source code and related artifacts
\r
3 * for CollectionSpace, an open source collections management system
\r
4 * for museums and related institutions:
\r
6 * http://www.collectionspace.org
\r
7 * http://wiki.collectionspace.org
\r
9 * Copyright 2009 Regents of the University of California
\r
11 * Licensed under the Educational Community License (ECL), Version 2.0.
\r
12 * You may not use this file except in compliance with this License.
\r
14 * You may obtain a copy of the ECL 2.0 License at
\r
16 * https://source.collectionspace.org/collection-space/LICENSE.txt
\r
18 * Unless required by applicable law or agreed to in writing, software
\r
19 * distributed under the License is distributed on an "AS IS" BASIS,
\r
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
21 * See the License for the specific language governing permissions and
\r
22 * limitations under the License.
\r
24 package org.collectionspace.services.note.nuxeo;
\r
26 import java.util.Iterator;
\r
27 import java.util.List;
\r
29 import org.collectionspace.services.note.NoteJAXBSchema;
\r
30 import org.collectionspace.services.common.document.DocumentHandler.Action;
\r
31 import org.collectionspace.services.common.document.DocumentWrapper;
\r
32 import org.collectionspace.services.note.NotesCommon;
\r
33 import org.collectionspace.services.note.NotesCommonList;
\r
34 import org.collectionspace.services.note.NotesCommonList.NoteListItem;
\r
36 import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
\r
37 import org.collectionspace.services.nuxeo.client.java.RemoteSubItemDocumentModelHandlerImpl;
\r
38 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
\r
39 import org.nuxeo.ecm.core.api.DocumentModel;
\r
40 import org.nuxeo.ecm.core.api.DocumentModelList;
\r
41 import org.slf4j.Logger;
\r
42 import org.slf4j.LoggerFactory;
\r
45 * The Class NoteDocumentModelHandler.
\r
47 public class NoteDocumentModelHandler
\r
48 extends RemoteSubItemDocumentModelHandlerImpl<NotesCommon, NotesCommonList> {
\r
51 private final Logger logger = LoggerFactory.getLogger(NoteDocumentModelHandler.class);
\r
54 private NotesCommon note;
\r
56 /** The note list. */
\r
57 private NotesCommonList noteList;
\r
60 private String owner;
\r
62 private final String commonSchemaName = "notes_common";
\r
64 public boolean schemaHasSubItem(String schema) {
\r
65 return commonSchemaName.equals(schema);
\r
74 public String getOwner() {
\r
81 * @param owner the new owner
\r
83 public void setInAuthority(String owner) {
\r
88 * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#getCommonPart()
\r
91 public NotesCommon getCommonPart() {
\r
96 * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPart(java.lang.Object)
\r
99 public void setCommonPart(NotesCommon note) {
\r
104 * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#getCommonPartList()
\r
107 public NotesCommonList getCommonPartList() {
\r
112 * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
\r
115 public void setCommonPartList(NotesCommonList noteList) {
\r
116 this.noteList = noteList;
\r
120 * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
\r
123 public NotesCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
\r
125 throw new UnsupportedOperationException();
\r
129 * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#fillCommonPart(java.lang.Object, org.collectionspace.services.common.document.DocumentWrapper)
\r
132 public void fillCommonPart(NotesCommon noteObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
\r
133 throw new UnsupportedOperationException();
\r
137 * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper)
\r
140 public NotesCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
\r
141 NotesCommonList coList = extractPagingInfo(new NotesCommonList(), wrapDoc);
\r
142 List<NotesCommonList.NoteListItem> list = coList.getNoteListItem();
\r
143 Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
\r
144 while(iter.hasNext()){
\r
145 DocumentModel docModel = iter.next();
\r
146 NoteListItem clistItem = new NoteListItem();
\r
147 clistItem.setContent((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
\r
148 NoteJAXBSchema.CONTENT));
\r
149 String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
\r
150 clistItem.setUri(getServiceContextPath() + id);
\r
151 clistItem.setCsid(id);
\r
152 list.add(clistItem);
\r
159 * @see org.collectionspace.services.common.document.AbstractMultipartDocumentHandlerImpl#getQProperty(java.lang.String)
\r
162 public String getQProperty(String prop) {
\r
163 return NoteConstants.NUXEO_SCHEMA_NAME + ":" + prop;
\r