Skip to content

Commit

Permalink
add logging for non successful dhis2 sync (#72)
Browse files Browse the repository at this point in the history
* add logging for non successful dhis2 sync

* update, log other responses as info
  • Loading branch information
bennsimon authored Feb 1, 2022
1 parent 0733261 commit fd453fe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<artifactId>opensrp-server-connector</artifactId>
<packaging>jar</packaging>
<version>2.3.5-SNAPSHOT</version>
<version>2.3.6-SNAPSHOT</version>
<name>opensrp-server-connector</name>
<description>OpenSRP Server Connector module</description>
<url>http://github.com/OpenSRP/opensrp-server-connector</url>
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/org/opensrp/connector/dhis2/DHIS2DatasetPush.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,21 @@ public void pushToDHIS2() {
}

JSONObject response = dhis2HttpUtils.post(DATAVALUESET_ENDPOINT, "", dhis2DatasetToPush.toString());
report.setStatus(response.getString("status"));
String status = response.optString("status");
if(DHIS2ResponseStatus.ERROR.name().equalsIgnoreCase(status)) {
logger.error(response);
} else if(DHIS2ResponseStatus.WARNING.name().equalsIgnoreCase(status)) {
logger.warn(response);
} else {
logger.info(response);
}
report.setStatus(status);
reportService.updateReport(report);
config.updateAppStateToken(DhisSchedulerConfig.dhis2_syncer_sync_report_by_date_updated,
report.getServerVersion());
}
catch (JSONException e) {
logger.error("", e);
logger.error(e);
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.opensrp.connector.dhis2;

public enum DHIS2ResponseStatus {
SUCCESS,
WARNING,
ERROR
}

0 comments on commit fd453fe

Please sign in to comment.