diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml index 2b452b3b..e355c3fa 100644 --- a/.github/workflows/manual.yml +++ b/.github/workflows/manual.yml @@ -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: | diff --git a/app/build.gradle b/app/build.gradle index efe39ba5..c9f93930 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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)) @@ -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 { diff --git a/app/src/main/java/org/openimis/imispolicies/ClientAndroidInterface.java b/app/src/main/java/org/openimis/imispolicies/ClientAndroidInterface.java index a08e11a6..b23cf98d 100644 --- a/app/src/main/java/org/openimis/imispolicies/ClientAndroidInterface.java +++ b/app/src/main/java/org/openimis/imispolicies/ClientAndroidInterface.java @@ -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(); } diff --git a/app/src/main/java/org/openimis/imispolicies/ToRestApi.java b/app/src/main/java/org/openimis/imispolicies/ToRestApi.java index 16c52cdc..c40511a1 100644 --- a/app/src/main/java/org/openimis/imispolicies/ToRestApi.java +++ b/app/src/main/java/org/openimis/imispolicies/ToRestApi.java @@ -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(); @@ -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(); } diff --git a/run_cli.sh b/run_cli.sh new file mode 100755 index 00000000..c162139e --- /dev/null +++ b/run_cli.sh @@ -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