Package org.apache.sling.feature.io
Class IOUtils
java.lang.Object
org.apache.sling.feature.io.IOUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The default directory to search for features.static final String
The default name of the feature file.static final String
The extension for a feature file.static final String
The extension for a feature file.static final String
The extension for a reference file. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetFeatureFiles
(File homeDirectory, String... files) Get the list of feature files.static File
getFileFromURL
(URL url, boolean cache, File tmpDir) Get a File from a local URL (if possible)static JarFile
getJarFileFromURL
(URL url, boolean cache, File tmpDir) Get a JarFile from a local URL (if possible)parseFeatureRefFile
(File file) Parse a feature reference file
-
Field Details
-
EXTENSION_REF_FILE
The extension for a reference file.- See Also:
-
EXTENSION_FEATURE_FILE
The extension for a feature file.- See Also:
-
EXTENSION_FEATURE_ARCHIVE
The extension for a feature file.- See Also:
-
DEFAULT_DIRECTORY
The default directory to search for features.- See Also:
-
DEFAULT_FEATURE_FILE
The default name of the feature file.- See Also:
-
-
Constructor Details
-
IOUtils
public IOUtils()
-
-
Method Details
-
parseFeatureRefFile
Parse a feature reference file- Parameters:
file
- The file- Returns:
- The referenced features
- Throws:
IOException
- If reading fails
-
getFeatureFiles
Get the list of feature files. If the provided list of files isnull
or an empty array, the default is used. The default checks for the following places, the first one found is used. If none is found an empty list is returned.- A directory named
DEFAULT_DIRECTORY
in the current directory - A file named
DEFAULT_FEATURE_FILE
in the current directory - A directory named
DEFAULT_DIRECTORY
in the home directory - A file named
DEFAULT_FEATURE_FILE
in the home directory
EXTENSION_FEATURE_FILE
orEXTENSION_REF_FILE
of that directory are read. If a file ends inEXTENSION_REF_FILE
the contents is read and every line not starting with the hash sign is considered a reference to a feature artifact.- Parameters:
homeDirectory
- If relative files should be resolved, this is the directory to usefiles
- Optional list of files. If none is provided, a default is used.- Returns:
- The list of files.
- Throws:
IOException
- If an error occurs.
- A directory named
-
getFileFromURL
Get a File from a local URL (if possible)- Parameters:
url
- a local url (like a file: url or a jar:file: urlcache
- if an attempt should be made to download the content of the url locally if it can not be presented as a file directlytmpDir
- the tmpDir to use (null for default)- Returns:
- the file the url points to (or null if none) - or a tmp file if cache is true and the url could be cached
- Throws:
IOException
- When an IO Exception occurs.
-
getJarFileFromURL
Get a JarFile from a local URL (if possible)- Parameters:
url
- a local url (like a file: url or a jar:file: urlcache
- if an attempt should be made to download the content of the url locally if it can not be presented as a jarfile directlytmpDir
- the tmpDir to use (null for default)- Returns:
- the jarfile the url points to
- Throws:
IOException
- if the url can't be represented as a jarfile
-