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.event.DocumentEventTypes;
12 import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
14 public interface RepositoryInstanceInterface {
16 public RepositoryInstance getRepositoryInstance();
19 * Gets the root document of this repository.
21 * @return the root document. cannot be null
22 * @throws ClientException
23 * @throws SecurityException
25 public DocumentModel getRootDocument() throws ClientException;
28 * Gets the current session id.
30 * If the client is not connected returns null.
32 * @return the session id or null if not connected
34 public String getSessionId();
40 public void close() throws Exception;
43 * Returns the repository name against which this core session is bound.
45 * @return the repository name used currently used as an identifier
47 public String getRepositoryName();
50 * Gets the principal that created the client session.
52 * @return the principal
54 public Principal getPrincipal();
56 public IterableQueryResult queryAndFetch(String query, String queryType,
57 Object... params) throws ClientException;
59 public DocumentModelList query(String query, Filter filter, long limit,
60 long offset, boolean countTotal) throws ClientException;
62 public DocumentModelList query(String query) throws ClientException;
65 * Executes the given NXQL query an returns the result.
67 * @param query the query to execute
68 * @param max number of document to retrieve
69 * @return the query result
70 * @throws ClientException
72 public DocumentModelList query(String query, int max) throws ClientException;
75 * Gets a document model given its reference.
77 * The default schemas are used to populate the returned document model.
78 * Default schemas are configured via the document type manager.
80 * Any other data model not part of the default schemas will be lazily
83 * @param docRef the document reference
84 * @return the document
85 * @throws ClientException
86 * @throws SecurityException
88 public DocumentModel getDocument(DocumentRef docRef) throws ClientException;
90 public DocumentModel saveDocument(DocumentModel docModel) throws ClientException;
92 public void save() throws ClientException;
95 * Bulk document saving.
97 * @param docModels the document models that needs to be saved
98 * @throws ClientException
100 public void saveDocuments(DocumentModel[] docModels) throws ClientException;
103 * Removes this document and all its children, if any.
105 * @param docRef the reference to the document to remove
106 * @throws ClientException
108 public void removeDocument(DocumentRef docRef) throws ClientException;
111 * Creates a document model using required information.
113 * Used to fetch initial datamodels from the type definition.
115 * DocumentModel creation notifies a
116 * {@link DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATED} so that core event
117 * listener can initialize its content with computed properties.
122 * @return the initial document model
123 * @throws ClientException
125 public DocumentModel createDocumentModel(String parentPath, String id,
126 String typeName) throws ClientException;
129 * Creates a document using given document model for initialization.
131 * The model contains path of the new document, its type and optionally the
132 * initial data models of the document.
135 * @param model the document model to use for initialization
136 * @return the created document
137 * @throws ClientException
139 public DocumentModel createDocument(DocumentModel model) throws ClientException;
142 * Gets the children of the given parent.
144 * @param parent the parent reference
145 * @return the children if any, an empty list if no children or null if the
146 * specified parent document is not a folder
147 * @throws ClientException
149 public DocumentModelList getChildren(DocumentRef parent) throws ClientException;