* SERVER NEED TO GET RID OF REGISTRY Consider USERNAME/PASSWORD/POLLINGINTERVAL
*/
public int addMonitoredServer(ServerDO server) throws BAMException {
int addingServerStatus = -1;
BAMConfigurationDSClient bamConfigurationDSClient = BAMUtil.getBAMConfigurationDSClient();
int tenantId;
if (server.getTenantID() == NO_TENANT_MODE) {
BAMTenantAdmin bamTenantAdmin = new BAMTenantAdmin();
tenantId = bamTenantAdmin.getTenantId();
} else {
tenantId = server.getTenantID();
}
String serverUrl = server.getServerURL();
String severType = server.getServerType();
int category = server.getCategory();
ServerDO monitoredServerDO = bamConfigurationDSClient.getServer(serverUrl, tenantId, severType, category);
try {
if (monitoredServerDO == null) {
server.setTenantID(tenantId);
server.setPassword(encryptPassword(server.getPassword()));
int serverID = bamConfigurationDSClient.addServer(server);
if (serverID != BAMConstants.UNASSIGNED_SERVER_ID) {
addingServerStatus = BAMConstants.SERVER_SUCCESSFULLY_ADDED;
}
} else {
addingServerStatus = BAMConstants.SERVER_ALREADY_EXIST;
}
} catch (CryptoException e) {
throw new BAMException("Unable to encrypt password of server " + serverUrl, e);
} finally {
if (bamConfigurationDSClient != null) {
bamConfigurationDSClient.cleanup();
}
}
return addingServerStatus;
}