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.data.RenditionData; 28 import org.apache.chemistry.opencmis.commons.enums.AclPropagation; 29 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships; 30 import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection; 31 import org.apache.chemistry.opencmis.commons.enums.VersioningState; 32 33 /** 34 * This is the interface an implementation must provide to store any kind of 35 * CMIS objects. The ObjectStore is the topmost container of all CMIS object 36 * that get persisted. It is comparable to a file system, one object store 37 * exists per repository id. The object store allows access objects by an id. In 38 * addition a object can be retrieved by path. Typically the object store owns 39 * the list of object ids and maintains the path hierarchy. 40 */ 41 public interface ObjectStore { 42 43 /** 44 * Class to represent a result of get children calls. 45 */ 46 public static class ChildrenResult { 47 private int noItems; 48 private List<Fileable> children; 49 50 /** 51 * Create new children results object. 52 * 53 * @param children 54 * list of children 55 * @param noItems 56 * number of items in result 57 */ 58 public ChildrenResult(List<Fileable> children, int noItems) { 59 this.children = children; 60 this.noItems = noItems; 61 } 62 63 /** 64 * Get number of items in this result. 65 * 66 * @return number of items 67 */ 68 public int getNoItems() { 69 return noItems; 70 } 71 72 /** 73 * Get the children objects. 74 * 75 * @return list of children 76 */ 77 public List<Fileable> getChildren() { 78 return children; 79 } 80 } 81 82 /** 83 * Get the root folder of this object store. 84 * 85 * @return the root folder of this store 86 */ 87 Folder getRootFolder(); 88 89 /** 90 * return an object by path. 91 * 92 * @param path 93 * the path to the object 94 * @param user 95 * user to check visibility 96 * @return the stored object with this path 97 */ 98 StoredObject getObjectByPath(String path, String user); 99 100 /** 101 * get an object by its id. 102 * 103 * @param folderId 104 * the id of the object 105 * @return the object identified by this id 106 */ 107 StoredObject getObjectById(String folderId); 108 109 /** 110 * Deletes an object from the store. For a folders the folder must be empty. 111 * 112 * @param objectId 113 * id of object to be deleted 114 * @param allVersions 115 * is TRUE all version of the document are deleted, otherwise 116 * just this one 117 * @param user 118 * user to check visibility 119 */ 120 void deleteObject(String objectId, Boolean allVersions, String user); 121 122 /** 123 * Create a document as initial step. The document is created but still 124 * temporary It is not yet persisted and does not have an id yet. After this 125 * call additional actions can take place (like assigning properties and a 126 * type) before it is persisted. 127 * 128 * @param propMap 129 * map of properties 130 * @param user 131 * the user who creates the document 132 * @param folder 133 * the parent folder 134 * @param contentStream 135 * the content of the document 136 * @param policies 137 * list of policies to apply 138 * @param addACEs 139 * aces that are added 140 * @param removeACEs 141 * aces that are removed 142 * @return document object 143 */ 144 Document createDocument(Map<String, PropertyData<?>> propMap, String user, Folder folder, 145 ContentStream contentStream, List<String> policies, Acl addACEs, Acl removeACEs); 146 147 /** 148 * Create a folder as initial step. The folder is created but still 149 * temporary. It is not yet persisted and does not have an id yet. After 150 * this call additional actions can take place (like assigning properties 151 * and a type) before it is persisted. 152 * 153 * @param name 154 * name of the folder 155 * @param propMap 156 * map of properties 157 * @param user 158 * the user who creates the document 159 * @param folder 160 * the parent folder 161 * @param policies 162 * list of policies to apply 163 * @param addACEs 164 * aces that are added 165 * @param removeACEs 166 * aces that are removed 167 * @return folder object 168 */ 169 Folder createFolder(String name, Map<String, PropertyData<?>> propMap, String user, Folder folder, 170 List<String> policies, Acl addACEs, Acl removeACEs); 171 172 /** 173 * Create a document that supports versions as initial step. The document is 174 * created but still temporary. It is not yet persisted and does not have an 175 * id yet. After this call additional actions can take place (like assigning 176 * properties and a type) before it is persisted. 177 * 178 * @param name 179 * name of the document * @param propMap map of properities 180 * @param user 181 * the user who creates the document 182 * @param folder 183 * the parent folder 184 * @param policies 185 * list of policies to apply 186 * @param addACEs 187 * aces that are added 188 * @param removeACEs 189 * aces that are removed 190 * @param contentStream 191 * content stream of the object to create 192 * @param versioningState 193 * version state of the object to be created in 194 * @return versioned document object 195 */ 196 DocumentVersion createVersionedDocument(String name, Map<String, PropertyData<?>> propMap, String user, 197 Folder folder, List<String> policies, Acl addACEs, Acl removeACEs, ContentStream contentStream, 198 VersioningState versioningState); 199 200 /** 201 * Create an item as initial step. The item is created but still temporary. 202 * It is not yet persisted and does not have an id yet. After this call 203 * additional actions can take place (like assigning properties and a type) 204 * before it is persisted. 205 * 206 * @param name 207 * name of the document 208 * @param propMap 209 * map of properties 210 * @param user 211 * the user who creates the document 212 * @param folder 213 * the parent folder 214 * @param policies 215 * list of policies to apply 216 * @param addACEs 217 * aces that are added 218 * @param removeACEs 219 * aces that are removed 220 * @return document object 221 */ 222 StoredObject createItem(String name, Map<String, PropertyData<?>> propMap, String user, Folder folder, 223 List<String> policies, Acl addACEs, Acl removeACEs); 224 225 /** 226 * Create a policy. The policy is created but still temporary. It is not yet 227 * persisted and does not have an id yet. After this call additional actions 228 * can take place (like assigning properties and a type) before it is 229 * persisted. 230 * 231 * @param name 232 * name of the document 233 * @param policyText 234 * policy text to apply to this policy 235 * @param propMap 236 * map of properties 237 * @param user 238 * the user who creates the document 239 * @param addACEs 240 * aces that are added 241 * @param removeACEs 242 * aces that are removed 243 * @return policy object 244 */ 245 StoredObject createPolicy(String name, String policyText, Map<String, PropertyData<?>> propMap, String user, 246 Acl addACEs, Acl removeACEs); 247 248 /** 249 * get all the children of this folder. To support paging an initial offset 250 * and a maximum number of children to retrieve can be passed. 251 * 252 * @param folder 253 * folder to get children from 254 * @param maxItems 255 * max. number of items to return 256 * @param skipCount 257 * initial offset where to start fetching 258 * @param user 259 * user to determine visible children 260 * @param usePwc 261 * if true return private working copy otherwise return latest 262 * version; 263 * 264 * @return list of children objects 265 */ 266 ChildrenResult getChildren(Folder folder, int maxItems, int skipCount, String user, boolean usePwc); 267 268 /** 269 * get all the children of this folder which are folders. To support paging 270 * an initial offset and a maximum number of children to retrieve can be 271 * passed. 272 * 273 * @param folder 274 * folder to get children from 275 * @param maxItems 276 * max. number of items to return 277 * @param skipCount 278 * initial offset where to start fetching 279 * @param user 280 * the user who performs the call 281 * @return list of children folders 282 */ 283 ChildrenResult getFolderChildren(Folder folder, int maxItems, int skipCount, String user); 284 285 /** 286 * Move an object to a different folder. 287 * 288 * @param so 289 * object to be moved 290 * @param oldParent 291 * old parent folder for the object 292 * @param newParent 293 * new parent folder for the object 294 * @param user 295 * user performing the operation 296 */ 297 void move(StoredObject so, Folder oldParent, Folder newParent, String user); 298 299 /** 300 * Rename an object. 301 * 302 * @param so 303 * object to be renamed 304 * @param newName 305 * new name to be assigned 306 * @param user 307 * user performing the operation 308 */ 309 void rename(StoredObject so, String newName, String user); 310 311 /** 312 * Persist a new version in the store (created from a check-out). 313 * 314 * @param version 315 * version to be stored 316 */ 317 void storeVersion(DocumentVersion version); 318 319 /** 320 * remove a version from the store (after a cancel check-out). 321 * 322 * @param version 323 * version to be deleted 324 */ 325 void deleteVersion(DocumentVersion version); 326 327 /** 328 * Modify and store the properties of an object. 329 * 330 * @param so 331 * object to update 332 * @param properties 333 * map containing properties to be updated 334 */ 335 void updateObject(StoredObject so, Map<String, PropertyData<?>> properties, String user); 336 337 /** 338 * get the path of this folder (for folder in CMIS path is unique). 339 * 340 * @param folderId 341 * id of folder 342 * @return path of this folder 343 */ 344 String getFolderPath(String folderId); 345 346 /** 347 * Clear repository and remove all data. 348 */ 349 void clear(); 350 351 /** 352 * For statistics: return the number of objects contained in the system. 353 * 354 * @return number of stored objects 355 */ 356 long getObjectCount(); 357 358 /** 359 * Create a relationship. The relationship is created but still temporary. 360 * It is not yet persisted and does not have an id yet. After this call 361 * additional actions can take place (like assigning properties and a type) 362 * before it is persisted. 363 * 364 * @param name 365 * name of relationship 366 * @param sourceObject 367 * source of the relationship 368 * @param targetObject 369 * target of the relationship 370 * @param propMap 371 * map of properities 372 * @param user 373 * the user who creates the document 374 * @param addACEs 375 * aces that are added 376 * @param removeACEs 377 * aces that are removed 378 * @return versioned document object 379 */ 380 StoredObject createRelationship(String name, StoredObject sourceObject, StoredObject targetObject, 381 Map<String, PropertyData<?>> propMap, String user, Acl addACEs, Acl removeACEs); 382 383 /** 384 * Return a list of all documents that are checked out in the repository. 385 * 386 * @param orderBy 387 * orderBy specification according to CMIS spec. 388 * @param user 389 * user id of user calling 390 * @param includeRelationships 391 * if true include all relationships in the response 392 * @return list of checked out documents in the repository 393 */ 394 List<StoredObject> getCheckedOutDocuments(String orderBy, String user, IncludeRelationships includeRelationships); 395 396 /** 397 * Apply a ACLs by relative adding and removing a list of ACEs to/from an 398 * object. 399 * 400 * @param so 401 * object where ACLs are applied 402 * @param addAces 403 * list of ACEs to be added 404 * @param removeAces 405 * list of ACEs to be removed 406 * @param aclPropagation 407 * enum value how to propagate ACLs to child objects 408 * @param user 409 * the user who applies ACL 410 * @return new ACL of object 411 */ 412 Acl applyAcl(StoredObject so, Acl addAces, Acl removeAces, AclPropagation aclPropagation, String user); 413 414 /** 415 * Apply a ACLs by setting a new list of ACEs to an object. 416 * 417 * @param so 418 * object where ACLs are applied 419 * @param aces 420 * list of ACEs to be applied 421 * @param aclPropagation 422 * enum value how to propagate ACLs to child objects 423 * @param user 424 * user who executes the call and needs to have permission to 425 * apply ACL 426 * @return new ACL of object 427 */ 428 Acl applyAcl(StoredObject so, Acl aces, AclPropagation aclPropagation, String user); 429 430 /** 431 * Check if this store contains any object with the given type id. 432 * 433 * @param typeId 434 * id of type definition to check 435 * @return true if at least one object in the store has the given type, 436 * false if no objects exist having this type 437 */ 438 boolean isTypeInUse(String typeId); 439 440 /** 441 * Get relationships to and from an object. 442 * 443 * @param objectId 444 * id of object to get relationships with 445 * @param typeIds 446 * list of all types to be included 447 * @param direction 448 * direction of relationship 449 * @return 450 * list of relationships belonging to this object 451 */ 452 List<StoredObject> getRelationships(String objectId, List<String> typeIds, RelationshipDirection direction); 453 454 /** 455 * get an ACL object from an ACL id. 456 * 457 * @param aclId 458 * id of ACL 459 * @return ACL of this id 460 */ 461 Acl getAcl(int aclId); 462 463 // Multifiling methods: 464 /** 465 * get all parent ids of this object visible for a user. 466 * 467 * @param so 468 * objects to get parents from 469 * @param user 470 * user who can see parents 471 * @return list of folder ids 472 */ 473 List<String> getParentIds(StoredObject so, String user); 474 475 /** 476 * Add this document to a new parent folder as child object. 477 * 478 * @param so 479 * objects to be added 480 * @param parent 481 * parent folder the object is to be added to 482 */ 483 void addParent(StoredObject so, Folder parent); 484 485 /** 486 * Remove this object from the children of parent. 487 * 488 * @param so 489 * object to be removed 490 * @param parent 491 * parent folder the object is to be removed from 492 */ 493 void removeParent(StoredObject so, Folder parent); 494 495 /** 496 * Retrieve the content of a document. 497 * 498 * @param so 499 * object to get content from 500 * @param offset 501 * offset in content stream 502 * @param length 503 * length of content to return 504 * 505 * @return object containing mime-type, length and a stream with content 506 */ 507 ContentStream getContent(StoredObject so, long offset, long length); 508 509 /** 510 * Write content and attach it to a document. Existing content gets overwritten. 511 * 512 * @param so 513 * object to set content to 514 * @param content 515 * content to be assigned to the document. If null any existing 516 * content is deleted 517 * @return 518 * the created content stream 519 */ 520 ContentStream setContent(StoredObject so, ContentStream content); 521 522 /** 523 * Append content to an existing content stream. 524 * 525 * @param so 526 * object to append content to 527 * @param content 528 * content to be assigned to the document. 529 */ 530 void appendContent(StoredObject so, ContentStream content); 531 532 /** 533 * get the rendition this objects supports. 534 * 535 * @param so 536 * object to get renditions from 537 * @param renditionFilter 538 * filter of renditions to return 539 * @param maxItems 540 * max nubmer of items to return 541 * @param skipCount 542 * number of objects to skip in result 543 * @return List of renditions or null if no renditions are available for 544 * this object 545 */ 546 List<RenditionData> getRenditions(StoredObject so, String renditionFilter, long maxItems, long skipCount); 547 548 /** 549 * get the rendition of this object. 550 * 551 * @param so 552 * object to get renditions from 553 * @param streamId 554 * stream if of rendition 555 * @param offset 556 * offset in rendition content 557 * @param length 558 * length of rendition content 559 * @return ContentStream containing the rendition 560 */ 561 ContentStream getRenditionContent(StoredObject so, String streamId, long offset, long length); 562 563 } 564