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
public class BoxRemoteAssetUpgradeOperation extends AbstractContentTypeUpgradeOperation
Implementation ofUpgradeOperation
to update item descriptors that use the Box File Upload controlSupported 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
Fields Modifier and Type Field Description static String
CONFIG_KEY_FIELD_XPATH
static String
CONFIG_KEY_ITEM_ID_XPATH
static String
CONFIG_KEY_ITEM_NAME_XPATH
static String
CONFIG_KEY_ITEM_XPATH
static String
CONFIG_KEY_PROFILE_XPATH
static String
CONFIG_KEY_URL_NAME
static String
CONFIG_KEY_URL_TEMPLATE
protected String
fieldNameXpath
XPath selector to find the name of the field that uses the Box controlprotected String
itemIdXpath
XPath selector to find the Box file idprotected String
itemNameXpath
XPath selector to find the Box file nameprotected String
itemXpath
XPath selector to find the value of the field that uses the Box controlstatic String
PLACEHOLDER_EXTENSION
static String
PLACEHOLDER_ID
static String
PLACEHOLDER_PROFILE
protected String
profileIdXpath
XPath selector to find the profile id configured for the Box controlprotected String
urlElementName
Name for the new XML tag to add to the fieldprotected String
urlTemplate
URL template to generate the new value for the Box file-
Fields 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
-
-
Constructor Summary
Constructors Constructor Description BoxRemoteAssetUpgradeOperation(StudioConfiguration studioConfiguration, String contentTypeXpath, String formDefinitionTemplate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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 file-
Methods 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
-
-
-
-
Field Detail
-
CONFIG_KEY_FIELD_XPATH
public static final String CONFIG_KEY_FIELD_XPATH
- See Also:
- Constant Field Values
-
CONFIG_KEY_PROFILE_XPATH
public static final String CONFIG_KEY_PROFILE_XPATH
- See Also:
- Constant Field Values
-
CONFIG_KEY_ITEM_XPATH
public static final String CONFIG_KEY_ITEM_XPATH
- See Also:
- Constant Field Values
-
CONFIG_KEY_ITEM_ID_XPATH
public static final String CONFIG_KEY_ITEM_ID_XPATH
- See Also:
- Constant Field Values
-
CONFIG_KEY_ITEM_NAME_XPATH
public static final String CONFIG_KEY_ITEM_NAME_XPATH
- See Also:
- Constant Field Values
-
CONFIG_KEY_URL_NAME
public static final String CONFIG_KEY_URL_NAME
- See Also:
- Constant Field Values
-
CONFIG_KEY_URL_TEMPLATE
public static final String CONFIG_KEY_URL_TEMPLATE
- See Also:
- Constant Field Values
-
PLACEHOLDER_PROFILE
public static final String PLACEHOLDER_PROFILE
- See Also:
- Constant Field Values
-
PLACEHOLDER_ID
public static final String PLACEHOLDER_ID
- See Also:
- Constant Field Values
-
PLACEHOLDER_EXTENSION
public static final String PLACEHOLDER_EXTENSION
- See Also:
- Constant Field Values
-
fieldNameXpath
protected String fieldNameXpath
XPath selector to find the name of the field that uses the Box control
-
profileIdXpath
protected String profileIdXpath
XPath selector to find the profile id configured for the Box control
-
itemXpath
protected String itemXpath
XPath selector to find the value of the field that uses the Box control
-
itemIdXpath
protected String itemIdXpath
XPath selector to find the Box file id
-
itemNameXpath
protected String itemNameXpath
XPath selector to find the Box file name
-
urlElementName
protected String urlElementName
Name for the new XML tag to add to the field
-
urlTemplate
protected String urlTemplate
URL template to generate the new value for the Box file
-
-
Constructor Detail
-
BoxRemoteAssetUpgradeOperation
@ConstructorProperties({"studioConfiguration","contentTypeXpath","formDefinitionTemplate"}) public BoxRemoteAssetUpgradeOperation(StudioConfiguration studioConfiguration, String contentTypeXpath, String formDefinitionTemplate)
-
-
Method Detail
-
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
-
-