Class ProjectFileUpgrader

java.lang.Object
org.apache.cayenne.project.upgrade.ProjectFileUpgrader

public class ProjectFileUpgrader extends Object
Upgrades project or DataMap XML resources created by older versions of Cayenne to the current project version.
Since:
5.0
  • Constructor Details

    • ProjectFileUpgrader

      public ProjectFileUpgrader(org.apache.cayenne.di.Provider<XMLReader> xmlReaderProvider)
  • Method Details

    • checkUpgradeNeeded

      public UpgradeType checkUpgradeNeeded(String version)
      Determines what kind of upgrade, if any, a project of the given version needs.
    • projectVersion

      public static String projectVersion(String rootNamespace, Attributes rootAttributes)
      Returns the version of a project or DataMap XML based on its root tag, or null if it can't be determined. The version is a part of the root namespace, e.g. "http://cayenne.apache.org/schema/14/dataMap". The documents older than version 14 may have no namespace, or a namespace with no project version in it, in which case the version is taken from their "project-version" attribute.
      Since:
      5.0
    • readVersion

      public String readVersion(Resource resource)
      Reads the version from the root tag of a project or DataMap XML, without reading the rest of the document.
    • upgradeProjectDOM

      public UpgradeContext upgradeProjectDOM(Resource resource, String fromVersion)
      Reads the project XML and upgrades its DOM from the given version. The project file is not modified. The referenced DataMaps are not touched, see upgradeDataMapDOM(Resource, String).
      Throws:
      ConfigurationException - if the version is newer than the current one, or is too old to be upgraded
    • upgradeDataMapDOM

      public UpgradeContext upgradeDataMapDOM(Resource resource, String fromVersion)
      Reads the DataMap XML and upgrades its DOM from the given version. The DataMap file is not modified.
      Throws:
      ConfigurationException - if the version is newer than the current one, or is too old to be upgraded