|
||||||||
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 |
DEFAULT_TEMPLATE
The path to the default template. |
static String |
MIMETYPE_HTML
The MIME type "text/html" . |
static String |
MIMETYPE_TEXT
The MIME type "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. |
I_CmsHtmlConverter |
addHtmlConverter(String name,
String className)
Adds a new HTML converter class to internal list of loaded converter classes. |
void |
addLoader(I_CmsResourceLoader loader)
Adds a new loader to the internal list of loaded loaders. |
CmsMimeType |
addMimeType(String extension,
String type)
Adds a new MIME type from the XML configuration to the internal list of MIME types. |
CmsRelationType |
addRelationType(String name,
String type)
Adds a new relation type from the XML configuration to the list of user defined relation types. |
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<String,String> |
getExtensionMapping()
Returns the file extensions (suffixes) mappings to resource types. |
CmsResourceTranslator |
getFileTranslator()
Returns the file translator. |
CmsResourceTranslator |
getFolderTranslator()
Returns the folder translator. |
String |
getHtmlConverter(String name)
Returns the matching HTML converter class name for the specified option name. |
List<CmsHtmlConverterOption> |
getHtmlConverters()
Returns an unmodifiable List of the configured CmsHtmlConverterOption objects. |
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<I_CmsResourceLoader> |
getLoaders()
Returns the (unmodifiable 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<CmsMimeType> |
getMimeTypes()
Returns an unmodifiable List of the configured CmsMimeType objects. |
I_CmsFileNameGenerator |
getNameGenerator()
Returns the name generator for XML content file names. |
List<I_CmsResourceCollector> |
getRegisteredContentCollectors()
Returns an (unmodifiable) list of class names of all currently registered content collectors ( I_CmsResourceCollector objects). |
List<CmsRelationType> |
getRelationTypes()
Returns an unmodifiable List of the configured CmsRelationType objects. |
I_CmsResourceType |
getResourceType(CmsResource resource)
Convenience method to get the initialized resource type instance for the given resource, with a fall back to special "unknown" resource types in case the resource type is not configured. |
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<I_CmsResourceType> |
getResourceTypes()
Returns the (unmodifiable) list with all initialized resource types. |
List<I_CmsResourceType> |
getResourceTypesWithUnknown()
Returns the (unmodifiable) list with all initialized resource types including unknown types. |
I_CmsResourceType |
getResTypeUnknownFile()
The configured default type for files when the resource type is missing. |
I_CmsResourceType |
getResTypeUnknownFolder()
The configured default type for folders when the resource type is missing. |
CmsTemplateLoaderFacade |
getTemplateLoaderFacade(CmsObject cms,
CmsResource resource,
String templateProperty)
Returns a template loader facade for the given file. |
CmsResourceTranslator |
getXsdTranslator()
Returns the XSD translator. |
boolean |
hasResourceType(I_CmsResourceType type)
Checks if an initialized resource type instance equal to the given resource type is available. |
boolean |
hasResourceType(int typeId)
Checks if an initialized resource type instance for the given resource type is is available. |
boolean |
hasResourceType(String typeName)
Checks if an initialized resource type instance for the given resource type name is available. |
void |
initConfiguration()
|
void |
initialize(CmsObject cms)
Initializes all additional resource types stored in the modules. |
void |
loadResource(CmsObject cms,
CmsResource resource,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Loads the requested resource and writes the contents to the response stream. |
void |
setNameGenerator(I_CmsFileNameGenerator nameGenerator)
Configures the URL name generator for XML contents. |
void |
setTranslators(CmsResourceTranslator folderTranslator,
CmsResourceTranslator fileTranslator,
CmsResourceTranslator xsdTranslator)
Sets the folder, the file and the XSD 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 DEFAULT_TEMPLATE
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 initializedpublic I_CmsHtmlConverter addHtmlConverter(String name, String className) throws CmsConfigurationException
name
- the name of the option that should trigger the HTML converter classclassName
- the name of the class to add
CmsConfigurationException
- in case the HTML converter could not be properly initializedpublic void addLoader(I_CmsResourceLoader loader) throws CmsConfigurationException
loader
- the loader to add
CmsConfigurationException
- in case the resource manager configuration is already initializedpublic CmsMimeType addMimeType(String extension, String type) throws CmsConfigurationException
extension
- the MIME type extensiontype
- the MIME type description
CmsConfigurationException
- in case the resource manager configuration is already initializedpublic CmsRelationType addRelationType(String name, String type) throws CmsConfigurationException
name
- the name of the relation typetype
- the type of the relation type, weak or strong
CmsConfigurationException
- in case the resource manager configuration is already initializedpublic 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<String,String> getExtensionMapping()
public CmsResourceTranslator getFileTranslator()
public CmsResourceTranslator getFolderTranslator()
public String getHtmlConverter(String name)
name
- the name of the option that should trigger the HTML converter class
null
if no match is foundpublic List<CmsHtmlConverterOption> getHtmlConverters()
CmsHtmlConverterOption
objects.
CmsHtmlConverterOption
objectspublic 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<I_CmsResourceLoader> 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 provided 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<CmsMimeType> getMimeTypes()
CmsMimeType
objects.
CmsMimeType
objectspublic I_CmsFileNameGenerator getNameGenerator()
public List<I_CmsResourceCollector> getRegisteredContentCollectors()
I_CmsResourceCollector
objects).
I_CmsResourceCollector
objects)public List<CmsRelationType> getRelationTypes()
CmsRelationType
objects.
CmsRelationType
objectspublic I_CmsResourceType getResourceType(CmsResource resource)
resource
- the resource to get the type for
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 idpublic 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<I_CmsResourceType> getResourceTypes()
public List<I_CmsResourceType> getResourceTypesWithUnknown()
public I_CmsResourceType getResTypeUnknownFile()
public I_CmsResourceType getResTypeUnknownFolder()
public CmsTemplateLoaderFacade getTemplateLoaderFacade(CmsObject cms, CmsResource resource, String templateProperty) throws CmsException
cms
- the current OpenCms user contextresource
- the requested filetemplateProperty
- the property to read for the template
CmsException
- if something goes wrongpublic CmsResourceTranslator getXsdTranslator()
public boolean hasResourceType(I_CmsResourceType type)
type
- the resource type to check
true
if such a resource type has been configured, false
otherwisegetResourceType(String)
,
getResourceType(int)
public boolean hasResourceType(int typeId)
typeId
- the id of the resource type to check
true
if such a resource type has been configured, false
otherwisegetResourceType(int)
public boolean hasResourceType(String typeName)
typeName
- the name of the resource type to check
true
if such a resource type has been configured, false
otherwisegetResourceType(String)
public void initConfiguration() throws CmsConfigurationException
CmsConfigurationException
- in case of duplicate resource types in the configurationI_CmsConfigurationParameterHandler.initConfiguration()
public void initialize(CmsObject cms) throws CmsRoleViolationException, CmsConfigurationException
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
CmsConfigurationException
- in case of duplicate resource types in the configurationpublic void loadResource(CmsObject cms, CmsResource resource, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletException, IOException, CmsException
req
- the current HTTP requestres
- the current HTTP responsecms
- the current OpenCms user contextresource
- the requested resource
javax.servlet.ServletException
- if something goes wrong
IOException
- if something goes wrong
CmsException
- if something goes wrongpublic void setNameGenerator(I_CmsFileNameGenerator nameGenerator) throws CmsConfigurationException
nameGenerator
- the configured name generator class
CmsConfigurationException
- if something goes wrongpublic void setTranslators(CmsResourceTranslator folderTranslator, CmsResourceTranslator fileTranslator, CmsResourceTranslator xsdTranslator)
folderTranslator
- the folder translator to setfileTranslator
- the file translator to setxsdTranslator
- the XSD translator to setpublic 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 |