Package org.opencms.search.documents
Class CmsDocumentDependency
java.lang.Object
org.opencms.search.documents.CmsDocumentDependency
Provides the dependency information about one search result document,
used to generate the list of document search results.
- Since:
- 8.5.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Defines the possible dependency types. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds another document attachment dependency to this document.void
Adds another document dependency to this document.void
Adds another language version document dependency to this document.boolean
static CmsDocumentDependency
fromDependencyString
(String input, String rootPath) Creates a dependency object from a String representation.void
fromJSON
(JSONObject json, String rootPath) Read the information out of the given JSON object to fill the values of the document.int
Returns the attachment number.Returns the attachments.Returns the list of resources the main resource depends on, including the main resource itself.Returns the file name of the document without attachment or locale suffixes.Returns the suffix of the document.Returns the locale of this document container.static Locale
Returns the locale (language) of the given resource based on the resource root path.Returns the main document in case this document is an attachment.Returns the VFS resource for which the dependencies are calculated.Returns the root path of this dependency.getType()
Returns the type.Returns the variants.int
hashCode()
boolean
Returns the locale file name flag.boolean
Returns true if this document is an attachment, i.e.static CmsDocumentDependency
load
(CmsObject cms, CmsPublishedResource pubRes) Loads or creates a dependency object for the given parameters.static CmsDocumentDependency
load
(CmsObject cms, CmsResource res) Loads or creates a dependency object for the given parameters.static CmsDocumentDependency
load
(CmsObject cms, CmsResource res, List<CmsResource> resources) Loads or creates a dependency object for the given parameters.protected static CmsDocumentDependency
loadForTest
(String rootPath) Creates a dependency object for the given root path, to be used only for test cases.void
Reads all dependencies that exist for this main resource in the OpenCms VFS.void
readDependencies
(CmsObject cms, List<CmsResource> folderContent) Reads all dependencies that exist for this main resource in provided list of resources.protected static void
removeFromContext
(CmsObject cms, CmsPublishedResource pubRes) Removes the dependency object for a published resource from the OpenCms runtime context.void
setAttachmentNumber
(Integer attachmentNumber) Sets the attachment number.void
setDocumentName
(String documentName) Sets the file name of the document without attachment or locale suffixes.void
setDocumentSuffix
(String documentSuffix) Sets the suffix (.pdf, .doc etc.) of the document.void
Sets the locale of this document container.void
setMainDocument
(CmsDocumentDependency mainDocument) Sets the main document in case this document is an attachment.void
Sets the type for this dependency.void
storeInContext
(CmsObject cms) Stores this dependency object for a published resource in the OpenCms runtime context.Creates the String representation of this dependency object.Returns a JSON object describing this dependency document.toString()
-
Method Details
-
fromDependencyString
Creates a dependency object from a String representation.- Parameters:
input
- the String representationrootPath
- the root path of the base document of which the dependencies are encoded- Returns:
- the dependency object created from a String representation
-
getLocale
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 contextpubRes
- the published resource to get the dependency object for- Returns:
- a dependency object for the given parameters
-
load
Loads or creates a dependency object for the given parameters.- Parameters:
cms
- the current OpenCms user contextres
- 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 contextres
- the VFS resource to get the dependency object forresources
- the resource folder data to check for dependencies- Returns:
- a dependency object for the given parameters
-
loadForTest
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
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 contextpubRes
- 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
Adds another language version document dependency to this document.- Parameters:
dep
- the language version document dependency to add
-
equals
-
fromJSON
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 documentrootPath
- the current path the home division
-
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
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
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
-
hasLocaleFileName
Returns the locale file name flag.- Returns:
- the locale file name flag
-
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
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
Reads all dependencies that exist for this main resource in provided list of resources.- Parameters:
cms
- the current users OpenCms contextfolderContent
- the contents of the folder to check the dependencies for
-
setAttachmentNumber
Sets the attachment number.- Parameters:
attachmentNumber
- the attachment number
-
setDocumentName
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
Sets the suffix (.pdf, .doc etc.) of the document.- Parameters:
documentSuffix
- the suffix to set
-
setLocale
Sets the locale of this document container.- Parameters:
locale
- the locale of this document container
-
setMainDocument
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
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
Returns a JSON object describing this dependency document.- Parameters:
cms
- the current cms objectincludeLang
- flag if language versions should be included- Returns:
- a JSON object describing this dependency document
-
toString
-