Ejemplo n.º 1
0
  /**
   * @param repositoryId TODO
   * @param key
   * @param userPermissions
   * @return
   */
  private boolean checkCalculatedPermissions(
      String repositoryId, String key, Set<String> userPermissions) {
    Map<String, PermissionMapping> table =
        repositoryInfoMap.get(repositoryId).getAclCapabilities().getPermissionMapping();
    List<String> actionPermissions = table.get(key).getPermissions();

    for (String up : userPermissions) {
      if (actionPermissions.contains(up) || CmisPermission.ALL.equals(up)) {
        // If any one of user permissions is contained, action is allowed.
        return true;
      }
    }
    return false;
  }
  @Override
  public void constraintPermissionDefined(
      String repositoryId, org.apache.chemistry.opencmis.commons.data.Acl acl, String objectId) {
    boolean aclIsEmpty =
        (acl == null) || (acl != null && CollectionUtils.isEmpty(acl.getAces())) ? true : false;
    List<PermissionDefinition> definitions =
        repositoryInfoMap.get(repositoryId).getAclCapabilities().getPermissions();
    List<String> definedIds = new ArrayList<String>();
    for (PermissionDefinition pdf : definitions) {
      definedIds.add(pdf.getId());
    }

    if (!aclIsEmpty) {
      for (org.apache.chemistry.opencmis.commons.data.Ace ace : acl.getAces()) {
        List<String> permissions = ace.getPermissions();
        for (String p : permissions) {
          if (!definedIds.contains(p)) {
            constraint(objectId, "A provided ACE includes an unsupported permission");
          }
        }
      }
    }
  }
 @Override
 public void objectNotFoundParentFolder(String repositoryId, String id, Content content) {
   if (!repositoryInfoMap.get(repositoryId).getCapabilities().isMultifilingSupported())
     objectNotFound(DomainType.OBJECT, content, id, "The specified parent folder is not found");
 }
 @Override
 public void invalidArgumentOrderBy(String repositoryId, String orderBy) {
   if (repositoryInfoMap.get(repositoryId).getCapabilities().getOrderByCapability()
           == CapabilityOrderBy.NONE
       && orderBy != null) invalidArgument("OrderBy capability is not supported");
 }
 @Override
 public void invalidArgumentRequiredParentFolderId(String repositoryId, String folderId) {
   if (!repositoryInfoMap.get(repositoryId).getCapabilities().isMultifilingSupported())
     invalidArgumentRequiredString("folderId", folderId);
 }
 public void constraintDeleteRootFolder(String repositoryId, String objectId) {
   String rootFolderId = repositoryInfoMap.get(repositoryId).getRootFolderId();
   if (rootFolderId.equals(objectId)) {
     constraint(objectId, "Cannot delete root folder");
   }
 }