-
Notifications
You must be signed in to change notification settings - Fork 19
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
base: master
Are you sure you want to change the base?
Conversation
@@ -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)); |
There was a problem hiding this comment.
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()
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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() );
There was a problem hiding this 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=") ) { |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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
Add utf-8 encoding on dhis2 endpoint: this resolve bad request error on win platform