Class 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.

    • 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.

        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.

        systemId - the system ID to add
        content - 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.

        systemId - the system id ID check
        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.

        schema - the schema id
        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.

        adminCms - an initialized OpenCms user context with "Administrator" role permissions
        typeSchemaBytes - the base widget type XML schema definitions
        See Also:
      • 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.

        systemId - the system id to use as cache key
        contentDefinition - the content definition to cache
      • getCachedContentDefinition

        public CmsXmlContentDefinition getCachedContentDefinition​(java.lang.String systemId)
        Looks up the given XML content definition system id in the internal content definition cache.

        systemId - the system id of the XML content definition to look up
        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)
        Specified by:
        resolveEntity in interface org.xml.sax.EntityResolver
        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.

        systemId - the system id (filename) to remove from the cache