]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
95ccdf1ce3136deaf2b3b6f62a7cb16ac5e3c7a2
[tmp/jakarta-migration.git] /
1 package org.collectionspace.services.nuxeo.client.java;
2
3 import java.security.Principal;
4
5 import org.nuxeo.ecm.core.api.ClientException;
6 import org.nuxeo.ecm.core.api.DocumentModel;
7 import org.nuxeo.ecm.core.api.DocumentModelList;
8 import org.nuxeo.ecm.core.api.DocumentRef;
9 import org.nuxeo.ecm.core.api.Filter;
10 import org.nuxeo.ecm.core.api.IterableQueryResult;
11 import org.nuxeo.ecm.core.api.NoRollbackOnException;
12 import org.nuxeo.ecm.core.api.event.DocumentEventTypes;
13 import org.nuxeo.ecm.core.api.impl.LifeCycleFilter;
14 import org.nuxeo.ecm.core.api.CoreSession;
15
16 public class CoreSessionWrapper implements CoreSessionInterface {
17
18         private CoreSession repoSession;
19         
20         public CoreSessionWrapper(CoreSession repoSession) {
21                 this.repoSession = repoSession;
22         }
23
24         @Override
25         public  CoreSession getCoreSession() {
26                 return repoSession;
27         }
28         
29         @Override
30     public String getSessionId() {
31         return repoSession.getSessionId();
32     }
33     
34     @Override
35     public void close() throws Exception {
36         repoSession.close();
37     }
38
39     /**
40      * Gets the root document of this repository.
41      *
42      * @return the root document. cannot be null
43      * @throws ClientException
44      * @throws SecurityException
45      */
46         @Override
47     public DocumentModel getRootDocument() throws ClientException {
48         return repoSession.getRootDocument();
49     }
50     
51     /**
52      * Returns the repository name against which this core session is bound.
53      *
54      * @return the repository name used currently used as an identifier
55      */
56         @Override
57     public String getRepositoryName() {
58                 return repoSession.getRepositoryName();
59         }
60     
61     /**
62      * Gets the principal that created the client session.
63      *
64      * @return the principal
65      */
66         @Override
67         public Principal getPrincipal() {
68                 return repoSession.getPrincipal();
69         }
70
71         @Override
72         public IterableQueryResult queryAndFetch(String query, String queryType,
73             Object... params) throws ClientException {
74                 return repoSession.queryAndFetch(query, queryType, params);
75         }
76
77         @Override
78         public DocumentModelList query(String query, Filter filter, long limit,
79             long offset, boolean countTotal) throws ClientException {
80                 return repoSession.query(query, filter, limit, offset, countTotal);
81         }
82
83         @Override
84     public DocumentModelList query(String query, int max) throws ClientException {
85         return repoSession.query(query, max);
86     }
87     
88         @Override
89         public DocumentModelList query(String query) throws ClientException {
90                 return repoSession.query(query);
91         }
92         
93         @Override
94         public DocumentModelList query(String query, LifeCycleFilter workflowStateFilter) {
95                 return repoSession.query(query, workflowStateFilter);
96         }
97
98     /**
99      * Gets a document model given its reference.
100      * <p>
101      * The default schemas are used to populate the returned document model.
102      * Default schemas are configured via the document type manager.
103      * <p>
104      * Any other data model not part of the default schemas will be lazily
105      * loaded as needed.
106      *
107      * @param docRef the document reference
108      * @return the document
109      * @throws ClientException
110      * @throws SecurityException
111      */
112     @NoRollbackOnException
113     @Override
114     public DocumentModel getDocument(DocumentRef docRef) throws ClientException {
115             return repoSession.getDocument(docRef);
116     }
117
118     @Override
119     public DocumentModel saveDocument(DocumentModel docModel) throws ClientException {
120         return repoSession.saveDocument(docModel);
121     }
122
123     @Override
124     public void save() throws ClientException {
125         repoSession.save();
126     }
127
128     /**
129      * Bulk document saving.
130      *
131      * @param docModels the document models that needs to be saved
132      * @throws ClientException
133      */
134     @Override
135     public void saveDocuments(DocumentModel[] docModels) throws ClientException {
136         repoSession.saveDocuments(docModels);
137     }
138
139     /**
140      * Removes this document and all its children, if any.
141      *
142      * @param docRef the reference to the document to remove
143      * @throws ClientException
144      */
145     @Override
146     public void removeDocument(DocumentRef docRef) throws ClientException {
147         repoSession.removeDocument(docRef);
148     }
149
150     /**
151      * Creates a document model using required information.
152      * <p>
153      * Used to fetch initial datamodels from the type definition.
154      * <p>
155      * DocumentModel creation notifies a
156      * {@link DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATED} so that core event
157      * listener can initialize its content with computed properties.
158      *
159      * @param parentPath
160      * @param id
161      * @param typeName
162      * @return the initial document model
163      * @throws ClientException
164      */
165     @Override
166     public DocumentModel createDocumentModel(String parentPath, String id,
167             String typeName) throws ClientException {
168         return repoSession.createDocumentModel(parentPath, id, typeName);
169     }
170     
171     /**
172      * Creates a document using given document model for initialization.
173      * <p>
174      * The model contains path of the new document, its type and optionally the
175      * initial data models of the document.
176      * <p>
177      *
178      * @param model the document model to use for initialization
179      * @return the created document
180      * @throws ClientException
181      */
182     @Override
183     public DocumentModel createDocument(DocumentModel model) throws ClientException {
184         return repoSession.createDocument(model);
185     }
186     
187     /**
188      * Gets the children of the given parent.
189      *
190      * @param parent the parent reference
191      * @return the children if any, an empty list if no children or null if the
192      *         specified parent document is not a folder
193      * @throws ClientException
194      */
195     @NoRollbackOnException
196     @Override
197     public DocumentModelList getChildren(DocumentRef parent) throws ClientException {
198         return repoSession.getChildren(parent);
199     }
200
201     
202         
203 }