String tenantId = System.getProperty(CUMULOCITY_TENANT);
String user = System.getProperty(CUMULOCITY_USER);
String password = System.getProperty(CUMULOCITY_PASSWORD);
String applicationKey = System.getProperty(CUMOLOCITY_APPLICATION_KEY);
if (host == null || tenantId == null || user == null || password == null) {
throw new SDKException("Cannot Create Platform as Mandatory Param are not set");
}
if (System.getProperty(CUMULOCITY_PAGE_SIZE) != null) {
int pageSize = Integer.parseInt(System.getProperty(CUMULOCITY_PAGE_SIZE));
platform = new PlatformImpl(host, port, tenantId, user, password, applicationKey, pageSize);
} else {
platform = new PlatformImpl(host, port, tenantId, user, password, applicationKey);
}
String proxyHost = System.getProperty(CUMOLOCITY_PROXY_HOST);
int proxyPort = -1;
if (System.getProperty(CUMULOCITY_PROXY_PORT) != null) {
proxyPort = Integer.parseInt(System.getProperty(CUMULOCITY_PROXY_PORT));
}
String proxyUser = System.getProperty(CUMULOCITY_PROXY_USER);
String proxyPassword = System.getProperty(CUMULOCITY_PROXY_PASSWORD);
if (proxyHost != null && proxyPort > 0) {
platform.setProxyHost(proxyHost);
platform.setProxyPort(proxyPort);
}
if (proxyUser != null && proxyPassword != null) {
platform.setProxyUserId(proxyUser);
platform.setProxyPassword(proxyPassword);
}
} catch (NumberFormatException e) {
throw new SDKException("Invalid Number :" + e.getMessage());
}
return platform;
}