Пример #1
0
 @Override
 public StoredObject createItem(
     String name,
     Map<String, PropertyData<?>> propMap,
     String user,
     Folder folder,
     List<String> policies,
     Acl addACEs,
     Acl removeACEs) {
   ItemImpl item = new ItemImpl();
   item.createSystemBasePropertiesWhenCreated(propMap, user);
   item.setCustomProperties(propMap);
   item.setRepositoryId(fRepositoryId);
   item.setName(name);
   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()));
     }
     item.addParentId(folder.getId());
   }
   if (null != policies) {
     item.setAppliedPolicies(policies);
   }
   int aclId = getAclId(((FolderImpl) folder), addACEs, removeACEs);
   item.setAclId(aclId);
   String id = storeObject(item);
   item.setId(id);
   applyAcl(item, addACEs, removeACEs);
   return item;
 }
Пример #2
0
 @Override
 public void rename(StoredObject so, String newName, String user) {
   try {
     lock();
     if (so.getId().equals(fRootFolder.getId())) {
       throw new CmisInvalidArgumentException("Root folder cannot be renamed.");
     }
     if (so instanceof Fileable) {
       for (String folderId : ((Fileable) so).getParentIds()) {
         Folder folder = (Folder) getObjectById(folderId);
         if (hasChild(folder, newName)) {
           throw new CmisNameConstraintViolationException(
               "Cannot rename object to "
                   + newName
                   + ". This path already exists in parent "
                   + getFolderPath(folder.getId())
                   + ".");
         }
       }
     }
     so.setName(newName);
   } finally {
     unlock();
   }
 }
Пример #3
0
 private List<Fileable> getChildren(Folder folder, String user, boolean usePwc) {
   List<Fileable> children = new ArrayList<Fileable>();
   for (String id : getIds()) {
     StoredObject obj = getObject(id);
     if (obj instanceof Fileable) {
       Fileable pathObj = (Fileable) obj;
       if ((null == user || hasReadAccess(user, obj))
           && pathObj.getParentIds().contains(folder.getId())) {
         if (pathObj instanceof VersionedDocument) {
           DocumentVersion ver;
           if (usePwc) {
             ver = ((VersionedDocument) pathObj).getPwc();
             if (null == ver) {
               ver = ((VersionedDocument) pathObj).getLatestVersion(false);
             }
           } else {
             ver = ((VersionedDocument) pathObj).getLatestVersion(false);
           }
           children.add(ver);
         } else if (!(pathObj instanceof DocumentVersion)) { // ignore
           // DocumentVersion
           children.add(pathObj);
         }
       }
     }
   }
   return children;
 }
Пример #4
0
  @Override
  public Folder createFolder(
      String name,
      Map<String, PropertyData<?>> propMap,
      String user,
      Folder parent,
      List<String> policies,
      Acl addACEs,
      Acl removeACEs) {

    if (null == parent) {
      throw new CmisInvalidArgumentException("Cannot create root folder.");
    } else if (hasChild(parent, name)) {
      throw new CmisNameConstraintViolationException(
          "Cannot create folder, this name already exists in parent folder.");
    }
    FolderImpl folder = new FolderImpl(name, parent.getId());
    if (null != propMap) {
      folder.createSystemBasePropertiesWhenCreated(propMap, user);
      folder.setCustomProperties(propMap);
    }
    folder.setRepositoryId(fRepositoryId);

    int aclId = getAclId(((FolderImpl) parent), addACEs, removeACEs);
    folder.setAclId(aclId);
    if (null != policies) {
      folder.setAppliedPolicies(policies);
    }

    String id = storeObject(folder);
    folder.setId(id);
    applyAcl(folder, addACEs, removeACEs);
    return folder;
  }
Пример #5
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;
 }
Пример #6
0
 @Override
 public void move(StoredObject so, Folder oldParent, Folder newParent, String user) {
   try {
     if (hasChild(newParent, so.getName())) {
       throw new CmisInvalidArgumentException(
           "Cannot move object "
               + so.getName()
               + " to folder "
               + getFolderPath(newParent.getId())
               + ". A child with this name already exists.");
     }
     lock();
     if (so instanceof MultiFiling) {
       MultiFiling fi = (MultiFiling) so;
       addParentIntern(fi, newParent);
       removeParentIntern(fi, oldParent);
     } else if (so instanceof FolderImpl) {
       ((FolderImpl) so).setParentId(newParent.getId());
     }
   } finally {
     unlock();
   }
 }
Пример #7
0
 @Override
 public Document createDocument(
     Map<String, PropertyData<?>> propMap,
     String user,
     Folder folder,
     ContentStream contentStream,
     List<String> policies,
     Acl addACEs,
     Acl removeACEs) {
   String name = (String) propMap.get(PropertyIds.NAME).getFirstValue();
   DocumentImpl doc = new DocumentImpl();
   doc.createSystemBasePropertiesWhenCreated(propMap, user);
   doc.setCustomProperties(propMap);
   doc.setRepositoryId(fRepositoryId);
   doc.setName(name);
   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());
   }
   ContentStream content = setContent(doc, contentStream);
   doc.setContent(content);
   int aclId = getAclId(((FolderImpl) folder), addACEs, removeACEs);
   doc.setAclId(aclId);
   if (null != policies) {
     doc.setAppliedPolicies(policies);
   }
   String id = storeObject(doc);
   doc.setId(id);
   applyAcl(doc, addACEs, removeACEs);
   return doc;
 }
Пример #8
0
  @Override
  public ChildrenResult getFolderChildren(Folder folder, int maxItems, int skipCount, String user) {
    List<Fileable> folderChildren = new ArrayList<Fileable>();
    for (String id : getIds()) {
      StoredObject obj = getObject(id);
      if (hasReadAccess(user, obj) && obj instanceof Folder) {
        Folder childFolder = (Folder) obj;
        if (childFolder.getParentIds().contains(folder.getId())) {
          folderChildren.add(childFolder);
        }
      }
    }
    sortFolderList(folderChildren);
    int from = Math.min(skipCount, folderChildren.size());
    int to = Math.min(maxItems + from, folderChildren.size());
    int noItems = folderChildren.size();

    folderChildren = folderChildren.subList(from, to);

    return new ChildrenResult(folderChildren, noItems);
  }
Пример #9
0
 private void removeParentIntern(MultiFiling so, Folder parent) {
   so.removeParentId(parent.getId());
 }
Пример #10
0
 private void addParentIntern(MultiFiling so, Folder parent) {
   so.addParentId(parent.getId());
 }