private void setExistingMemberships() {
    if (existingMemberships == null) {
      existingMemberships = new HashSet<GroupKey>();
    }

    for (GroupEntity existingMembership : groupToUpdate.getAllMemberships()) {
      existingMemberships.add(existingMembership.getGroupKey());
    }
  }
  private ContentAccessEntity createContentAccessEntity(
      String contentKey,
      String groupKey,
      boolean readAccess,
      boolean updateAccess,
      boolean deleteAccess) {
    final ContentAccessEntity accessRights = new ContentAccessEntity();
    accessRights.setKey(contentKey);
    accessRights.setDeleteAccess(deleteAccess);
    accessRights.setUpdateAccess(updateAccess);
    accessRights.setReadAccess(readAccess);

    final GroupEntity group = new GroupEntity();
    group.setKey(new GroupKey(groupKey));
    accessRights.setGroup(group);

    return accessRights;
  }
Exemplo n.º 3
0
 public GroupEntity createGroupInUserstore(
     String name, GroupType groupType, String userstoreName) {
   GroupEntity group = new GroupEntity();
   group.setKey(new GroupKey(Integer.toString(mockKeyService.generateNextKeySafe("TGROUP"))));
   group.setName(name);
   group.setSyncValue("sync_" + name);
   group.setDeleted(0);
   group.setRestricted(1);
   group.setType(groupType);
   group.setUserStore(fixture.findUserStoreByName(userstoreName));
   return group;
 }
  private CategoryAccessEntity createCategoryAccessEntity(
      String groupKey,
      boolean readAccess,
      boolean adminBrowseAccess,
      boolean publishAccess,
      boolean createAccess,
      boolean adminAccess) {
    final CategoryAccessEntity accessRights = new CategoryAccessEntity();
    accessRights.setReadAccess(readAccess);
    accessRights.setCreateAccess(createAccess);
    accessRights.setAdminAccess(adminAccess);
    accessRights.setAdminBrowseAccess(adminBrowseAccess);
    accessRights.setPublishAccess(publishAccess);

    final GroupEntity group = new GroupEntity();
    group.setKey(new GroupKey(groupKey));
    accessRights.setGroup(group);
    return accessRights;
  }
Exemplo n.º 5
0
 public CategoryAccessControl createCategoryAccessControl(GroupEntity group, String accesses) {
   CategoryAccessControl access = new CategoryAccessControl();
   access.setGroupKey(group.getGroupKey());
   access.setReadAccess(accesses.contains(CategoryAccessType.READ.toString().toLowerCase()));
   access.setAdminAccess(
       accesses.contains(CategoryAccessType.ADMINISTRATE.toString().toLowerCase()));
   access.setCreateAccess(accesses.contains(CategoryAccessType.CREATE.toString().toLowerCase()));
   access.setPublishAccess(accesses.contains(CategoryAccessType.APPROVE.toString().toLowerCase()));
   access.setAdminBrowseAccess(
       accesses.contains(CategoryAccessType.ADMIN_BROWSE.toString().toLowerCase()));
   return access;
 }
Exemplo n.º 6
0
 public MenuItemAccessEntity createMenuItemAccess(
     MenuItemEntity menuItem, GroupEntity group, String accesses) {
   MenuItemAccessEntity access = new MenuItemAccessEntity();
   access.setKey(new MenuItemAccessKey(menuItem.getKey(), group.getGroupKey()));
   access.setAddAccess(accesses.contains(MenuItemAccessType.ADD.toString().toLowerCase()));
   access.setAdminAccess(
       accesses.contains(MenuItemAccessType.ADMINISTRATE.toString().toLowerCase()));
   access.setCreateAccess(accesses.contains(MenuItemAccessType.CREATE.toString().toLowerCase()));
   access.setDeleteAccess(accesses.contains(MenuItemAccessType.DELETE.toString().toLowerCase()));
   access.setPublishAccess(accesses.contains(MenuItemAccessType.PUBLISH.toString().toLowerCase()));
   access.setReadAccess(accesses.contains(MenuItemAccessType.READ.toString().toLowerCase()));
   access.setUpdateAccess(accesses.contains(MenuItemAccessType.UPDATE.toString().toLowerCase()));
   return access;
 }
Exemplo n.º 7
0
 public GroupEntity createGroup(String name, GroupType groupType) {
   GroupEntity group = new GroupEntity();
   group.setName(name);
   group.setSyncValue("sync_" + name);
   group.setDeleted(0);
   group.setRestricted(1);
   group.setType(groupType);
   return group;
 }
Exemplo n.º 8
0
  public CategoryAccessEntity createCategoryAccess(
      String categoryName, GroupEntity group, String accesses) {
    CategoryEntity category = fixture.findCategoryByName(categoryName);

    CategoryAccessEntity access = new CategoryAccessEntity();
    access.setKey(new CategoryAccessKey(category.getKey(), group.getGroupKey()));
    access.setGroup(group);
    access.setReadAccess(accesses.contains(CategoryAccessType.READ.toString().toLowerCase()));
    access.setAdminAccess(
        accesses.contains(CategoryAccessType.ADMINISTRATE.toString().toLowerCase()));
    access.setCreateAccess(accesses.contains(CategoryAccessType.CREATE.toString().toLowerCase()));
    access.setPublishAccess(accesses.contains(CategoryAccessType.APPROVE.toString().toLowerCase()));
    access.setAdminBrowseAccess(
        accesses.contains(CategoryAccessType.ADMIN_BROWSE.toString().toLowerCase()));
    return access;
  }
Exemplo n.º 9
0
  @Before
  public void setUp() throws Exception {
    final GroupEntity adminGroupEntity = new GroupEntity();
    final GroupKey adminGroupKey = new GroupKey("admin");
    adminGroupEntity.setKey(adminGroupKey);

    final GroupEntity anonGroupEntity = new GroupEntity();
    final GroupKey anonGroupKey = new GroupKey("anonymous");
    anonGroupEntity.setKey(anonGroupKey);

    servlet = new MyPageServlet();
    servlet.groupDao = Mockito.mock(GroupDao.class);
    Mockito.when(servlet.groupDao.findBuiltInAnonymous()).thenReturn(anonGroupEntity);
    Mockito.when(servlet.groupDao.findBuiltInEnterpriseAdministrator())
        .thenReturn(adminGroupEntity);

    final GroupEntity groupEntity = new GroupEntity();
    final GroupKey groupKey = new GroupKey("user_group");
    groupEntity.setKey(groupKey);

    userEntity = new UserEntity();
    userEntity.setName("user");
    userEntity.setType(UserType.NORMAL);
    userEntity.setUserGroup(groupEntity);

    final Map<GroupKey, CategoryAccessEntity> accessRights =
        new HashMap<GroupKey, CategoryAccessEntity>();

    accessEntity = new CategoryAccessEntity();
    accessRights.put(groupKey, accessEntity);

    contentType = Mockito.mock(ContentTypeEntity.class);

    final CategoryEntity categoryEntity = new CategoryEntity();
    categoryEntity.setAccessRights(accessRights);
    Mockito.when(contentType.getCategories(false))
        .thenReturn(Arrays.<CategoryEntity>asList(categoryEntity));
  }