use of io.hops.hopsworks.exceptions.DelaException 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.exceptions.DelaException in project hopsworks by logicalclocks.
the class DelaService method getContentsForUser.
@GET
@Path("/transfers")
@Produces(MediaType.APPLICATION_JSON)
public Response getContentsForUser(@Context SecurityContext sc, @QueryParam("filter") TransfersFilter filter) throws DelaException {
if (!filter.equals(TransfersFilter.USER)) {
throw new DelaException(RESTCodes.DelaErrorCode.ILLEGAL_ARGUMENT, Level.FINE, DelaException.Source.LOCAL, "not handling filter value:" + filter);
}
Users user = jWTHelper.getUserPrincipal(sc);
List<ProjectTeam> teams = projectCtrl.findProjectByUser(user.getEmail());
List<Integer> projectIds = new LinkedList<>();
for (ProjectTeam t : teams) {
projectIds.add(t.getProject().getId());
}
HopsContentsSummaryJSON.Contents resp = delaTransferCtrl.getContents(projectIds);
List<UserContentsSummaryJSON> userContents = new ArrayList<>();
Iterator<Map.Entry<Integer, ElementSummaryJSON[]>> it = resp.getContents().entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Integer, ElementSummaryJSON[]> n = it.next();
userContents.add(new UserContentsSummaryJSON(n.getKey(), n.getValue()));
}
GenericEntity<List<UserContentsSummaryJSON>> userContentsList = new GenericEntity<List<UserContentsSummaryJSON>>(userContents) {
};
return success(userContentsList);
}
use of io.hops.hopsworks.exceptions.DelaException in project hopsworks by logicalclocks.
the class HopssiteController method addComment.
public void addComment(String publicCId, String publicDSId, CommentDTO.Publish comment) throws DelaException {
checkHopssiteReady();
try {
ClientWrapper client = getClient(HopsSite.CommentService.addComment(publicCId, publicDSId), String.class);
LOG.log(Settings.DELA_DEBUG, "hops-site:comment:add {0}", client.getFullPath());
client.setPayload(comment);
client.doPost();
LOG.log(Settings.DELA_DEBUG, "hops-site:comment:add - done {0}", client.getFullPath());
} catch (IllegalStateException ise) {
throw new DelaException(RESTCodes.DelaErrorCode.COMMUNICATION_FAILURE, Level.SEVERE, DelaException.Source.HOPS_SITE, null, ise.getMessage(), ise);
}
}
use of io.hops.hopsworks.exceptions.DelaException in project hopsworks by logicalclocks.
the class HopssiteController method getDatasetAllRating.
// **************************************************RATING PUBLIC*****************************************************
public RatingDTO getDatasetAllRating(String publicDSId) throws DelaException {
checkHopssiteReady();
try {
ClientWrapper client = getClient(HopsSite.RatingService.getDatasetAllRating(publicDSId), RatingDTO.class);
LOG.log(Settings.DELA_DEBUG, "hops-site:rating:get:all - {0}", client.getFullPath());
RatingDTO result = (RatingDTO) client.doGet();
LOG.log(Settings.DELA_DEBUG, "hops-site:rating:get:all - done {0}", client.getFullPath());
return result;
} catch (IllegalStateException ise) {
throw new DelaException(RESTCodes.DelaErrorCode.COMMUNICATION_FAILURE, Level.SEVERE, DelaException.Source.HOPS_SITE, null, ise.getMessage(), ise);
}
}
use of io.hops.hopsworks.exceptions.DelaException in project hopsworks by logicalclocks.
the class HopssiteController method ping.
public void ping(ClusterServiceDTO.Ping ping) throws DelaException {
checkHopssiteReady();
String publicCId = SettingsHelper.clusterId(settings);
try {
ClientWrapper client = getClient(HopsSite.ClusterService.ping(publicCId), String.class);
client.setPayload(ping);
LOG.log(Settings.DELA_DEBUG, "hops-site:cluster - {0}", client.getFullPath());
String result = (String) client.doPut();
LOG.log(Settings.DELA_DEBUG, "hops-site:cluster -done {0}", client.getFullPath());
} catch (IllegalStateException ise) {
throw new DelaException(RESTCodes.DelaErrorCode.COMMUNICATION_FAILURE, Level.SEVERE, DelaException.Source.HOPS_SITE, null, ise.getMessage(), ise);
}
}
Aggregations