|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.opencms.loader.CmsResourceManager
public class CmsResourceManager
Collects all available resource loaders, resource types and resource collectors at startup and provides methods to access them during OpenCms runtime.
| Field Summary | |
|---|---|
static String |
MIMETYPE_HTML
The mimetype "text/html". |
static String |
MIMETYPE_TEXT
The mimetype "text/plain". |
| Constructor Summary | |
|---|---|
CmsResourceManager()
Creates a new instance for the resource manager, will be called by the vfs configuration manager. |
|
| Method Summary | |
|---|---|
I_CmsResourceCollector |
addContentCollector(String className,
String order)
Adds a given content collector class to the type manager. |
void |
addLoader(I_CmsResourceLoader loader)
Adds a new loader to the internal list of loaded loaders. |
void |
addResourceType(I_CmsResourceType resourceType)
Adds a new resource type from the XML configuration to the internal list of loaded resource types. |
I_CmsResourceCollector |
getContentCollector(String collectorName)
Returns the configured content collector with the given name, or null if
no collector with this name is configured. |
I_CmsResourceType |
getDefaultTypeForName(String resourcename)
Returns the default resource type for the given resource name, using the configured resource type file extensions. |
Map |
getExtensionMapping()
Returns the file extensions (suffixes) mappings to resource types. |
CmsResourceTranslator |
getFileTranslator()
Returns the file translator. |
CmsResourceTranslator |
getFolderTranslator()
Returns the folder translator. |
I_CmsResourceLoader |
getLoader(CmsResource resource)
Returns the loader class instance for a given resource. |
I_CmsResourceLoader |
getLoader(int id)
Returns the loader class instance for the given loader id. |
List |
getLoaders()
Returns the (unmodifyable array) list with all initialized resource loaders. |
String |
getMimeType(String filename,
String encoding)
Returns the mime type for a specified file name. |
String |
getMimeType(String filename,
String encoding,
String defaultMimeType)
Returns the mime type for a specified file name. |
List |
getRegisteredContentCollectors()
Returns an (unmodifiable) list of class names of all currently registered content collectors. |
I_CmsResourceType |
getResourceType(int typeId)
Returns the initialized resource type instance for the given id. |
I_CmsResourceType |
getResourceType(String typeName)
Returns the initialized resource type instance for the given resource type name. |
List |
getResourceTypes()
Returns the (unmodifyable array) list with all initialized resource types. |
CmsTemplateLoaderFacade |
getTemplateLoaderFacade(CmsObject cms,
CmsResource resource,
String templateProperty)
Returns a template loader facade for the given file. |
void |
initConfiguration()
|
void |
initialize(CmsObject cms)
Initializes all additional resource types stored in the modules. |
void |
loadResource(CmsObject cms,
CmsResource resource,
HttpServletRequest req,
HttpServletResponse res)
Loads the requested resource and writes the contents to the response stream. |
String |
resolveIncludeExtensions(String target,
String element,
boolean editable,
Map paramMap,
ServletRequest req,
ServletResponse res)
Extension method for handling special, loader depended actions during the include process. |
void |
setTranslators(CmsResourceTranslator folderTranslator,
CmsResourceTranslator fileTranslator)
Sets the folder and the file translator. |
void |
shutDown()
Shuts down this resource manage instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String MIMETYPE_HTML
"text/html".
public static final String MIMETYPE_TEXT
"text/plain".
| Constructor Detail |
|---|
public CmsResourceManager()
| Method Detail |
|---|
public I_CmsResourceCollector addContentCollector(String className,
String order)
throws CmsConfigurationException
className - the name of the class to addorder - the order number for this collector
CmsConfigurationException - in case the collector could not be properly initialized
public void addLoader(I_CmsResourceLoader loader)
throws CmsConfigurationException
loader - the loader to add
CmsConfigurationException - in case the resource manager configuration is already initialized
public void addResourceType(I_CmsResourceType resourceType)
throws CmsConfigurationException
Resource types can also be added from a module.
resourceType - the resource type to add
CmsConfigurationException - in case the resource manager configuration is already initializedpublic I_CmsResourceCollector getContentCollector(String collectorName)
null if
no collector with this name is configured.
collectorName - the name of the collector to get
public I_CmsResourceType getDefaultTypeForName(String resourcename)
throws CmsException
In case the given name does not map to a configured resource type,
CmsResourceTypePlain is returned.
This is only required (and should not be used otherwise) when creating a new resource automatically during file upload or synchronization. Only in this case, the file type for the new resource is determined using this method. Otherwise the resource type is always stored as part of the resource, and is not related to the file name.
resourcename - the resource name to look up the resource type for
CmsException - if something goes wrongpublic Map getExtensionMapping()
public CmsResourceTranslator getFileTranslator()
public CmsResourceTranslator getFolderTranslator()
public I_CmsResourceLoader getLoader(CmsResource resource)
throws CmsLoaderException
resource - the resource
CmsLoaderException - if something goes wrongpublic I_CmsResourceLoader getLoader(int id)
id - the id of the loader to return
public List getLoaders()
public String getMimeType(String filename,
String encoding)
If an encoding parameter that is not null is provided,
the returned mime type is extended with a ; charset={encoding} setting.
If no mime type for the given filename can be determined, the
default is used.MIMETYPE_HTML
filename - the file name to check the mime type forencoding - the default encoding (charset) in case of mime types is of type "text"
public String getMimeType(String filename,
String encoding,
String defaultMimeType)
If an encoding parameter that is not null is provided,
the returned mime type is extended with a ; charset={encoding} setting.
If no mime type for the given filename can be determined, the privided default is used.
filename - the file name to check the mime type forencoding - the default encoding (charset) in case of mime types is of type "text"defaultMimeType - the default mime type to use if no matching type for the filename is found
public List getRegisteredContentCollectors()
public I_CmsResourceType getResourceType(int typeId)
throws CmsLoaderException
typeId - the id of the resource type to get
CmsLoaderException - if no resource type is available for the given id
public I_CmsResourceType getResourceType(String typeName)
throws CmsLoaderException
typeName - the name of the resource type to get
CmsLoaderException - if no resource type is available for the given namepublic List getResourceTypes()
public CmsTemplateLoaderFacade getTemplateLoaderFacade(CmsObject cms,
CmsResource resource,
String templateProperty)
throws CmsException
cms - the current cms contextresource - the requested filetemplateProperty - the property to read for the template
CmsException - if something goes wrongpublic void initConfiguration()
I_CmsConfigurationParameterHandler.initConfiguration()
public void initialize(CmsObject cms)
throws CmsRoleViolationException
cms - an initialized OpenCms user context with "module manager" role permissions
CmsRoleViolationException - in case the provided OpenCms user context did not have "module manager" role permissions
public void loadResource(CmsObject cms,
CmsResource resource,
HttpServletRequest req,
HttpServletResponse res)
throws ServletException,
IOException,
CmsException
req - the current http requestres - the current http responsecms - the curren cms contextresource - the requested resource
ServletException - if something goes wrong
IOException - if something goes wrong
CmsException - if something goes wrong
public String resolveIncludeExtensions(String target,
String element,
boolean editable,
Map paramMap,
ServletRequest req,
ServletResponse res)
throws CmsException
Note: If you have multiple loaders configured that require include extensions, all loaders are called in the order they are configured in.
target - the target for the include, might be nullelement - the element to select form the target might be nulleditable - the flag to indicate if the target is editableparamMap - a map of parameters for the include, can be modified, might be nullreq - the current requestres - the current response
CmsException - in case something goes wrong
public void setTranslators(CmsResourceTranslator folderTranslator,
CmsResourceTranslator fileTranslator)
folderTranslator - the folder translator to setfileTranslator - the file translator to set
public void shutDown()
throws Exception
Exception - in case of errors during shutdown
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||