Package org.apache.sis.setup
Class InstallationResources
Object
InstallationResources
- Direct Known Subclasses:
- InstallationScriptProvider,- OptionalInstallations
Resources needed for installation of third-party or optional components.
 
   
 In order to allow those classes to discover which resources are available,
 
InstallationResources can be used for downloading large files that may not be of interest
 to every users, or data that are subject to more restricting terms of use than the Apache license.
 Examples:
 Some authorities implemented in Apache SIS modules are listed below.
 In this list, - The NADCON grid files provide datum shifts data for North America. Since those files are in the public domain, they could be bundled in Apache SIS. But the weight of those files (about 2.4 Mb) is unnecessary for users who do not live in North America.
- On the other hand, the EPSG geodetic dataset is important for most users.
     Codes like "EPSG:4326"became a de-facto standard in various places like Web Map Services, images encoded in GeoTIFF format, etc. But the EPSG terms of use are more restrictive than the Apache license and require that we inform the users about those conditions.
"Embedded" is a pseudo-authority for an embedded database containing EPSG and other data.
 The embedded database is provided as a convenience for avoiding the need to define a SIS_DATA directory
 on the local machine.
 | Authority | Provided by Maven module | Used by class | 
|---|---|---|
| "EPSG" | org.apache.sis.non-free:sis-epsg | EPSGFactory | 
| "Embedded" | org.apache.sis.non-free:sis-embedded-data | All the above | 
InstallationResources implementations shall be declared in the following file:
 Above registration is usually done automatically when extension modules are added on the classpath. For example, adding theMETA-INF/services/org.apache.sis.setup.InstallationResources
org.apache.sis.non-free:sis-epsg Maven dependency as documented on
 the Apache SIS web site is the only step needed for
 allowing Apache SIS to read the EPSG scripts (however SIS still needs an installation directory
 for writing the database; see above-cited web page for more information).- Since:
- 0.7
Defined in the sis-utility module
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionReturns identifiers of the resources provided by this instance.Returns a URL where users can get more information about the installation process.abstract StringgetLicense(String authority, Locale locale, String mimeType) Returns the terms of use of the resources distributed by the specified authority, ornullif none.getResource(String authority, int index) Returns an installation resource for the given authority, ornullif not available.abstract String[]getResourceNames(String authority) Returns the names of all resources of the specified authority that are distributed by this instance.abstract BufferedReaderopenScript(String authority, int resource) Returns a reader for the resources at the given index.
- 
Constructor Details- 
InstallationResourcesprotected InstallationResources()For subclass constructors.
 
- 
- 
Method Details- 
getAuthoritiesReturns identifiers of the resources provided by this instance. The values recognized by SIS are listed below (note that this list may be expanded in any future SIS versions):Authorities supported by Apache SIS Authority Resources "EPSG"SQL installation scripts for EPSG geodetic dataset. "Embedded"Data source of embedded database containing EPSG and other resources. Note:This method may return an empty set if this"Embedded"is a pseudo-authority for an embedded database containing EPSG and other data. This embedded database is provided by theorg.apache.sis.non-free:sis-embedded-datamodule as a convenience for avoiding the need to define aSIS_DATAdirectory on the local machine. In this particular case, the resource is more for execution than for installation.InstallationResourcesinstance did not find the resources (for example because of files not found) or does not have the permission to distribute them.- Returns:
- identifiers of resources that this instance can distribute.
 
- 
getInstructionURLReturns a URL where users can get more information about the installation process.- Returns:
- URL to installation instruction, or nullif none.
- Since:
- 1.2
 
- 
getLicensepublic abstract String getLicense(String authority, Locale locale, String mimeType) throws IOException Returns the terms of use of the resources distributed by the specified authority, ornullif none. The terms of use can be returned in either plain text or HTML.Licenses for some supported authorities Authority License "EPSG"A copy of the https://epsg.org/terms-of-use.html page. "Embedded"Above EPSG license. - 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 all resources of the specified authority that are distributed by this instance. The resources will be used in the order they appear in the array. Examples:- "EPSG"authority: the resource names are the filenames of all SQL scripts to execute. One of the first script creates tables, followed by a script that populates tables with data, followed by a script that creates foreigner keys.
- "Embedded"pseudo-authority: the database name, which is- "SpatialMetadata". When embedded, this database is read-only.
 - Parameters:
- authority- one of the values returned by- getAuthorities().
- Returns:
- the names of all resources of the given authority that are distributed by this instance.
- Throws:
- IllegalArgumentException- if the given- authorityargument is not one of the expected values.
- IOException- if fetching the resource names required an I/O operation and that operation failed.
 
- 
getResourceReturns an installation resource for the given authority, ornullif not available. The return value may be an instance of any type, at implementation choice. This may be for example aURLreferencing the actual resource, or aDataSourcefor an embedded database.The default implementation returns null. A null value means that the resource is fetched byopenScript(String, int)instead of this method. We do not returnURLto text files in order to ensure that the file is opened with proper character encoding.- 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), or nullif not available.
- 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.
- Since:
- 0.8
- See Also:
 
- 
openScriptReturns a reader for the resources at the given index. The resource may be a SQL script or any other resources readable as a text. The returnedBufferedReaderinstance shall be closed by the caller.- 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.
- IOException- if an error occurred while creating the reader.
 
 
-