Search in sources :

Example 1 with DHIS2TransportService

use of net.geoprism.registry.etl.export.dhis2.DHIS2TransportService 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;
}
Also used : IncompatibleServerVersionException(net.geoprism.dhis2.dhis2adapter.exception.IncompatibleServerVersionException) HTTPConnector(net.geoprism.dhis2.dhis2adapter.HTTPConnector) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) DHIS2TransportService(net.geoprism.registry.etl.export.dhis2.DHIS2TransportService)

Aggregations

ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)1 HTTPConnector (net.geoprism.dhis2.dhis2adapter.HTTPConnector)1 IncompatibleServerVersionException (net.geoprism.dhis2.dhis2adapter.exception.IncompatibleServerVersionException)1 DHIS2TransportService (net.geoprism.registry.etl.export.dhis2.DHIS2TransportService)1