Search in sources :

Example 1 with DelaException

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);
}
Also used : Dataset(io.hops.hopsworks.persistence.entity.dataset.Dataset) FilePreviewDTO(io.hops.hopsworks.common.dataset.FilePreviewDTO) DelaException(io.hops.hopsworks.exceptions.DelaException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with DelaException

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);
}
Also used : ArrayList(java.util.ArrayList) Users(io.hops.hopsworks.persistence.entity.user.Users) DelaException(io.hops.hopsworks.exceptions.DelaException) LinkedList(java.util.LinkedList) ProjectTeam(io.hops.hopsworks.persistence.entity.project.team.ProjectTeam) GenericEntity(javax.ws.rs.core.GenericEntity) ElementSummaryJSON(io.hops.hopsworks.dela.old_dto.ElementSummaryJSON) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) HopsContentsSummaryJSON(io.hops.hopsworks.dela.old_dto.HopsContentsSummaryJSON) Map(java.util.Map) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with DelaException

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);
    }
}
Also used : DelaException(io.hops.hopsworks.exceptions.DelaException) ClientWrapper(io.hops.hopsworks.common.util.ClientWrapper)

Example 4 with DelaException

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);
    }
}
Also used : RatingDTO(io.hops.hopsworks.dela.dto.hopssite.RatingDTO) DelaException(io.hops.hopsworks.exceptions.DelaException) ClientWrapper(io.hops.hopsworks.common.util.ClientWrapper)

Example 5 with DelaException

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);
    }
}
Also used : DelaException(io.hops.hopsworks.exceptions.DelaException) ClientWrapper(io.hops.hopsworks.common.util.ClientWrapper)

Aggregations

DelaException (io.hops.hopsworks.exceptions.DelaException)62 ClientWrapper (io.hops.hopsworks.common.util.ClientWrapper)31 Users (io.hops.hopsworks.persistence.entity.user.Users)8 Path (javax.ws.rs.Path)8 Gson (com.google.gson.Gson)7 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)7 IOException (java.io.IOException)6 HopsSite (io.hops.hopsworks.dela.hopssite.HopsSite)5 ManifestJSON (io.hops.hopsworks.dela.old_dto.ManifestJSON)5 SuccessJSON (io.hops.hopsworks.dela.old_dto.SuccessJSON)5 Dataset (io.hops.hopsworks.persistence.entity.dataset.Dataset)5 Produces (javax.ws.rs.Produces)5 AddressJSON (io.hops.hopsworks.common.dela.AddressJSON)4 DistributedFileSystemOps (io.hops.hopsworks.common.hdfs.DistributedFileSystemOps)4 TorrentId (io.hops.hopsworks.dela.old_dto.TorrentId)4 LinkedList (java.util.LinkedList)4 GET (javax.ws.rs.GET)4 POST (javax.ws.rs.POST)4 UserDTO (io.hops.hopsworks.dela.dto.common.UserDTO)3 SearchServiceDTO (io.hops.hopsworks.dela.dto.hopssite.SearchServiceDTO)3