Class 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])
    • 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
      • 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
      • getFile

        public static File getFile​(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