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 Summary
FieldsModifier and TypeFieldDescriptionprotected ContentRepositoryprotected StringVersion returned if none is found.protected StringPath of the file containing the version.protected booleanIndicates if the skip flag should be returnedprotected StringXPath's expression to extract the version.Fields inherited from class org.craftercms.commons.upgrade.impl.providers.AbstractVersionProvider
defaultValue, loggerFields inherited from interface org.craftercms.commons.upgrade.VersionProvider
SKIP, VERSION -
Constructor Summary
ConstructorsConstructorDescriptionXmlFileVersionProvider(String path, String xpath, String defaultVersion, ContentRepository contentRepository) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringdoGetVersion(org.craftercms.commons.upgrade.impl.UpgradeContext<String> context) protected voiddoSetVersion(org.craftercms.commons.upgrade.impl.UpgradeContext<String> context, String newVersion) protected StringgetFilePath(StudioUpgradeContext context) protected StringgetVersionFromFile(String site, String filePath) Get the version from the XML file.voidvoidsetSkipIfMissing(boolean skipIfMissing) Methods inherited from class org.craftercms.commons.upgrade.impl.providers.AbstractVersionProvider
getVersion, setDefaultValue, setVersion
-
Field Details
-
path
Path of the file containing the version. -
xpath
XPath's expression to extract the version. -
defaultVersion
Version returned if none is found. -
skipIfMissing
protected boolean skipIfMissingIndicates if the skip flag should be returned -
contentRepository
-
-
Constructor Details
-
XmlFileVersionProvider
@ConstructorProperties({"path","xpath","defaultVersion","contentRepository"}) public XmlFileVersionProvider(String path, String xpath, String defaultVersion, ContentRepository contentRepository)
-
-
Method Details
-
setPath
-
setSkipIfMissing
public void setSkipIfMissing(boolean skipIfMissing) -
getFilePath
-
doGetVersion
-
getVersionFromFile
Get the version from the XML file. This method assumes the file existence has been checked previously.- Parameters:
site- Site namefilePath- 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 fileException
-
doSetVersion
-