]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
797805a0e30934645540c2c0e7ddd2da95b8107b
[tmp/jakarta-migration.git] /
1 package org.collectionspace.services.nuxeo.client.java;
2
3 import java.security.Principal;
4
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;
14
15 public class RepositoryInstanceWrapper implements RepositoryInstanceInterface {
16
17         private RepositoryInstance repoSession;
18         
19         public RepositoryInstanceWrapper(RepositoryInstance repoSession) {
20                 this.repoSession = repoSession;
21         }
22
23         @Override
24         public  RepositoryInstance getRepositoryInstance() {
25                 return repoSession;
26         }
27         
28         @Override
29     public String getSessionId() {
30         return repoSession.getSessionId();
31     }
32     
33     @Override
34     public void close() throws Exception {
35         repoSession.close();
36     }
37
38     /**
39      * Gets the root document of this repository.
40      *
41      * @return the root document. cannot be null
42      * @throws ClientException
43      * @throws SecurityException
44      */
45         @Override
46     public DocumentModel getRootDocument() throws ClientException {
47         return repoSession.getRootDocument();
48     }
49     
50     /**
51      * Returns the repository name against which this core session is bound.
52      *
53      * @return the repository name used currently used as an identifier
54      */
55         @Override
56     public String getRepositoryName() {
57                 return repoSession.getRepositoryName();
58         }
59     
60     /**
61      * Gets the principal that created the client session.
62      *
63      * @return the principal
64      */
65         @Override
66         public Principal getPrincipal() {
67                 return repoSession.getPrincipal();
68         }
69
70         @Override
71         public IterableQueryResult queryAndFetch(String query, String queryType,
72             Object... params) throws ClientException {
73                 return repoSession.queryAndFetch(query, queryType, params);
74         }
75
76         @Override
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);
80         }
81
82         @Override
83     public DocumentModelList query(String query, int max) throws ClientException {
84         return repoSession.query(query, max);
85     }
86     
87         @Override
88         public DocumentModelList query(String query) throws ClientException {
89                 return repoSession.query(query);
90         }
91
92     /**
93      * Gets a document model given its reference.
94      * <p>
95      * The default schemas are used to populate the returned document model.
96      * Default schemas are configured via the document type manager.
97      * <p>
98      * Any other data model not part of the default schemas will be lazily
99      * loaded as needed.
100      *
101      * @param docRef the document reference
102      * @return the document
103      * @throws ClientException
104      * @throws SecurityException
105      */
106     @NoRollbackOnException
107     @Override
108     public DocumentModel getDocument(DocumentRef docRef) throws ClientException {
109             return repoSession.getDocument(docRef);
110     }
111
112     @Override
113     public DocumentModel saveDocument(DocumentModel docModel) throws ClientException {
114         return repoSession.saveDocument(docModel);
115     }
116
117     @Override
118     public void save() throws ClientException {
119         repoSession.save();
120     }
121
122     /**
123      * Bulk document saving.
124      *
125      * @param docModels the document models that needs to be saved
126      * @throws ClientException
127      */
128     @Override
129     public void saveDocuments(DocumentModel[] docModels) throws ClientException {
130         repoSession.saveDocuments(docModels);
131     }
132
133     /**
134      * Removes this document and all its children, if any.
135      *
136      * @param docRef the reference to the document to remove
137      * @throws ClientException
138      */
139     @Override
140     public void removeDocument(DocumentRef docRef) throws ClientException {
141         repoSession.removeDocument(docRef);
142     }
143
144     /**
145      * Creates a document model using required information.
146      * <p>
147      * Used to fetch initial datamodels from the type definition.
148      * <p>
149      * DocumentModel creation notifies a
150      * {@link DocumentEventTypes.EMPTY_DOCUMENTMODEL_CREATED} so that core event
151      * listener can initialize its content with computed properties.
152      *
153      * @param parentPath
154      * @param id
155      * @param typeName
156      * @return the initial document model
157      * @throws ClientException
158      */
159     @Override
160     public DocumentModel createDocumentModel(String parentPath, String id,
161             String typeName) throws ClientException {
162         return repoSession.createDocumentModel(parentPath, id, typeName);
163     }
164     
165     /**
166      * Creates a document using given document model for initialization.
167      * <p>
168      * The model contains path of the new document, its type and optionally the
169      * initial data models of the document.
170      * <p>
171      *
172      * @param model the document model to use for initialization
173      * @return the created document
174      * @throws ClientException
175      */
176     @Override
177     public DocumentModel createDocument(DocumentModel model) throws ClientException {
178         return repoSession.createDocument(model);
179     }
180     
181     /**
182      * Gets the children of the given parent.
183      *
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
188      */
189     @NoRollbackOnException
190     @Override
191     public DocumentModelList getChildren(DocumentRef parent) throws ClientException {
192         return repoSession.getChildren(parent);
193     }
194
195     
196         
197 }