Package org.apache.sis.setup
Class OptionalInstallations
Object
InstallationResources
OptionalInstallations
- All Implemented Interfaces:
- Localized
- Direct Known Subclasses:
- ResourcesDownloader
A predefined set of data important to Apache SIS but not redistributed for space or licensing reasons.
 This class is in charge of downloading the data if necessary and asking user's agreement before to install them.
 Authorities managed by the current implementation are:
 
- "EPSG"for the EPSG geodetic dataset.
getDownloadURL(String).
 This is useful as a workaround if a URL is no longer accessible.- Since:
- 1.1
Defined in the sis-utility module
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final PathThe target directory where to install the resources, ornullif none.
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedOptionalInstallations(String licenseMimeType) Creates a new installation resources downloader.
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract booleanaskUserAgreement(String authority, String license) Asks to the user if (s)he agree to download and install the resource for the given authority.Returns the names of the authorities providing data that can be installed.getLicense(String authority, Locale locale, String mimeType) Returns the terms of use of the dataset provided by the given authority, ornullif none.Returns the locale to use for messages shown to the user.getResource(String authority, int index) Returns an installation resource for the given authority.String[]getResourceNames(String authority) Returns the names of installation scripts provided by the given authority.intgetSpaceRequirement(String authority) Returns an estimation of the space required on the host computer after download and installation.openScript(String authority, int resource) Returns a reader for the installation script at the given index.Methods inherited from class InstallationResourcesgetInstructionURL
- 
Field Details- 
destinationDirectoryThe target directory where to install the resources, ornullif none. This is the directory specified by theSIS_DATAenvironment variable.
 
- 
- 
Constructor Details- 
OptionalInstallationsCreates a new installation resources downloader.- Parameters:
- licenseMimeType- either- "text/plain"or- "text/html".
 
 
- 
- 
Method Details- 
askUserAgreementAsks to the user if (s)he agree to download and install the resource for the given authority. This method may be invoked twice for the sameauthorityargument:- With a null licenseargument for asking if the user agrees to download the data.
- With a non-null licenseargument for asking if the user agrees with the license terms.
 Design note: the download action needs to be initiated before to ask for license agreement because the license text is bundled in the resource to download.- Parameters:
- authority- one of the authorities returned by- getAuthorities().
- license- the license, or- nullfor asking if the user wants to download the data.
- Returns:
- whether user accepted.
 
- With a null 
- 
getLocaleReturns the locale to use for messages shown to the user. The default implementation returns the system default locale.- Specified by:
- getLocalein interface- Localized
- Returns:
- the locale of messages shown to the user.
 
- 
getAuthoritiesReturns the names of the authorities providing data that can be installed. The default implementation returns the authorities listed in class javadoc, or a subset of those authorities if some of them cannot be installed (for example because theSIS_DATAenvironment variable is not set).- Specified by:
- getAuthoritiesin class- InstallationResources
- Returns:
- authorities of data that can be installed (may be an empty set).
 
- 
getSpaceRequirementReturns an estimation of the space required on the host computer after download and installation. This information can be shown to the user before to ask for confirmation.- Parameters:
- authority- one of the authorities returned by- getAuthorities().
- Returns:
- an estimation of space requirement in megabytes.
- Throws:
- IllegalArgumentException- if the given- authorityargument is not one of the expected values.
 
- 
getLicenseReturns the terms of use of the dataset provided by the given authority, ornullif none. The terms of use can be returned in either plain text or HTML.- Specified by:
- getLicensein class- InstallationResources
- Parameters:
- authority- one of the values returned by- getAuthorities().
- locale- the preferred locale for the terms of use.
- mimeType- either- "text/plain"or- "text/html".
- Returns:
- the terms of use in plain text or HTML, or nullif none.
- Throws:
- IllegalArgumentException- if the given- authorityargument is not one of the expected values.
- IOException- if an error occurred while reading the license file.
 
- 
getResourceNamesReturns the names of installation scripts provided by the given authority. This method is invoked byEPSGFactory.install(Connection)for listing the SQL scripts to execute during EPSG dataset installation.If that question has not already been asked, this method asks to the user if (s)he accepts EPSG terms of use. If (s)he refuses, then an AccessDeniedExceptionwill be thrown.- Specified by:
- getResourceNamesin class- InstallationResources
- Parameters:
- authority- one of the values returned by- getAuthorities().
- Returns:
- the names of all SQL scripts to execute.
- Throws:
- IllegalArgumentException- if the given- authorityargument is not one of the expected values.
- IOException- if an error occurred while fetching the script names.
 
- 
getResourceReturns an installation resource for the given authority. If that question has not already been asked, this method asks to the user if (s)he accepts EPSG terms of use. If (s)he refuses, then anAccessDeniedExceptionwill be thrown.- Overrides:
- getResourcein class- InstallationResources
- Parameters:
- authority- one of the values returned by- getAuthorities().
- index- index of the resource to get, from 0 inclusive to- getResourceNames(authority).lengthexclusive.
- Returns:
- the resource as an URL or any other type, at implementation choice.
- Throws:
- IllegalArgumentException- if the given- authorityargument is not one of the expected values.
- IndexOutOfBoundsException- if the given- resourceargument is out of bounds.
- IOException- if an error occurred while fetching the resource.
- See Also:
 
- 
openScriptReturns a reader for the installation script at the given index. This method is invoked byEPSGFactory.install(Connection)for getting the SQL scripts to execute during EPSG dataset installation.If that question has not already been asked, this method asks to the user if (s)he accepts EPSG terms of use. If (s)he refuses, then an AccessDeniedExceptionwill be thrown.- Specified by:
- openScriptin class- InstallationResources
- Parameters:
- authority- one of the values returned by- getAuthorities().
- resource- index of the script to open, from 0 inclusive to- getResourceNames(authority).lengthexclusive.
- Returns:
- a reader for the installation script content.
- Throws:
- IllegalArgumentException- if the given- authorityargument is not one of the expected values.
- IndexOutOfBoundsException- if the given- resourceargument is out of bounds.
- FileNotFoundException- if the SQL script of the given name has not been found.
- IOException- if an error occurred while creating the reader.
 
 
-