Search in sources :

Example 86 with SMSException

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

the class SetAttributeSchemaChoiceValues 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();
    String schemaType = getStringOptionValue(IArgument.SCHEMA_TYPE);
    String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
    String subSchemaName = getStringOptionValue(IArgument.SUBSCHEMA_NAME);
    String attributeName = getStringOptionValue(IArgument.ATTRIBUTE_NAME);
    String datafile = getStringOptionValue(IArgument.DATA_FILE);
    List choiceValues = rc.getOption(IArgument.CHOICE_VALUES);
    boolean toAdd = isOptionSet(ARGUMENT_ADD);
    if ((datafile == null) && (choiceValues == null)) {
        throw new CLIException(getResourceString("missing-choicevalues"), ExitCodes.INCORRECT_OPTION, rc.getSubCommand().getName());
    }
    Map attributeValues = AttributeValues.parse(getCommandManager(), datafile, choiceValues);
    ServiceSchema ss = getServiceSchema();
    IOutput outputWriter = getOutputWriter();
    String[] params = { serviceName, schemaType, subSchemaName, attributeName };
    if (toAdd) {
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_ATTRIBUTE_SCHEMA_CHOICE_VALUES", params);
    } else {
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SET_ATTRIBUTE_SCHEMA_CHOICE_VALUES", params);
    }
    try {
        AttributeSchema attrSchema = ss.getAttributeSchema(attributeName);
        if (attrSchema == null) {
            String[] args = { serviceName, schemaType, subSchemaName, attributeName, "attribute schema does not exist" };
            attributeSchemaNoExist(attributeName, (toAdd) ? "FAILED_ADD_ATTRIBUTE_SCHEMA_CHOICE_VALUES" : "FAILED_SET_ATTRIBUTE_SCHEMA_CHOICE_VALUES", args);
        }
        if (toAdd) {
            addChoiceValues(attrSchema, attributeValues);
            writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_ATTRIBUTE_SCHEMA_CHOICE_VALUES", params);
        } else {
            setChoiceValues(attrSchema, attributeValues);
            writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_SET_ATTRIBUTE_SCHEMA_CHOICE_VALUES", params);
        }
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("attribute-schema-set-choice-value-succeed"), (Object[]) params));
    } catch (SSOException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeName, e.getMessage() };
        debugError("SetAttributeSchemaChoiceValues.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, (toAdd) ? "FAILED_ADD_ATTRIBUTE_SCHEMA_CHOICE_VALUES" : "FAILED_SET_ATTRIBUTE_SCHEMA_CHOICE_VALUES", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeName, e.getMessage() };
        debugError("SetAttributeSchemaChoiceValues.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, (toAdd) ? "FAILED_ADD_ATTRIBUTE_SCHEMA_CHOICE_VALUES" : "FAILED_SET_ATTRIBUTE_SCHEMA_CHOICE_VALUES", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) AttributeSchema(com.sun.identity.sm.AttributeSchema) CLIException(com.sun.identity.cli.CLIException) List(java.util.List) SSOException(com.iplanet.sso.SSOException) Map(java.util.Map)

Example 87 with SMSException

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

the class RemoveAttributeSchemas 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();
    String schemaType = getStringOptionValue(IArgument.SCHEMA_TYPE);
    String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
    String subSchemaName = getStringOptionValue(IArgument.SUBSCHEMA_NAME);
    List attributeSchemaNames = (List) rc.getOption(IArgument.ATTRIBUTE_SCHEMA);
    ServiceSchema ss = getServiceSchema();
    IOutput outputWriter = getOutputWriter();
    String attributeSchemaName = null;
    try {
        for (Iterator i = attributeSchemaNames.iterator(); i.hasNext(); ) {
            attributeSchemaName = (String) i.next();
            String[] params = { serviceName, schemaType, subSchemaName, attributeSchemaName };
            writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_REMOVE_ATTRIBUTE_SCHEMA", params);
            ss.removeAttributeSchema(attributeSchemaName);
            writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_REMOVE_ATTRIBUTE_SCHEMA", params);
            outputWriter.printlnMessage(MessageFormat.format(getResourceString("remove-attribute-schema-succeed"), (Object[]) params));
        }
    } catch (SSOException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, e.getMessage() };
        debugError("RemoveAttributeSchemas.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_REMOVE_ATTRIBUTE_SCHEMA", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, e.getMessage() };
        debugError("RemoveAttributeSchemas.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_REMOVE_ATTRIBUTE_SCHEMA", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) Iterator(java.util.Iterator) CLIException(com.sun.identity.cli.CLIException) List(java.util.List) SSOException(com.iplanet.sso.SSOException)

Example 88 with SMSException

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

the class SchemaCommand method getServiceSchemaManager.

protected ServiceSchemaManager getServiceSchemaManager(String serviceName) throws CLIException {
    ServiceSchemaManager mgr = null;
    SSOToken adminSSOToken = getAdminSSOToken();
    if (serviceName != null) {
        try {
            mgr = new ServiceSchemaManager(serviceName, adminSSOToken);
        } catch (SSOException e) {
            debugError("SchemaCommand.getServiceSchemaManager", e);
            throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
        } catch (SMSException e) {
            debugError("SchemaCommand.getServiceSchemaManager", e);
            throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
        }
    }
    return mgr;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) SMSException(com.sun.identity.sm.SMSException) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 89 with SMSException

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

the class SetAttributeSchemaStartRange 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();
    String schemaType = getStringOptionValue(IArgument.SCHEMA_TYPE);
    String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
    String subSchemaName = getStringOptionValue(IArgument.SUBSCHEMA_NAME);
    String attributeSchemaName = getStringOptionValue(IArgument.ATTRIBUTE_SCHEMA);
    String range = getStringOptionValue(ARGUMENT_RANGE);
    ServiceSchema ss = getServiceSchema();
    IOutput outputWriter = getOutputWriter();
    try {
        String[] params = { serviceName, schemaType, subSchemaName, attributeSchemaName, range };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SET_ATTRIBUTE_SCHEMA_START_RANGE", params);
        AttributeSchema attrSchema = ss.getAttributeSchema(attributeSchemaName);
        if (attrSchema == null) {
            String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, range, "attribute schema does not exist" };
            attributeSchemaNoExist(attributeSchemaName, "FAILED_SET_ATTRIBUTE_SCHEMA_START_RANGE", args);
        }
        attrSchema.setStartRange(range);
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_SET_ATTRIBUTE_SCHEMA_START_RANGE", params);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("attribute-schema-set-start-range-succeed"), (Object[]) params));
    } catch (SSOException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, range, e.getMessage() };
        debugError("SetAttributeSchemaStartRange.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_ATTRIBUTE_SCHEMA_START_RANGE", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, range, e.getMessage() };
        debugError("SetAttributeSchemaStartRange.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_ATTRIBUTE_SCHEMA_START_RANGE", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) AttributeSchema(com.sun.identity.sm.AttributeSchema) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException)

