Constants.OUTPUT_OP_MODIFY, warningMsgList, false)) {
return;
}
}
AppManagerAdd appManagerAdd = new AppManagerAdd();
appManagerAdd.setName(name);
//appManagerAdd.setDescription(description);
appManagerAdd.setDescription(appManagerRead.getDescription());
//appManagerAdd.setType(type);
appManagerAdd.setType(appManagerRead.getType());
if (url == null) {
appManagerAdd.setUrl(appManagerRead.getUrl());
} else {
//validate url in appManagerAdd
List<String> errorMsgs = new ArrayList<String>();
if (!CommonUtil.validateUrl(url, errorMsgs)) {
CommandsUtils.printCmdFailure(
Constants.OUTPUT_OBJECT_APPMANAGER,
name,
Constants.OUTPUT_OP_ADD,
Constants.OUTPUT_OP_RESULT_FAIL,
"Invalid URL: " + CommonUtil.mergeErrorMsgList(errorMsgs) + ".");
return;
}
appManagerAdd.setUrl(url);
}
if (changeAccount) {
Map<String, String> loginInfo = getAccount();
if (null == loginInfo) {
return;
}
appManagerAdd.setUsername(loginInfo.get(Constants.LOGIN_USERNAME));
appManagerAdd.setPassword(loginInfo.get(Constants.LOGIN_PASSWORD));
} else {
appManagerAdd.setUsername(appManagerRead.getUsername());
appManagerAdd.setPassword(appManagerRead.getPassword());
}
if ((url != null && url.toLowerCase().startsWith("https"))
|| (url == null && changeCertificate && appManagerAdd
.getUrl().toLowerCase().startsWith("https"))) {
// new URL starts with https or
// changeCertificate for old URL starts with https (no new URL)
String sslCertificate = getSslCertificate();
if (null == sslCertificate) {
CommandsUtils.printCmdFailure(Constants.OUTPUT_OBJECT_APPMANAGER,
name, Constants.OUTPUT_OP_MODIFY, Constants.OUTPUT_OP_RESULT_FAIL,
"Fail to get ssl certificate.");
return;
}
appManagerAdd.setSslCertificate(sslCertificate);
} else if (url == null && changeCertificate
&& !appManagerAdd.getUrl().toLowerCase().startsWith("https")) {
// changeCertificate for old URL does not start with https (no new URL)
CommandsUtils.printCmdFailure(Constants.OUTPUT_OBJECT_APPMANAGER,
name, Constants.OUTPUT_OP_MODIFY, Constants.OUTPUT_OP_RESULT_FAIL,
"Cannot set ssl certificate for http service.");
return;
} else if (url != null && !url.toLowerCase().startsWith("https")) {
// new url does not start with https
appManagerAdd.setSslCertificate(null);
} else {
// no new url or changeCertificate
appManagerAdd.setSslCertificate(appManagerRead.getSslCertificate());
}
restClient.modify(appManagerAdd);
CommandsUtils.printCmdSuccess(Constants.OUTPUT_OBJECT_APPMANAGER,
name, Constants.OUTPUT_OP_RESULT_MODIFY);