Search in sources :

Example 1 with Dataset

use of io.hops.hopsworks.persistence.entity.dataset.Dataset in project hopsworks by logicalclocks.

the class DatasetAccessController method accessorProjects.

private void accessorProjects(Users user, DatasetDetails datasetDetails, ProjectsCollector collector, ShortLivedCache cache) {
    // <project, userProjectRole>
    Pair<Project, String> projectAux = getProjectWithCache(user, datasetDetails.getParentProjectId(), cache);
    // check if parent project and parent dataset still exist or is this a stale item
    if (projectAux == null) {
        LOGGER.log(Level.FINE, "parent project of item - not found - probably stale item:{0}", datasetDetails);
        return;
    }
    Dataset dataset = getDatasetWithCache(projectAux.getValue0(), datasetDetails.getParentDatasetIId(), cache);
    if (dataset == null) {
        LOGGER.log(Level.FINE, "parent dataset of item - not found - probably stale item:{0}", datasetDetails);
        return;
    }
    // check parent project for access
    if (projectAux.getValue1() != null) {
        collector.addAccessProject(projectAux.getValue0());
    }
    // check shared datasets for access
    checkSharedDatasetsAccess(user, dataset, collector, cache);
}
Also used : Project(io.hops.hopsworks.persistence.entity.project.Project) Dataset(io.hops.hopsworks.persistence.entity.dataset.Dataset)

Example 2 with Dataset

use of io.hops.hopsworks.persistence.entity.dataset.Dataset in project hopsworks by logicalclocks.

the class DelaProjectService method publish.

@POST
@Path("/uploads")
@Produces(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_OWNER })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response publish(@Context SecurityContext sc, InodeIdDTO inodeId) throws DelaException {
    Inode inode = getInode(inodeId.getId());
    Dataset dataset = getDatasetByInode(inode);
    Users user = jWTHelper.getUserPrincipal(sc);
    delaWorkerCtrl.shareDatasetWithHops(project, dataset, user);
    RESTApiJsonResponse json = new RESTApiJsonResponse();
    json.setSuccessMessage("Dataset transfer is started - published");
    return successResponse(json);
}
Also used : Inode(io.hops.hopsworks.persistence.entity.hdfs.inode.Inode) Dataset(io.hops.hopsworks.persistence.entity.dataset.Dataset) RESTApiJsonResponse(io.hops.hopsworks.api.util.RESTApiJsonResponse) Users(io.hops.hopsworks.persistence.entity.user.Users) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Example 3 with Dataset

use of io.hops.hopsworks.persistence.entity.dataset.Dataset in project hopsworks by logicalclocks.

the class DelaProjectService method downloadDatasetHdfs.

@POST
@Path("/downloads/{publicDSId}/hdfs")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@AllowedProjectRoles({ AllowedProjectRoles.DATA_SCIENTIST, AllowedProjectRoles.DATA_OWNER })
@JWTRequired(acceptedTokens = { Audience.API }, allowedUserRoles = { "HOPS_ADMIN", "HOPS_USER" })
public Response downloadDatasetHdfs(@Context SecurityContext sc, @PathParam("publicDSId") String publicDSId, HopsworksTransferDTO.Download downloadDTO) throws DelaException {
    Users user = jWTHelper.getUserPrincipal(sc);
    Dataset dataset = getDatasetByPublicId(downloadDTO.getPublicDSId());
    delaWorkerCtrl.advanceDownload(project, dataset, user, downloadDTO, null, null);
    return successResponse(new SuccessJSON(""));
}
Also used : Dataset(io.hops.hopsworks.persistence.entity.dataset.Dataset) SuccessJSON(io.hops.hopsworks.dela.old_dto.SuccessJSON) Users(io.hops.hopsworks.persistence.entity.user.Users) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) JWTRequired(io.hops.hopsworks.jwt.annotation.JWTRequired) AllowedProjectRoles(io.hops.hopsworks.api.filter.AllowedProjectRoles)

Example 4 with Dataset

use of io.hops.hopsworks.persistence.entity.dataset.Dataset in project hopsworks by logicalclocks.

the class RemoteDelaService method readme.

