Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,28 @@ jobs:
with:
java-version: 1.8

- uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-${{ github.event.inputs.application_id }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}

- uses: actions/cache@v2
with:
path: |
~/.android
key: ${{ runner.os }}-${{ github.event.inputs.application_id }}

- name: Environment info
run: |
gradle --version
echo url ${{ github.event.inputs.api_base_url }}
echo app name ${{ github.event.inputs.app_name }}
echo app dir ${{ github.event.inputs.app_dir }}
echo CLI_JAVA_DIR "${{ github.event.inputs.cli_java_dir }}"
echo CLI_RES_DIR "${{ github.event.inputs.cli_res_dir }}"
echo APPLICATION_ID "${{ github.event.inputs.application_id }}"

- name: build
run: |
Expand Down
12 changes: 7 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ apply from: "$project.rootDir/script-git-version.gradle"
apply plugin: 'com.android.application'

// Load keystore
def keystorePropertiesFile = file("keystore.properties");
def keystorePropertiesFile = file("keystore.properties")
def keystoreProperties = new Properties()
if ( keystorePropertiesFile.exists() ) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
Expand Down Expand Up @@ -149,16 +149,18 @@ android {
resValue "string", "app_name_policies", "Policies CHF SIT"
}
niger {
print("Building niger flavour" + "API_BASE_URL" + '"' + (System.getenv("API_BASE_URL") ?: 'http://192.168.0.100/') + '"')
print("App name: " + System.getenv("CLI_APP_NAME") ?: "Polices Niger")
applicationId "org.openimis.imispolicies.niger"
buildConfigField "String", "API_BASE_URL", '"http://oiniger.bluesquare.org/rest/"'
buildConfigField "String", "APP_DIR", '"IMIS-NIGER"'
resValue "string", "app_name_policies", "Polices Niger"
buildConfigField "String", "API_BASE_URL", '"' + (System.getenv("API_BASE_URL") ?: 'http://192.168.0.100/') + '"'
buildConfigField "String", "APP_DIR", '"' + (System.getenv("CLI_APP_DIR") ?: 'IMIS-POL') + '"'
resValue "string", "app_name_policies", System.getenv("CLI_APP_NAME") ?: "Polices Niger"
}
cli {
applicationIdSuffix System.getenv("APPLICATION_ID") ?: "org.openimis.imispolicies.cli"
buildConfigField "String", "API_BASE_URL", '"' + (System.getenv("API_BASE_URL") ?: 'http://10.0.2.2:35787/') + '"'
buildConfigField "String", "APP_DIR", '"' + (System.getenv("CLI_APP_DIR") ?: 'IMIS-CLI') + '"'
resValue "string", "app_name_claims", System.getenv("CLI_APP_NAME") ?: "Policies CLI"
resValue "string", "app_name_policies", System.getenv("CLI_APP_NAME") ?: "Policies CLI"
dimension 'std'
}
mauritaniaTrain {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4227,6 +4227,10 @@ public boolean LoginToken(final String Username, final String Password) {
if (respEntity != null) {
try {
content = EntityUtils.toString(respEntity);
if (content != null && content.length() > 0
&& response.getStatusLine().getStatusCode() >= 400) {
Log.e("HTTP", "Error response: " + content);
}
} catch (IOException e) {
e.printStackTrace();
}
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/org/openimis/imispolicies/ToRestApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ public HttpResponse postToRestApi(JSONObject object, String functionName, boolea

int responseCode = response.getStatusLine().getStatusCode();
Log.i("HTTP_POST", uri + functionName + " - " + responseCode);
if (object != null && responseCode >= 400) {
String body = object.toString();
if (body.length() > 1000) {
body = body.substring(0,1000);
}
Log.e("HTTP_POST", "Body: " + body);
}
return response;
} catch (IOException e) {
e.printStackTrace();
Expand Down Expand Up @@ -157,6 +164,10 @@ public String getContent(HttpResponse response) {
if (respEntity != null) {
try {
content = EntityUtils.toString(respEntity);
if (content != null && content.length() > 0
&& response.getStatusLine().getStatusCode() >= 400) {
Log.e("HTTP", "Error response: " + content);
}
} catch (IOException e) {
e.printStackTrace();
}
Expand Down
1 change: 1 addition & 0 deletions run_cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo '{"api_base_url":"http://192.168.0.100/rest/", "app_name":"IMIS Polices Gaya", "app_dir":"IMIS-POL-GAYA", "application_id":"org.openimis.imispolicies.niger", "cli_java_dir": "src/niger/java", "cli_res_dir": "src/niger/res"}' | gh workflow run manual.yml --ref develop --json