1 package org.collectionspace.services.nuxeo.client.java;
3 import java.security.Principal;
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;
16 public class CoreSessionWrapper implements CoreSessionInterface {
18 private CoreSession repoSession;
20 public CoreSessionWrapper(CoreSession repoSession) {
21 this.repoSession = repoSession;
25 public CoreSession getCoreSession() {
30 public String getSessionId() {
31 return repoSession.getSessionId();
35 public void close() throws Exception {
40 * Gets the root document of this repository.
42 * @return the root document. cannot be null
43 * @throws ClientException
44 * @throws SecurityException
47 public DocumentModel getRootDocument() throws ClientException {
48 return repoSession.getRootDocument();
52 * Returns the repository name against which this core session is bound.
54 * @return the repository name used currently used as an identifier
57 public String getRepositoryName() {
58 return repoSession.getRepositoryName();
62 * Gets the principal that created the client session.
64 * @return the principal
67 public Principal getPrincipal() {
68 return repoSession.getPrincipal();
72 public IterableQueryResult queryAndFetch(String query, String queryType,
73 Object... params) throws ClientException {
74 return repoSession.queryAndFetch(query, queryType, params);
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);
84 public DocumentModelList query(String query, int max) throws ClientException {
85 return repoSession.query(query, max);
89 public DocumentModelList query(String query) throws ClientException {
90 return repoSession.query(query);
94 public DocumentModelList query(String query, LifeCycleFilter workflowStateFilter) {
95 return repoSession.query(query, workflowStateFilter);
99 * Gets a document model given its reference.
101 * The default schemas are used to populate the returned document model.
102 * Default schemas are configured via the document type manager.
104 * Any other data model not part of the default schemas will be lazily
107 * @param docRef the document reference
108 * @return the document
109 * @throws ClientException
110 * @throws SecurityException
112 @NoRollbackOnException
114 public DocumentModel getDocument(DocumentRef docRef) throws ClientException {
115 return repoSession.getDocument(docRef);
119 public DocumentModel saveDocument(DocumentModel docModel) throws ClientException {
120 return repoSession.saveDocument(docModel);
124 public void save() throws ClientException {
129 * Bulk document saving.
131 * @param docModels the document models that needs to be saved
132 * @throws ClientException
135 public void saveDocuments(DocumentModel[] docModels) throws ClientException {
136 repoSession.saveDocuments(docModels);
140 * Removes this document and all its children, if any.
142 * @param docRef the reference to the document to remove
143 * @throws ClientException
146 public void removeDocument(DocumentRef docRef) throws ClientException {
147 repoSession.removeDocument(docRef);
151 * Creates a document model using required information.
153 * Used to fetch initial datamodels from the type definition.
155 * DocumentModel creation notifies a
156 * {@link DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATED} so that core event
157 * listener can initialize its content with computed properties.
162 * @return the initial document model
163 * @throws ClientException
166 public DocumentModel createDocumentModel(String parentPath, String id,
167 String typeName) throws ClientException {
168 return repoSession.createDocumentModel(parentPath, id, typeName);
172 * Creates a document using given document model for initialization.
174 * The model contains path of the new document, its type and optionally the
175 * initial data models of the document.
178 * @param model the document model to use for initialization
179 * @return the created document
180 * @throws ClientException
183 public DocumentModel createDocument(DocumentModel model) throws ClientException {
184 return repoSession.createDocument(model);
188 * Gets the children of the given parent.
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
195 @NoRollbackOnException
197 public DocumentModelList getChildren(DocumentRef parent) throws ClientException {
198 return repoSession.getChildren(parent);