Search in sources :

Example 1 with RepositoryStatus

use of io.hops.hopsworks.common.jupyter.RepositoryStatus in project hopsworks by logicalclocks.

the class JupyterService method getGitStatusOfJupyterRepo.

@GET
@Path("/git/status")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER, AllowedProjectRoles.DATA_SCIENTIST })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response getGitStatusOfJupyterRepo(@Context SecurityContext sc) throws ProjectException, ServiceException {
    Users user = jWTHelper.getUserPrincipal(sc);
    String projectUser = hdfsUsersController.getHdfsUserName(project, user);
    JupyterProject jupyterProject = jupyterFacade.findByUser(projectUser);
    if (jupyterProject == null) {
        throw new ProjectException(RESTCodes.ProjectErrorCode.JUPYTER_SERVER_NOT_FOUND, Level.FINE, "Could not found Jupyter server", "Could not found Jupyter server for Hopsworks user: " + projectUser);
    }
    if (!jupyterManager.ping(jupyterProject)) {
        throw new ServiceException(RESTCodes.ServiceErrorCode.JUPYTER_SERVERS_NOT_RUNNING, Level.FINE, "Jupyter server is not running", "Jupyter server for Hopsworks user: " + projectUser + " is not running");
    }
    JupyterSettings jupyterSettings = jupyterSettingsFacade.findByProjectUser(project, user.getEmail());
    RepositoryStatus status = NullJupyterNbVCSController.EMPTY_REPOSITORY_STATUS;
    if (jupyterSettings.isGitBackend()) {
        status = jupyterNbVCSController.status(jupyterProject, jupyterSettings);
    }
    return Response.ok(status).build();
}
Also used : ProjectException(io.hops.hopsworks.exceptions.ProjectException) ServiceException(io.hops.hopsworks.exceptions.ServiceException) JupyterSettings(io.hops.hopsworks.persistence.entity.jupyter.JupyterSettings) RepositoryStatus(io.hops.hopsworks.common.jupyter.RepositoryStatus) JupyterProject(io.hops.hopsworks.persistence.entity.jupyter.JupyterProject) HdfsUsers(io.hops.hopsworks.persistence.entity.hdfs.user.HdfsUsers) Users(io.hops.hopsworks.persistence.entity.user.Users) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Aggregations

AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)1 RepositoryStatus (io.hops.hopsworks.common.jupyter.RepositoryStatus)1 ProjectException (io.hops.hopsworks.exceptions.ProjectException)1 ServiceException (io.hops.hopsworks.exceptions.ServiceException)1 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)1 HdfsUsers (io.hops.hopsworks.persistence.entity.hdfs.user.HdfsUsers)1 JupyterProject (io.hops.hopsworks.persistence.entity.jupyter.JupyterProject)1 JupyterSettings (io.hops.hopsworks.persistence.entity.jupyter.JupyterSettings)1 Users (io.hops.hopsworks.persistence.entity.user.Users)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1