Search in sources :

Example 11 with DhisHttpResponse

use of org.hisp.dhis.system.util.DhisHttpResponse in project dhis2-core by dhis2.

the class MetadataVersionDelegate method downloadMetadataVersionSnapshot.

public String downloadMetadataVersionSnapshot(MetadataVersion version) throws MetadataVersionServiceException {
    String downloadVersionSnapshotURL = metadataSystemSettingService.getDownloadVersionSnapshotURL(version.getName());
    DhisHttpResponse dhisHttpResponse = getDhisHttpResponse(downloadVersionSnapshotURL, DOWNLOAD_TIMEOUT);
    if (isValidDhisHttpResponse(dhisHttpResponse)) {
        return dhisHttpResponse.getResponse();
    }
    return null;
}
Also used : DhisHttpResponse(org.hisp.dhis.system.util.DhisHttpResponse)

Example 12 with DhisHttpResponse

use of org.hisp.dhis.system.util.DhisHttpResponse in project dhis2-core by dhis2.

the class MetadataVersionDelegate method getRemoteMetadataVersion.

public MetadataVersion getRemoteMetadataVersion(String versionName) {
    String versionDetailsUrl = metadataSystemSettingService.getVersionDetailsUrl(versionName);
    DhisHttpResponse dhisHttpResponse = getDhisHttpResponse(versionDetailsUrl, VERSION_TIMEOUT);
    MetadataVersion dataVersion = null;
    if (isValidDhisHttpResponse(dhisHttpResponse)) {
        try {
            dataVersion = renderService.fromJson(dhisHttpResponse.getResponse(), MetadataVersion.class);
        } catch (Exception e) {
            String message = "Exception occurred while trying to do JSON conversion for metadata version";
            log.error(message, e);
            throw new MetadataVersionServiceException(message, e);
        }
    }
    return dataVersion;
}
Also used : MetadataVersion(org.hisp.dhis.metadata.version.MetadataVersion) MetadataVersionServiceException(org.hisp.dhis.dxf2.metadata.version.exception.MetadataVersionServiceException) DhisHttpResponse(org.hisp.dhis.system.util.DhisHttpResponse) IOException(java.io.IOException) RemoteServerUnavailableException(org.hisp.dhis.exception.RemoteServerUnavailableException) MetadataVersionServiceException(org.hisp.dhis.dxf2.metadata.version.exception.MetadataVersionServiceException)

Aggregations

DhisHttpResponse (org.hisp.dhis.system.util.DhisHttpResponse)12 AvailabilityStatus (org.hisp.dhis.dxf2.synch.AvailabilityStatus)9 MetadataVersion (org.hisp.dhis.metadata.version.MetadataVersion)9 DhisSpringTest (org.hisp.dhis.DhisSpringTest)8 IntegrationTest (org.hisp.dhis.IntegrationTest)8 Test (org.junit.Test)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 IOException (java.io.IOException)5 MetadataVersionServiceException (org.hisp.dhis.dxf2.metadata.version.exception.MetadataVersionServiceException)4 HttpResponse (org.apache.http.HttpResponse)3 InputStream (org.omg.CORBA.portable.InputStream)3 ArrayList (java.util.ArrayList)2 RemoteServerUnavailableException (org.hisp.dhis.exception.RemoteServerUnavailableException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1