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 ofUpgradeOperationto 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 StringCONFIG_KEY_FIELD_XPATHstatic StringCONFIG_KEY_ITEM_ID_XPATHstatic StringCONFIG_KEY_ITEM_NAME_XPATHstatic StringCONFIG_KEY_ITEM_XPATHstatic StringCONFIG_KEY_PROFILE_XPATHstatic StringCONFIG_KEY_URL_NAMEstatic StringCONFIG_KEY_URL_TEMPLATEprotected StringfieldNameXpathXPath selector to find the name of the field that uses the Box controlprotected StringitemIdXpathXPath selector to find the Box file idprotected StringitemNameXpathXPath selector to find the Box file nameprotected StringitemXpathXPath selector to find the value of the field that uses the Box controlstatic StringPLACEHOLDER_EXTENSIONstatic StringPLACEHOLDER_IDstatic StringPLACEHOLDER_PROFILEprotected StringprofileIdXpathXPath selector to find the profile id configured for the Box controlprotected StringurlElementNameName for the new XML tag to add to the fieldprotected StringurlTemplateURL 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 voiddoInit(org.apache.commons.configuration2.HierarchicalConfiguration config)protected booleanfindFields(Path file, Document definition, Document descriptor, Node formField)Find all fields in the given descriptor that use the Box controlprotected booleanupdateField(Document descriptor, Node item, String profileId, String fieldName)Updates the given field to add the new element if neededprotected voidupdateFile(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:
doInitin classAbstractContentTypeUpgradeOperation
-
updateFile
protected void updateFile(StudioUpgradeContext context, Path file) 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 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
-
-