Esempio n. 1
0
  @Override
  public void deleteObject(String objectId, Boolean allVersions, String user) {
    StoredObject obj = fStoredObjectMap.get(objectId);

    if (null == obj) {
      throw new CmisObjectNotFoundException(
          "Cannot delete object with id  " + objectId + ". Object does not exist.");
    }

    if (obj instanceof FolderImpl) {
      deleteFolder(objectId, user);
    } else if (obj instanceof DocumentVersion) {
      DocumentVersion vers = (DocumentVersion) obj;
      VersionedDocument parentDoc = vers.getParentDocument();
      boolean otherVersionsExists;
      if (allVersions != null && allVersions) {
        otherVersionsExists = false;
        List<DocumentVersion> allVers = parentDoc.getAllVersions();
        for (DocumentVersion ver : allVers) {
          fStoredObjectMap.remove(ver.getId());
        }
      } else {
        fStoredObjectMap.remove(objectId);
        otherVersionsExists = parentDoc.deleteVersion(vers);
      }

      if (!otherVersionsExists) {
        fStoredObjectMap.remove(parentDoc.getId());
      }
    } else {
      fStoredObjectMap.remove(objectId);
    }
  }
Esempio n. 2
0
  @Override
  public void deleteVersion(DocumentVersion version) {
    StoredObject found = fStoredObjectMap.remove(version.getId());

    if (null == found) {
      throw new CmisInvalidArgumentException(
          "Cannot delete object with id  " + version.getId() + ". Object does not exist.");
    }
  }
Esempio n. 3
0
 @Override
 public DocumentVersion createVersionedDocument(
     String name,
     Map<String, PropertyData<?>> propMap,
     String user,
     Folder folder,
     List<String> policies,
     Acl addACEs,
     Acl removeACEs,
     ContentStream contentStream,
     VersioningState versioningState) {
   WebdavVersionedDocumentImpl doc = new WebdavVersionedDocumentImpl();
   doc.createSystemBasePropertiesWhenCreated(propMap, user);
   doc.setCustomProperties(propMap);
   doc.setRepositoryId(fRepositoryId);
   doc.setName(name);
   String id = storeObject(doc);
   doc.setId(id);
   DocumentVersion version = doc.addVersion(versioningState, user);
   setContent(version, contentStream);
   version.createSystemBasePropertiesWhenCreated(propMap, user);
   version.setCustomProperties(propMap);
   if (null != folder) {
     if (hasChild(folder, name)) {
       throw new CmisNameConstraintViolationException(
           "Cannot create document an object with name "
               + name
               + " already exists in folder "
               + getFolderPath(folder.getId()));
     }
     doc.addParentId(folder.getId());
   }
   int aclId = getAclId(((FolderImpl) folder), addACEs, removeACEs);
   doc.setAclId(aclId);
   if (null != policies) {
     doc.setAppliedPolicies(policies);
   }
   id = storeObject(version);
   version.setId(id);
   applyAcl(doc, addACEs, removeACEs);
   return version;
 }
Esempio n. 4
0
 @Override
 public void storeVersion(DocumentVersion version) {
   String id = storeObject(version);
   version.setId(id);
 }