Class BoxRemoteAssetUpgradeOperation
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
org.craftercms.studio.impl.v2.upgrade.operations.site.BoxRemoteAssetUpgradeOperation
- 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
to update item descriptors that use the Box File Upload control
Supported YAML properties:
- fieldNameXpath: (required) XPath selector to find the name of the field that uses the Box control
- profileIdXpath: (required) XPath selector to find the profile id configured for the Box control
- itemXpath: (required) XPath selector to find the value of the field that uses the Box control
- itemIdXpath: (required) XPath selector to find the Box file id
- itemNameXpath: (required) XPath selector to find the Box file name
- urlElementName: (required) Name for the new XML tag to add to the field
- urlTemplate: (required) URL template to generate the new value for the Box file
- 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 TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
protected String
XPath selector to find the name of the field that uses the Box controlprotected String
XPath selector to find the Box file idprotected String
XPath selector to find the Box file nameprotected String
XPath selector to find the value of the field that uses the Box controlstatic final String
static final String
static final String
protected String
XPath selector to find the profile id configured for the Box controlprotected String
Name for the new XML tag to add to the fieldprotected String
URL template to generate the new value for the Box fileFields inherited from class org.craftercms.studio.impl.v2.upgrade.operations.site.AbstractContentTypeUpgradeOperation
cache, CONFIG_KEY_CONTENT_TYPES, CONFIG_KEY_FORM_DEFINITION, CONFIG_KEY_MAX_ITEMS, contentTypeXpath, DEFAULT_MAX_ITEMS, factory, formDefinitionTemplate, formDefinitionXpath, includedContentTypes, NAME_PLACEHOLDER, transformerFactory, xPathFactory
Fields inherited from class org.craftercms.studio.impl.v2.upgrade.operations.site.AbstractContentUpgradeOperation
CONFIG_KEY_INCLUDED_PATHS, includedPaths
Fields inherited from class org.craftercms.studio.impl.v2.upgrade.operations.AbstractUpgradeOperation
changedFiles, commitDetails, CONFIG_KEY_COMMIT_DETAILS, deletedFiles, servletContext, studioConfiguration
Fields inherited from class org.craftercms.commons.upgrade.impl.operations.AbstractUpgradeOperation
applicationContext, currentVersion, enabled, nextVersion
-
Constructor Summary
ConstructorsConstructorDescriptionBoxRemoteAssetUpgradeOperation
(StudioConfiguration studioConfiguration, String contentTypeXpath, String formDefinitionTemplate) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
doInit
(org.apache.commons.configuration2.HierarchicalConfiguration config) protected boolean
findFields
(Path file, Document definition, Document descriptor, Node formField) Find all fields in the given descriptor that use the Box controlprotected boolean
updateField
(Document descriptor, Node item, String profileId, String fieldName) Updates the given field to add the new element if neededprotected void
updateFile
(StudioUpgradeContext context, Path file) Performs any needed updates on the content of the given fileMethods inherited from class org.craftercms.studio.impl.v2.upgrade.operations.site.AbstractContentTypeUpgradeOperation
getFormDefinition, loadDocument, select, shouldBeUpdated, writeFile
Methods inherited from class org.craftercms.studio.impl.v2.upgrade.operations.site.AbstractContentUpgradeOperation
doExecute, filterPaths, findIncludedPaths, readFile, writeFile
Methods inherited from class org.craftercms.studio.impl.v2.upgrade.operations.AbstractUpgradeOperation
commitAllChanges, doExecute, getCommitMessage, init, loadResource, setServletContext, trackChangedFiles, trackDeletedFiles
Methods inherited from class org.craftercms.commons.upgrade.impl.operations.AbstractUpgradeOperation
execute, setApplicationContext, setEnabled
-
Field Details
-
CONFIG_KEY_FIELD_XPATH
- See Also:
-
CONFIG_KEY_PROFILE_XPATH
- See Also:
-
CONFIG_KEY_ITEM_XPATH
- See Also:
-
CONFIG_KEY_ITEM_ID_XPATH
- See Also:
-
CONFIG_KEY_ITEM_NAME_XPATH
- See Also:
-
CONFIG_KEY_URL_NAME
- See Also:
-
CONFIG_KEY_URL_TEMPLATE
- See Also:
-
PLACEHOLDER_PROFILE
- See Also:
-
PLACEHOLDER_ID
- See Also:
-
PLACEHOLDER_EXTENSION
- See Also:
-
fieldNameXpath
XPath selector to find the name of the field that uses the Box control -
profileIdXpath
XPath selector to find the profile id configured for the Box control -
itemXpath
XPath selector to find the value of the field that uses the Box control -
itemIdXpath
XPath selector to find the Box file id -
itemNameXpath
XPath selector to find the Box file name -
urlElementName
Name for the new XML tag to add to the field -
urlTemplate
URL template to generate the new value for the Box file
-
-
Constructor Details
-
BoxRemoteAssetUpgradeOperation
@ConstructorProperties({"studioConfiguration","contentTypeXpath","formDefinitionTemplate"}) public BoxRemoteAssetUpgradeOperation(StudioConfiguration studioConfiguration, String contentTypeXpath, String formDefinitionTemplate)
-
-
Method Details
-
doInit
protected void doInit(org.apache.commons.configuration2.HierarchicalConfiguration config) - Overrides:
doInit
in classAbstractContentTypeUpgradeOperation
-
updateFile
protected void updateFile(StudioUpgradeContext context, Path file) throws org.craftercms.commons.upgrade.exception.UpgradeException Description copied from class:AbstractContentUpgradeOperation
Performs any needed updates on the content of the given file- Specified by:
updateFile
in classAbstractContentUpgradeOperation
- Parameters:
context
- the current upgrade contextfile
- the file to update- Throws:
org.craftercms.commons.upgrade.exception.UpgradeException
- if there is any error updating the file
-
findFields
protected boolean findFields(Path file, Document definition, Document descriptor, Node formField) throws XPathExpressionException Find all fields in the given descriptor that use the Box control- Parameters:
file
- the XML filedefinition
- the form definition of the content-typedescriptor
- the item descriptorformField
- the form field- Returns:
- true if any field was updated
- Throws:
XPathExpressionException
- if there is an error evaluating a XPath selector
-
updateField
protected boolean updateField(Document descriptor, Node item, String profileId, String fieldName) throws XPathExpressionException Updates the given field to add the new element if needed- Parameters:
descriptor
- the item descriptoritem
- the field itemprofileId
- the profile idfieldName
- the field name- Returns:
- true if any field was updated
- Throws:
XPathExpressionException
- if there is an error evaluating a XPath selector
-