Exemplo n.º 1
0
 /**
  * Remove all members of the project from the dataset group.
  *
  * <p>
  *
  * @param project
  * @param dataset
  */
 public void unShareDataset(Project project, Dataset dataset) {
   if (project == null || dataset == null) {
     throw new IllegalArgumentException("One or more arguments are null.");
   }
   String datasetGroup = getHdfsGroupName(dataset);
   byte[] groupId = UsersGroups.getGroupID(datasetGroup);
   HdfsGroups hdfsGroup = hdfsGroupsFacade.findHdfsGroup(groupId);
   if (hdfsGroup == null) {
     throw new IllegalArgumentException("Dataset group not found");
   }
   if (hdfsGroup.getHdfsUsersCollection() == null) {
     throw new IllegalArgumentException("The dataset group have no members.");
   }
   Collection<ProjectTeam> projectTeam = projectTeamFacade.findMembersByProject(project);
   String hdfsUsername;
   HdfsUsers hdfsUser;
   byte[] userId;
   // every member of the project the ds is going to be unshard from is
   // removed from the dataset group.
   for (ProjectTeam member : projectTeam) {
     hdfsUsername = getHdfsUserName(project, member.getUser());
     userId = UsersGroups.getUserID(hdfsUsername);
     hdfsUser = hdfsUsersFacade.findHdfsUser(userId);
     if (hdfsUser != null) {
       hdfsGroup.getHdfsUsersCollection().remove(hdfsUser);
     }
   }
   hdfsGroupsFacade.merge(hdfsGroup);
 }
Exemplo n.º 2
0
 /**
  * Adds all members of project to the dataset's group. This will give the added members read and
  * execute privileges.
  *
  * <p>
  *
  * @param project
  * @param dataset
  */
 public void shareDataset(Project project, Dataset dataset) {
   if (project == null || dataset == null) {
     throw new IllegalArgumentException("One or more arguments are null.");
   }
   String datasetGroup = getHdfsGroupName(dataset);
   byte[] groupId = UsersGroups.getGroupID(datasetGroup);
   HdfsGroups hdfsGroup = hdfsGroupsFacade.findHdfsGroup(groupId);
   if (hdfsGroup == null) {
     throw new IllegalArgumentException("Dataset group not found");
   }
   if (hdfsGroup.getHdfsUsersCollection() == null) {
     hdfsGroup.setHdfsUsersCollection(new ArrayList<HdfsUsers>());
   }
   Collection<ProjectTeam> projectTeam = projectTeamFacade.findMembersByProject(project);
   String hdfsUsername;
   HdfsUsers hdfsUser;
   byte[] userId;
   // every member of the project the ds is going to be shard with is
   // added to the dataset group.
   for (ProjectTeam member : projectTeam) {
     hdfsUsername = getHdfsUserName(project, member.getUser());
     userId = UsersGroups.getUserID(hdfsUsername);
     hdfsUser = hdfsUsersFacade.findHdfsUser(userId);
     if (hdfsUser == null) {
       hdfsUser = new HdfsUsers(userId, hdfsUsername);
     }
     if (!hdfsGroup.getHdfsUsersCollection().contains(hdfsUser)) {
       hdfsGroup.getHdfsUsersCollection().add(hdfsUser);
     }
   }
   hdfsGroupsFacade.merge(hdfsGroup);
 }