use of io.hops.hopsworks.common.dataset.FilePreviewDTO 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);
}
use of io.hops.hopsworks.common.dataset.FilePreviewDTO in project hopsworks by logicalclocks.
the class DelaHdfsController method getPublicReadme.
public FilePreviewDTO getPublicReadme(Dataset dataset) throws DelaException {
LOGGER.log(Settings.DELA_DEBUG, "dela:hdfs:readme");
DistributedFileSystemOps dfso = dfs.getDfsOps();
FilePreviewDTO result = new FilePreviewDTO("text", "md", new String(read(dfso, readmePath(dataset))));
LOGGER.log(Settings.DELA_DEBUG, "dela:hdfs:readme");
return result;
}
use of io.hops.hopsworks.common.dataset.FilePreviewDTO in project hopsworks by logicalclocks.
the class RemoteDelaController method readme.
// ********************************************************************************************************************
public FilePreviewDTO readme(String publicDSId, ClusterAddressDTO source) throws DelaException {
checkReady();
try {
ClientWrapper client = getClient(source.getDelaClusterAddress(), Path.readme(publicDSId), FilePreviewDTO.class);
LOGGER.log(Settings.DELA_DEBUG, "dela:cross:readme {0}", client.getFullPath());
FilePreviewDTO result = (FilePreviewDTO) client.doGet();
LOGGER.log(Settings.DELA_DEBUG, "dela:cross:readme:done {0}", client.getFullPath());
return result;
} catch (IllegalStateException ex) {
throw new DelaException(RESTCodes.DelaErrorCode.COMMUNICATION_FAILURE, Level.SEVERE, DelaException.Source.REMOTE_DELA, null, ex.getMessage(), ex);
}
}
use of io.hops.hopsworks.common.dataset.FilePreviewDTO in project hopsworks by logicalclocks.
the class ProjectService method getReadmeByInodeId.
@GET
@Path("/readme/byInodeId/{inodeId}")
@Produces(MediaType.APPLICATION_JSON)
public Response getReadmeByInodeId(@PathParam("inodeId") Long inodeId, @Context SecurityContext sc) throws DatasetException {
if (inodeId == null) {
throw new IllegalArgumentException("No inodeId provided.");
}
Inode inode = inodes.findById(inodeId);
Inode parent = inodes.findParent(inode);
Project proj = projectFacade.findByName(parent.getInodePK().getName());
Dataset ds = datasetFacade.findByProjectAndInode(proj, inode);
if (ds != null && !ds.isSearchable()) {
throw new DatasetException(RESTCodes.DatasetErrorCode.README_NOT_ACCESSIBLE, Level.FINE);
}
DistributedFileSystemOps dfso = dfs.getDfsOps();
FilePreviewDTO filePreviewDTO;
String path = inodeController.getPath(inode);
try {
filePreviewDTO = datasetController.getReadme(path + "/README.md", dfso);
} catch (IOException ex) {
filePreviewDTO = new FilePreviewDTO();
filePreviewDTO.setContent("No README file found for this dataset.");
return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(filePreviewDTO).build();
}
return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(filePreviewDTO).build();
}
Aggregations