validateInputParameters(new String[] { profileName, dialectName });
try {
UserRealm realm = null;
ProfileConfigurationManager profileManager = null;
realm = getRealm();
profileManager = realm.getProfileConfigurationManager();
if (profileManager == null) {
String message = "No profile configurations defined";
if (log.isDebugEnabled()) {
log.debug(message);
}
throw new ProfileManagementException(message);
}
ProfileConfiguration profConfig =
(ProfileConfiguration) profileManager.getProfileConfig(profileName);
if (profConfig != null) {
String message = "Profile configuration already exist for the user store. " +
"Please select a different name.";
if (log.isDebugEnabled()) {
log.debug(message);
}
throw new ProfileManagementException(message);
}
List<String> hidden = new ArrayList<String>();
List<String> overridden = new ArrayList<String>();
List<String> inherited = new ArrayList<String>();
for (ClaimConfigurationDTO claim : claimsConfiguration) {
String claimURI = claim.getClaimUri();
String behavior = claim.getBehavior();
if (UserCoreConstants.CLAIM_HIDDEN.equals(behavior)) {
hidden.add(claimURI);
} else if (UserCoreConstants.CLAIM_OVERRIDEN.equals(behavior)) {
overridden.add(claimURI);
} else {
inherited.add(claimURI);
}
}
ProfileConfiguration config = new ProfileConfiguration(profileName, hidden, overridden,
inherited);
config.setDialectName(dialectName);
profileManager.addProfileConfig(config);
} catch (org.wso2.carbon.user.api.UserStoreException e) {
String message = "Error while adding profile configurations for dialect " + dialectName;
log.error(message, e);
throw new ProfileManagementException(message, e);
}