Class XmlFileVersionProvider

java.lang.Object
org.craftercms.commons.upgrade.impl.providers.AbstractVersionProvider<String>
org.craftercms.studio.impl.v2.upgrade.providers.XmlFileVersionProvider
All Implemented Interfaces:
org.craftercms.commons.upgrade.VersionProvider<String>
Direct Known Subclasses:
SiteVersionProvider, XmlStreamVersionProvider

public class XmlFileVersionProvider extends org.craftercms.commons.upgrade.impl.providers.AbstractVersionProvider<String>
Implementation of VersionProvider for XML files.
Author:
joseross
  • Field Details

    • path

      protected String path
      Path of the file containing the version.
    • xpath

      protected String xpath
      XPath's expression to extract the version.
    • defaultVersion

      protected String defaultVersion
      Version returned if none is found.
    • skipIfMissing

      protected boolean skipIfMissing
      Indicates if the skip flag should be returned
    • contentRepository

      protected ContentRepository contentRepository
  • Constructor Details

  • Method Details

    • setPath

      public void setPath(String path)
    • setSkipIfMissing

      public void setSkipIfMissing(boolean skipIfMissing)
    • getFilePath

      protected String getFilePath(StudioUpgradeContext context)
    • doGetVersion

      protected String doGetVersion(org.craftercms.commons.upgrade.impl.UpgradeContext<String> context) throws Exception
      Specified by:
      doGetVersion in class org.craftercms.commons.upgrade.impl.providers.AbstractVersionProvider<String>
      Throws:
      Exception
    • getVersionFromFile

      protected String getVersionFromFile(String site, String filePath) throws Exception
      Get the version from the XML file. This method assumes the file existence has been checked previously.
      Parameters:
      site - Site name
      filePath - Path of the file containing the version
      Returns:
      the version of the file, as found in the XML file <version> tag
      Throws:
      org.craftercms.commons.upgrade.exception.UpgradeException - if there is an error reading the file
      Exception
    • doSetVersion

      protected void doSetVersion(org.craftercms.commons.upgrade.impl.UpgradeContext<String> context, String newVersion) throws Exception
      Specified by:
      doSetVersion in class org.craftercms.commons.upgrade.impl.providers.AbstractVersionProvider<String>
      Throws:
      Exception