Class CmsDocumentDependency

java.lang.Object
org.opencms.search.documents.CmsDocumentDependency

public final class CmsDocumentDependency extends Object
Provides the dependency information about one search result document, used to generate the list of document search results.

Since:
8.5.0
  • Method Details

    • fromDependencyString

      public static CmsDocumentDependency fromDependencyString(String input, String rootPath)
      Creates a dependency object from a String representation.

      Parameters:
      input - the String representation
      rootPath - the root path of the base document of which the dependencies are encoded
      Returns:
      the dependency object created from a String representation
    • getLocale

      public static Locale getLocale(String rootPath)
      Returns the locale (language) of the given resource based on the resource root path.

      Parameters:
      rootPath - the resource name to check for the locale information
      Returns:
      the locale of the given resource based on the resource root path
    • load

      Loads or creates a dependency object for the given parameters.

      Parameters:
      cms - the current OpenCms user context
      pubRes - the published resource to get the dependency object for
      Returns:
      a dependency object for the given parameters
    • load

      public static CmsDocumentDependency load(CmsObject cms, CmsResource res)
      Loads or creates a dependency object for the given parameters.

      Parameters:
      cms - the current OpenCms user context
      res - the VFS resource to get the dependency object for
      Returns:
      a dependency object for the given parameters
    • load

      public static CmsDocumentDependency load(CmsObject cms, CmsResource res, List<CmsResource> resources)
      Loads or creates a dependency object for the given parameters.

      Parameters:
      cms - the current OpenCms user context
      res - the VFS resource to get the dependency object for
      resources - the resource folder data to check for dependencies
      Returns:
      a dependency object for the given parameters
    • loadForTest

      protected static CmsDocumentDependency loadForTest(String rootPath)
      Creates a dependency object for the given root path, to be used only for test cases.

      Parameters:
      rootPath - the root path to create the dependency object for
      Returns:
      a dependency object for the given parameters
    • removeFromContext

      protected static void removeFromContext(CmsObject cms, CmsPublishedResource pubRes)
      Removes the dependency object for a published resource from the OpenCms runtime context.

      Please note: This must be used with caution since the information may be required to generate documents for several configured indexes. It must be ensured that this is called only when all indexes have been updated.

      Parameters:
      cms - the current OpenCms user context
      pubRes - the published resource info
      See Also:
    • addAttachment

      Adds another document attachment dependency to this document.

      Parameters:
      dep - the document attachment dependency to add
    • addDependency

      Adds another document dependency to this document.

      Parameters:
      dep - the document dependency to add
    • addVariant

      public void addVariant(CmsDocumentDependency dep)
      Adds another language version document dependency to this document.

      Parameters:
      dep - the language version document dependency to add
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
      See Also:
    • fromJSON

      public void fromJSON(JSONObject json, String rootPath)
      Read the information out of the given JSON object to fill the values of the document.

      Parameters:
      json - the JSON object with the information about this document
      rootPath - the current path the home division
    • getAttachmentNumber

      public int getAttachmentNumber()
      Returns the attachment number.

      Returns:
      the attachment number
    • getAttachments

      Returns the attachments.

      Returns:
      the attachments
    • getDependencies

      Returns the list of resources the main resource depends on, including the main resource itself.

      Returns:
      the list of resources the main resource depends on, including the main resource itself
    • getDocumentName

      Returns the file name of the document without attachment or locale suffixes.

      Returns:
      the file name of the document without attachment or locale suffixes
    • getDocumentSuffix

      Returns the suffix of the document.

      Returns:
      the suffix of the document
    • getLocale

      public Locale getLocale()
      Returns the locale of this document container.

      Returns:
      the locale of this document container
    • getMainDocument

      Returns the main document in case this document is an attachment.

      Returns:
      the main document in case this document is an attachment
    • getResource

      Returns the VFS resource for which the dependencies are calculated.

      Returns:
      the VFS resource for which the dependencies are calculated
    • getRootPath

      public String getRootPath()
      Returns the root path of this dependency.

      Returns:
      the root path
    • getType

      Returns the type.

      Returns:
      the type
    • getVariants

      Returns the variants.

      Returns:
      the variants
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also:
    • hasLocaleFileName

      public boolean hasLocaleFileName()
      Returns the locale file name flag.

      Returns:
      the locale file name flag
    • isAttachment

      public boolean isAttachment()
      Returns true if this document is an attachment, i.e. an attachment number is provided.

      Returns:
      true if this document is an attachment, otherwise false
    • readDependencies

      public void readDependencies(CmsObject cms)
      Reads all dependencies that exist for this main resource in the OpenCms VFS.

      To be used when incremental updating an index.

      Parameters:
      cms - the current users OpenCms context
    • readDependencies

      public void readDependencies(CmsObject cms, List<CmsResource> folderContent)
      Reads all dependencies that exist for this main resource in provided list of resources.

      Parameters:
      cms - the current users OpenCms context
      folderContent - the contents of the folder to check the dependencies for
    • setAttachmentNumber

      public void setAttachmentNumber(Integer attachmentNumber)
      Sets the attachment number.

      Parameters:
      attachmentNumber - the attachment number
    • setDocumentName

      public void setDocumentName(String documentName)
      Sets the file name of the document without attachment or locale suffixes.

      Parameters:
      documentName - the file name of the document without attachment or locale suffixes
    • setDocumentSuffix

      public void setDocumentSuffix(String documentSuffix)
      Sets the suffix (.pdf, .doc etc.) of the document.

      Parameters:
      documentSuffix - the suffix to set
    • setLocale

      public void setLocale(Locale locale)
      Sets the locale of this document container.

      Parameters:
      locale - the locale of this document container
    • setMainDocument

      public void setMainDocument(CmsDocumentDependency mainDocument)
      Sets the main document in case this document is an attachment.

      Parameters:
      mainDocument - the main document to set
    • setType

      Sets the type for this dependency.

      Parameters:
      type - the type to set
    • storeInContext

      public void storeInContext(CmsObject cms)
      Stores this dependency object for a published resource in the OpenCms runtime context.

      This done to optimize indexing speed. When the index update information is calculated, all dependencies for a resource must be calculated also. The same information is later needed when the Lucene document is created, for example in order to store the list of other available languages.

      Parameters:
      cms - the current OpenCms user context
    • toDependencyString

      Creates the String representation of this dependency object.

      Parameters:
      cms - the current OpenCms user context
      Returns:
      the String representation of this dependency object
    • toJSON

      public JSONObject toJSON(CmsObject cms, boolean includeLang)
      Returns a JSON object describing this dependency document.

      Parameters:
      cms - the current cms object
      includeLang - flag if language versions should be included
      Returns:
      a JSON object describing this dependency document
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also: