use of io.hops.hopsworks.persistence.entity.dataset.DatasetSharedWith in project hopsworks by logicalclocks.
the class DatasetController method getByProjectAndFullPath.
public Dataset getByProjectAndFullPath(Project project, String fullPath) throws DatasetException {
Inode inode = inodeController.getInodeAtPath(fullPath);
if (project == null || inode == null) {
throw new DatasetException(RESTCodes.DatasetErrorCode.DATASET_NOT_FOUND, Level.FINE, "path: " + fullPath);
}
Dataset dataset = datasetFacade.findByProjectAndInode(project, inode);
if (dataset == null) {
// not owned by project check shared
dataset = datasetFacade.findByInode(inode);
if (dataset == null) {
throw new DatasetException(RESTCodes.DatasetErrorCode.DATASET_NOT_FOUND, Level.FINE, "path: " + fullPath);
}
DatasetSharedWith datasetSharedWith = datasetSharedWithFacade.findByProjectAndDataset(project, dataset);
if (datasetSharedWith == null) {
throw new DatasetException(RESTCodes.DatasetErrorCode.DATASET_NOT_FOUND, Level.FINE, "path: " + fullPath);
}
return datasetSharedWith.getDataset();
}
return dataset;
}
use of io.hops.hopsworks.persistence.entity.dataset.DatasetSharedWith in project hopsworks by logicalclocks.
the class ProjectController method getProjectByName.
/**
* Project info as data transfer object that can be sent to the user.
*
* @param name
* @return project DTO that contains team members and services
*/
public ProjectDTO getProjectByName(String name) throws ProjectException {
// find the project entity from hopsworks database
Project project = projectFacade.findByName(name);
if (project == null) {
throw new ProjectException(RESTCodes.ProjectErrorCode.PROJECT_NOT_FOUND, Level.FINE, "project: " + name);
}
// find the project as an inode from hops database
Inode inode = inodeController.getInodeAtPath(Utils.getProjectPath(name));
List<ProjectTeam> projectTeam = projectTeamFacade.findMembersByProject(project);
List<ProjectServiceEnum> projectServices = projectServicesFacade.findEnabledServicesForProject(project);
List<String> services = new ArrayList<>();
for (ProjectServiceEnum s : projectServices) {
services.add(s.toString());
}
Inode parent;
List<InodeView> kids = new ArrayList<>();
Collection<Dataset> dsInProject = project.getDatasetCollection();
Collection<DatasetSharedWith> dsSharedWithProject = project.getDatasetSharedWithCollection();
for (Dataset ds : dsInProject) {
parent = inodes.findParent(ds.getInode());
kids.add(new InodeView(parent, ds, inodeController.getPath(ds.getInode())));
}
for (DatasetSharedWith ds : dsSharedWithProject) {
parent = inodes.findParent(ds.getDataset().getInode());
kids.add(new InodeView(parent, ds, inodeController.getPath(ds.getDataset().getInode())));
}
// send the project back to client
return new ProjectDTO(project, inode.getId(), services, projectTeam, kids, projectUtils.dockerImageIsPreinstalled(project.getDockerImage()), projectUtils.isOldDockerImage(project.getDockerImage()));
}
use of io.hops.hopsworks.persistence.entity.dataset.DatasetSharedWith in project hopsworks by logicalclocks.
the class ProjectController method fixSharedDatasets.
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
private void fixSharedDatasets(Project project, DistributedFileSystemOps dfso) throws IOException {
List<DatasetSharedWith> sharedDataSets = datasetSharedWithFacade.findByProject(project);
for (DatasetSharedWith dataSet : sharedDataSets) {
String owner = dataSet.getDataset().getInode().getHdfsUser().getName();
String group = dataSet.getDataset().getInode().getHdfsGroup().getName();
List<Inode> children = new ArrayList<>();
inodeController.getAllChildren(dataSet.getDataset().getInode(), children);
for (Inode child : children) {
if (child.getHdfsUser().getName().startsWith(project.getName() + "__")) {
Path childPath = new Path(inodeController.getPath(child));
dfso.setOwner(childPath, owner, group);
}
}
}
}
Aggregations