Class 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 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
  • Field Details

    • CONFIG_KEY_FIELD_XPATH

      public static final String CONFIG_KEY_FIELD_XPATH
      See Also:
    • CONFIG_KEY_PROFILE_XPATH

      public static final String CONFIG_KEY_PROFILE_XPATH
      See Also:
    • CONFIG_KEY_ITEM_XPATH

      public static final String CONFIG_KEY_ITEM_XPATH
      See Also:
    • CONFIG_KEY_ITEM_ID_XPATH

      public static final String CONFIG_KEY_ITEM_ID_XPATH
      See Also:
    • CONFIG_KEY_ITEM_NAME_XPATH

      public static final String CONFIG_KEY_ITEM_NAME_XPATH
      See Also:
    • CONFIG_KEY_URL_NAME

      public static final String CONFIG_KEY_URL_NAME
      See Also:
    • CONFIG_KEY_URL_TEMPLATE

      public static final String CONFIG_KEY_URL_TEMPLATE
      See Also:
    • PLACEHOLDER_PROFILE

      public static final String PLACEHOLDER_PROFILE
      See Also:
    • PLACEHOLDER_ID

      public static final String PLACEHOLDER_ID
      See Also:
    • PLACEHOLDER_EXTENSION

      public static final String PLACEHOLDER_EXTENSION
      See Also:
    • 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 Details

  • Method Details

    • doInit

      protected void doInit(org.apache.commons.configuration2.HierarchicalConfiguration config)
      Overrides:
      doInit in class AbstractContentTypeUpgradeOperation
    • 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 class AbstractContentUpgradeOperation
      Parameters:
      context - the current upgrade context
      file - 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 file
      definition - the form definition of the content-type
      descriptor - the item descriptor
      formField - 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 descriptor
      item - the field item
      profileId - the profile id
      fieldName - the field name
      Returns:
      true if any field was updated
      Throws:
      XPathExpressionException - if there is an error evaluating a XPath selector