Package org.codehaus.mojo.license.utils
Class UrlRequester
java.lang.Object
org.codehaus.mojo.license.utils.UrlRequester
This class should be used to load the content from a URL.
Supported URL protocols are those standards plus classpath protocol.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondownloadList
(String url) will download a external resource and read the content of the file that will then be translated into a new list.static String
findProtocol
(String url) Returns the protocol of the given URL as a string.static String
getFromUrl
(String url) Returns the content of the resource pointed by the given URL as a string.static String
getFromUrl
(String url, String encoding) Returns the content of the resource pointed by the given URL as a string.static boolean
isExternalUrl
(String url) Check if URL point to external resource.static boolean
isStringUrl
(String data) Checks if the given input is a URL value.
-
Field Details
-
CLASSPATH_PROTOCOL
- See Also:
-
-
Constructor Details
-
UrlRequester
public UrlRequester()
-
-
Method Details
-
isStringUrl
Checks if the given input is a URL value.- Parameters:
data
- the license string or a URL- Returns:
- true if URL, false else
-
isExternalUrl
Check if URL point to external resource.- Parameters:
url
- the URL as a string- Returns:
- true if URL use external protocol
-
getFromUrl
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
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
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 textencoding
- 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
-