This project has retired. For details please refer to its Attic page.
ObjectStore xref

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.chemistry.opencmis.inmemory.storedobj.api;
20  
21  import java.util.List;
22  import java.util.Map;
23  
24  import org.apache.chemistry.opencmis.commons.data.Acl;
25  import org.apache.chemistry.opencmis.commons.data.ContentStream;
26  import org.apache.chemistry.opencmis.commons.data.PropertyData;
27  import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
28  import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
29  import org.apache.chemistry.opencmis.commons.enums.VersioningState;
30  
31  /**
32   * @author Jens
33   * 
34   *         This is the interface an implementation must provide to store any
35   *         kind of CMIS objects. The ObjectStore is the topmost container of all
36   *         CMIS object that get persisted. It is comparable to a file system,
37   *         one object store exists per repository id. The object store allows
38   *         access objects by an id. In addition a object can be retrieved by
39   *         path. Typically the object store owns the list of object ids and
40   *         maintains the path hierarchy.
41   */
42  public interface ObjectStore {
43  
44      /**
45       * Get the root folder of this object store
46       * 
47       * @return the root folder of this store
48       */
49      Folder getRootFolder();
50  
51      /**
52       * return an object by path.
53       * 
54       * @param path
55       *            the path to the object
56       * @return the stored object with this path
57       */
58      StoredObject getObjectByPath(String path, String user);
59  
60      /**
61       * get an object by its id
62       * 
63       * @param folderId
64       *            the id of the object
65       * @return the object identified by this id
66       */
67      StoredObject getObjectById(String folderId);
68  
69      /**
70       * Deletes an object from the store. For a folders the folder must be empty.
71       * 
72       * @param objectId
73       * @param user 
74       * @param allVersions is TRUE all version of the document are deleted, otherwise just this one
75       */
76      void deleteObject(String objectId, Boolean allVersions, String user);
77         
78      /**
79       * Create a document as initial step. The document is created but still
80       * temporary It is not yet persisted and does not have an id yet. After this
81       * call additional actions can take place (like assigning properties and a
82       * type) before it is persisted.
83       * 
84       * @param name
85       *            name of the document
86       * @param propMap
87       * 			  map of properties   
88       * @param user
89       * 			  the user who creates the document
90       * @param folder
91       * 			  the parent folder 
92       * @param addACEs
93       * 			  aces that are added 
94       * @param removeACEs 
95       *            aces that are removed
96       * @return document object
97       */
98       Document createDocument(String name, Map<String, PropertyData<?>> propMap, String user, Folder folder,
99   			Acl addACEs, Acl removeACEs);
100 
101 
102     /**
103      * Create a folder as initial step. The folder is created but still
104      * temporary It is not yet persisted and does not have an id yet. After this
105      * call additional actions can take place (like assigning properties and a
106      * type) before it is persisted.
107      * 
108      * @param name
109      *            name of the folder
110      * @param propMap
111      * 			  map of properties   
112      * @param user
113      * 			  the user who creates the document
114      * @param folder
115      * 			  the parent folder 
116      * @param addACEs
117      * 			  aces that are added 
118      * @param removeACEs 
119      *            aces that are removed
120      * @return folder object
121      */
122     Folder createFolder(String name, Map<String, PropertyData<?>> propMap, String user, Folder folder,
123 			Acl addACEs, Acl removeACEs);
124 
125     /**
126      * Create a document that supports versions as initial step. The document is
127      * created but still temporary. It is not yet persisted and does not have an
128      * id yet. After this call additional actions can take place (like assigning
129      * properties and a type) before it is persisted.
130      * 
131      * @param name
132      *            name of the document
133      *             * @param propMap
134      * 			  map of properities   
135      * @param user
136      * 			  the user who creates the document
137      * @param folder
138      * 			  the parent folder 
139      * @param addACEs
140      * 			  aces that are added 
141      * @param removeACEs 
142      *            aces that are removed
143      * @return versioned document object
144      */
145     DocumentVersion createVersionedDocument(String name,
146 			Map<String, PropertyData<?>> propMap, String user, Folder folder,
147 			Acl addACEs, Acl removeACEs, ContentStream contentStream, VersioningState versioningState);
148 
149     /**
150      * Clear repository and remove all data.
151      */
152     void clear();
153     
154     /**
155      * For statistics: return the number of objects contained in the system
156      * @return
157      *      number of stored objects
158      */
159     long getObjectCount();
160     
161     /**
162      * Create a relationship. The relationship is
163      * created but still temporary. It is not yet persisted and does not have an
164      * id yet. After this call additional actions can take place (like assigning
165      * properties and a type) before it is persisted.
166      * 
167      * @param sourceObject
168      *            source of the relationship
169      * @param targetObject
170      *            target of the relationship
171      * @param propMap
172      * 			  map of properities   
173      * @param user
174      * 			  the user who creates the document
175      * @param folder
176      * 			  the parent folder 
177      * @param addACEs
178      * 			  aces that are added 
179      * @param removeACEs 
180      *            aces that are removed
181      * @return versioned document object
182      */
183     StoredObject createRelationship(StoredObject sourceObject, StoredObject targetObject, 
184     		Map<String, PropertyData<?>> propMap,
185 			String user, Acl addACEs, Acl removeACEs);
186     
187     /**
188      * Return a list of all documents that are checked out in the repository.
189      * 
190      * @param orderBy
191      *            orderBy specification according to CMIS spec.
192      * @param user
193      * 			user id of user calling
194      * @param includeRelationships
195      * 			if true include all relationships in the response
196      * @return list of checked out documents in the repository
197      */
198     List<StoredObject> getCheckedOutDocuments(String orderBy, String user, IncludeRelationships includeRelationships);
199     
200     /**
201      * Apply a ACLs by relative adding and removing a list of ACEs to/from an object
202      * 
203      * @param so
204      *      object where ACLs are applied
205      * @param addAces
206      *      list of ACEs to be added
207      * @param removeAces
208      *      list of ACEs to be removed
209      * @param aclPropagation
210      *      enum value how to propagate ACLs to child objects
211      * @return
212      *      new ACL of object
213      */
214     Acl applyAcl(StoredObject so, Acl addAces, Acl removeAces, AclPropagation aclPropagation, String principalId);
215     
216     /**
217      * Apply a ACLs by setting a new list of ACEs to an object
218      * 
219      * @param so
220      *      object where ACLs are applied
221      * @param aces
222      *      list of ACEs to be applied
223      * @param aclPropagation
224      *      enum value how to propagate ACLs to child objects
225      * @return
226      *      new ACL of object
227      */
228     Acl applyAcl(StoredObject so, Acl aces, AclPropagation aclPropagation, String principalId);
229     
230     /**
231      * Check if this store contains any object with the given type id
232      * 
233      * @param typeId
234      *      id of type definition to check
235      * @return
236      *      true if at least one object in the store has the given type, false
237      *      if no objects exist having this type
238      */
239     boolean isTypeInUse(String typeId);
240 }