Search in sources :

Example 26 with AttributeSchema

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

the class ModifyAttributeSchemaUIType 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 uitype = getStringOptionValue(ARGUMENT_UI_TYPE);
    ServiceSchema ss = getServiceSchema();
    IOutput outputWriter = getOutputWriter();
    try {
        String[] params = { serviceName, schemaType, subSchemaName, attributeSchemaName, uitype };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_MODIFY_ATTRIBUTE_SCHEMA_UI_TYPE", params);
        AttributeSchema attrSchema = ss.getAttributeSchema(attributeSchemaName);
        if (attrSchema == null) {
            String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, uitype, "attribute schema does not exist" };
            attributeSchemaNoExist(attributeSchemaName, "FAILED_MODIFY_ATTRIBUTE_SCHEMA_UI_TYPE", args);
        }
        attrSchema.setUIType(uitype);
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_MODIFY_ATTRIBUTE_SCHEMA_UI_TYPE", params);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("attribute-schema-modify-type-succeed"), (Object[]) params));
    } catch (SSOException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, uitype, e.getMessage() };
        debugError("ModifyAttributeSchemaUIType.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_MODIFY_ATTRIBUTE_SCHEMA_UI_TYPE", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, uitype, e.getMessage() };
        debugError("ModifyAttributeSchemaUIType.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_MODIFY_ATTRIBUTE_SCHEMA_UI_TYPE", 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 27 with AttributeSchema

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

the class RemoveAttributeSchemaChoiceValues 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);
    List choiceValues = (List) rc.getOption(IArgument.CHOICE_VALUES);
    ServiceSchema ss = getServiceSchema();
    IOutput outputWriter = getOutputWriter();
    String[] params = { serviceName, schemaType, subSchemaName, attributeName };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_REMOVE_ATTRIBUTE_SCHEMA_CHOICE_VALUE", params);
    try {
        AttributeSchema attrSchema = ss.getAttributeSchema(attributeName);
        if (attrSchema == null) {
            String[] args = { serviceName, schemaType, subSchemaName, attributeName, "attribute schema does not exist" };
            attributeSchemaNoExist(attributeName, "FAILED_REMOVE_ATTRIBUTE_SCHEMA_CHOICE_VALUE", args);
        }
        for (Iterator i = choiceValues.iterator(); i.hasNext(); ) {
            String choiceValue = (String) i.next();
            attrSchema.removeChoiceValue(choiceValue);
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_REMOVE_ATTRIBUTE_SCHEMA_CHOICE_VALUE", params);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("attribute-schema-remove-choice-value-succeed"), (Object[]) params));
    } catch (SSOException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeName, e.getMessage() };
        debugError("RemoveAttributeSchemaChoiceValues.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_REMOVE_ATTRIBUTE_SCHEMA_CHOICE_VALUE", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeName, e.getMessage() };
        debugError("RemoveAttributeSchemaChoiceValues.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_REMOVE_ATTRIBUTE_SCHEMA_CHOICE_VALUE", 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) Iterator(java.util.Iterator) CLIException(com.sun.identity.cli.CLIException) List(java.util.List) SSOException(com.iplanet.sso.SSOException)

Example 28 with AttributeSchema

use of com.sun.identity.sm.AttributeSchema 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 29 with AttributeSchema

use of com.sun.identity.sm.AttributeSchema 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 30 with AttributeSchema

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

the class MAPCreateDeviceModelImpl method getReqAttributeSchemas.

private Set getReqAttributeSchemas() {
    Set required = null;
    AMClientCapData ccd = getClientCapDataExtInstance();
    if (ccd != null) {
        Set names = AMClientCapData.getSchemaElements();
        if ((names != null) && !names.isEmpty()) {
            required = getAttributeSchemas(names);
            for (Iterator iter = required.iterator(); iter.hasNext(); ) {
                AttributeSchema as = (AttributeSchema) iter.next();
                String any = as.getAny();
                if ((any == null) || (any.indexOf(AMAdminConstants.REQUIRED_ATTRIBUTE) == -1)) {
                    iter.remove();
                }
            }
        }
    }
    return (required == null) ? Collections.EMPTY_SET : required;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) AMClientCapData(com.iplanet.services.cdm.clientschema.AMClientCapData) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema)

Aggregations

AttributeSchema (com.sun.identity.sm.AttributeSchema)149 Iterator (java.util.Iterator)80 ServiceSchema (com.sun.identity.sm.ServiceSchema)76 Set (java.util.Set)75 SMSException (com.sun.identity.sm.SMSException)67 HashSet (java.util.HashSet)59 SSOException (com.iplanet.sso.SSOException)58 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)46 HashMap (java.util.HashMap)36 Map (java.util.Map)34 CLIException (com.sun.identity.cli.CLIException)28 CLIRequest (com.sun.identity.cli.CLIRequest)18 AfterTest (org.testng.annotations.AfterTest)18 BeforeTest (org.testng.annotations.BeforeTest)18 Parameters (org.testng.annotations.Parameters)18 Test (org.testng.annotations.Test)18 IOutput (com.sun.identity.cli.IOutput)14 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)10 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)9 SSOToken (com.iplanet.sso.SSOToken)8