Class IdmRestClient


  • public class IdmRestClient
    extends Object
    • Field Detail

      • logger

        protected static org.slf4j.Logger logger
      • BASE_URL

        protected URI BASE_URL
    • Method Detail

      • getBASE_URL

        public URI getBASE_URL()
      • setBASE_URL

        public void setBASE_URL​(URI bASE_URL)
      • bearerAuth

        public static String bearerAuth​(String token)
      • performGetRequest

        public <T> ResponseBean<T> performGetRequest​(String relativeUrl,
                                                     String auth_token,
                                                     Class<T> classtype)
        perform a get request. argument type as classtype (TheClass.class)
        Type Parameters:
        T -
        Parameters:
        relativeUrl -
        auth_token -
        classtype -
        Returns:
      • performGetRequest

        public <T> ResponseBean<T> performGetRequest​(String relativeUrl,
                                                     Map<String,​String> headers,
                                                     Map<String,​String> params,
                                                     Class<T> classtype)
                                              throws jakarta.ws.rs.NotAuthorizedException,
                                                     jakarta.ws.rs.BadRequestException
        Throws:
        jakarta.ws.rs.NotAuthorizedException
        jakarta.ws.rs.BadRequestException
      • performGetRequest

        public <T> ResponseBean<T> performGetRequest​(String relativeUrl,
                                                     String auth_token,
                                                     org.gcube.com.fasterxml.jackson.databind.JavaType objectsType)
                                              throws jakarta.ws.rs.NotAuthorizedException,
                                                     jakarta.ws.rs.BadRequestException
        perform a get request. argument type as JavaType ( => JavaType objectsType = JsonUtilsCustom.getObjectJT(TheClass.class) ) when you have a composed java tape from genrics (es HashMap) use the JsonUtilsCustom methods to obtain the relative JavaType
        Parameters:
        auth_token -
        headers - // null to create a new HashMap
        Returns:
        Throws:
        jakarta.ws.rs.NotAuthorizedException
        jakarta.ws.rs.BadRequestException
      • performGetRequest

        public <T> ResponseBean<T> performGetRequest​(String relativeUrl,
                                                     Map<String,​String> headers,
                                                     Map<String,​String> params,
                                                     org.gcube.com.fasterxml.jackson.databind.JavaType objectsType)
                                              throws jakarta.ws.rs.NotAuthorizedException,
                                                     jakarta.ws.rs.BadRequestException
        Throws:
        jakarta.ws.rs.NotAuthorizedException
        jakarta.ws.rs.BadRequestException
      • performPostRequest

        public <T> ResponseBean<T> performPostRequest​(String relativeUrl,
                                                      Map<String,​String> headers,
                                                      Map<String,​List<String>> params,
                                                      Class<T> classtype)
                                               throws jakarta.ws.rs.NotAuthorizedException,
                                                      jakarta.ws.rs.BadRequestException
        Throws:
        jakarta.ws.rs.NotAuthorizedException
        jakarta.ws.rs.BadRequestException
      • safeSetAsExternalCallForOldAPI

        public static void safeSetAsExternalCallForOldAPI​(org.gcube.common.gxrest.request.GXHTTPStringRequest request)
      • getStreamedContentAsString

        public static String getStreamedContentAsString​(HttpURLConnection response)
                                                 throws IOException
        Gets the streamed content as a string, if possible.
        Returns:
        the content
        Throws:
        IOException - if unable to read the content
      • tryConvertStreamedContentFromJson

        public static <T> T tryConvertStreamedContentFromJson​(HttpURLConnection response,
                                                              Class<T> classtype)
                                                       throws IOException,
                                                              Exception
        Tries to convert the content from its Json serialization, if possible.
        Type Parameters:
        T - the type of the desired object
        Returns:
        an object of type T from the content
        Throws:
        IOException
        Exception - if the deserialization fails
      • tryConvertStreamedContentFromJson

        public static <T> T tryConvertStreamedContentFromJson​(org.gcube.common.gxrest.response.inbound.GXInboundResponse response,
                                                              org.gcube.com.fasterxml.jackson.databind.JavaType objectType)
                                                       throws IOException,
                                                              Exception
        Throws:
        IOException
        Exception
      • tryConvertStreamedContentFromJson

        public static <T> T tryConvertStreamedContentFromJson​(org.gcube.common.gxrest.response.inbound.GXInboundResponse response,
                                                              Class<T> classtype)
                                                       throws IOException,
                                                              Exception
        Throws:
        IOException
        Exception
      • preparePostRequest

        public static org.gcube.common.gxrest.request.GXHTTPStringRequest preparePostRequest​(URL url,
                                                                                             Map<String,​String> headers,
                                                                                             Map<String,​List<String>> params)
                                                                                      throws jakarta.ws.rs.BadRequestException
        Throws:
        jakarta.ws.rs.BadRequestException
      • prepareGetRequest

        public static org.gcube.common.gxrest.request.GXHTTPStringRequest prepareGetRequest​(URL url,
                                                                                            Map<String,​String> headers,
                                                                                            Map<String,​String> params)
                                                                                     throws jakarta.ws.rs.BadRequestException
        Throws:
        jakarta.ws.rs.BadRequestException