| org.apache.cocoon.components.modules.input.AbstractInputModule org.apache.cocoon.components.modules.input.LocateResource
LocateResource | public class LocateResource extends AbstractInputModule implements Composable,ThreadSafe(Code) | | Locate a resource in a resource tree. Any attribute name is interpreted as a
URI with the last part being the resource name unless it ends with a slash.
The URI is checked if the resource exists and the URI is returned. If the
resource does not exist, the URI is shortened until the resource name is found
and the new URI is returned. If no resource with the given name exists, null
is returned.
A use case is to locate the closest menu file or when moving a site from
a filesystem path == URL system from a httpd to Cocoon and provide similar
functions to .htaccess files.
Example: for context:/some/path/to/a/file.xml the following URIs
are tested: context:/some/path/to/a/file.xml, context:/some/path/to/file.xml,
context:/some/path/file.xml, context:/some/file.xml, and context:/file.xml.
For the attribute name context:/some/path/foo/ tests context:/some/path/foo/,
context:/some/path/, context:/some/, and context:/ are tested.
The getAttribute() method will return the URI for the first match while
getAttributeValues() will return an array of all existing paths.
getAttributeNames() will return an Iterator to an empty collection.
author: Christian Haul version: $Id: LocateResource.java 540711 2007-05-22 19:36:07Z cziegeler $ |
manager | protected ComponentManager manager(Code) | | |
calculateMinLen | protected int calculateMinLen(String name)(Code) | | Calculate the minimal length of the URL, that is the position
of the first ":" if a protocol is provided or otherwise 0.
Parameters: name - minimal length |
compose | public void compose(ComponentManager manager) throws ComponentException(Code) | | Set the current ComponentManager instance used by this
Composable .
|
extractFilename | protected String extractFilename(String urlstring)(Code) | | if the url does not end with a "/", keep the last part in
order to add it later again after traversing up
|
getAttribute | public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException(Code) | | |
getAttributeNames | public Iterator getAttributeNames(Configuration modeConf, Map objectModel) throws ConfigurationException(Code) | | |
getAttributeValues | public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel) throws ConfigurationException(Code) | | |
locateResource | protected String locateResource(String urlstring, String filename, int minLen)(Code) | | Locate a resource with the given URL consisting of urlstring + filename.
The filename is appended each time the path is shortened. Returns the first
existing occurance.
Parameters: urlstring - Parameters: filename - Parameters: minLen - urlstring if resource was found, null otherwise |
shortenURI | protected String shortenURI(String urlstring, int minLen)(Code) | | Remove one path element from the URL unless minimum length has
been reached.
Parameters: urlstring - Parameters: minLen - shortened URI |
|
|