Search in sources :

Example 16 with UpgradeException

use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.

the class UpgradeCTSMaxConnectionsConfigurationStep method perform.

@Override
public void perform() throws UpgradeException {
    try {
        DEBUG.message("External CTS Configuration upgrading: {}", serversToUpdate);
        helper.clearState();
        for (Entry<String, String> ctsMaxConnectionsProperty : serversToUpdate.entrySet()) {
            UpgradeProgress.reportStart(PROGRESS_REPORT, ctsMaxConnectionsProperty.getKey());
            if (ServerConfiguration.DEFAULT_SERVER_CONFIG.equals(ctsMaxConnectionsProperty.getKey())) {
                helper.getDefaultServerConfig(getAdminToken()).setCTSMaxConnections(ctsMaxConnectionsProperty.getValue());
            } else {
                helper.getServerConfigs(getAdminToken()).get(ctsMaxConnectionsProperty.getKey()).setCTSMaxConnections(ctsMaxConnectionsProperty.getValue());
            }
            UpgradeProgress.reportEnd(PROGRESS_SUCCESS);
        }
        UpgradeProgress.reportEnd(PROGRESS_SUCCESS);
    } catch (Exception ex) {
        DEBUG.error("Unable to upgrade External CTS properties", ex);
        throw new UpgradeException(ex);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) UpgradeException(org.forgerock.openam.upgrade.UpgradeException) SMSException(com.sun.identity.sm.SMSException) IOException(java.io.IOException) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) SSOException(com.iplanet.sso.SSOException)

Example 17 with UpgradeException

use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.

the class UpgradeEntitlementSubConfigsStep method addMissingApplicationTypes.

/**
     * Add missing application types.
     *
     * @throws UpgradeException
     *         should the process of creating new application types fail
     */
private void addMissingApplicationTypes() throws UpgradeException {
    for (final Node typeNode : missingApplicationTypes) {
        final Map<String, Set<String>> keyValueMap = parseAttributeValuePairTags(typeNode);
        final String name = getNodeAttributeValue(typeNode, NAME);
        UpgradeProgress.reportStart(AUDIT_NEW_TYPE_START, name);
        keyValueMap.put(NAME, Collections.singleton(name));
        try {
            DEBUG.message("Saving new entitlement application type: " + name);
            entitlementService.storeApplicationType(createApplicationType(name, keyValueMap));
            UpgradeProgress.reportEnd(AUDIT_UPGRADE_SUCCESS);
        } catch (EntitlementException eE) {
            UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
            throw new UpgradeException(eE);
        } catch (InstantiationException ie) {
            UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
            throw new UpgradeException(ie);
        } catch (IllegalAccessException iae) {
            UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
            throw new UpgradeException(iae);
        }
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) EntitlementException(com.sun.identity.entitlement.EntitlementException) HashSet(java.util.HashSet) Set(java.util.Set) Node(org.w3c.dom.Node)

Example 18 with UpgradeException

use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.

the class RemoveReferralsStep method cloneApplication.

private Application cloneApplication(Application application, String resourceTypeId) throws UpgradeException {
    try {
        Application newApplication = new Application(application.getName(), application.getApplicationType());
        newApplication.setDescription(application.getDescription());
        newApplication.setSubjects(application.getSubjects());
        newApplication.setConditions(application.getConditions());
        newApplication.setResourceComparator(application.getResourceComparatorClass());
        newApplication.setSearchIndex(application.getSearchIndexClass());
        newApplication.setSaveIndex(application.getSaveIndexClass());
        newApplication.setEntitlementCombiner(application.getEntitlementCombinerClass());
        newApplication.setAttributeNames(application.getAttributeNames());
        newApplication.addAllResourceTypeUuids(singleton(resourceTypeId));
        return newApplication;
    } catch (InstantiationException | IllegalAccessException e) {
        throw new UpgradeException(format("Failed to clone application %s", application.getName()), e);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) Application(com.sun.identity.entitlement.Application)

Example 19 with UpgradeException

use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.

the class RemoveReferralsStep method deleteExistingReferrals.

private void deleteExistingReferrals() throws UpgradeException {
    try (Connection connection = getConnection()) {
        for (DN referral : referralsToBeRemoved) {
            UpgradeProgress.reportStart(AUDIT_REMOVING_REFERRAL_START, referral);
            DeleteRequest request = LDAPRequests.newDeleteRequest(referral);
            connection.delete(request);
            UpgradeProgress.reportEnd(AUDIT_UPGRADE_SUCCESS);
        }
    } catch (DataLayerException | LdapException e) {
        UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
        throw new UpgradeException("Failed to delete referrals", e);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) DataLayerException(org.forgerock.openam.sm.datalayer.api.DataLayerException) Connection(org.forgerock.opendj.ldap.Connection) DN(org.forgerock.opendj.ldap.DN) DeleteRequest(org.forgerock.opendj.ldap.requests.DeleteRequest) LdapException(org.forgerock.opendj.ldap.LdapException)

Example 20 with UpgradeException

use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.

the class RemoveReferralsStep method instateAssociatedResourceType.

private String instateAssociatedResourceType(String resourceTypeId, String sourceRealm, String destinationRealm) throws EntitlementException, UpgradeException {
    Pair<String, String> key = Pair.of(destinationRealm, resourceTypeId);
    if (clonedResourceTypes.containsKey(key)) {
        return clonedResourceTypes.get(key);
    }
    ResourceType resourceType = resourceTypeService.getResourceType(getAdminSubject(), sourceRealm, resourceTypeId);
    if (resourceType == null) {
        throw new UpgradeException(format("Expected resource type %s in realm %s", resourceTypeId, sourceRealm));
    }
    ResourceType clonedResourceType = cloneResourceType(resourceType);
    resourceTypeService.saveResourceType(getAdminSubject(), destinationRealm, clonedResourceType);
    clonedResourceTypes.put(key, clonedResourceType.getUUID());
    return clonedResourceType.getUUID();
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) ResourceType(org.forgerock.openam.entitlement.ResourceType)

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