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");
}
}
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);
}
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");
}
}
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);
}
}
}
}
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");
}
}
Aggregations