Search in sources :

Example 6 with DatasetSharedWith

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

the class ProjectService method getDatasetInfo.

@GET
@Path("getDatasetInfo/{inodeId}")
@Produces(MediaType.APPLICATION_JSON)
public Response getDatasetInfo(@PathParam("inodeId") Long inodeId, @Context SecurityContext sc) throws DatasetException {
    Inode inode = inodes.findById(inodeId);
    Project proj = datasetController.getOwningProject(inode);
    Dataset ds = datasetFacade.findByProjectAndInode(proj, inode);
    if (ds == null) {
        throw new DatasetException(RESTCodes.DatasetErrorCode.DATASET_NOT_FOUND, Level.FINE, "inodeId: " + inodeId);
    }
    Collection<DatasetSharedWith> projectsContainingInode = proj.getDatasetSharedWithCollection();
    List<String> sharedWith = new ArrayList<>();
    for (DatasetSharedWith d : projectsContainingInode) {
        if (!d.getProject().getId().equals(proj.getId())) {
            sharedWith.add(d.getProject().getName());
        }
    }
    DataSetDTO dataset = new DataSetDTO(ds, proj, sharedWith);
    return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(dataset).build();
}
Also used : Project(io.hops.hopsworks.persistence.entity.project.Project) Inode(io.hops.hopsworks.persistence.entity.hdfs.inode.Inode) Dataset(io.hops.hopsworks.persistence.entity.dataset.Dataset) DatasetSharedWith(io.hops.hopsworks.persistence.entity.dataset.DatasetSharedWith) ArrayList(java.util.ArrayList) DataSetDTO(io.hops.hopsworks.common.dao.dataset.DataSetDTO) DatasetException(io.hops.hopsworks.exceptions.DatasetException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 7 with DatasetSharedWith

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

the class DatasetController method unshareAll.

public void unshareAll(Dataset dataset, Users user) throws DatasetException {
    List<DatasetSharedWith> shared = datasetSharedWithFacade.findByDataset(dataset);
    DistributedFileSystemOps dfso = null;
    try {
        dfso = dfs.getDfsOps();
        for (DatasetSharedWith s : shared) {
            unshare(dataset.getProject(), user, dataset, s.getProject().getName(), dfso);
        }
    } finally {
        dfs.closeDfsClient(dfso);
    }
}
Also used : DatasetSharedWith(io.hops.hopsworks.persistence.entity.dataset.DatasetSharedWith) DistributedFileSystemOps(io.hops.hopsworks.common.hdfs.DistributedFileSystemOps)

Example 8 with DatasetSharedWith

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

the class DatasetController method updateSharePermission.

public void updateSharePermission(Dataset ds, DatasetAccessPermission datasetPermissions, Project project, String targetProjectName, Users user, DistributedFileSystemOps dfso) throws DatasetException, ProjectException {
    if (ds.isShared(project)) {
        throw new DatasetException(RESTCodes.DatasetErrorCode.DATASET_OWNER_ERROR, Level.FINE);
    }
    if (ds.isPublicDs()) {
        throw new DatasetException(RESTCodes.DatasetErrorCode.DATASET_PUBLIC_IMMUTABLE, Level.FINE);
    }
    Project targetProject = projectFacade.findByName(targetProjectName);
    if (targetProject == null) {
        throw new ProjectException(RESTCodes.ProjectErrorCode.PROJECT_NOT_FOUND, Level.FINE, "Target project not " + "found.");
    }
    DatasetSharedWith datasetSharedWith = datasetSharedWithFacade.findByProjectAndDataset(targetProject, ds);
    if (datasetSharedWith == null) {
        throw new DatasetException(RESTCodes.DatasetErrorCode.DATASET_NOT_SHARED_WITH_PROJECT, Level.FINE, "project: " + targetProject.getName());
    }
    PermissionTransition permissionTransition = PermissionTransition.valueOf(datasetSharedWith.getPermission(), datasetPermissions);
    updateSharePermission(datasetSharedWith, permissionTransition, project, user, dfso);
}
Also used : ProjectException(io.hops.hopsworks.exceptions.ProjectException) Project(io.hops.hopsworks.persistence.entity.project.Project) DatasetSharedWith(io.hops.hopsworks.persistence.entity.dataset.DatasetSharedWith) PermissionTransition(io.hops.hopsworks.persistence.entity.dataset.PermissionTransition) DatasetException(io.hops.hopsworks.exceptions.DatasetException)

Example 9 with DatasetSharedWith

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

the class DatasetController method acceptShared.

public void acceptShared(Project project, Users user, DatasetSharedWith datasetSharedWith) throws DatasetException {
    acceptSharedDs(user, datasetSharedWith);
    if (DatasetType.FEATURESTORE.equals(datasetSharedWith.getDataset().getDsType())) {
        DatasetSharedWith trainingDataset = getOrCreateSharedTrainingDataset(project, datasetSharedWith.getDataset().getProject(), datasetSharedWith.getPermission(), datasetSharedWith.getSharedBy());
        if (trainingDataset != null && !trainingDataset.getAccepted()) {
            try {
                acceptSharedDs(user, trainingDataset);
            } catch (DatasetException de) {
            // Dataset not shared or already accepted nothing to do
            }
        }
        // If we migrate Training Datasets to remove the project prefix, these methods can be reused
        acceptSharedFeatureStoreServiceDataset(project, datasetSharedWith, datasetSharedWith.getPermission(), datasetSharedWith.getSharedBy(), user, Settings.ServiceDataset.STATISTICS);
    }
}
Also used : DatasetSharedWith(io.hops.hopsworks.persistence.entity.dataset.DatasetSharedWith) DatasetException(io.hops.hopsworks.exceptions.DatasetException)

Example 10 with DatasetSharedWith

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

the class DatasetController method getOrCreateSharedFeatureStoreServiceDataset.

private DatasetSharedWith getOrCreateSharedFeatureStoreServiceDataset(Project project, Project parentProject, DatasetAccessPermission permission, Users sharedBy, Settings.ServiceDataset serviceDataset) {
    Dataset dataset = getFeatureStoreServiceDataset(parentProject, serviceDataset);
    DatasetSharedWith sharedDataset = datasetSharedWithFacade.findByProjectAndDataset(project, dataset);
    if (sharedDataset == null) {
        sharedDataset = new DatasetSharedWith(project, dataset, permission, false, sharedBy);
        datasetSharedWithFacade.save(sharedDataset);
        sharedDataset = datasetSharedWithFacade.findByProjectAndDataset(project, dataset);
    }
    return sharedDataset;
}
Also used : Dataset(io.hops.hopsworks.persistence.entity.dataset.Dataset) DatasetSharedWith(io.hops.hopsworks.persistence.entity.dataset.DatasetSharedWith)

Aggregations

DatasetSharedWith (io.hops.hopsworks.persistence.entity.dataset.DatasetSharedWith)28 DatasetException (io.hops.hopsworks.exceptions.DatasetException)12 Dataset (io.hops.hopsworks.persistence.entity.dataset.Dataset)12 Project (io.hops.hopsworks.persistence.entity.project.Project)11 ArrayList (java.util.ArrayList)7 ProjectException (io.hops.hopsworks.exceptions.ProjectException)6 Inode (io.hops.hopsworks.persistence.entity.hdfs.inode.Inode)5 DistributedFileSystemOps (io.hops.hopsworks.common.hdfs.DistributedFileSystemOps)4 PermissionTransition (io.hops.hopsworks.persistence.entity.dataset.PermissionTransition)4 ProjectTeam (io.hops.hopsworks.persistence.entity.project.team.ProjectTeam)3 TransactionAttribute (javax.ejb.TransactionAttribute)3 Path (org.apache.hadoop.fs.Path)3 HopsSecurityException (io.hops.hopsworks.exceptions.HopsSecurityException)2 ServiceException (io.hops.hopsworks.exceptions.ServiceException)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 AccessControlException (org.apache.hadoop.security.AccessControlException)2 Pair (io.hops.common.Pair)1 ModelRegistryDTO (io.hops.hopsworks.api.modelregistry.dto.ModelRegistryDTO)1 ModelsBuilder (io.hops.hopsworks.api.modelregistry.models.ModelsBuilder)1