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();
19 public void setTransactionRollbackOnly();
21 public boolean isTransactionMarkedForRollbackOnly();
24 * Gets the root document of this repository.
26 * @return the root document. cannot be null
27 * @throws ClientException
28 * @throws SecurityException
30 public DocumentModel getRootDocument() throws ClientException;
33 * Gets the current session id.
35 * If the client is not connected returns null.
37 * @return the session id or null if not connected
39 public String getSessionId();
45 public void close() throws Exception;
48 * Returns the repository name against which this core session is bound.
50 * @return the repository name used currently used as an identifier
52 public String getRepositoryName();
55 * Gets the principal that created the client session.
57 * @return the principal
59 public Principal getPrincipal();
61 public IterableQueryResult queryAndFetch(String query, String queryType,
62 Object... params) throws ClientException;
64 public DocumentModelList query(String query, Filter filter, long limit,
65 long offset, boolean countTotal) throws ClientException;
67 public DocumentModelList query(String query) throws ClientException;
70 * Executes the given NXQL query an returns the result.
72 * @param query the query to execute
73 * @param max number of document to retrieve
74 * @return the query result
75 * @throws ClientException
77 public DocumentModelList query(String query, int max) throws ClientException;
80 * Executes the given NXQL query and returns the result that matches the
83 * @param query the query to execute
84 * @param filter the filter to apply to result
85 * @return the query result
86 * @throws ClientException
88 public DocumentModelList query(String query, LifeCycleFilter workflowStateFilter);
91 * Gets a document model given its reference.
93 * The default schemas are used to populate the returned document model.
94 * Default schemas are configured via the document type manager.
96 * Any other data model not part of the default schemas will be lazily
99 * @param docRef the document reference
100 * @return the document
101 * @throws ClientException
102 * @throws SecurityException
104 public DocumentModel getDocument(DocumentRef docRef) throws ClientException;
106 public DocumentModel saveDocument(DocumentModel docModel) throws ClientException;
108 public void save() throws ClientException;
111 * Bulk document saving.
113 * @param docModels the document models that needs to be saved
114 * @throws ClientException
116 public void saveDocuments(DocumentModel[] docModels) throws ClientException;
119 * Removes this document and all its children, if any.
121 * @param docRef the reference to the document to remove
122 * @throws ClientException
124 public void removeDocument(DocumentRef docRef) throws ClientException;
127 * Creates a document model using required information.
129 * Used to fetch initial datamodels from the type definition.
131 * DocumentModel creation notifies a
132 * {@link DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATED} so that core event
133 * listener can initialize its content with computed properties.
138 * @return the initial document model
139 * @throws ClientException
141 public DocumentModel createDocumentModel(String parentPath, String id,
142 String typeName) throws ClientException;
145 * Creates a document using given document model for initialization.
147 * The model contains path of the new document, its type and optionally the
148 * initial data models of the document.
151 * @param model the document model to use for initialization
152 * @return the created document
153 * @throws ClientException
155 public DocumentModel createDocument(DocumentModel model) throws ClientException;
158 * Gets the children of the given parent.
160 * @param parent the parent reference
161 * @return the children if any, an empty list if no children or null if the
162 * specified parent document is not a folder
163 * @throws ClientException
165 public DocumentModelList getChildren(DocumentRef parent) throws ClientException;