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 Detail

      • 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

      • 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