Package org.dspace.servicemanager.spring
Class ResourceFinder
- java.lang.Object
-
- org.dspace.servicemanager.spring.ResourceFinder
-
public class ResourceFinder extends Object
Takes a list of paths to resources and turns them into different things (file/IS/resource). This also allows us to look on a relative or absolute path and will automatically check the typical places one might expect to put DSpace config files.- Author:
- Aaron Zeckoski ([email protected])
-
-
Field Summary
Fields Modifier and Type Field Description static String
environmentPathVariable
static String
relativePath
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
getContainerHome()
If running in Tomcat, get its home directory.protected static String
getEnvironmentPath()
static File
getFile(String path)
static File[]
getFiles(List<String> paths)
static InputStream
getInputStream(String path)
static InputStream[]
getInputStreams(List<String> paths)
protected static String
getRelativePath()
static org.springframework.core.io.Resource
getResource(String path)
Resolve a path into a resource relative to environmental defaults or relative paths or the classloader.static org.springframework.core.io.Resource
getResourceFromPaths(String[] paths)
Attempt to resolve multiple paths in order until one is found.static org.springframework.core.io.Resource[]
getResources(List<String> paths)
Resolves a list of paths into resources relative to environmental defaults or relative paths or the classloader.
-
-
-
Field Detail
-
relativePath
public static final String relativePath
- See Also:
- Constant Field Values
-
environmentPathVariable
public static final String environmentPathVariable
- See Also:
- Constant Field Values
-
-
Method Detail
-
getResources
public static org.springframework.core.io.Resource[] getResources(List<String> paths)
Resolves a list of paths into resources relative to environmental defaults or relative paths or the classloader.- Parameters:
paths
- a list of paths to resources (org/sakaiproject/mystuff/Thing.xml)- Returns:
- an array of Spring Resource objects
-
getInputStreams
public static InputStream[] getInputStreams(List<String> paths)
-
getResource
public static org.springframework.core.io.Resource getResource(String path)
Resolve a path into a resource relative to environmental defaults or relative paths or the classloader.- Parameters:
path
- a path to a resource (org/dspace/mystuff/Thing.xml)- Returns:
- the Spring Resource object
- Throws:
IllegalArgumentException
- if no resource can be found
-
getResourceFromPaths
public static org.springframework.core.io.Resource getResourceFromPaths(String[] paths)
Attempt to resolve multiple paths in order until one is found.- Parameters:
paths
- an array of paths to a resource (org/dspace/mystuff/Thing.xml)- Returns:
- the Spring Resource object
- Throws:
IllegalArgumentException
- if no resource can be found
-
getInputStream
public static InputStream getInputStream(String path)
-
getRelativePath
protected static String getRelativePath()
-
getEnvironmentPath
protected static String getEnvironmentPath()
-
getContainerHome
public static String getContainerHome()
If running in Tomcat, get its home directory.- Returns:
- the container home if one can be found
-
-