Class UrlRequester

java.lang.Object
org.codehaus.mojo.license.utils.UrlRequester

public class UrlRequester extends Object
This class should be used to load the content from a URL.

Supported URL protocols are those standards plus classpath protocol.

  • Field Details

  • Constructor Details

    • UrlRequester

      public UrlRequester()
  • Method Details

    • isStringUrl

      public static boolean isStringUrl(String data)
      Checks if the given input is a URL value.
      Parameters:
      data - the license string or a URL
      Returns:
      true if URL, false else
    • isExternalUrl

      public static boolean isExternalUrl(String url)
      Check if URL point to external resource.
      Parameters:
      url - the URL as a string
      Returns:
      true if URL use external protocol
    • getFromUrl

      public static String getFromUrl(String url) throws IOException
      Returns the content of the resource pointed by the given URL as a string.
      Parameters:
      url - the resource destination that is expected to contain pure text
      Returns:
      the string representation of the resource at the given URL
      Throws:
      IOException - If an I/O error occurs when retrieve of the content URL
    • findProtocol

      public static String findProtocol(String url)
      Returns the protocol of the given URL as a string. The RFC specifies that the url is composed by :invalid input: '<'schema-part>.
      Parameters:
      url - the URL as a string.
      Returns:
      the protocol from the URL.
    • getFromUrl

      public static String getFromUrl(String url, String encoding) throws IOException
      Returns the content of the resource pointed by the given URL as a string.
      Parameters:
      url - the resource destination that is expected to contain pure text
      encoding - the resource content encoding
      Returns:
      the string representation of the resource at the given URL
      Throws:
      IOException - If an I/O error occurs when retrieve of the content URL
    • downloadList

      public static List<String> downloadList(String url) throws org.apache.maven.plugin.MojoExecutionException
      will download a external resource and read the content of the file that will then be translated into a new list.
      Lines starting with the character '#' will be omitted from the list

      NOTE:
      certificate checking for this request will be disabled because some resources might be present on some local servers in the internal network that do not use a safe connection
      Parameters:
      url - the URL to the external resource
      Returns:
      a new list with all license entries from the remote resource
      Throws:
      org.apache.maven.plugin.MojoExecutionException