try {
List<ApplicationAlias> applicationAliasList = new ArrayList<ApplicationAlias>();
BlueGreenSettings blueGreenSettings = BlueGreenSettings.getInstance(client, getAccount(), name);
// Get the app1 alias if any
ApplicationInfo applicationInfo = client.applicationInfo(blueGreenSettings.getApplication1());
String aliases = applicationInfo.getSettings().get("aliases");
ApplicationAlias application1 = new ApplicationAlias(getAccount(), blueGreenSettings.getApplication1(), aliases);
// If the app1 has the alias already, set the other app alias
if (application1.containAliases(blueGreenSettings.getActiveAliases())) {
addApplicationAlias(applicationAliasList, blueGreenSettings.getApplication2(), blueGreenSettings.getActiveAliases());
// Check to see if the other app has aliases
ApplicationInfo applicationInfo2 = client.applicationInfo(blueGreenSettings.getApplication2());
String aliases2 = applicationInfo2.getSettings().get("aliases");
// If it has aliases, let swap them to the app1
if (aliases2 != null) {
addApplicationAlias(applicationAliasList, application1.getAppId(), aliases2);
}
// If the app1 does not have the alias, set them