Example 90 with SMSException

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

the class MAPCreateDeviceModelImpl method getCreateDevicePropertyXML.

/**
     * Returns the XML for create device property sheet.
     *
     * @param clientType Name of Client Type.
     * @param style Name of Style.
     * @throws AMConsoleException if there are no attributes to display.
     * @return XML for create device property sheet.
     */
public String getCreateDevicePropertyXML(String clientType, String style) throws AMConsoleException {
    String xml = "";
    createDeviceReqAttrs = getReqAttributeSchemas();
    if ((createDeviceReqAttrs != null) && !createDeviceReqAttrs.isEmpty()) {
        getCreateDeviceDefaultValues(createDeviceReqAttrs, clientType, style);
        String serviceName = getClientCapDataIntInstance().getServiceName();
        try {
            PropertyXMLBuilder builder = new PropertyXMLBuilder(serviceName, this, createDeviceReqAttrs);
            xml = builder.getXML();
        } catch (SMSException e) {
            debug.warning("MAPCreateDeviceModelImpl.getCreateDevicePropertyXML", e);
        } catch (SSOException e) {
            debug.warning("MAPCreateDeviceModelImpl.getCreateDevicePropertyXML", e);
        }
    }
    return xml;
}
Also used : SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) PropertyXMLBuilder(com.sun.identity.console.property.PropertyXMLBuilder)

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