use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class UpgradeUtils method getAttributeValueString.
/**
* Returns a value of an attribute.
* This method assumes that the attribute is single valued.
*
* @param serviceName name of the service.
* @param attributeName name of the attribute.
* @param schemaType the schema type.
* @return the value of the attribute
* @throws UpgradeException if there is an error.
*/
public static String getAttributeValueString(String serviceName, String attributeName, String schemaType) throws UpgradeException {
String value = null;
try {
ServiceSchemaManager sm = getServiceSchemaManager(serviceName);
ServiceSchema ss = sm.getSchema(schemaType);
Map attributeDefaults = ss.getAttributeDefaults();
if (attributeDefaults.containsKey(attributeName)) {
HashSet hashSet = (HashSet) attributeDefaults.get(attributeName);
value = (String) (hashSet.iterator().next());
}
} catch (SMSException sme) {
throw new UpgradeException("Error getting attr value : " + sme.getMessage());
}
return value;
}
use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class UpgradeUtils method getServiceSchemaManager.
/**
* Returns the <code>ServiceSchemaManager</code> for a service.
*
* @param serviceName the service name
* @param ssoToken the admin SSOToken.
* @return the <code>ServiceSchemaManager</code> of the service.
*/
protected static ServiceSchemaManager getServiceSchemaManager(String serviceName, SSOToken ssoToken) {
String classMethod = "UpgradeUtils:getServiceSchemaManager : ";
ServiceSchemaManager mgr = null;
if (serviceName != null) {
try {
if (serviceName.equals(IDFF_PROVIDER_SERVICE)) {
mgr = new ServiceSchemaManager(ssoToken, serviceName, IDFF_SERVICE_VERSION);
} else {
mgr = new ServiceSchemaManager(serviceName, ssoToken);
}
} catch (SSOException e) {
debug.error(classMethod + "SchemaCommand.getServiceSchemaManager", e);
} catch (SMSException e) {
debug.error(classMethod + "SchemaCommand.getServiceSchemaManager", e);
} catch (Exception e) {
debug.error(classMethod + "Error : ", e);
}
}
return mgr;
}
use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class UpgradeUtils method getServiceRevision.
/**
* Returns the current service revision number .
*
* @param serviceName name of the service.
* @return revisionNumber the service revision number.
*/
public static int getServiceRevision(String serviceName) {
int revisionNumber = -1;
ServiceSchemaManager ssm = getServiceSchemaManager(serviceName);
if (ssm != null) {
revisionNumber = ssm.getRevisionNumber();
}
return revisionNumber;
}
use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class UpgradeUtils method deletePolicyRule.
private static void deletePolicyRule(String serviceName, SSOToken adminToken) throws SMSException, SSOException, AMException {
String classMethod = "UpgradeUtils:deletePolicyRule : ";
ServiceSchemaManager ssm = new ServiceSchemaManager(serviceName, adminToken);
if (ssm == null) {
if (debug.messageEnabled()) {
debug.message(classMethod + "delete-service-no-policy-rules");
}
} else {
if (ssm.getPolicySchema() == null) {
if (debug.messageEnabled()) {
debug.message(classMethod + "delete-service-no-policy-schema");
}
} else {
processCleanPolicies(serviceName, adminToken);
if (debug.messageEnabled()) {
debug.message(classMethod + "policy schemas cleaned");
}
}
}
}
use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class UpgradeUtils method attributeExists.
/**
* Checks the service scheam for existance of an attribute.
*
* @param serviceName name of the service.
* @param attributeName the attribute name
* @param schemaType the schema type
* @return true if attrbute exist else false.
* @throws UpgradeException if there is an error
*/
public static boolean attributeExists(String serviceName, String attributeName, String schemaType) throws UpgradeException {
boolean isExists = false;
try {
ServiceSchemaManager sm = getServiceSchemaManager(serviceName);
ServiceSchema ss = sm.getSchema(schemaType);
Map attributeDefaults = ss.getAttributeDefaults();
if (attributeDefaults.containsKey(attributeName)) {
HashSet hashSet = (HashSet) attributeDefaults.get(attributeName);
String value = (String) (hashSet.iterator().next());
isExists = true;
}
} catch (SMSException sme) {
throw new UpgradeException("Error getting attribute value");
}
return isExists;
}
Aggregations