Package org.opencms.xml
Class CmsXmlEntityResolver
- java.lang.Object
-
- org.opencms.xml.CmsXmlEntityResolver
-
- All Implemented Interfaces:
I_CmsEventListener
,org.xml.sax.EntityResolver
public class CmsXmlEntityResolver extends java.lang.Object implements org.xml.sax.EntityResolver, I_CmsEventListener
Resolves XML entities (e.g. external DTDs) in the OpenCms VFS.Also provides a cache for XML content schema definitions.
- Since:
- 6.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static int
CONTENT_DEFINITION_CACHE_SIZE
Maximum size of the content definition cache.static java.lang.String
INTERNAL_SCHEME
Scheme for files which should be retrieved from the classpath.static java.lang.String
OPENCMS_SCHEME
The scheme to identify a file in the OpenCms VFS.-
Fields inherited from interface org.opencms.main.I_CmsEventListener
EVENT_BEFORE_PUBLISH_PROJECT, EVENT_CLEAR_CACHES, EVENT_CLEAR_OFFLINE_CACHES, EVENT_CLEAR_ONLINE_CACHES, EVENT_CLEAR_PRINCIPAL_CACHES, EVENT_FLEX_CACHE_CLEAR, EVENT_FLEX_PURGE_JSP_REPOSITORY, EVENT_FULLSTATIC_EXPORT, EVENT_GROUP_MODIFIED, EVENT_LOGIN_USER, EVENT_OU_MODIFIED, EVENT_PROJECT_MODIFIED, EVENT_PROPERTY_DEFINITION_CREATED, EVENT_PROPERTY_DEFINITION_MODIFIED, EVENT_PROPERTY_MODIFIED, EVENT_PUBLISH_PROJECT, EVENT_REBUILD_SEARCHINDEXES, EVENT_REINDEX_OFFLINE, EVENT_REINDEX_ONLINE, EVENT_RESOURCE_AND_PROPERTIES_MODIFIED, EVENT_RESOURCE_COPIED, EVENT_RESOURCE_CREATED, EVENT_RESOURCE_DELETED, EVENT_RESOURCE_MODIFIED, EVENT_RESOURCE_MOVED, EVENT_RESOURCES_AND_PROPERTIES_MODIFIED, EVENT_RESOURCES_MODIFIED, EVENT_SITEMAP_CHANGED, EVENT_UPDATE_EXPORTS, EVENT_USER_MODIFIED, KEY_CHANGE, KEY_DBCONTEXT, KEY_GROUP_ID, KEY_GROUP_NAME, KEY_INDEX_NAMES, KEY_IS_ONLINE, KEY_OU_ID, KEY_OU_NAME, KEY_PROJECTID, KEY_PUBLISHID, KEY_PUBLISHLIST, KEY_REINDEX_RELATED, KEY_REPORT, KEY_RESOURCE, KEY_RESOURCES, KEY_SKIPINDEX, KEY_USER_ACTION, KEY_USER_CHANGES, KEY_USER_ID, KEY_USER_NAME, LISTENERS_FOR_ALL_EVENTS, VALUE_CREATE_SIBLING, VALUE_GROUP_MODIFIED_ACTION_CREATE, VALUE_GROUP_MODIFIED_ACTION_DELETE, VALUE_GROUP_MODIFIED_ACTION_WRITE, VALUE_OU_MODIFIED_ACTION_CREATE, VALUE_OU_MODIFIED_ACTION_DELETE, VALUE_USER_MODIFIED_ACTION_ADD_USER_TO_GROUP, VALUE_USER_MODIFIED_ACTION_CREATE_USER, VALUE_USER_MODIFIED_ACTION_DELETE_USER, VALUE_USER_MODIFIED_ACTION_REMOVE_USER_FROM_GROUP, VALUE_USER_MODIFIED_ACTION_RESET_PASSWORD, VALUE_USER_MODIFIED_ACTION_SET_OU, VALUE_USER_MODIFIED_ACTION_WRITE_USER
-
-
Constructor Summary
Constructors Constructor Description CmsXmlEntityResolver(CmsObject cms)
Creates a new XML entity resolver based on the provided CmsObject.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cacheContentDefinition(java.lang.String systemId, CmsXmlContentDefinition contentDefinition)
Caches an XML content definition based on the given system id and the online / offline status of this entity resolver instance.static void
cacheSystemId(java.lang.String systemId, byte[] content)
Adds a system ID URL to to internal permanent cache.void
cmsEvent(CmsEvent event)
Acknowledge the occurrence of the specified event, implement this method to check for CmsEvents in your class.CmsXmlContentDefinition
getCachedContentDefinition(java.lang.String systemId)
Looks up the given XML content definition system id in the internal content definition cache.protected static void
initialize(CmsObject adminCms, byte[] typeSchemaBytes)
Initialize the OpenCms XML entity resolver.static boolean
isCachedSystemId(java.lang.String systemId)
Checks if a given system ID URL is in the internal permanent cache.static boolean
isInternalId(java.lang.String schema)
Checks whether the given schema id is an internal schema id or is translated to an internal schema id.org.xml.sax.InputSource
resolveEntity(java.lang.String publicId, java.lang.String systemId)
void
uncacheSystemId(java.lang.String systemId)
Removes a cached entry for a system id (filename) from the internal offline temporary and content definition caches.
-
-
-
Field Detail
-
CONTENT_DEFINITION_CACHE_SIZE
public static final int CONTENT_DEFINITION_CACHE_SIZE
Maximum size of the content definition cache.- See Also:
- Constant Field Values
-
INTERNAL_SCHEME
public static final java.lang.String INTERNAL_SCHEME
Scheme for files which should be retrieved from the classpath.- See Also:
- Constant Field Values
-
OPENCMS_SCHEME
public static final java.lang.String OPENCMS_SCHEME
The scheme to identify a file in the OpenCms VFS.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CmsXmlEntityResolver
public CmsXmlEntityResolver(CmsObject cms)
Creates a new XML entity resolver based on the provided CmsObject.If the provided CmsObject is null, then the OpenCms VFS is not searched for XML entities, however the internal cache and other OpenCms internal entities not in the VFS are still resolved.
- Parameters:
cms
- the cms context to use for resolving XML files from the OpenCms VFS
-
-
Method Detail
-
cacheSystemId
public static void cacheSystemId(java.lang.String systemId, byte[] content)
Adds a system ID URL to to internal permanent cache.This cache will NOT be cleared automatically.
- Parameters:
systemId
- the system ID to addcontent
- the content of the system id
-
isCachedSystemId
public static boolean isCachedSystemId(java.lang.String systemId)
Checks if a given system ID URL is in the internal permanent cache.This check is required to see if a XML content is based on a file that actually exists in the OpenCms VFS, or if the schema has been just cached without a VFS file.
- Parameters:
systemId
- the system id ID check- Returns:
true
if the system ID is in the internal permanent cache,false
otherwise
-
isInternalId
public static boolean isInternalId(java.lang.String schema)
Checks whether the given schema id is an internal schema id or is translated to an internal schema id.- Parameters:
schema
- the schema id- Returns:
- true if the given schema id is an internal schema id or translated to an internal schema id
-
initialize
protected static void initialize(CmsObject adminCms, byte[] typeSchemaBytes)
Initialize the OpenCms XML entity resolver.- Parameters:
adminCms
- an initialized OpenCms user context with "Administrator" role permissionstypeSchemaBytes
- the base widget type XML schema definitions- See Also:
CmsXmlContentTypeManager.initialize(CmsObject)
-
cacheContentDefinition
public void cacheContentDefinition(java.lang.String systemId, CmsXmlContentDefinition contentDefinition)
Caches an XML content definition based on the given system id and the online / offline status of this entity resolver instance.- Parameters:
systemId
- the system id to use as cache keycontentDefinition
- the content definition to cache
-
cmsEvent
public void cmsEvent(CmsEvent event)
Description copied from interface:I_CmsEventListener
Acknowledge the occurrence of the specified event, implement this method to check for CmsEvents in your class.- Specified by:
cmsEvent
in interfaceI_CmsEventListener
- Parameters:
event
- CmsEvent that has occurred- See Also:
I_CmsEventListener.cmsEvent(org.opencms.main.CmsEvent)
-
getCachedContentDefinition
public CmsXmlContentDefinition getCachedContentDefinition(java.lang.String systemId)
Looks up the given XML content definition system id in the internal content definition cache.- Parameters:
systemId
- the system id of the XML content definition to look up- Returns:
- the XML content definition found, or null if no definition is cached for the given system id
-
resolveEntity
public org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId) throws java.io.IOException
- Specified by:
resolveEntity
in interfaceorg.xml.sax.EntityResolver
- Throws:
java.io.IOException
- See Also:
EntityResolver.resolveEntity(java.lang.String, java.lang.String)
-
uncacheSystemId
public void uncacheSystemId(java.lang.String systemId)
Removes a cached entry for a system id (filename) from the internal offline temporary and content definition caches.The online resources cached for the online project are only flushed when a project is published.
- Parameters:
systemId
- the system id (filename) to remove from the cache
-
-