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();
}
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);
}
}
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);
}
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);
}
}
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;
}
Aggregations