@Override public void initialize() throws UpgradeException {
  if (!isCurrentVersionLessThan(1300,true)) {
    return;
  }
  try {
    DEBUG.message("Initializing OldPolicyConditionMigrationStep");
    for (    String realm : getRealmNames()) {
      if (!realm.startsWith("/")) {
        realm="/" + realm;
      }
      PrivilegeManager privilegeManager=getPrivilegeManager(realm);
      List<Privilege> privileges;
      try {
        privileges=privilegeManager.findAllPolicies();
      }
 catch (      EntitlementException e) {
        continue;
      }
      for (      Privilege privilege : privileges) {
        if (conditionUpgrader.isPolicyUpgradable(privilege)) {
          try {
            MigrationReport report=conditionUpgrader.dryRunPolicyUpgrade(privilege);
            addReport(realm,report);
            addUpgradablePolicy(realm,privilege);
          }
 catch (          Exception e) {
            addUnupgradablePolicy(realm,privilege);
          }
        }
      }
    }
  }
 catch (  UpgradeException e) {
    DEBUG.error("Error while trying to detect changes in entitlements",e);
    throw e;
  }
catch (  Exception ex) {
    DEBUG.error("Error while trying to detect changes in entitlements",ex);
    throw new UpgradeException(ex);
  }
}

@ Override public void initialize ( ) throws UpgradeException { if ( ! isCurrentVersionLessThan ( 1300 , true ) ) { return ; } try { DEBUG . message ( "Initializing OldPolicyConditionMigrationStep" ) ; for ( String realm : getRealmNames ( ) ) { if ( ! realm . startsWith ( "/" ) ) { realm = "/" + realm ; } PrivilegeManager privilegeManager = getPrivilegeManager ( realm ) ; List < Privilege > privileges ; try { privileges = privilegeManager . findAllPolicies ( ) ; } catch ( EntitlementException e ) { continue ; } for ( Privilege privilege : privileges ) { if ( conditionUpgrader . isPolicyUpgradable ( privilege ) ) { try { MigrationReport report = conditionUpgrader . dryRunPolicyUpgrade ( privilege ) ; addReport ( realm , report ) ; addUpgradablePolicy ( realm , privilege ) ; } catch ( Exception e ) { addUnupgradablePolicy ( realm , privilege ) ; } } } } } catch ( UpgradeException e ) { DEBUG . error ( "Error while trying to detect changes in entitlements" , e ) ; throw e ; } catch ( Exception ex ) { DEBUG . error ( "Error while trying to detect changes in entitlements" , ex ) ; throw new UpgradeException ( ex ) ; } }
checks what policies could be automatically upgraded and performs the upgrade without saving so that the migrated policy can be validated to ensure the upgrade went well .
