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.CoreSession;
7 import org.nuxeo.ecm.core.api.DocumentModel;
8 import org.nuxeo.ecm.core.api.DocumentModelList;
9 import org.nuxeo.ecm.core.api.DocumentRef;
10 import org.nuxeo.ecm.core.api.Filter;
11 import org.nuxeo.ecm.core.api.IterableQueryResult;
12 import org.nuxeo.ecm.core.api.event.DocumentEventTypes;
13 import org.nuxeo.ecm.core.api.impl.LifeCycleFilter;
15 public interface CoreSessionInterface {
17 public CoreSession getCoreSession();
20 * Gets the root document of this repository.
22 * @return the root document. cannot be null
23 * @throws ClientException
24 * @throws SecurityException
26 public DocumentModel getRootDocument() throws ClientException;
29 * Gets the current session id.
31 * If the client is not connected returns null.
33 * @return the session id or null if not connected
35 public String getSessionId();
41 public void close() throws Exception;
44 * Returns the repository name against which this core session is bound.
46 * @return the repository name used currently used as an identifier
48 public String getRepositoryName();
51 * Gets the principal that created the client session.
53 * @return the principal
55 public Principal getPrincipal();
57 public IterableQueryResult queryAndFetch(String query, String queryType,
58 Object... params) throws ClientException;
60 public DocumentModelList query(String query, Filter filter, long limit,
61 long offset, boolean countTotal) throws ClientException;
63 public DocumentModelList query(String query) throws ClientException;
66 * Executes the given NXQL query an returns the result.
68 * @param query the query to execute
69 * @param max number of document to retrieve
70 * @return the query result
71 * @throws ClientException
73 public DocumentModelList query(String query, int max) throws ClientException;
76 * Executes the given NXQL query and returns the result that matches the
79 * @param query the query to execute
80 * @param filter the filter to apply to result
81 * @return the query result
82 * @throws ClientException
84 public DocumentModelList query(String query, LifeCycleFilter workflowStateFilter);
87 * Gets a document model given its reference.
89 * The default schemas are used to populate the returned document model.
90 * Default schemas are configured via the document type manager.
92 * Any other data model not part of the default schemas will be lazily
95 * @param docRef the document reference
96 * @return the document
97 * @throws ClientException
98 * @throws SecurityException
100 public DocumentModel getDocument(DocumentRef docRef) throws ClientException;
102 public DocumentModel saveDocument(DocumentModel docModel) throws ClientException;
104 public void save() throws ClientException;
107 * Bulk document saving.
109 * @param docModels the document models that needs to be saved
110 * @throws ClientException
112 public void saveDocuments(DocumentModel[] docModels) throws ClientException;
115 * Removes this document and all its children, if any.
117 * @param docRef the reference to the document to remove
118 * @throws ClientException
120 public void removeDocument(DocumentRef docRef) throws ClientException;
123 * Creates a document model using required information.
125 * Used to fetch initial datamodels from the type definition.
127 * DocumentModel creation notifies a
128 * {@link DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATED} so that core event
129 * listener can initialize its content with computed properties.
134 * @return the initial document model
135 * @throws ClientException
137 public DocumentModel createDocumentModel(String parentPath, String id,
138 String typeName) throws ClientException;
141 * Creates a document using given document model for initialization.
143 * The model contains path of the new document, its type and optionally the
144 * initial data models of the document.
147 * @param model the document model to use for initialization
148 * @return the created document
149 * @throws ClientException
151 public DocumentModel createDocument(DocumentModel model) throws ClientException;
154 * Gets the children of the given parent.
156 * @param parent the parent reference
157 * @return the children if any, an empty list if no children or null if the
158 * specified parent document is not a folder
159 * @throws ClientException
161 public DocumentModelList getChildren(DocumentRef parent) throws ClientException;