Search in sources :

Example 16 with DelaException

use of io.hops.hopsworks.exceptions.DelaException in project hopsworks by logicalclocks.

the class HopssiteController method updateRating.

public boolean updateRating(RateDTO datasetRating) throws DelaException {
    checkHopssiteReady();
    try {
        ClientWrapper client = getClient(HopsSite.RatingService.rating(), String.class);
        client.setPayload(datasetRating);
        String res = (String) client.doPut();
        return "OK".equals(res);
    } 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 17 with DelaException

use of io.hops.hopsworks.exceptions.DelaException in project hopsworks by logicalclocks.

the class HopssiteController method delaVersion.

// *************************************************HEARTBEAT**********************************************************
public String delaVersion() throws DelaException {
    checkSetupReady();
    try {
        ClientWrapper client = getClient(HopsSite.ClusterService.delaVersion(), String.class);
        LOG.log(Settings.DELA_DEBUG, "hops-site:cluster - {0}", client.getFullPath());
        String result = (String) client.doGet();
        LOG.log(Settings.DELA_DEBUG, "hops-site:cluster - 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 : DelaException(io.hops.hopsworks.exceptions.DelaException) ClientWrapper(io.hops.hopsworks.common.util.ClientWrapper)

Example 18 with DelaException

use of io.hops.hopsworks.exceptions.DelaException in project hopsworks by logicalclocks.

the class HopssiteController method updateUser.

// *************************************************SETTINGS CHECK*****************************************************
public boolean updateUser(UserDTO.Publish userDTO) throws DelaException {
    checkHopssiteReady();
    try {
        ClientWrapper client = getClient(HopsSite.UserService.user(), String.class);
        client.setPayload(userDTO);
        String res = (String) client.doPut();
        return "OK".equals(res);
    } 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 19 with DelaException

use of io.hops.hopsworks.exceptions.DelaException in project hopsworks by logicalclocks.

the class HopssiteController method getDatasetAllComments.

// ***********************************************COMMENT PUBLIC*******************************************************
public List<CommentDTO.RetrieveComment> getDatasetAllComments(String publicDSId) throws DelaException {
    checkHopssiteReady();
    try {
        ClientWrapper client = getClient(HopsSite.CommentService.getDatasetAllComments(publicDSId), String.class);
        LOG.log(Settings.DELA_DEBUG, "hops-site:comment:get:all {0}", client.getFullPath());
        String aux = (String) client.doGet();
        CommentDTO.RetrieveComment[] result = new Gson().fromJson(aux, CommentDTO.RetrieveComment[].class);
        LOG.log(Settings.DELA_DEBUG, "hops-site:comment:get:all - done {0}", client.getFullPath());
        return Arrays.asList(result);
    } catch (IllegalStateException ise) {
        throw new DelaException(RESTCodes.DelaErrorCode.COMMUNICATION_FAILURE, Level.SEVERE, DelaException.Source.HOPS_SITE, null, ise.getMessage(), ise);
    }
}
Also used : Gson(com.google.gson.Gson) DelaException(io.hops.hopsworks.exceptions.DelaException) ClientWrapper(io.hops.hopsworks.common.util.ClientWrapper)

Example 20 with DelaException

use of io.hops.hopsworks.exceptions.DelaException in project hopsworks by logicalclocks.

the class ManifestHelper method marshall.

public static byte[] marshall(ManifestJSON manifest) throws DelaException {
    Gson gson = new GsonBuilder().create();
    String jsonString = gson.toJson(manifest);
    byte[] jsonByte;
    try {
        jsonByte = jsonString.getBytes("UTF-8");
    } catch (UnsupportedEncodingException ex) {
        throw new DelaException(RESTCodes.DelaErrorCode.MANIFEST_ENCODING_ERROR, Level.SEVERE, DelaException.Source.LOCAL, null, ex.getMessage(), ex);
    }
    return jsonByte;
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) UnsupportedEncodingException(java.io.UnsupportedEncodingException) DelaException(io.hops.hopsworks.exceptions.DelaException)

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