Search in sources :

Example 1 with UnknownPropertyNameException

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

the class UpgradeUtils method createServiceInstance.

/**
     * Creates a service instance.
     *
     * @param serverInstance the server instance value
     * @param serverId the server identifier
     * @throws UpgradeException if there is an error.
     */
public static void createServiceInstance(String serverInstance, String serverId, Set values, String serverConfigXML) {
    //throws UpgradeException {
    String classMethod = "UpgradeUtils:createServiceInstance : ";
    if (debug.messageEnabled()) {
        debug.message(classMethod + "serverInstance :" + serverInstance);
        debug.message(classMethod + "serverId :" + serverId);
    }
    try {
        ServerConfiguration.createServerInstance(ssoToken, serverInstance, serverId, values, serverConfigXML);
    } catch (UnknownPropertyNameException uce) {
    //throw new UpgradeException("Unknwon property ");
    } catch (ConfigurationException ce) {
    //throw new UpgradeException("Unable to create Service instance");
    } catch (SMSException sme) {
    //throw new UpgradeException("Unable to create Service instance");
    } catch (SSOException ssoe) {
    //throw new UpgradeException("invalid ssotoken");
    }
}
Also used : UnknownPropertyNameException(com.sun.identity.common.configuration.UnknownPropertyNameException) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ByteString(org.forgerock.opendj.ldap.ByteString)

Example 2 with UnknownPropertyNameException

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

the class CreateServer method handleRequest.

