Search in sources :

Example 1 with ProjectTeamPK

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() });
    }
}
Also used : ProjectTeam(io.hops.hopsworks.persistence.entity.project.team.ProjectTeam) DistributedFileSystemOps(io.hops.hopsworks.common.hdfs.DistributedFileSystemOps) ProjectTeamPK(io.hops.hopsworks.persistence.entity.project.team.ProjectTeamPK) HdfsUsers(io.hops.hopsworks.persistence.entity.hdfs.user.HdfsUsers) Users(io.hops.hopsworks.persistence.entity.user.Users)

Example 2 with ProjectTeamPK

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);
}
Also used : ProjectTeam(io.hops.hopsworks.persistence.entity.project.team.ProjectTeam) ProjectTeamPK(io.hops.hopsworks.persistence.entity.project.team.ProjectTeamPK) Date(java.util.Date)

Example 3 with ProjectTeamPK

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;
}
Also used : ProjectTeam(io.hops.hopsworks.persistence.entity.project.team.ProjectTeam) ProjectTeamPK(io.hops.hopsworks.persistence.entity.project.team.ProjectTeamPK) HdfsUsers(io.hops.hopsworks.persistence.entity.hdfs.user.HdfsUsers) Users(io.hops.hopsworks.persistence.entity.user.Users) Date(java.util.Date) TensorBoardException(io.hops.hopsworks.exceptions.TensorBoardException) DatasetException(io.hops.hopsworks.exceptions.DatasetException) EJBException(javax.ejb.EJBException) AlertException(io.hops.hopsworks.exceptions.AlertException) PythonException(io.hops.hopsworks.exceptions.PythonException) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException) RESTException(io.hops.hopsworks.restutils.RESTException) SQLException(java.sql.SQLException) ElasticException(io.hops.hopsworks.exceptions.ElasticException) AlertManagerConfigUpdateException(io.hops.hopsworks.alerting.exceptions.AlertManagerConfigUpdateException) IOException(java.io.IOException) ServiceException(io.hops.hopsworks.exceptions.ServiceException) UserException(io.hops.hopsworks.exceptions.UserException) ExecutionException(java.util.concurrent.ExecutionException) ServingException(io.hops.hopsworks.exceptions.ServingException) AlertManagerResponseException(io.hops.hopsworks.alerting.exceptions.AlertManagerResponseException) CryptoPasswordNotFoundException(io.hops.hopsworks.exceptions.CryptoPasswordNotFoundException) ProjectException(io.hops.hopsworks.exceptions.ProjectException) AlertManagerUnreachableException(io.hops.hopsworks.alert.exception.AlertManagerUnreachableException) AlertManagerConfigReadException(io.hops.hopsworks.alerting.exceptions.AlertManagerConfigReadException) ServiceDiscoveryException(com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException) JobException(io.hops.hopsworks.exceptions.JobException) GenericException(io.hops.hopsworks.exceptions.GenericException) AlertManagerConfigCtrlCreateException(io.hops.hopsworks.alerting.exceptions.AlertManagerConfigCtrlCreateException) KafkaException(io.hops.hopsworks.exceptions.KafkaException) HopsSecurityException(io.hops.hopsworks.exceptions.HopsSecurityException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) ProvenanceException(io.hops.hopsworks.exceptions.ProvenanceException) AlertManagerClientCreateException(io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException) SchemaException(io.hops.hopsworks.exceptions.SchemaException) HopsSecurityException(io.hops.hopsworks.exceptions.HopsSecurityException)

Aggregations

ProjectTeam (io.hops.hopsworks.persistence.entity.project.team.ProjectTeam)3 ProjectTeamPK (io.hops.hopsworks.persistence.entity.project.team.ProjectTeamPK)3 HdfsUsers (io.hops.hopsworks.persistence.entity.hdfs.user.HdfsUsers)2 Users (io.hops.hopsworks.persistence.entity.user.Users)2 Date (java.util.Date)2 ServiceDiscoveryException (com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException)1 AlertManagerUnreachableException (io.hops.hopsworks.alert.exception.AlertManagerUnreachableException)1 AlertManagerClientCreateException (io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException)1 AlertManagerConfigCtrlCreateException (io.hops.hopsworks.alerting.exceptions.AlertManagerConfigCtrlCreateException)1 AlertManagerConfigReadException (io.hops.hopsworks.alerting.exceptions.AlertManagerConfigReadException)1 AlertManagerConfigUpdateException (io.hops.hopsworks.alerting.exceptions.AlertManagerConfigUpdateException)1 AlertManagerResponseException (io.hops.hopsworks.alerting.exceptions.AlertManagerResponseException)1 DistributedFileSystemOps (io.hops.hopsworks.common.hdfs.DistributedFileSystemOps)1 AlertException (io.hops.hopsworks.exceptions.AlertException)1 CryptoPasswordNotFoundException (io.hops.hopsworks.exceptions.CryptoPasswordNotFoundException)1 DatasetException (io.hops.hopsworks.exceptions.DatasetException)1 ElasticException (io.hops.hopsworks.exceptions.ElasticException)1 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)1 GenericException (io.hops.hopsworks.exceptions.GenericException)1 HopsSecurityException (io.hops.hopsworks.exceptions.HopsSecurityException)1