use of com.sun.identity.entitlement.PrivilegeManager in project OpenAM by OpenRock.
the class OldPolicyConditionMigrationUpgradeStep method initialize.
/**
* 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.
*
* @throws UpgradeException If a problem occurred checking the policies.
*/
@Override
public void initialize() throws UpgradeException {
if (!isCurrentVersionLessThan(1200, 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);
}
}
Aggregations