Search in sources :

Example 76 with ServiceSchema

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

the class ModifyInheritance 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 serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
    String schemaType = getStringOptionValue(IArgument.SCHEMA_TYPE);
    String subSchemaName = getStringOptionValue(IArgument.SUBSCHEMA_NAME);
    String inheritance = getStringOptionValue(ARGUMENT_INHERITANCE);
    IOutput outputWriter = getOutputWriter();
    String[] params = { serviceName, schemaType, subSchemaName };
    ServiceSchema ss = getServiceSchema();
    try {
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_MODIFY_INHERITANCE_SUB_SCHEMA", params);
        ss.setInheritance(inheritance);
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_MODIFY_INHERITANCE_SUB_SCHEMA", params);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("modify-inheritance-succeed"), (Object[]) params));
    } catch (SSOException e) {
        String[] args = { serviceName, schemaType, subSchemaName, e.getMessage() };
        debugError("ModifyInheritance.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_MODIFY_INHERITANCE_SUB_SCHEMA", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serviceName, schemaType, subSchemaName, e.getMessage() };
        debugError("ModifyInheritance.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_MODIFY_INHERITANCE_SUB_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) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException)

Example 77 with ServiceSchema

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

the class RemoveAttributeDefaults 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);
    Set attributeNames = new HashSet();
    attributeNames.addAll(rc.getOption(IArgument.ATTRIBUTE_NAMES));
    ServiceSchema ss = getServiceSchema();
    IOutput outputWriter = getOutputWriter();
    try {
        String[] params = { serviceName, schemaType, subSchemaName, attributeNames.toString() };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_REMOVE_SCHEMA_ATTR_DEFAULTS", params);
        ss.removeAttributeDefaults(attributeNames);
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_REMOVE_SCHEMA_ATTR_DEFAULTS", params);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("schema-remove-attribute-defaults-succeed"), (Object[]) params));
    } catch (SSOException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeNames.toString(), e.getMessage() };
        debugError("RemoveAttributeDefaults.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_REMOVE_SCHEMA_ATTR_DEFAULTS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeNames.toString(), e.getMessage() };
        debugError("RemoveAttributeDefaults.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_REMOVE_SCHEMA_ATTR_DEFAULTS", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) HashSet(java.util.HashSet) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) HashSet(java.util.HashSet)

Example 78 with ServiceSchema

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

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

use of com.sun.identity.sm.ServiceSchema 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)

Aggregations

ServiceSchema (com.sun.identity.sm.ServiceSchema)216 SMSException (com.sun.identity.sm.SMSException)152 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)131 SSOException (com.iplanet.sso.SSOException)117 Set (java.util.Set)101 AttributeSchema (com.sun.identity.sm.AttributeSchema)76 HashSet (java.util.HashSet)71 Map (java.util.Map)70 HashMap (java.util.HashMap)57 Iterator (java.util.Iterator)56 CLIException (com.sun.identity.cli.CLIException)46 SSOToken (com.iplanet.sso.SSOToken)27 IOutput (com.sun.identity.cli.IOutput)26 BeforeTest (org.testng.annotations.BeforeTest)22 CLIRequest (com.sun.identity.cli.CLIRequest)21 ByteString (org.forgerock.opendj.ldap.ByteString)21 AfterTest (org.testng.annotations.AfterTest)21 Test (org.testng.annotations.Test)21 Parameters (org.testng.annotations.Parameters)18 TreeSet (java.util.TreeSet)15