]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
8a6a12d4be4898ff0d36e6eda215c3d98b2e4809
[tmp/jakarta-migration.git] /
1 /**\r
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
5 \r
6  *  http://www.collectionspace.org\r
7  *  http://wiki.collectionspace.org\r
8 \r
9  *  Copyright 2009 Regents of the University of California\r
10 \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
13 \r
14  *  You may obtain a copy of the ECL 2.0 License at\r
15 \r
16  *  https://source.collectionspace.org/collection-space/LICENSE.txt\r
17 \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
23  */\r
24 package org.collectionspace.services.note.nuxeo;\r
25 \r
26 import java.util.Iterator;\r
27 import java.util.List;\r
28 \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
35 \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
43 \r
44 /**\r
45  * The Class NoteDocumentModelHandler.\r
46  */\r
47 public class NoteDocumentModelHandler\r
48         extends RemoteSubItemDocumentModelHandlerImpl<NotesCommon, NotesCommonList> {\r
49 \r
50     /** The logger. */\r
51     private final Logger logger = LoggerFactory.getLogger(NoteDocumentModelHandler.class);\r
52     \r
53     /** The note. */\r
54     private NotesCommon note;\r
55     \r
56     /** The note list. */\r
57     private NotesCommonList noteList;\r
58 \r
59     /** The owner. */\r
60     private String owner;\r
61 \r
62     /**\r
63      * Gets the owner.\r
64      *\r
65      * @return the owner\r
66      */\r
67     public String getOwner() {\r
68         return owner;\r
69     }\r
70 \r
71     /**\r
72      * Sets the owner.\r
73      *\r
74      * @param owner the new owner\r
75      */\r
76     public void setInAuthority(String owner) {\r
77         this.owner = owner;\r
78     }\r
79 \r
80     /* (non-Javadoc)\r
81      * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#getCommonPart()\r
82      */\r
83     @Override\r
84     public NotesCommon getCommonPart() {\r
85         return note;\r
86     }\r
87 \r
88     /* (non-Javadoc)\r
89      * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPart(java.lang.Object)\r
90      */\r
91     @Override\r
92     public void setCommonPart(NotesCommon note) {\r
93         this.note = note;\r
94     }\r
95 \r
96     /* (non-Javadoc)\r
97      * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#getCommonPartList()\r
98      */\r
99     @Override\r
100     public NotesCommonList getCommonPartList() {\r
101         return noteList;\r
102     }\r
103 \r
104     /* (non-Javadoc)\r
105      * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)\r
106      */\r
107     @Override\r
108     public void setCommonPartList(NotesCommonList noteList) {\r
109         this.noteList = noteList;\r
110     }\r
111 \r
112     /* (non-Javadoc)\r
113      * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)\r
114      */\r
115     @Override\r
116     public NotesCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)\r
117             throws Exception {\r
118         throw new UnsupportedOperationException();\r
119     }\r
120 \r
121     /* (non-Javadoc)\r
122      * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#fillCommonPart(java.lang.Object, org.collectionspace.services.common.document.DocumentWrapper)\r
123      */\r
124     @Override\r
125     public void fillCommonPart(NotesCommon noteObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {\r
126         throw new UnsupportedOperationException();\r
127     }\r
128 \r
129     /* (non-Javadoc)\r
130      * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper)\r
131      */\r
132     @Override\r
133     public NotesCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {\r
134         NotesCommonList coList = extractPagingInfo(new NotesCommonList(), wrapDoc);\r
135         List<NotesCommonList.NoteListItem> list = coList.getNoteListItem();\r
136         Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();\r
137         while(iter.hasNext()){\r
138             DocumentModel docModel = iter.next();\r
139             NoteListItem clistItem = new NoteListItem();\r
140             clistItem.setContent((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),\r
141                     NoteJAXBSchema.CONTENT));\r
142             String id = NuxeoUtils.extractId(docModel.getPathAsString());\r
143             clistItem.setUri(getServiceContextPath() + id);\r
144             clistItem.setCsid(id);\r
145             list.add(clistItem);\r
146         }\r
147 \r
148         return coList;\r
149     }\r
150 \r
151     /* (non-Javadoc)\r
152      * @see org.collectionspace.services.common.document.AbstractMultipartDocumentHandlerImpl#getQProperty(java.lang.String)\r
153      */\r
154     @Override\r
155     public String getQProperty(String prop) {\r
156         return NoteConstants.NUXEO_SCHEMA_NAME + ":" + prop;\r
157     }\r
158 }\r
159 \r