Search in sources :

Example 46 with ServiceSchema

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

the class UpgradeUtils method removeAttributeChoiceValues.

/**
     * Removes choice values from attribute schema.
     *
     * @param serviceName Name of service.
     * @param schemaType Type of schema.
     * @param attributeName Name of attribute.
     * @param choiceValues Choice values e.g. Inactive
     * @param subSchema Name of sub schema.
     * @throws UpgradeException if there is an error.
     */
public static void removeAttributeChoiceValues(String serviceName, String schemaType, String attributeName, Set choiceValues, String subSchema) throws UpgradeException {
    try {
        ServiceSchema ss = getServiceSchema(serviceName, subSchema, schemaType);
        AttributeSchema attrSchema = ss.getAttributeSchema(attributeName);
        for (Iterator i = choiceValues.iterator(); i.hasNext(); ) {
            String choiceValue = (String) i.next();
            attrSchema.removeChoiceValue(choiceValue);
        }
    } catch (SSOException ssoe) {
        throw new UpgradeException("Invalid SSOToken");
    } catch (SMSException sme) {
        throw new UpgradeException("Error removing attribute choice vals");
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) AttributeSchema(com.sun.identity.sm.AttributeSchema) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) SSOException(com.iplanet.sso.SSOException) ByteString(org.forgerock.opendj.ldap.ByteString)

Example 47 with ServiceSchema

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

the class UpgradeUtils method addAttributeToSchema.

/**
     * Adds new attribute schema to an existing service.
     *
     * @param serviceName the service name.
     * @param schemaType the schema type.
     * @param attributeSchemaNode attribute to add
     * @param adminToken admin SSOToken
     * @throws UpgradeException if there is an error adding the
     *         attribute schema.
     * @supported.api
     */
public static void addAttributeToSchema(String serviceName, String subSchemaName, String schemaType, Node attributeSchemaNode, SSOToken adminToken) throws UpgradeException {
    ServiceSchema ss = getServiceSchema(serviceName, subSchemaName, schemaType, adminToken);
    addAttributeToSchema(ss, attributeSchemaNode);
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema)

Example 48 with ServiceSchema

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

the class UpgradeUtils method removeAttributeDefaultValues.

/**
     * Removes attributes default values.
     *
     * @param serviceName name of the service
     * @param schemaType the schema type
     * @param attributeName name of the attribute
     * @param defaultValues a set of values to be removed
     * @param subSchema name of the sub schema
     * @throws UpgradeException if there is an error
     */
public static void removeAttributeDefaultValues(String serviceName, String schemaType, String attributeName, Set defaultValues, String subSchema) throws UpgradeException {
    String classMethod = "UpgradeUtils:removeAttributeDefaultValues : ";
    try {
        ServiceSchema ss = getServiceSchema(serviceName, subSchema, schemaType);
        // check if service schema exists.
        if (ss != null) {
            AttributeSchema attrSchema = ss.getAttributeSchema(attributeName);
            for (Iterator i = defaultValues.iterator(); i.hasNext(); ) {
                String defaultValue = (String) i.next();
                attrSchema.removeDefaultValue(defaultValue);
            }
        }
    } catch (SSOException ssoe) {
        throw new UpgradeException("Invalid SSOToken");
    } catch (SMSException sme) {
        throw new UpgradeException("Error removing attribute" + " default vals");
    } catch (Exception e) {
        UpgradeUtils.debug.error(classMethod + "Error removing attribute default vals", e);
        throw new UpgradeException("Error removing attribute" + " default values");
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) AttributeSchema(com.sun.identity.sm.AttributeSchema) ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) SSOException(com.iplanet.sso.SSOException) ByteString(org.forgerock.opendj.ldap.ByteString) LoginException(javax.security.auth.login.LoginException) InvalidAuthContextException(com.sun.identity.authentication.internal.InvalidAuthContextException) UnknownPropertyNameException(com.sun.identity.common.configuration.UnknownPropertyNameException) PolicyException(com.sun.identity.policy.PolicyException) FileNotFoundException(java.io.FileNotFoundException) SSOException(com.iplanet.sso.SSOException) LdapException(org.forgerock.opendj.ldap.LdapException) SMSException(com.sun.identity.sm.SMSException) IOException(java.io.IOException) AMException(com.iplanet.am.sdk.AMException) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException)

Example 49 with ServiceSchema

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

the class UpgradeUtils method addNewSubSchema.

public static void addNewSubSchema(String serviceName, SubSchemaModificationWrapper ssMod, ServiceSchema serviceSchema, SSOToken adminToken) throws UpgradeException {
    if (ssMod.hasNewSubSchema()) {
        for (Map.Entry<String, NewSubSchemaWrapper> newSubSchema : ssMod.entrySet()) {
            addSubSchema(serviceName, newSubSchema.getValue().getSubSchemaName(), serviceSchema, newSubSchema.getValue().getSubSchemaNode());
            if (ssMod.getSubSchema() != null && ssMod.getSubSchema().hasSubSchema()) {
                ServiceSchema subSchema = null;
                try {
                    subSchema = serviceSchema.getSubSchema(newSubSchema.getKey());
                } catch (SMSException smse) {
                    debug.error("unable to add new sub schema: " + newSubSchema.getKey(), smse);
                    throw new UpgradeException(smse);
                }
                addNewSubSchema(serviceName, ssMod.getSubSchema(), subSchema, adminToken);
            }
        }
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) ByteString(org.forgerock.opendj.ldap.ByteString) Map(java.util.Map) HashMap(java.util.HashMap)

Example 50 with ServiceSchema

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

the class UpgradeUtils method modifyAnyInAttributeSchema.

/**
     * Updates the values of the <code>any</code> attribute in the attribute
     * schema.
     *
     * @param serviceName the service name where the attribute exists.
     * @param subSchema the subschema name.
     * @param schemaType the schema type
     * @param attrName the attribute name.
     * @param value the value of the <code>any</code> attribute
     * @throws UpgradeException if there is an error.
     */
public static void modifyAnyInAttributeSchema(String serviceName, String subSchema, String schemaType, String attrName, String value) throws UpgradeException {
    try {
        ServiceSchema ss = getServiceSchema(serviceName, subSchema, schemaType);
        AttributeSchema attrSchema = ss.getAttributeSchema(attrName);
        attrSchema.setAny(value);
    } catch (SSOException ssoe) {
        throw new UpgradeException("Invalid token");
    } catch (SMSException sme) {
        throw new UpgradeException("Error setting any attribute");
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) AttributeSchema(com.sun.identity.sm.AttributeSchema) 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