Search in sources :

Example 1 with ConfigurationException

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

the class ServerConfigXMLAddServerViewBean method handleButton1Request.

/**
     * Handles create server to server configuration XML request.
     *
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    ServerSiteModel model = (ServerSiteModel) getModel();
    String serverName = (String) getPageSessionAttribute(ServerEditViewBeanBase.PG_ATTR_SERVER_NAME);
    String serverGroupType = (String) getPageSessionAttribute(PG_ATTR_SERVER_GROUP_TYPE);
    String name = (String) getDisplayFieldValue(TF_NAME);
    name = name.trim();
    String host = (String) getDisplayFieldValue(TF_HOST);
    host = host.trim();
    String port = (String) getDisplayFieldValue(TF_PORT);
    port = port.trim();
    String type = (String) getDisplayFieldValue(CHOICE_TYPE);
    if ((name.length() > 0) && (port.length() > 0) && (host.length() > 0)) {
        try {
            ServerConfigXML xmlObj = model.getServerConfigObject(serverName);
            ServerConfigXML.ServerGroup serverGroup = (serverGroupType.equals(DSConfigMgr.DEFAULT)) ? xmlObj.getDefaultServerGroup() : xmlObj.getSMSServerGroup();
            serverGroup.addHost(name, host, port, type);
            model.setServerConfigXML(serverName, xmlObj.toXML());
            backTrail();
            ServerConfigXMLViewBean vb = (ServerConfigXMLViewBean) getViewBean(ServerConfigXMLViewBean.class);
            removePageSessionAttribute(PG_ATTR_SERVER_GROUP_TYPE);
            passPgSessionMap(vb);
            vb.forwardTo(getRequestContext());
        } catch (ConfigurationException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
            forwardTo();
        } catch (AMConsoleException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
            forwardTo();
        }
    } else {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "serverconfig.create.server.missing.atributes");
        forwardTo();
    }
}
Also used : ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) ServerSiteModel(com.sun.identity.console.service.model.ServerSiteModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) ServerConfigXML(com.sun.identity.common.configuration.ServerConfigXML)

Example 2 with ConfigurationException

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

the class AgentsModelImpl method setAttributeValues.

/**
     * Modifies agent or agent group attribute values.
     *
     * @param universalId Universal ID of the agent/agent group.
     * @param values attribute values of an agent or agent group.
     * @throws AMConsoleException if object cannot located.
     */
public void setAttributeValues(String universalId, Map values) throws AMConsoleException {
    String[] param = { universalId };
    logEvent("ATTEMPT_SET_AGENT_ATTRIBUTE_VALUE", param);
    try {
        AMIdentity amid = IdUtils.getIdentity(getUserSSOToken(), universalId);
        values.remove(IdConstants.AGENT_TYPE);
        if (!isAgentGroup(universalId)) {
            AgentConfiguration.validateAgentRootURLs(values);
        }
        amid.setAttributes(values);
        amid.store();
        logEvent("SUCCEED_SET_AGENT_ATTRIBUTE_VALUE", param);
    } catch (ConfigurationException e) {
        String[] paramsEx = { universalId, getErrorString(e) };
        logEvent("EXCEPTION_SET_AGENT_ATTRIBUTE_VALUE", paramsEx);
        throw new AMConsoleException(getErrorString(e));
    } catch (SSOException e) {
        String[] paramsEx = { universalId, getErrorString(e) };
        logEvent("EXCEPTION_SET_AGENT_ATTRIBUTE_VALUE", paramsEx);
        throw new AMConsoleException(getErrorString(e));
    } catch (IdRepoException e) {
        String[] paramsEx = { universalId, getErrorString(e) };
        logEvent("EXCEPTION_SET_AGENT_ATTRIBUTE_VALUE", paramsEx);
        throw new AMConsoleException(getErrorString(e));
    }
}
Also used : ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) AMIdentity(com.sun.identity.idm.AMIdentity) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 3 with ConfigurationException

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

the class SitesResourceProvider method createInstance.

@Override
public Promise<ResourceResponse, ResourceException> createInstance(Context context, CreateRequest request) {
    JsonValue content = request.getContent();
    String id = request.getNewResourceId();
    try {
        id = validWriteOperation(content, id);
    } catch (BadRequestException e) {
        return e.asPromise();
    }
    String url = content.get(PRIMARY_URL).asString();
    try {
        SSOToken token = getSsoToken(context);
        if (SiteConfiguration.isSiteExist(token, id)) {
            return new ConflictException("Site with id already exists: " + id).asPromise();
        }
        SiteConfiguration.createSite(token, id, url, content.get(SECONDARY_URLS).asSet());
        debug.message("Site created: {}", id);
        return newResultPromise(getSite(token, id));
    } catch (SMSException | SSOException | ConfigurationException e) {
        debug.error("Could not create site", e);
        return new InternalServerErrorException("Could not create site").asPromise();
    } catch (NotFoundException e) {
        return new InternalServerErrorException("Could not read site just created").asPromise();
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ConflictException(org.forgerock.json.resource.ConflictException) 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)

Example 4 with ConfigurationException

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

the class SitesResourceProvider method queryCollection.

@Override
public Promise<QueryResponse, ResourceException> queryCollection(Context context, QueryRequest request, QueryResourceHandler handler) {
    if (!"true".equals(request.getQueryFilter().toString())) {
        return new BadRequestException("Query only supports 'true' filter").asPromise();
    }
    try {
        SSOToken token = getSsoToken(context);
        Set<String> siteNames = SiteConfiguration.getSites(token);
        for (String siteName : siteNames) {
            handler.handleResource(getSite(token, siteName));
        }
        return newResultPromise(newQueryResponse());
    } catch (SSOException | SMSException | ConfigurationException e) {
        debug.error("Could not read sites", e);
        return new InternalServerErrorException("Could not read sites").asPromise();
    } catch (NotFoundException e) {
        debug.error("Could not read site", e);
        return new InternalServerErrorException("Could not read site we've just got name for").asPromise();
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) SMSException(com.sun.identity.sm.SMSException) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) BadRequestException(org.forgerock.json.resource.BadRequestException) InternalServerErrorException(org.forgerock.json.resource.InternalServerErrorException) NotFoundException(org.forgerock.json.resource.NotFoundException) SSOException(com.iplanet.sso.SSOException)

Example 5 with ConfigurationException

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

the class SitesResourceProvider method readInstance.

@Override
public Promise<ResourceResponse, ResourceException> readInstance(Context context, String id, ReadRequest request) {
    try {
        SSOToken token = getSsoToken(context);
        ResourceResponse site = getSite(token, id);
        return newResultPromise(site);
    } 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();
    }
}
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)

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