use of io.hops.hopsworks.dela.old_dto.ElementSummaryJSON 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.dela.old_dto.ElementSummaryJSON in project hopsworks by logicalclocks.
the class TransferDelaController method getContents.
/**
* @return <upldDS, dwnlDS>
*/
public Pair<List<String>, List<String>> getContents() throws DelaException {
if (!delaStateController.transferDelaAvailable()) {
throw new DelaException(RESTCodes.DelaErrorCode.DELA_TRANSFER_NOT_AVAILABLE, Level.SEVERE, DelaException.Source.LOCAL);
}
HopsContentsSummaryJSON.Contents contents = TransferDelaController.this.getContents(new LinkedList<>());
List<String> upldDSIds = new LinkedList<>();
List<String> dwnlDSIds = new LinkedList<>();
for (ElementSummaryJSON[] ea : contents.getContents().values()) {
for (ElementSummaryJSON e : ea) {
if (e.getTorrentStatus().toLowerCase().equals("uploading")) {
upldDSIds.add(e.getTorrentId().getVal());
} else if (e.getTorrentStatus().toLowerCase().equals("downloading")) {
dwnlDSIds.add(e.getTorrentId().getVal());
}
}
}
return Pair.with(upldDSIds, dwnlDSIds);
}
Aggregations