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
Nested ClassesModifier and TypeClassDescriptionstatic enumDefines the possible dependency types. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds another document attachment dependency to this document.voidAdds another document dependency to this document.voidAdds another language version document dependency to this document.booleanstatic CmsDocumentDependencyfromDependencyString(String input, String rootPath) Creates a dependency object from a String representation.voidfromJSON(JSONObject json, String rootPath) Read the information out of the given JSON object to fill the values of the document.intReturns 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 LocaleReturns 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.inthashCode()booleanReturns the locale file name flag.booleanReturns true if this document is an attachment, i.e.static CmsDocumentDependencyload(CmsObject cms, CmsPublishedResource pubRes) Loads or creates a dependency object for the given parameters.static CmsDocumentDependencyload(CmsObject cms, CmsResource res) Loads or creates a dependency object for the given parameters.static CmsDocumentDependencyload(CmsObject cms, CmsResource res, List<CmsResource> resources) Loads or creates a dependency object for the given parameters.protected static CmsDocumentDependencyloadForTest(String rootPath) Creates a dependency object for the given root path, to be used only for test cases.voidReads all dependencies that exist for this main resource in the OpenCms VFS.voidreadDependencies(CmsObject cms, List<CmsResource> folderContent) Reads all dependencies that exist for this main resource in provided list of resources.protected static voidremoveFromContext(CmsObject cms, CmsPublishedResource pubRes) Removes the dependency object for a published resource from the OpenCms runtime context.voidsetAttachmentNumber(Integer attachmentNumber) Sets the attachment number.voidsetDocumentName(String documentName) Sets the file name of the document without attachment or locale suffixes.voidsetDocumentSuffix(String documentSuffix) Sets the suffix (.pdf, .doc etc.) of the document.voidSets the locale of this document container.voidsetMainDocument(CmsDocumentDependency mainDocument) Sets the main document in case this document is an attachment.voidSets the type for this dependency.voidstoreInContext(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
-