Class MultiFindAndReplaceUpgradeOperation
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.MultiFindAndReplaceUpgradeOperation
- All Implemented Interfaces:
org.craftercms.commons.upgrade.UpgradeOperation<String>,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,org.springframework.web.context.ServletContextAware
Implementation of
UpgradeOperation that replaces text in the content repository
according to multiple 'pattern/replacement' rules.
Supported YAML properties:
- rules: (required) the list of rules to find and replace text. Each rule should contain the properties:
- pattern: (required) the pattern to search in the files, can be a regular expression
- replacement: (required) the expression to replace in the files, can use matched groups from the regular expression in the pattern
- Author:
- jmendeza
-
Nested Class Summary
Nested classes/interfaces inherited from class org.craftercms.studio.impl.v2.upgrade.operations.site.AbstractContentUpgradeOperation
AbstractContentUpgradeOperation.ListFileVisitor -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringprotected List<org.craftercms.studio.impl.v2.upgrade.operations.site.MultiFindAndReplaceUpgradeOperation.Rule> The list of find-replace rulesFields 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
ConstructorsConstructorDescriptionMultiFindAndReplaceUpgradeOperation(StudioConfiguration studioConfiguration) -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoInit(org.apache.commons.configuration2.HierarchicalConfiguration config) protected booleanshouldBeUpdated(StudioUpgradeContext context, Path file) Indicates if the given file should be updated by this classprotected voidupdateFile(StudioUpgradeContext context, Path path) Performs any needed updates on the content of the given fileMethods inherited from class org.craftercms.studio.impl.v2.upgrade.operations.site.AbstractContentUpgradeOperation
doExecute, filterPaths, findIncludedPaths, readFile, 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_RULES
- See Also:
-
CONFIG_KEY_PATTERN
- See Also:
-
CONFIG_KEY_REPLACEMENT
- See Also:
-
rules
protected List<org.craftercms.studio.impl.v2.upgrade.operations.site.MultiFindAndReplaceUpgradeOperation.Rule> rulesThe list of find-replace rules
-
-
Constructor Details
-
MultiFindAndReplaceUpgradeOperation
-
-
Method Details
-
doInit
protected void doInit(org.apache.commons.configuration2.HierarchicalConfiguration config) - Overrides:
doInitin classAbstractContentUpgradeOperation
-
shouldBeUpdated
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
-
updateFile
protected void updateFile(StudioUpgradeContext context, Path path) throws org.craftercms.commons.upgrade.exception.UpgradeException Description copied from class:AbstractContentUpgradeOperationPerforms any needed updates on the content of the given file- Specified by:
updateFilein classAbstractContentUpgradeOperation- Parameters:
context- the current upgrade contextpath- the file to update- Throws:
org.craftercms.commons.upgrade.exception.UpgradeException- if there is any error updating the file
-