use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeEntitlementSubConfigsStep method addChangedCombiners.
/**
* Alter EntitlementCombiner references.
*
* @throws UpgradeException
*/
private void addChangedCombiners() throws UpgradeException {
for (final Map.Entry<String, String> entry : changedCombiners.entrySet()) {
final String name = entry.getKey();
final String combiner = entry.getValue();
try {
UpgradeProgress.reportStart(AUDIT_MODIFIED_COM_START, name);
if (DEBUG.messageEnabled()) {
DEBUG.message("Modifying application " + name + " ; setting combiner: " + combiner);
}
final Application application = getApplication(name);
application.setEntitlementCombinerName(EntitlementUtils.getEntitlementCombiner(combiner));
entitlementService.storeApplication(application);
UpgradeProgress.reportEnd(AUDIT_UPGRADE_SUCCESS);
} catch (EntitlementException ee) {
UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
throw new UpgradeException(ee);
}
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeEntitlementSubConfigsStep method addChangedDescription.
/**
* Clears the description currently associated with an application, then replaces it with
* the new description defined.
*
* @throws UpgradeException If there was an error while updating the application.
*/
private void addChangedDescription() throws UpgradeException {
for (final Map.Entry<String, String> entry : changedDescriptions.entrySet()) {
final String name = entry.getKey();
final String description = entry.getValue();
try {
UpgradeProgress.reportStart(AUDIT_MODIFIED_DES_START, name);
if (DEBUG.messageEnabled()) {
DEBUG.message("Modifying application " + name + " ; adding description: " + description);
}
final Application application = getApplication(name);
application.setDescription(description);
entitlementService.storeApplication(application);
UpgradeProgress.reportEnd(AUDIT_UPGRADE_SUCCESS);
} catch (EntitlementException ee) {
UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
throw new UpgradeException(ee);
}
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeEntitlementSubConfigsStep method addChangedConditions.
/**
* Clears the conditions currently associated with an application, then replaces them with
* the new set of conditions defined.
*
* @throws UpgradeException If there was an error while updating the application.
*/
private void addChangedConditions() throws UpgradeException {
for (final Map.Entry<String, Set<String>> entry : changedConditions.entrySet()) {
final String name = entry.getKey();
final Set<String> conditions = entry.getValue();
try {
UpgradeProgress.reportStart(AUDIT_MODIFIED_CON_START, name);
if (DEBUG.messageEnabled()) {
DEBUG.message("Modifying application " + name + " ; adding conditions: " + conditions);
}
final Application application = getApplication(name);
application.setConditions(conditions);
entitlementService.storeApplication(application);
UpgradeProgress.reportEnd(AUDIT_UPGRADE_SUCCESS);
} catch (EntitlementException ee) {
UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
throw new UpgradeException(ee);
}
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class ResavePoliciesStep method perform.
public void perform() throws UpgradeException {
try {
for (Map.Entry<String, Set<String>> entry : policyMap.entrySet()) {
String realm = entry.getKey();
Set<String> policyNames = entry.getValue();
PolicyManager pm = new PolicyManager(getAdminToken(), realm);
for (String policyName : policyNames) {
if (DEBUG.messageEnabled()) {
DEBUG.message("Resaving the following policy: " + policyName);
}
UpgradeProgress.reportStart("upgrade.policy.start", policyName);
Policy policy = pm.getPolicy(policyName);
pm.replacePolicy(policy);
UpgradeProgress.reportEnd("upgrade.success");
}
}
} catch (Exception ex) {
UpgradeProgress.reportEnd("upgrade.failed");
DEBUG.error("An error occurred while trying to resave policies", ex);
throw new UpgradeException(ex);
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class ResavePoliciesStep method initialize.
public void initialize() throws UpgradeException {
DEBUG.message("Initializing ResavePoliciesStep");
if (VersionUtils.isCurrentVersionEqualTo(UpgradeUtils.ELEVEN_VERSION_NUMBER)) {
try {
for (String realm : getRealmNames()) {
PolicyManager pm = new PolicyManager(getAdminToken(), realm);
Set<String> policyNames = pm.getPolicyNames();
if (policyNames != null && !policyNames.isEmpty()) {
policyMap.put(realm, new HashSet<String>(policyNames));
}
}
if (DEBUG.messageEnabled()) {
DEBUG.message("Discovered following policies:\n" + policyMap);
}
} catch (Exception ex) {
DEBUG.error("Error while trying to retrieve policy names", ex);
throw new UpgradeException(ex);
}
}
}
Aggregations