@GET
@Path("/datasets/{publicDSId}/readme")
@Produces(MediaType.APPLICATION_JSON)
public Response readme(@PathParam("publicDSId") String publicDSId, @Context SecurityContext sc) throws DelaException {
    LOGGER.log(Settings.DELA_DEBUG, "remote:dela:readme {0}", publicDSId);
    Optional<Dataset> dataset = datasetFacade.findByPublicDsId(publicDSId);
    if (!dataset.isPresent() || !dataset.get().isPublicDs()) {
        throw new DelaException(RESTCodes.DelaErrorCode.DATASET_DOES_NOT_EXIST, Level.FINE, DelaException.Source.REMOTE_DELA);
    }
    FilePreviewDTO result = hdfsDelaCtrl.getPublicReadme(dataset.get());
    LOGGER.log(Settings.DELA_DEBUG, "remote:dela:readme - done {0}", publicDSId);
    return success(result);
}
Also used : Dataset(io.hops.hopsworks.persistence.entity.dataset.Dataset) FilePreviewDTO(io.hops.hopsworks.common.dataset.FilePreviewDTO) DelaException(io.hops.hopsworks.exceptions.DelaException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with Dataset

use of io.hops.hopsworks.persistence.entity.dataset.Dataset in project hopsworks by logicalclocks.

the class ElasticHitsBuilder method buildElasticInodes.

public void buildElasticInodes(SearchHit hit, ElasticInodeDTO elasticInodeDTO) {
    ElasticInodeDTO item = new ElasticInodeDTO();
    item.setMap(hit.getSourceAsMap());
    item.setScore(hit.getScore());
    item.setInodeId(Long.parseLong(hit.getId()));
    item.setParentDatasetIId(getLongValue(hit, "dataset_id"));
    item.setParentProjectId(getIntValue(hit, "project_id"));
    item.setName(getStringValue(hit, "name"));
    item.setCreator(getStringValue(hit, "user"));
    item.setDescription(getStringValue(hit, "description"));
    item.setSize(getLongValue(hit, "size"));
    item.setHighlights(hit.getHighlightFields());
    if (elasticInodeDTO.getItems() == null) {
        elasticInodeDTO.setItems(new ArrayList<>());
    }
    if (item.getParentDatasetIId() != null) {
        Dataset dataset = datasetController.getDatasetByInodeId(item.getParentDatasetIId());
        if (dataset != null) {
            item.setParentDatasetId(dataset.getId());
            item.setParentDatasetName(dataset.getName());
            item.setModificationTime(new Date(dataset.getInode().getModificationTime().longValue()));
        }
    }
    if (item.getInodeId() != null) {
        Inode inode = inodeFacade.findById(item.getInodeId());
        if (inode != null) {
            item.setPath(inodeController.getPath(inode));
        }
    }
    item.setCreator(setUserName(item.getCreator()));
    elasticInodeDTO.getItems().add(item);
}
Also used : Inode(io.hops.hopsworks.persistence.entity.hdfs.inode.Inode) Dataset(io.hops.hopsworks.persistence.entity.dataset.Dataset) Date(java.util.Date)

Aggregations

Dataset (io.hops.hopsworks.persistence.entity.dataset.Dataset)63 DatasetException (io.hops.hopsworks.exceptions.DatasetException)20 Project (io.hops.hopsworks.persistence.entity.project.Project)19 Inode (io.hops.hopsworks.persistence.entity.hdfs.inode.Inode)18 Path (javax.ws.rs.Path)14 Produces (javax.ws.rs.Produces)13 DatasetSharedWith (io.hops.hopsworks.persistence.entity.dataset.DatasetSharedWith)12 Users (io.hops.hopsworks.persistence.entity.user.Users)12 ArrayList (java.util.ArrayList)11 DistributedFileSystemOps (io.hops.hopsworks.common.hdfs.DistributedFileSystemOps)10 Path (org.apache.hadoop.fs.Path)10 IOException (java.io.IOException)9 ProjectException (io.hops.hopsworks.exceptions.ProjectException)8 GET (javax.ws.rs.GET)8 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)7 DatasetPath (io.hops.hopsworks.common.dataset.util.DatasetPath)7 GenericException (io.hops.hopsworks.exceptions.GenericException)7 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)7 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)6 POST (javax.ws.rs.POST)6