Class HttpRequestUtils

java.lang.Object
com.ultikits.ultitools.utils.HttpRequestUtils

public class HttpRequestUtils extends Object
The UltiCloud base URL, plus the three protected protocol v1 REST calls kept so 6.3.0 subclasses still link.

As of 6.3.1 the base URL (env.yml api-url) is read by the protocol 2.0.0 client, and the v1 calls (/server/getByUUID, /editor/register, /editor/updateServer) send nothing: protocol 2.0.0 has no v1 REST cloud. Each returns a failure response with status -1 (no HTTP exchange happened) and writes one INFO line per run; all three are deprecated for removal in 6.4.0.

Since:
6.0.0
Author:
wisdomme
  • Field Details

    • baseUrl

      private static volatile String baseUrl
      Base URL for the API server (lazy initialized).
    • customBaseUrl

      private static String customBaseUrl
      Custom base URL for testing purposes.
    • NO_EXCHANGE

      private static final int NO_EXCHANGE
      Status of the failure response the removed v1 calls return: no HTTP exchange happened.
      See Also:
    • REFUSED_BODY

      private static final String REFUSED_BODY
      Body of that failure response.
      See Also:
    • NOTICE_LOGGER

      private static final Logger NOTICE_LOGGER
    • GET_SERVER_NOTICE

      private static final AtomicBoolean GET_SERVER_NOTICE
    • REGISTER_NOTICE

      private static final AtomicBoolean REGISTER_NOTICE
    • UPDATE_NOTICE

      private static final AtomicBoolean UPDATE_NOTICE
  • Constructor Details

    • HttpRequestUtils

      public HttpRequestUtils()
  • Method Details

    • getBaseUrl

      static String getBaseUrl()
      Get the base URL for API calls. Uses lazy initialization to avoid requiring UltiTools at class loading time.
      Returns:
      the base URL
    • setBaseUrlForTesting

      static void setBaseUrlForTesting(String url)
      Set a custom base URL for testing purposes. This should only be used in unit tests.
      Parameters:
      url - the custom base URL, or null to reset to default
    • resetBaseUrl

      static void resetBaseUrl()
      Reset the base URL to force re-initialization. This should only be used in unit tests.
    • getServerByUUID

      @Deprecated(since="6.3.1", forRemoval=true) protected static SimpleHttpClient.Response getServerByUUID(String uuid, TokenEntity token)
      Deprecated, for removal: This API element is subject to removal in a future version.
      There is no replacement: a protocol 2.0.0 server is linked with /ulticloud login and identified by its server credential. Removed in 6.4.0.
      Looked up a server by its installation UUID in the protocol v1 cloud. Sends nothing as of 6.3.1.
      Parameters:
      uuid - ignored, nothing is sent
      token - ignored, nothing is sent
      Returns:
      a failure response with status -1 and a body naming the removal
      Scheduled removal version:
      6.4.0
    • registerServer

      @Deprecated(since="6.3.1", forRemoval=true) protected static SimpleHttpClient.Response registerServer(String uuid, String name, int port, String domain, boolean ssl, TokenEntity token)
      Deprecated, for removal: This API element is subject to removal in a future version.
      There is no replacement: /ulticloud login links a protocol 2.0.0 server through the device authorization. Removed in 6.4.0.
      Registered a server with the protocol v1 cloud. Sends nothing as of 6.3.1.
      Parameters:
      uuid - ignored, nothing is sent
      name - ignored, nothing is sent
      port - ignored, nothing is sent
      domain - ignored, nothing is sent
      ssl - ignored, nothing is sent
      token - ignored, nothing is sent
      Returns:
      a failure response with status -1 and a body naming the removal
      Scheduled removal version:
      6.4.0
    • updateServer

      @Deprecated(since="6.3.1", forRemoval=true) protected static SimpleHttpClient.Response updateServer(String uuid, int port, String domain, boolean ssl, TokenEntity token)
      Deprecated, for removal: This API element is subject to removal in a future version.
      There is no replacement: a protocol 2.0.0 server reports its own state over its connection. Removed in 6.4.0.
      Updated a server's address in the protocol v1 cloud. Sends nothing as of 6.3.1.
      Parameters:
      uuid - ignored, nothing is sent
      port - ignored, nothing is sent
      domain - ignored, nothing is sent
      ssl - ignored, nothing is sent
      token - ignored, nothing is sent
      Returns:
      a failure response with status -1 and a body naming the removal
      Scheduled removal version:
      6.4.0
    • refused

      private static SimpleHttpClient.Response refused(AtomicBoolean notice, String method)
      The removed calls' failure response; the first call of each method in a run logs one INFO line.
    • resetV1NoticeForTesting

      static void resetV1NoticeForTesting()
      Test-only: forgets that this run already logged each removed call's INFO line.