/**
     * Services a Commandline Request.
     *
     * @param rc Request Context.
     * @throws CLIException if the request cannot serviced.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    SSOToken adminSSOToken = getAdminSSOToken();
    IOutput outputWriter = getOutputWriter();
    String serverName = getStringOptionValue(IArgument.SERVER_NAME);
    String datafile = getStringOptionValue(IArgument.DATA_FILE);
    List attrValues = rc.getOption(IArgument.ATTRIBUTE_VALUES);
    if ((datafile == null) && (attrValues == null)) {
        throw new CLIException(getResourceString("missing-attributevalues"), ExitCodes.INCORRECT_OPTION, rc.getSubCommand().getName());
    }
    Map attributeValues = AttributeValues.parse(getCommandManager(), datafile, attrValues);
    String serverconfigxml = CLIUtil.getFileContent(getCommandManager(), getStringOptionValue(SERVER_CONFIG_XML_FILE));
    String[] params = { serverName };
    try {
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_CREATE_SERVER", params);
        if (!ServerConfiguration.isServerInstanceExist(adminSSOToken, serverName)) {
            ServerConfiguration.createServerInstance(adminSSOToken, serverName, attributeValues, serverconfigxml);
            outputWriter.printlnMessage(MessageFormat.format(getResourceString("create-server-config-succeeded"), (Object[]) params));
        } else {
            outputWriter.printlnMessage(MessageFormat.format(getResourceString("create-server-config-already-exists"), (Object[]) params));
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_CREATE_SERVER", params);
    } catch (UnknownPropertyNameException e) {
        String[] args = { serverName, e.getMessage() };
        debugError("CreateServer.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_SERVER", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (ConfigurationException e) {
        String[] args = { serverName, e.getMessage() };
        debugError("CreateServer.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_SERVER", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (IOException e) {
        String[] args = { serverName, e.getMessage() };
        debugError("CreateServer.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_SERVER", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException e) {
        String[] args = { serverName, e.getMessage() };
        debugError("CreateServer.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_SERVER", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serverName, e.getMessage() };
        debugError("CreateServer.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_SERVER", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : UnknownPropertyNameException(com.sun.identity.common.configuration.UnknownPropertyNameException) SSOToken(com.iplanet.sso.SSOToken) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) CLIException(com.sun.identity.cli.CLIException) List(java.util.List) SSOException(com.iplanet.sso.SSOException) IOException(java.io.IOException) Map(java.util.Map)

Example 3 with UnknownPropertyNameException

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

the class ServerEditGeneralViewBean method handleButton1Request.

/**
     * Handles create site request.
     *
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    submitCycle = true;
    String serverName = (String) getPageSessionAttribute(PG_ATTR_SERVER_NAME);
    String parentSite = (serverName.equals(ServerConfiguration.DEFAULT_SERVER_CONFIG)) ? null : (String) getDisplayFieldValue(PARENT_SITE);
    ServerSiteModel model = (ServerSiteModel) getModel();
    try {
        model.modifyServer(serverName, parentSite, getAttributeValues());
        setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "serverconfig.updated");
    } catch (UnknownPropertyNameException e) {
    // ignore. this cannot happen because property in this page
    // is customized.
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    forwardTo();
}
Also used : UnknownPropertyNameException(com.sun.identity.common.configuration.UnknownPropertyNameException) ServerSiteModel(com.sun.identity.console.service.model.ServerSiteModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 4 with UnknownPropertyNameException

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

the class ServerEditViewBeanBase method modifyProperties.

protected void modifyProperties() {
    String serverName = (String) getPageSessionAttribute(PG_ATTR_SERVER_NAME);
    ServerSiteModel model = (ServerSiteModel) getModel();
    try {
        model.modifyServer(serverName, null, getAttributeValues());
        setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "serverconfig.updated");
    } catch (UnknownPropertyNameException e) {
    // ignore, this cannot happen because properties on this page
    // are pre checked.
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
}
Also used : UnknownPropertyNameException(com.sun.identity.common.configuration.UnknownPropertyNameException) ServerSiteModel(com.sun.identity.console.service.model.ServerSiteModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 5 with UnknownPropertyNameException

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

the class ServerEditAdvancedViewBean method handleButton1Request.

/**
     * Handles save properties  request.
     *
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    submitCycle = true;
    String valProperties = (String) getDisplayFieldValue(PROPERTIES);
    properties = new HashSet();
    Map map = new HashMap();
    StringTokenizer st = new StringTokenizer(valProperties, "\n");
    while (st.hasMoreElements()) {
        String t = st.nextToken();
        t = t.replaceAll("\r", "");
        int idx = t.indexOf('=');
        String name = t.substring(0, idx).trim();
        String value = t.substring(idx + 1).trim();
        properties.add(t);
        map.put(name, value);
    }
    ServerSiteModel model = (ServerSiteModel) getModel();
    String serverName = (String) getPageSessionAttribute(ServerEditViewBeanBase.PG_ATTR_SERVER_NAME);
    /*
         * only global default has values for hidden properties. should not
         * try to set hidden property values for server instance
         */
    if (serverName.equals(ServerConfiguration.DEFAULT_SERVER_CONFIG)) {
        for (Iterator i = hiddenProperties.entrySet().iterator(); i.hasNext(); ) {
            Map.Entry entry = (Map.Entry) i.next();
            map.put(entry.getKey(), entry.getValue());
        }
    }
    try {
        Map origValues = model.getServerConfiguration(serverName);
        discardDealtWithProperties(origValues);
        String unkownPropertyMessage = null;
        try {
            model.modifyServer(serverName, null, map);
        } catch (UnknownPropertyNameException ex) {
            unkownPropertyMessage = ex.getL10NMessage(model.getUserLocale());
        }
        for (Iterator i = origValues.keySet().iterator(); i.hasNext(); ) {
            String key = (String) i.next();
            if (map.containsKey(key)) {
                i.remove();
            }
        }
        if (!origValues.isEmpty()) {
            model.updateServerConfigInheritance(serverName, origValues.keySet(), null);
        }
        if (unkownPropertyMessage != null) {
            Object[] args = { unkownPropertyMessage };
            setInlineAlertMessage(CCAlert.TYPE_WARNING, "message.warning", MessageFormat.format(model.getLocalizedString("serverconfig.updated.with.invalid.properties"), args));
        } else {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "serverconfig.updated");
        }
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    }
    forwardTo();
}
Also used : UnknownPropertyNameException(com.sun.identity.common.configuration.UnknownPropertyNameException) HashMap(java.util.HashMap) ServerSiteModel(com.sun.identity.console.service.model.ServerSiteModel) StringTokenizer(java.util.StringTokenizer) Iterator(java.util.Iterator) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

UnknownPropertyNameException (com.sun.identity.common.configuration.UnknownPropertyNameException)9 ConfigurationException (com.sun.identity.common.configuration.ConfigurationException)6 SMSException (com.sun.identity.sm.SMSException)6 SSOException (com.iplanet.sso.SSOException)5 SSOToken (com.iplanet.sso.SSOToken)5 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)5 IOException (java.io.IOException)5 Map (java.util.Map)4 ServerSiteModel (com.sun.identity.console.service.model.ServerSiteModel)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 CLIException (com.sun.identity.cli.CLIException)2 IOutput (com.sun.identity.cli.IOutput)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Set (java.util.Set)2 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)1 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)1 IdRepoException (com.sun.identity.idm.IdRepoException)1 StringTokenizer (java.util.StringTokenizer)1