use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeServerDefaultsStep method initialize.
@Override
public void initialize() throws UpgradeException {
try {
existingDefaults = new HashMap(ServerConfiguration.getServerInstance(getAdminToken(), ServerConfiguration.DEFAULT_SERVER_CONFIG));
Map<String, String> newDefaults = ServerConfiguration.getNewServerDefaults(getAdminToken());
Properties validProperties = new Properties();
validProperties.load(getClass().getResourceAsStream(VALID_SERVER_CONFIG_PROPERTIES));
Map<String, String> validServerProperties = new HashMap(validProperties);
Set<String> attrsToUpgrade = ServerUpgrade.getAttrsToUpgrade();
addedAttrs = calculateAddedServerDefaults(newDefaults, existingDefaults);
modifiedAttrs = calculateModifiedServerDefaults(newDefaults, existingDefaults, attrsToUpgrade);
deletedAttrs = calculateDeletedServerDefaults(existingDefaults, validServerProperties);
} catch (Exception ex) {
throw new UpgradeException(ex);
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeServerDefaultsStep method perform.
@Override
public void perform() throws UpgradeException {
try {
UpgradeProgress.reportStart("upgrade.platformupdate");
existingDefaults = new HashMap(ServerConfiguration.getServerInstance(getAdminToken(), ServerConfiguration.DEFAULT_SERVER_CONFIG));
Map<String, String> upgradedValues = new HashMap<String, String>(existingDefaults);
upgradedValues.putAll(addedAttrs);
upgradedValues.putAll(modifiedAttrs);
upgradedValues.keySet().removeAll(deletedAttrs);
ServerConfiguration.upgradeServerInstance(getAdminToken(), DEFAULT_SERVER_CONFIG, DEFAULT_SERVER_ID, upgradedValues);
UpgradeProgress.reportEnd("upgrade.success");
} catch (Exception ex) {
UpgradeUtils.debug.error("Unable to upgrade server default properties", ex);
throw new UpgradeException(ex);
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeServerDefaultsStep method getUpdatedDefaults.
/**
* Gets the current server default values to see if any updates in previous upgrade steps need to be re-applied.
* @return the key value pairs of attributes that will need to be re-applied
* @throws UpgradeException
*/
private Map<String, String> getUpdatedDefaults() throws UpgradeException {
HashMap<String, String> modifiedValues = new HashMap<String, String>();
try {
Map<String, String> currentDefaults = new HashMap(ServerConfiguration.getServerInstance(getAdminToken(), ServerConfiguration.DEFAULT_SERVER_CONFIG));
String currentDefault = currentDefaults.get(CoreTokenConstants.CTS_STORE_HOSTNAME);
String existingDefault = existingDefaults.get(CoreTokenConstants.CTS_STORE_HOSTNAME);
if (DEBUG.messageEnabled()) {
DEBUG.message("currentDefault: " + currentDefault + "existingDefault: " + existingDefault);
}
if (currentDefault != null && existingDefault != null && !existingDefault.equals(currentDefault)) {
modifiedValues.put(CoreTokenConstants.CTS_STORE_HOSTNAME, currentDefault);
}
} catch (Exception ex) {
DEBUG.error("An error occurred trying to get current configuration.", ex);
throw new UpgradeException(ex);
}
return modifiedValues;
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeIdRepoSubConfigs method perform.
@Override
public void perform() throws UpgradeException {
for (Map.Entry<String, Set<String>> entry : repos.entrySet()) {
try {
String realm = entry.getKey();
OrganizationConfigManager ocm = new OrganizationConfigManager(getAdminToken(), realm);
for (String subConfig : entry.getValue()) {
UpgradeProgress.reportStart("upgrade.data.store.start", subConfig);
Map<String, Set<String>> newValues = new HashMap<String, Set<String>>(2);
ServiceConfig sc = ocm.getServiceConfig(IdConstants.REPO_SERVICE);
ServiceConfig repoConfig = sc.getSubConfig(subConfig);
Map<String, Set<String>> attributes = repoConfig.getAttributes();
String className = CollectionHelper.getMapAttr(attributes, IdConstants.ID_REPO);
if (OLD_IDREPO_CLASS.equals(className)) {
newValues.put(IdConstants.ID_REPO, asSet(NEW_IDREPO_CLASS));
}
String newFilter = getModifiedFilter(attributes);
if (newFilter != null) {
if (DEBUG.messageEnabled()) {
DEBUG.message("Upgrading psearch filter for datastore: " + subConfig + " to: " + newFilter);
}
newValues.put(PSEARCH_FILTER, asSet(newFilter));
}
Map<String, String> sslModes = oldConnectionModeRepos.get(realm);
String sslMode = (sslModes == null) ? null : sslModes.get(subConfig);
if (sslMode != null) {
if (DEBUG.messageEnabled()) {
DEBUG.message("Upgrading connection mode for datastore: " + subConfig + " to: " + sslMode);
}
newValues.put(NEW_CONNECTION_MODE, asSet(sslMode));
}
//There is no need to remove the obsolete attributes here, because once we set an attribute, the SMS
//framework will automagically remove those that do not adhere to the schema.
repoConfig.setAttributes(newValues);
UpgradeProgress.reportEnd("upgrade.success");
}
} catch (Exception ex) {
UpgradeProgress.reportEnd("upgrade.failed");
DEBUG.error("An error occurred while upgrading service config ", ex);
throw new UpgradeException("Unable to upgrade IdRepo configuration");
}
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeLDAPAuthModulesStep method perform.
@Override
public void perform() throws UpgradeException {
UpgradeProgress.reportStart("upgrade.auth.instances.ldap.start");
for (final Map.Entry<String, Map<String, Boolean>> entry : instances.entrySet()) {
final String realm = entry.getKey();
final Map<String, Boolean> instanceMap = entry.getValue();
try {
updateAttributes(realm, instanceMap);
} catch (final Exception ex) {
UpgradeProgress.reportEnd("upgrade.failed");
DEBUG.error("An error occurred while upgrading service configs for auth module instances " + " in realm " + realm, ex);
throw new UpgradeException("Unable to upgrade ldap/ad auth module instance configurations " + " in realm " + realm, ex);
}
}
UpgradeProgress.reportEnd("upgrade.success");
}
Aggregations