@Test public void createGroup() throws CatalogDBException { catalogStudyDBAdaptor.createGroup(5L, new Group("name", Arrays.asList("user1", "user2"))); thrown.expect(CatalogDBException.class); thrown.expectMessage("Group already existed"); catalogStudyDBAdaptor.createGroup(5L, new Group("name", Arrays.asList("user1", "user2"))); }
@Test public void removeUsersFromAllGroups() throws CatalogDBException { catalogStudyDBAdaptor.createGroup(5L, new Group("name1", Arrays.asList("user1", "user2"))); catalogStudyDBAdaptor.createGroup(5L, new Group("name2", Arrays.asList("user1", "user2", "user3"))); catalogStudyDBAdaptor.createGroup(5L, new Group("name3", Arrays.asList("user1", "user3"))); QueryResult<Group> group = catalogStudyDBAdaptor.getGroup(5L, null, Arrays.asList("user1", "user3")); assertEquals(3, group.getNumResults()); catalogStudyDBAdaptor.removeUsersFromAllGroups(5L, Arrays.asList("user1", "user3")); group = catalogStudyDBAdaptor.getGroup(5L, null, Arrays.asList("user1", "user3")); assertEquals(0, group.getNumResults()); }
public QueryResult<Group> createGroup(String studyStr, String groupId, String users, String sessionId) throws CatalogException { ParamUtils.checkParameter(groupId, "group name"); String userId = catalogManager.getUserManager().getUserId(sessionId); Study study = resolveId(studyStr, userId); // Fix the groupId if (!groupId.startsWith("@")) { groupId = "@" + groupId; } authorizationManager.checkCreateDeleteGroupPermissions(study.getUid(), userId, groupId); // Create the list of users List<String> userList; if (StringUtils.isNotEmpty(users)) { userList = Arrays.asList(users.split(",")); } else { userList = Collections.emptyList(); } // Check group exists if (existsGroup(study.getUid(), groupId)) { throw new CatalogException("The group " + groupId + " already exists."); } // Check the list of users is ok if (userList.size() > 0) { userDBAdaptor.checkIds(userList); } // Add those users to the members group studyDBAdaptor.addUsersToGroup(study.getUid(), MEMBERS, userList); // Create the group return studyDBAdaptor.createGroup(study.getUid(), new Group(groupId, userList)); }
0, cipher, Arrays.asList(new Group(MEMBERS, Collections.emptyList()), new Group(ADMINS, Collections.emptyList())), experiments, files, jobs, new LinkedList<>(), new LinkedList<>(), new LinkedList<>(), new LinkedList<>(), Collections.emptyList(), new LinkedList<>(), null, null, datastores, project.getCurrentRelease(), stats,
} else { Group newGroup = new Group(catalogGroup, Collections.emptyList(), new Group.Sync(authenticationOriginId, externalGroup)); studyDBAdaptor.createGroup(study.getUid(), newGroup);
Arrays.asList(new Project("pr1", "90 GigaGenomes", null, "very long description", "Spain", null, new Status(), "", 0, Arrays.asList(new Study("name", "Study name", "ph1", Study.Type.CONTROL_SET, "", "", new Status(), "", 0, "", Arrays.asList(new Group("@members", Collections.emptyList())), Collections.<Experiment>emptyList(), Arrays.asList( new File("data/", File.Type.DIRECTORY, File.Format.PLAIN, File.Bioformat.NONE, "data/", "", Arrays.asList( new Study("spongeScan", "spongeScan", "sponges", Study.Type.COLLECTION, "", "", new Status(), "", 0, "", Arrays.asList(new Group("@members", Collections.emptyList())), null, Arrays.asList( new File("data/", File.Type.DIRECTORY, File.Format.UNKNOWN, File.Bioformat.NONE, "data/", "Description", new File.FileStatus(File.FileStatus.READY), 10, 1), ), new Study("mineco", "MINECO", "mineco", Study.Type.COLLECTION, "", "", new Status(), "", 0, "", Arrays.asList(new Group("@members", Collections.emptyList())), null, Arrays.asList( new File("data/", File.Type.DIRECTORY, File.Format.UNKNOWN, File.Bioformat.NONE, "data/",
@Test public void resyncUserWithSyncedGroups() throws CatalogDBException { Group group = new Group("@notSyncedGroup", Arrays.asList("user1", "user2", "user3")); catalogStudyDBAdaptor.createGroup(5L, group); group.setName("@syncedGroup1"); group.setSyncedFrom(new Group.Sync("otherOrigin", "@syncedGroup3")); catalogStudyDBAdaptor.createGroup(5L, group); group = new Group("@otherNotSyncedGroup", Arrays.asList("user1", "user3")); catalogStudyDBAdaptor.createGroup(5L, group); group = new Group("@notSyncedGroup", Arrays.asList("user1", "user2", "user3")); catalogStudyDBAdaptor.createGroup(9L, group); group.setName("@syncedGroup1"); group.setSyncedFrom(new Group.Sync("otherOrigin", "@syncedGroup3")); catalogStudyDBAdaptor.createGroup(9L, group); group = new Group("@otherNotSyncedGroup", Arrays.asList("user1", "user3")); catalogStudyDBAdaptor.createGroup(9L, group);