use of io.hops.hopsworks.persistence.entity.project.team.ProjectTeamPK in project hopsworks by logicalclocks.
the class ProjectController method addMember.
public void addMember(Users user, String role, Project project) throws KafkaException, ProjectException, UserException, FeaturestoreException, IOException {
if (user == null || project == null) {
throw new IllegalArgumentException("User and project can not be null.");
}
ProjectTeam projectTeam = new ProjectTeam(new ProjectTeamPK(project.getId(), user.getEmail()));
projectTeam.setTeamRole(role);
Users owner = project.getOwner();
boolean added;
DistributedFileSystemOps dfso = null;
try {
dfso = dfs.getDfsOps();
added = addMember(projectTeam, project, user, owner, dfso);
} finally {
dfs.closeDfsClient(dfso);
}
if (!added) {
LOGGER.log(Level.FINE, "User {0} is already a member in this project {1}.", new Object[] { user.getUsername(), project.getName() });
}
}
use of io.hops.hopsworks.persistence.entity.project.team.ProjectTeamPK in project hopsworks by logicalclocks.
the class ProjectController method addProjectOwner.
// Set the project owner as project master in ProjectTeam table
private void addProjectOwner(Project project, Users user) {
ProjectTeamPK stp = new ProjectTeamPK(project.getId(), user.getEmail());
ProjectTeam st = new ProjectTeam(stp);
st.setTeamRole(ProjectRoleTypes.DATA_OWNER.getRole());
// We don't trigger ProjectTeamRole handlers here. Owner's project team role must be handled within the project
// creation handler.
st.setTimestamp(new Date());
st.setProject(project);
st.setUser(user);
project.getProjectTeamCollection().add(st);
projectFacade.update(project);
}
use of io.hops.hopsworks.persistence.entity.project.team.ProjectTeamPK in project hopsworks by logicalclocks.
the class ProjectController method addServiceUser.
private Future<CertificatesController.CertsResult> addServiceUser(Project project, String username) throws IOException, HopsSecurityException, ProjectException {
// Add the Serving Manager user to the project team
Users serviceUser = userFacade.findByUsername(username);
ProjectTeamPK stp = new ProjectTeamPK(project.getId(), serviceUser.getEmail());
ProjectTeam st = new ProjectTeam(stp);
st.setTeamRole(ProjectRoleTypes.DATA_SCIENTIST.getRole());
st.setTimestamp(new Date());
st.setUser(serviceUser);
// Not fetched by jpa from project id in PK
st.setProject(project);
projectTeamFacade.persistProjectTeam(st);
// Create the Hdfs user
hdfsUsersController.addNewMember(st);
// Create the certificate for this project user
Future<CertificatesController.CertsResult> certsResultFuture = null;
try {
certsResultFuture = certificatesController.generateCertificates(project, serviceUser);
} catch (Exception e) {
throw new HopsSecurityException(RESTCodes.SecurityErrorCode.CERT_CREATION_ERROR, Level.SEVERE, "failed adding service user to project: " + project.getName() + "owner: " + username, e.getMessage(), e);
}
// trigger project team role add handlers
ProjectTeamRoleHandler.runProjectTeamRoleAddMembersHandlers(projectTeamRoleHandlers, project, Collections.singletonList(serviceUser), ProjectRoleTypes.fromString(st.getTeamRole()), true);
return certsResultFuture;
}
Aggregations