Search in sources :

Example 81 with SMSException

use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.

the class UpdateService method deleteService.

private void deleteService(RequestContext rc, ServiceManager ssm, String serviceName, SSOToken adminSSOToken) throws CLIException {
    try {
        ServiceConfigManager scm = new ServiceConfigManager(serviceName, adminSSOToken);
        if (scm.getGlobalConfig(null) != null) {
            scm.removeGlobalConfiguration(null);
        }
        ssm.deleteService(serviceName);
    } catch (SSOException e) {
        String[] args = { serviceName, e.getMessage() };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_DELETE_SERVICE", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serviceName, e.getMessage() };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_DELETE_SERVICE", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SMSException(com.sun.identity.sm.SMSException) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 82 with SMSException

use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.

the class UpdateService method handleRequest.

/**
     * Updates service schema. Delete the service schema if it exists and
     * load the schema.
     *
     * @param rc Request Context.
     * @throws CLIException if request cannot be processed.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    SSOToken adminSSOToken = getAdminSSOToken();
    boolean continueFlag = isOptionSet(IArgument.CONTINUE);
    IOutput outputWriter = getOutputWriter();
    List xmlFiles = (List) rc.getOption(IArgument.XML_FILE);
    ServiceManager ssm = null;
    try {
        ssm = new ServiceManager(adminSSOToken);
    } catch (SMSException e) {
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException e) {
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
    CommandManager mgr = getCommandManager();
    String url = mgr.getWebEnabledURL();
    if ((url != null) && (url.length() > 0)) {
        String strXML = (String) xmlFiles.iterator().next();
        try {
            List serviceNames = getServiceNames(SMSSchema.getXMLDocument(strXML, true));
            deleteServices(rc, ssm, serviceNames, adminSSOToken, continueFlag, outputWriter);
            loadSchemaXML(ssm, strXML);
            outputWriter.printlnMessage(getResourceString("service-updated"));
        } catch (SMSException e) {
            throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
        }
    } else {
        for (Iterator i = xmlFiles.iterator(); i.hasNext(); ) {
            String file = (String) i.next();
            FileInputStream fis = null;
            try {
                fis = new FileInputStream(file);
                List serviceNames = getServiceNames(SMSSchema.getXMLDocument(fis));
                deleteServices(rc, ssm, serviceNames, adminSSOToken, continueFlag, outputWriter);
                loadSchema(ssm, file);
                outputWriter.printlnMessage(getResourceString("service-updated"));
            } catch (CLIException e) {
                if (continueFlag) {
                    outputWriter.printlnError(getResourceString("service-updated-failed") + e.getMessage());
                    if (isVerbose()) {
                        outputWriter.printlnError(Debugger.getStackTrace(e));
                    }
                } else {
                    throw e;
                }
            } catch (SMSException e) {
                if (continueFlag) {
                    outputWriter.printlnError(getResourceString("service-updated-failed") + e.getMessage());
                    if (isVerbose()) {
                        outputWriter.printlnError(Debugger.getStackTrace(e));
                    }
                } else {
                    throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
                }
            } catch (FileNotFoundException e) {
                if (continueFlag) {
                    outputWriter.printlnError(getResourceString("service-updated-failed") + e.getMessage());
                    if (isVerbose()) {
                        outputWriter.printlnError(Debugger.getStackTrace(e));
                    }
                } else {
                    throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
                }
            } finally {
                if (fis != null) {
                    try {
                        fis.close();
                    } catch (IOException ie) {
                    //igore if file input stream cannot be closed.
                    }
                }
            }
        }
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) SMSException(com.sun.identity.sm.SMSException) FileNotFoundException(java.io.FileNotFoundException) SSOException(com.iplanet.sso.SSOException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) CommandManager(com.sun.identity.cli.CommandManager) IOutput(com.sun.identity.cli.IOutput) ServiceManager(com.sun.identity.sm.ServiceManager) Iterator(java.util.Iterator) CLIException(com.sun.identity.cli.CLIException) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List)

Example 83 with SMSException

use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.

the class UpdateService method loadSchema.

private void loadSchema(ServiceManager ssm, String fileName) throws CLIException {
    String[] param = { fileName };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_LOAD_SCHEMA", param);
    FileInputStream fis = null;
    try {
        fis = new FileInputStream(fileName);
        ssm.registerServices(fis);
    } catch (IOException e) {
        String[] args = { fileName, e.getMessage() };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_LOAD_SCHEMA", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException e) {
        String[] args = { fileName, e.getMessage() };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_LOAD_SCHEMA", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { fileName, e.getMessage() };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_LOAD_SCHEMA", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } finally {
        if (fis != null) {
            try {
                fis.close();
            } catch (IOException ie) {
            //igore if file input stream cannot be closed.
            }
        }
    }
}
Also used : SMSException(com.sun.identity.sm.SMSException) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream)

Example 84 with SMSException

use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.

the class AddSiteFailoverURLs 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 siteName = getStringOptionValue(IArgument.SITE_NAME);
    List secondaryURLs = (List) rc.getOption(IArgument.SECONDARY_URLS);
    String[] params = { siteName };
    try {
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_SITE_FAILOVER_URLS", params);
        if (SiteConfiguration.isSiteExist(adminSSOToken, siteName)) {
            SiteConfiguration.addSiteSecondaryURLs(adminSSOToken, siteName, secondaryURLs);
            outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-site-secondary-urls-succeeded"), (Object[]) params));
        } else {
            outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-site-secondary-urls-no-exists"), (Object[]) params));
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_SITE_FAILOVER_URLS", params);
    } catch (SSOException e) {
        String[] args = { siteName, e.getMessage() };
        debugError("AddSiteFailoverURLs.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SITE_FAILOVER_URLS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (ConfigurationException e) {
        String[] args = { siteName, e.getMessage() };
        debugError("AddSiteFailoverURLs.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SITE_FAILOVER_URLS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { siteName, e.getMessage() };
        debugError("AddSiteFailoverURLs.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SITE_FAILOVER_URLS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : 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)

Example 85 with SMSException

use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.

the class AddSiteMembers method handleRequest.

/**
     * Adds members to a site.
     *
     * @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();
    String siteName = getStringOptionValue(IArgument.SITE_NAME);
    List serverNames = (List) rc.getOption(IArgument.SERVER_NAMES);
    IOutput outputWriter = getOutputWriter();
    try {
        String[] params = { siteName };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_SITE_MEMBERS", params);
        if (SiteConfiguration.isSiteExist(adminSSOToken, siteName)) {
            SiteConfiguration.addServersToSite(adminSSOToken, siteName, serverNames);
            outputWriter.printlnMessage(getResourceString("add-site-members-succeeded"));
        } else {
            outputWriter.printlnMessage(getResourceString("add-site-members-site-not-exist"));
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_SITE_MEMBERS", params);
    } catch (ConfigurationException e) {
        String[] args = { siteName, e.getMessage() };
        debugError("AddSiteMembers.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SITE_MEMBERS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException e) {
        String[] args = { siteName, e.getMessage() };
        debugError("AddSiteMembers.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SITE_MEMBERS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { siteName, e.getMessage() };
        debugError("AddSiteMembers.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SITE_MEMBERS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : 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)

Aggregations

SMSException (com.sun.identity.sm.SMSException)704 SSOException (com.iplanet.sso.SSOException)525 Set (java.util.Set)272 HashSet (java.util.HashSet)200 SSOToken (com.iplanet.sso.SSOToken)185 Map (java.util.Map)166 ServiceConfig (com.sun.identity.sm.ServiceConfig)164 HashMap (java.util.HashMap)158 CLIException (com.sun.identity.cli.CLIException)149 ServiceSchema (com.sun.identity.sm.ServiceSchema)138 Iterator (java.util.Iterator)133 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)131 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)104 IOutput (com.sun.identity.cli.IOutput)96 IdRepoException (com.sun.identity.idm.IdRepoException)86 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)84 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)83 AttributeSchema (com.sun.identity.sm.AttributeSchema)66 IOException (java.io.IOException)55 List (java.util.List)51