Search in sources :

Example 51 with UpgradeException

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);
        }
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) EntitlementException(com.sun.identity.entitlement.EntitlementException) HashMap(java.util.HashMap) Map(java.util.Map) EntitlementUtils.resourceTypeFromMap(org.forgerock.openam.entitlement.utils.EntitlementUtils.resourceTypeFromMap) Application(com.sun.identity.entitlement.Application)

Example 52 with UpgradeException

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);
        }
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) EntitlementException(com.sun.identity.entitlement.EntitlementException) HashMap(java.util.HashMap) Map(java.util.Map) EntitlementUtils.resourceTypeFromMap(org.forgerock.openam.entitlement.utils.EntitlementUtils.resourceTypeFromMap) Application(com.sun.identity.entitlement.Application)

Example 53 with UpgradeException

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);
        }
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) EntitlementException(com.sun.identity.entitlement.EntitlementException) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) Map(java.util.Map) EntitlementUtils.resourceTypeFromMap(org.forgerock.openam.entitlement.utils.EntitlementUtils.resourceTypeFromMap) Application(com.sun.identity.entitlement.Application)

Example 54 with UpgradeException

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);
    }
}
Also used : Policy(com.sun.identity.policy.Policy) UpgradeException(org.forgerock.openam.upgrade.UpgradeException) PolicyManager(com.sun.identity.policy.PolicyManager) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) Map(java.util.Map) UpgradeException(org.forgerock.openam.upgrade.UpgradeException)

Example 55 with UpgradeException

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);
        }
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) PolicyManager(com.sun.identity.policy.PolicyManager) UpgradeException(org.forgerock.openam.upgrade.UpgradeException)

Aggregations

UpgradeException (org.forgerock.openam.upgrade.UpgradeException)81 SSOException (com.iplanet.sso.SSOException)29 HashMap (java.util.HashMap)27 SMSException (com.sun.identity.sm.SMSException)25 Set (java.util.Set)25 HashSet (java.util.HashSet)22 Map (java.util.Map)22 ServiceConfig (com.sun.identity.sm.ServiceConfig)21 EntitlementException (com.sun.identity.entitlement.EntitlementException)16 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)14 Application (com.sun.identity.entitlement.Application)10 IOException (java.io.IOException)10 PolicyManager (com.sun.identity.policy.PolicyManager)8 PolicyException (com.sun.identity.policy.PolicyException)6 ServiceNotFoundException (com.sun.identity.sm.ServiceNotFoundException)6 EntitlementUtils.resourceTypeFromMap (org.forgerock.openam.entitlement.utils.EntitlementUtils.resourceTypeFromMap)6 Node (org.w3c.dom.Node)5 ServiceSchema (com.sun.identity.sm.ServiceSchema)4 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)4 Properties (java.util.Properties)4