private void populateProfileAndClaimMaps(Map<String, ClaimMapping> claimMappings,
Map<String, ProfileConfiguration> profileConfigs) throws UserStoreException {
ClaimDAO claimDAO = new ClaimDAO(dataSource, tenantId);
ProfileConfigDAO profileDAO = new ProfileConfigDAO(dataSource, tenantId);
ClaimBuilder claimBuilder = new ClaimBuilder(tenantId);
ProfileConfigurationBuilder profileBilder = new ProfileConfigurationBuilder(tenantId);
int count = claimDAO.getDialectCount();
if (count == 0) {
try {
claimMappings.putAll(claimBuilder.buildClaimMappingsFromConfigFile());
} catch (ClaimBuilderException e) {
String msg = "Error in building claims.";
log.error(msg);
throw new UserStoreException(msg, e);
}
claimDAO.addCliamMappings(claimMappings.values().toArray(
new ClaimMapping[claimMappings.size()]));
try {
profileConfigs.putAll(profileBilder.buildProfileConfigurationFromConfigFile());
} catch (ProfileBuilderException e) {
String msg = "Error in building the profile.";
log.error(msg);
throw new UserStoreException(msg, e);
}
profileDAO.addProfileConfig(profileConfigs.values().toArray(
new ProfileConfiguration[profileConfigs.size()]));
} else {
try {
claimMappings.putAll(claimBuilder.buildClaimMappingsFromDatabase(dataSource,
UserCoreConstants.INTERNAL_USERSTORE));
} catch (ClaimBuilderException e) {
String msg = "Error in building claims.";
log.error(msg);
throw new UserStoreException(msg, e);
}
try {
profileConfigs.putAll(profileBilder.buildProfileConfigurationFromDatabase(dataSource,
UserCoreConstants.INTERNAL_USERSTORE));
} catch (ProfileBuilderException e) {
String msg = "Error in building the profile.";
log.error(msg);
throw new UserStoreException(msg, e);