Search in sources :

Example 11 with ClientWrapper

use of io.hops.hopsworks.common.util.ClientWrapper 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)

Example 12 with ClientWrapper

use of io.hops.hopsworks.common.util.ClientWrapper in project hopsworks by logicalclocks.

the class HopssiteController method registerUser.

// *****************************************************USER***********************************************************
public int registerUser(String publicCId, String firstname, String lastname, String userEmail) throws DelaException {
    checkHopssiteReady();
    try {
        UserDTO.Publish user = new UserDTO.Publish(firstname, lastname, userEmail);
        ClientWrapper client = getClient(HopsSite.UserService.registerUser(publicCId), String.class);
        client.setPayload(user);
        LOG.log(Settings.DELA_DEBUG, "hops-site:user - {0}", client.getFullPath());
        Integer result = Integer.parseInt((String) client.doPost());
        LOG.log(Settings.DELA_DEBUG, "hops-site:user - 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 : UserDTO(io.hops.hopsworks.dela.dto.common.UserDTO) DelaException(io.hops.hopsworks.exceptions.DelaException) ClientWrapper(io.hops.hopsworks.common.util.ClientWrapper)

Example 13 with ClientWrapper

use of io.hops.hopsworks.common.util.ClientWrapper 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 14 with ClientWrapper

use of io.hops.hopsworks.common.util.ClientWrapper 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 15 with ClientWrapper

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

Aggregations

ClientWrapper (io.hops.hopsworks.common.util.ClientWrapper)31 DelaException (io.hops.hopsworks.exceptions.DelaException)31 Gson (com.google.gson.Gson)3 UserDTO (io.hops.hopsworks.dela.dto.common.UserDTO)3 ClusterServiceDTO (io.hops.hopsworks.dela.dto.hopssite.ClusterServiceDTO)2 HopsSiteDatasetDTO (io.hops.hopsworks.dela.dto.hopssite.HopsSiteDatasetDTO)2 RatingDTO (io.hops.hopsworks.dela.dto.hopssite.RatingDTO)2 SearchServiceDTO (io.hops.hopsworks.dela.dto.hopssite.SearchServiceDTO)2 FilePreviewDTO (io.hops.hopsworks.common.dataset.FilePreviewDTO)1 DatasetDTO (io.hops.hopsworks.dela.dto.hopssite.DatasetDTO)1 List (java.util.List)1