Search in sources :

Example 46 with ConfigurationException

use of com.sun.identity.common.configuration.ConfigurationException in project OpenAM by OpenRock.

the class ServerSiteModelImpl method modifySite.

/**
     * Modifies site profile.
     *
     * @param siteName name of site.
     * @param primaryURL Primary URL.
     * @param failoverURLs Failover URLs.
     * @throws AMConsoleException if site profile cannot be modified.
     */
public void modifySite(String siteName, String primaryURL, Set failoverURLs) throws AMConsoleException {
    try {
        SSOToken ssoToken = getUserSSOToken();
        String[] param = { siteName };
        logEvent("ATTEMPT_MODIFY_SITE", param);
        SiteConfiguration.setSitePrimaryURL(ssoToken, siteName, primaryURL);
        SiteConfiguration.setSiteSecondaryURLs(ssoToken, siteName, failoverURLs);
        logEvent("SUCCEED_MODIFY_SITE", param);
    } catch (ConfigurationException e) {
        String[] params = { siteName, e.getMessage() };
        logEvent("CONFIGURATION_EXCEPTION_MODIFY_SITE", params);
        throw new AMConsoleException(getErrorString(e));
    } catch (SMSException e) {
        String[] params = { siteName, e.getMessage() };
        logEvent("SMS_EXCEPTION_MODIFY_SITE", params);
        throw new AMConsoleException(getErrorString(e));
    } catch (SSOException e) {
        String[] params = { siteName, e.getMessage() };
        logEvent("SSO_EXCEPTION_MODIFY_SITE", params);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 47 with ConfigurationException

use of com.sun.identity.common.configuration.ConfigurationException in project OpenAM by OpenRock.

the class SitesResourceProvider method deleteInstance.

@Override
public Promise<ResourceResponse, ResourceException> deleteInstance(Context context, String id, DeleteRequest request) {
    ResourceResponse site;
    SSOToken token;
    try {
        token = getSsoToken(context);
        site = getSite(token, id);
    } catch (SMSException | SSOException | ConfigurationException e) {
        debug.error("Could not read site {}", id, e);
        return new InternalServerErrorException("Could not read site").asPromise();
    } catch (NotFoundException e) {
        return e.asPromise();
    }
    try {
        if (!site.getRevision().equals(request.getRevision())) {
            return new PreconditionFailedException("Revision did not match").asPromise();
        } else if (!SiteConfiguration.listServers(token, id).isEmpty()) {
            return new PreconditionFailedException("Site still has servers attached to it").asPromise();
        } else if (!SiteConfiguration.deleteSite(token, id)) {
            return new InternalServerErrorException("Could not delete site: " + id).asPromise();
        } else {
            return newResultPromise(site);
        }
    } catch (SSOException | SMSException | ConfigurationException e) {
        debug.error("Could not delete site {}", id, e);
        return new InternalServerErrorException("Could not delete site").asPromise();
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ResourceResponse(org.forgerock.json.resource.ResourceResponse) SMSException(com.sun.identity.sm.SMSException) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) InternalServerErrorException(org.forgerock.json.resource.InternalServerErrorException) NotFoundException(org.forgerock.json.resource.NotFoundException) SSOException(com.iplanet.sso.SSOException) PreconditionFailedException(org.forgerock.json.resource.PreconditionFailedException)

Example 48 with ConfigurationException

use of com.sun.identity.common.configuration.ConfigurationException in project OpenAM by OpenRock.

the class SitesResourceProvider method updateInstance.

@Override
public Promise<ResourceResponse, ResourceException> updateInstance(Context context, String id, UpdateRequest request) {
    JsonValue content = request.getContent();
    try {
        validWriteOperation(content, id);
    } catch (BadRequestException e) {
        return e.asPromise();
    }
    ResourceResponse site;
    SSOToken token;
    try {
        token = getSsoToken(context);
        site = getSite(token, id);
    } catch (SMSException | SSOException | ConfigurationException e) {
        debug.error("Could not read site {}", id, e);
        return new InternalServerErrorException("Could not read site").asPromise();
    } catch (NotFoundException e) {
        return e.asPromise();
    }
    try {
        if (!site.getRevision().equals(request.getRevision())) {
            return new PreconditionFailedException("Revision did not match").asPromise();
        }
        SiteConfiguration.setSitePrimaryURL(token, id, content.get("url").asString());
        SiteConfiguration.setSiteSecondaryURLs(token, id, content.get("secondaryURLs").asSet());
        return newResultPromise(getSite(token, id));
    } catch (SSOException | SMSException | ConfigurationException e) {
        debug.error("Could not update site {}", id, e);
        return new InternalServerErrorException("Could not update site").asPromise();
    } catch (NotFoundException e) {
        return new InternalServerErrorException("Could not read site after just updating it", e).asPromise();
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ResourceResponse(org.forgerock.json.resource.ResourceResponse) SMSException(com.sun.identity.sm.SMSException) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) JsonValue(org.forgerock.json.JsonValue) BadRequestException(org.forgerock.json.resource.BadRequestException) InternalServerErrorException(org.forgerock.json.resource.InternalServerErrorException) NotFoundException(org.forgerock.json.resource.NotFoundException) SSOException(com.iplanet.sso.SSOException) PreconditionFailedException(org.forgerock.json.resource.PreconditionFailedException)

Aggregations

ConfigurationException (com.sun.identity.common.configuration.ConfigurationException)48 SSOException (com.iplanet.sso.SSOException)40 SMSException (com.sun.identity.sm.SMSException)39 SSOToken (com.iplanet.sso.SSOToken)30 CLIException (com.sun.identity.cli.CLIException)19 IOutput (com.sun.identity.cli.IOutput)17 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)14 List (java.util.List)12 IdRepoException (com.sun.identity.idm.IdRepoException)11 IOException (java.io.IOException)11 Map (java.util.Map)10 Set (java.util.Set)9 UnknownPropertyNameException (com.sun.identity.common.configuration.UnknownPropertyNameException)6 HashSet (java.util.HashSet)6 Iterator (java.util.Iterator)6 NotFoundException (org.forgerock.json.resource.NotFoundException)6 AMIdentity (com.sun.identity.idm.AMIdentity)5 MalformedURLException (java.net.MalformedURLException)5 InternalServerErrorException (org.forgerock.json.resource.InternalServerErrorException)5 HashMap (java.util.HashMap)4