use of net.geoprism.dhis2.dhis2adapter.exception.IncompatibleServerVersionException in project geoprism-registry by terraframe.
the class DHIS2ServiceFactory method instanceGetDhis2Service.
public synchronized DHIS2TransportServiceIF instanceGetDhis2Service(DHIS2ExternalSystem system) throws UnexpectedResponseException, InvalidLoginException, HTTPException, BadServerUriException {
if (this.dhis2 == null) {
HTTPConnector connector = new HTTPConnector();
connector.setServerUrl(system.getUrl());
connector.setCredentials(system.getUsername(), system.getPassword());
DHIS2TransportService dhis2 = new DHIS2TransportService(connector);
try {
dhis2.initialize();
if (dhis2.getVersionRemoteServerApi() > DHIS2FeatureService.LAST_TESTED_DHIS2_API_VERSION) {
Integer compatLayerVersion = dhis2.getVersionRemoteServerApi() - 2;
if (compatLayerVersion < DHIS2FeatureService.LAST_TESTED_DHIS2_API_VERSION) {
compatLayerVersion = DHIS2FeatureService.LAST_TESTED_DHIS2_API_VERSION;
}
dhis2.setVersionApiCompat(compatLayerVersion);
}
} catch (IncompatibleServerVersionException e) {
throw new ProgrammingErrorException(e);
}
return dhis2;
}
return this.dhis2;
}
Aggregations