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.repository.RepositoryInstance;
15 public class RepositoryInstanceWrapper implements RepositoryInstanceInterface {
17 private RepositoryInstance repoSession;
19 public RepositoryInstanceWrapper(RepositoryInstance repoSession) {
20 this.repoSession = repoSession;
24 public RepositoryInstance getRepositoryInstance() {
29 public String getSessionId() {
30 return repoSession.getSessionId();
34 public void close() throws Exception {
39 * Gets the root document of this repository.
41 * @return the root document. cannot be null
42 * @throws ClientException
43 * @throws SecurityException
46 public DocumentModel getRootDocument() throws ClientException {
47 return repoSession.getRootDocument();
51 * Returns the repository name against which this core session is bound.
53 * @return the repository name used currently used as an identifier
56 public String getRepositoryName() {
57 return repoSession.getRepositoryName();
61 * Gets the principal that created the client session.
63 * @return the principal
66 public Principal getPrincipal() {
67 return repoSession.getPrincipal();
71 public IterableQueryResult queryAndFetch(String query, String queryType,
72 Object... params) throws ClientException {
73 return repoSession.queryAndFetch(query, queryType, params);
77 public DocumentModelList query(String query, Filter filter, long limit,
78 long offset, boolean countTotal) throws ClientException {
79 return repoSession.query(query, filter, limit, offset, countTotal);
83 public DocumentModelList query(String query, int max) throws ClientException {
84 return repoSession.query(query, max);
88 public DocumentModelList query(String query) throws ClientException {
89 return repoSession.query(query);
93 * Gets a document model given its reference.
95 * The default schemas are used to populate the returned document model.
96 * Default schemas are configured via the document type manager.
98 * Any other data model not part of the default schemas will be lazily
101 * @param docRef the document reference
102 * @return the document
103 * @throws ClientException
104 * @throws SecurityException
106 @NoRollbackOnException
108 public DocumentModel getDocument(DocumentRef docRef) throws ClientException {
109 return repoSession.getDocument(docRef);
113 public DocumentModel saveDocument(DocumentModel docModel) throws ClientException {
114 return repoSession.saveDocument(docModel);
118 public void save() throws ClientException {
123 * Bulk document saving.
125 * @param docModels the document models that needs to be saved
126 * @throws ClientException
129 public void saveDocuments(DocumentModel[] docModels) throws ClientException {
130 repoSession.saveDocuments(docModels);
134 * Removes this document and all its children, if any.
136 * @param docRef the reference to the document to remove
137 * @throws ClientException
140 public void removeDocument(DocumentRef docRef) throws ClientException {
141 repoSession.removeDocument(docRef);
145 * Creates a document model using required information.
147 * Used to fetch initial datamodels from the type definition.
149 * DocumentModel creation notifies a
150 * {@link DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATED} so that core event
151 * listener can initialize its content with computed properties.
156 * @return the initial document model
157 * @throws ClientException
160 public DocumentModel createDocumentModel(String parentPath, String id,
161 String typeName) throws ClientException {
162 return repoSession.createDocumentModel(parentPath, id, typeName);
166 * Creates a document using given document model for initialization.
168 * The model contains path of the new document, its type and optionally the
169 * initial data models of the document.
172 * @param model the document model to use for initialization
173 * @return the created document
174 * @throws ClientException
177 public DocumentModel createDocument(DocumentModel model) throws ClientException {
178 return repoSession.createDocument(model);
182 * Gets the children of the given parent.
184 * @param parent the parent reference
185 * @return the children if any, an empty list if no children or null if the
186 * specified parent document is not a folder
187 * @throws ClientException
189 @NoRollbackOnException
191 public DocumentModelList getChildren(DocumentRef parent) throws ClientException {
192 return repoSession.getChildren(parent);