Class HttpRequestUtils

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

public class HttpRequestUtils extends Object
Utility class for HTTP request operations. Provides methods for communicating with the UltiPanel API server. This class handles authentication, server registration, and server updates.
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.
  • 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

      protected static SimpleHttpClient.Response getServerByUUID(String uuid, TokenEntity token)
      Get server information by UUID from the API server.
      Parameters:
      uuid - the unique identifier of the server
      token - the authentication token
      Returns:
      HttpResponse containing the server information
    • registerServer

      protected static SimpleHttpClient.Response registerServer(String uuid, String name, int port, String domain, boolean ssl, TokenEntity token)
      Register a new server with the API server.
      Parameters:
      uuid - the unique identifier for the server
      name - the display name for the server
      port - the port number of the server
      domain - the domain name of the server
      ssl - whether SSL is enabled
      token - the authentication token
      Returns:
      HttpResponse containing the registration result
    • updateServer

      protected static SimpleHttpClient.Response updateServer(String uuid, int port, String domain, boolean ssl, TokenEntity token)
      Update an existing server on the API server.
      Parameters:
      uuid - the unique identifier of the server
      port - the new port number
      domain - the new domain name
      ssl - whether SSL is enabled
      token - the authentication token
      Returns:
      HttpResponse containing the update result