use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class UpgradeUtils method getAttributeValue.
/**
* Returns a set of values of an attribute.
*
* @param serviceName name of the service.
* @param attributeName the attribute name.
* @param schemaType the schema type.
* @param isOrgAttrSchema boolean value indicating whether
* the attribute is to be retrieved from
* <OrganizationAttributeSchema>
* @return a set of values for the attribute.
* @throws UpgradeException if there is an error.
*/
public static Set getAttributeValue(String serviceName, String attributeName, String schemaType, boolean isOrgAttrSchema) throws UpgradeException {
String classMethod = "UpgradeUtils:getAttributeValue : ";
Set attrValues = Collections.EMPTY_SET;
try {
ServiceSchemaManager sm = getServiceSchemaManager(serviceName);
ServiceSchema ss = null;
if (isOrgAttrSchema) {
ss = sm.getOrganizationCreationSchema();
} else {
ss = sm.getSchema(schemaType);
}
Map attributeDefaults = ss.getAttributeDefaults();
if (attributeDefaults.containsKey(attributeName)) {
attrValues = (Set) attributeDefaults.get(attributeName);
}
} catch (SMSException sme) {
debug.error(classMethod + "Error retreiving attribute values : ", sme);
throw new UpgradeException("Unable to get attribute values : " + sme.getMessage());
}
return attrValues;
}
use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class UpgradeUtils method setServiceRevision.
/**
* Sets the service revision number.
*
* @param serviceName name of the service.
* @param revisionNumber the revisionNumber of the service.
* @throws <code>UpgradeException</code> if there is an error.
*/
public static void setServiceRevision(String serviceName, String revisionNumber) throws UpgradeException {
String classMethod = "UpgradeUtils:setServiceRevision : ";
try {
System.out.println(bundle.getString("upg-service-name") + ":" + serviceName);
System.out.println(bundle.getString("upg-revision-number") + ":" + revisionNumber);
if (debug.messageEnabled()) {
debug.message("Setting service revision for :" + serviceName + "to : " + revisionNumber);
}
ServiceSchemaManager ssm = getServiceSchemaManager(serviceName);
ssm.setRevisionNumber(Integer.parseInt(revisionNumber));
if (debug.messageEnabled()) {
debug.message(classMethod + serviceName + ":Setting Service Revision Number" + revisionNumber);
}
} catch (SSOException ssoe) {
throw new UpgradeException("Invalid SSOToken ");
} catch (SMSException sme) {
throw new UpgradeException("Error setting serviceRevision value");
}
}
use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class ClientResourceTest method setUp.
@BeforeTest
public void setUp() throws SMSException {
mockManager = mock(ClientResourceManager.class);
ServiceSchemaManager mockSchemaManager = mock(ServiceSchemaManager.class);
ServiceSchema mockSchema = mock(ServiceSchema.class);
mockSubSchema = mock(ServiceSchema.class);
Mockito.doReturn(mockSchema).when(mockSchemaManager).getOrganizationSchema();
Mockito.doReturn(mockSubSchema).when(mockSchema).getSubSchema(anyString());
resource = new ClientResource(mockManager, mock(CTSPersistentStore.class), mockSchemaManager, mock(OAuth2AuditLogger.class), mock(Debug.class));
}
use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class SpecialRepo method replaceDNAttributeIfPresent.
private void replaceDNAttributeIfPresent(Map attributes) {
// to be added
if (ssm == null) {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
try {
ssm = new ServiceSchemaManager(adminToken, IdConstants.REPO_SERVICE, "1.0");
} catch (SMSException smse) {
debug.error("SpecialRepo.replaceDN: Unable to get Schema" + "to determine revision number", smse);
return;
} catch (SSOException ssoe) {
// should not happen
return;
}
}
if (ssm.getRevisionNumber() >= 30) {
Set values;
if ((attributes != null) && ((values = (Set) attributes.get(dnAttribute)) != null)) {
for (Iterator items = values.iterator(); items.hasNext(); ) {
String name = items.next().toString();
// Hence check if it ends with SMS root suffix
if (name.toLowerCase().endsWith(SMSEntry.getRootSuffix().toLowerCase())) {
// Replace only if the they are different
if (!SMSEntry.getRootSuffix().equals(SMSEntry.getAMSdkBaseDN())) {
name = name.substring(0, name.length() - SMSEntry.getRootSuffix().length());
name = name + SMSEntry.getAMSdkBaseDN();
}
} else {
name = name + SMSEntry.getAMSdkBaseDN();
}
Set newValues = new HashSet();
newValues.add(name);
attributes.put(dnAttribute, newValues);
break;
}
}
}
}
use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class SpecialRepo method removeListener.
/*
* (non-Javadoc)
*
* @see com.sun.identity.idm.IdRepo#removeListener()
*/
public void removeListener() {
if (scm != null) {
scm.removeListener(scmListenerId);
scm = null;
}
if (ssm != null) {
ssm.removeListener(ssmListenerId);
//make sure old reference get GCed asap
ssm = null;
//make sure any old lingering object would be cleaned.
try {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
ssm = new ServiceSchemaManager(adminToken, IdConstants.REPO_SERVICE, "1.0");
ssm.removeListener(ssmListenerId);
} catch (SSOException ssoe) {
// listener should be removed in first try. ignoring any error
} catch (SMSException smse) {
// listener should be removed in first try. ignoring any error
}
}
repoListener = null;
}
Aggregations