Package org.vosao.entity

Examples of org.vosao.entity.FolderPermissionEntity


    getDao().getUserGroupDao().save(userGroup);
  }
 
  private void addPermission(FolderEntity folder, GroupEntity group,
      FolderPermissionType perm) {
    FolderPermissionEntity p = new FolderPermissionEntity(folder.getId(),
        perm, group.getId());
    getDao().getFolderPermissionDao().save(p);
  }
View Full Code Here


    FolderEntity php = addFolder("php", services);
    addPermission(home, guests, FolderPermissionType.READ);
    addPermission(about, guests, FolderPermissionType.DENIED);
    addPermission(about, developers, FolderPermissionType.READ);
    addPermission(team, developers, FolderPermissionType.WRITE);
    FolderPermissionEntity p = getBusiness().getFolderPermissionBusiness()
        .getPermission(home, developer);
    assertEquals(FolderPermissionType.READ, p.getPermission());
    p = getBusiness().getFolderPermissionBusiness().getPermission(
        about, developer);
    assertEquals(FolderPermissionType.READ, p.getPermission());
    p = getBusiness().getFolderPermissionBusiness().getPermission(
        team, developer);
    assertEquals(FolderPermissionType.WRITE, p.getPermission());
    p = getBusiness().getFolderPermissionBusiness().getGuestPermission(
        home);
    assertEquals(FolderPermissionType.READ, p.getPermission());
    p = getBusiness().getFolderPermissionBusiness().getGuestPermission(
        about);
    assertEquals(FolderPermissionType.DENIED, p.getPermission());
    p = getBusiness().getFolderPermissionBusiness().getGuestPermission(
        team);
    assertEquals(FolderPermissionType.DENIED, p.getPermission());
    p = getBusiness().getFolderPermissionBusiness().getGuestPermission(
        services);
    assertEquals(FolderPermissionType.READ, p.getPermission());
    p = getBusiness().getFolderPermissionBusiness().getGuestPermission(
        php);
    assertEquals(FolderPermissionType.READ, p.getPermission());
  }
View Full Code Here

    getDao().getUserGroupDao().save(userGroup);
  }
 
  private void addPermission(FolderEntity folder, GroupEntity group,
      FolderPermissionType perm) {
    FolderPermissionEntity p = new FolderPermissionEntity(folder.getId(),
        perm, group.getId());
    getDao().getFolderPermissionDao().save(p);
  }
View Full Code Here

    dao = aDao;
  }
 
  public FolderPermissionEntity addPermission(Long folderId,
      FolderPermissionType perm,  Long aGroupId) {
    return dao.getFolderPermissionDao().save(new FolderPermissionEntity(
        folderId, perm, aGroupId));
  }
View Full Code Here

        .getId(), name);
    if (file == null) {
      logger.error("File not found. " + filename);
      return;
    }
    FolderPermissionEntity perm = getFolderPermissionBusiness()
        .getPermission(folder.getEntity(),
            VosaoContext.getInstance().getUser());
    if (perm.isChangeGranted()) {
      getDao().getFileDao().remove(file.getId());
      getSystemService().getFileCache().remove(filename);
    }
  }
View Full Code Here

      final UserEntity user) {
    if (user == null) {
      return getGuestPermission(folder);
    }
    if (user.isAdmin()) {
      return new FolderPermissionEntity(folder.getId(),
          FolderPermissionType.ADMIN);
    }
    List<UserGroupEntity> userGroups = getDao().getUserGroupDao()
        .selectByUser(user.getId());
    userGroups.add(new UserGroupEntity(getDao().getGroupDao()
        .getGuestsGroup().getId(), user.getId()));
    List<FolderPermissionEntity> permissions =
        new ArrayList<FolderPermissionEntity>();
    for (UserGroupEntity userGroup : userGroups) {
      FolderPermissionEntity FolderPermission = getGroupPermission(folder,
          userGroup.getGroupId());
      if (FolderPermission != null) {
        permissions.add(FolderPermission);
      }
    }
    permissions.add(getPagePermission(folder));
    FolderPermissionEntity result = consolidatePermissions(permissions);
    result.setFolderId(folder.getId());
    return result;
  }
View Full Code Here

    return result;
  }

  private FolderPermissionEntity consolidatePermissions(
      List<FolderPermissionEntity> permissions) {
    FolderPermissionEntity result = new FolderPermissionEntity();
    result.setPermission(FolderPermissionType.DENIED);
    for (FolderPermissionEntity perm : permissions) {
      if (perm.isMyPermissionHigher(result)) {
        result.setPermission(perm.getPermission());
      }
    }
    return result;
  }
View Full Code Here

  }

  private FolderPermissionEntity getGroupPermission(FolderEntity folder,
      Long groupId) {
    FolderEntity myFolder = folder;
    FolderPermissionEntity result = new FolderPermissionEntity(folder.getId());
    result.setPermission(FolderPermissionType.DENIED);
    while (myFolder != null) {
      FolderPermissionEntity perm = getDao().getFolderPermissionDao()
        .getByFolderGroup(myFolder.getId(), groupId);
      if (perm != null) {
        return perm;
      }
      if (myFolder.isRoot()) {
View Full Code Here

  }

  @Override
  public void setPermission(FolderEntity folder, GroupEntity group,
      FolderPermissionType permission) {
    FolderPermissionEntity perm = getDao().getFolderPermissionDao()
        .getByFolderGroup(folder.getId(), group.getId());
    if (perm == null) {
      perm = new FolderPermissionEntity();
      perm.setFolderId(folder.getId());
      perm.setGroupId(group.getId());
    }
    perm.setPermission(permission);
    getDao().getFolderPermissionDao().save(perm);
  }
View Full Code Here

    return result;
  }

  private FolderPermissionEntity getPagePermission(FolderEntity folder) {
    String path = getDao().getFolderDao().getFolderPath(folder.getId());
    FolderPermissionEntity result = new FolderPermissionEntity();
    result.setPermission(FolderPermissionType.DENIED);
    if (path.startsWith(PAGE)) {
      String pageUrl = getFolderFromPageUrl(path);     
      ContentPermissionEntity pagePermission =
        getContentPermissionBusiness().getPermission(
          pageUrl, VosaoContext.getInstance().getUser());
      result.setPermission(FolderPermissionType
          .fromContentPermissionType(pagePermission.getPermission()));
    }
    return result;
  }
View Full Code Here

TOP

Related Classes of org.vosao.entity.FolderPermissionEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.