Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utf-8 encoding on dhis2 endpoint: this resolve bad request error on win platform #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ahammi
Copy link

@ahammi ahammi commented Jan 9, 2019

Add utf-8 encoding on dhis2 endpoint: this resolve bad request error on win platform

@@ -212,7 +213,7 @@ private void saveToBackUp(String path, String jsonResponse) {
}

String directoryStructure = OpenmrsUtil.getApplicationDataDirectory() + DHISCONNECTOR_DHIS2BACKUP_FOLDER
+ path.substring(0, path.lastIndexOf(File.separator));
+ path.substring(0, path.lastIndexOf(File.separator) == -1? path.length() - 1 :path.lastIndexOf(File.separator));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahammi maybe this?

import java.nio.file.Paths;

Paths.get(OpenmrsUtil.getApplicationDataDirectory(), DHISCONNECTOR_DHIS2BACKUP_FOLDER, path)
.toString()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like that looks better if tested to work

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaweesi yes this a vetted Java lib that is working fine, please try it out :-)
Example:

System.out.println( Paths.get("/path/to", "some", "/place", "somewhere/").toString() );

Copy link
Contributor

@kaweesi kaweesi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @ahammi, left some feedback, you could format your code well enough to remove trailing spaces

DefaultHttpClient client = null;
String payload = "";

if (StringUtils.isNotBlank(endpoint)) {
try {
if( endpoint.contains("fields=") ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see some trailing spaces, rightly format the code to remove such spaces like after 'if(' and before ') {'

@@ -212,7 +213,7 @@ private void saveToBackUp(String path, String jsonResponse) {
}

String directoryStructure = OpenmrsUtil.getApplicationDataDirectory() + DHISCONNECTOR_DHIS2BACKUP_FOLDER
+ path.substring(0, path.lastIndexOf(File.separator));
+ path.substring(0, path.lastIndexOf(File.separator) == -1? path.length() - 1 :path.lastIndexOf(File.separator));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like that looks better if tested to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants