Class AbstractContentTypeUpgradeOperation
java.lang.Object
org.craftercms.commons.upgrade.impl.operations.AbstractUpgradeOperation<String>
org.craftercms.studio.impl.v2.upgrade.operations.AbstractUpgradeOperation
org.craftercms.studio.impl.v2.upgrade.operations.site.AbstractContentUpgradeOperation
org.craftercms.studio.impl.v2.upgrade.operations.site.AbstractContentTypeUpgradeOperation
- All Implemented Interfaces:
org.craftercms.commons.upgrade.UpgradeOperation<String>,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,org.springframework.web.context.ServletContextAware
- Direct Known Subclasses:
BoxRemoteAssetUpgradeOperation
Base implementation of
UpgradeOperation for all content-type related upgrades
Supported YAML properties:
- includedContentTypes: (optional) list of content-types that can be handled by this operation, if left unset all content-types will be included
- formDefinitionXpath: (optional) XPath selector to evaluate if a content-type should be handled by this operation, if left unset all content-types will be included
- maxCacheItems: (optional) maximum number of items in the cache, can be used for performance tuning in case an upgrade needs to parse too many files in the repository. Defaults to 200
- Author:
- joseross
-
Nested Class Summary
Nested classes/interfaces inherited from class org.craftercms.studio.impl.v2.upgrade.operations.site.AbstractContentUpgradeOperation
AbstractContentUpgradeOperation.ListFileVisitor -
Field Summary
FieldsModifier and TypeFieldDescriptionCache used to avoid parsing the same file multiple times during the execution of this operationstatic final Stringstatic final Stringstatic final Stringprotected StringXPath to query the content-type of item descriptorsstatic final intprotected DocumentBuilderFactoryprotected StringPath template to find the form-definition.xml file for a content-typeprotected StringXPath to evaluate if a content-type can be handled by this operation (optional)List of content-types that can be handled by this operation (optional)static final Stringprotected TransformerFactoryprotected XPathFactoryFields inherited from class org.craftercms.studio.impl.v2.upgrade.operations.site.AbstractContentUpgradeOperation
CONFIG_KEY_INCLUDED_PATHS, includedPathsFields inherited from class org.craftercms.studio.impl.v2.upgrade.operations.AbstractUpgradeOperation
changedFiles, commitDetails, CONFIG_KEY_COMMIT_DETAILS, deletedFiles, servletContext, studioConfigurationFields inherited from class org.craftercms.commons.upgrade.impl.operations.AbstractUpgradeOperation
applicationContext, currentVersion, enabled, nextVersion -
Constructor Summary
ConstructorsConstructorDescriptionAbstractContentTypeUpgradeOperation(StudioConfiguration studioConfiguration, String contentTypeXpath, String formDefinitionTemplate) -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoInit(org.apache.commons.configuration2.HierarchicalConfiguration config) protected PathgetFormDefinition(StudioUpgradeContext context, String contentTypeName) Finds the form-definition.xml five for the given content-typeprotected DocumentloadDocument(Path file) Parses the given XML fileprotected ObjectEvaluates a XPath selector on the given objectprotected booleanshouldBeUpdated(StudioUpgradeContext context, Path file) Indicates if the given file should be updated by this classprotected voidWrites an XML file to the file system without committing any changes in the repositoryMethods inherited from class org.craftercms.studio.impl.v2.upgrade.operations.site.AbstractContentUpgradeOperation
doExecute, filterPaths, findIncludedPaths, readFile, updateFile, writeFileMethods inherited from class org.craftercms.studio.impl.v2.upgrade.operations.AbstractUpgradeOperation
commitAllChanges, doExecute, getCommitMessage, init, loadResource, setServletContext, trackChangedFiles, trackDeletedFilesMethods inherited from class org.craftercms.commons.upgrade.impl.operations.AbstractUpgradeOperation
execute, setApplicationContext, setEnabled
-
Field Details
-
CONFIG_KEY_CONTENT_TYPES
- See Also:
-
CONFIG_KEY_FORM_DEFINITION
- See Also:
-
CONFIG_KEY_MAX_ITEMS
- See Also:
-
NAME_PLACEHOLDER
- See Also:
-
DEFAULT_MAX_ITEMS
public static final int DEFAULT_MAX_ITEMS- See Also:
-
includedContentTypes
List of content-types that can be handled by this operation (optional) -
formDefinitionXpath
XPath to evaluate if a content-type can be handled by this operation (optional) -
contentTypeXpath
XPath to query the content-type of item descriptors -
formDefinitionTemplate
Path template to find the form-definition.xml file for a content-type -
cache
Cache used to avoid parsing the same file multiple times during the execution of this operation -
factory
-
xPathFactory
-
transformerFactory
-
-
Constructor Details
-
AbstractContentTypeUpgradeOperation
public AbstractContentTypeUpgradeOperation(StudioConfiguration studioConfiguration, String contentTypeXpath, String formDefinitionTemplate)
-
-
Method Details
-
doInit
protected void doInit(org.apache.commons.configuration2.HierarchicalConfiguration config) - Overrides:
doInitin classAbstractContentUpgradeOperation
-
shouldBeUpdated
protected boolean shouldBeUpdated(StudioUpgradeContext context, Path file) throws org.craftercms.commons.upgrade.exception.UpgradeException Description copied from class:AbstractContentUpgradeOperationIndicates if the given file should be updated by this class- Specified by:
shouldBeUpdatedin classAbstractContentUpgradeOperation- Parameters:
context- the current upgrade contextfile- the file to check- Returns:
- true if the file should be updated
- Throws:
org.craftercms.commons.upgrade.exception.UpgradeException- if there is any error checking the file
-
loadDocument
Parses the given XML file- Parameters:
file- the file to parse- Returns:
- the parsed file
- Throws:
ExecutionException- if there is any error parsing the file
-
getFormDefinition
Finds the form-definition.xml five for the given content-type- Parameters:
context- the current upgrade contextcontentTypeName- the content-type name- Returns:
- the form definition file
-
select
Evaluates a XPath selector on the given object- Parameters:
source- the object to evaluatexpath- the selector to evaluatetype- the type to return- Returns:
- the evaluation result
- Throws:
XPathExpressionException- if there is any error evaluating the selector
-
writeFile
protected void writeFile(Path file, Document document) throws org.craftercms.commons.upgrade.exception.UpgradeException Writes an XML file to the file system without committing any changes in the repository- Parameters:
file- the file to writedocument- the XML document to write- Throws:
org.craftercms.commons.upgrade.exception.UpgradeException- if there is any error writing the file
-