diff --git a/changes.xml b/changes.xml index 29c8cad..73584fe 100644 --- a/changes.xml +++ b/changes.xml @@ -23,6 +23,12 @@ xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd"> + + + Add explicit handling for responses with invalid JSON payload for packager manager install status and bundle status calls. + + + Check package manager installstatus.jsp before and after installation of content package to make sure packager manager is also completed with installing embedded packages. diff --git a/pom.xml b/pom.xml index 15c6524..530dcd3 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ io.wcm.tooling.commons io.wcm.tooling.commons.crx-packmgr-helper - 2.1.0 + 2.1.2 jar CRX Package Manager Helper @@ -48,7 +48,7 @@ tooling/commons/crx-packmgr-helper - 2022-06-16T17:01:06Z + 2022-06-20T10:50:19Z diff --git a/src/main/java/io/wcm/tooling/commons/packmgr/httpaction/BundleStatusCall.java b/src/main/java/io/wcm/tooling/commons/packmgr/httpaction/BundleStatusCall.java index feca20f..bc866d0 100644 --- a/src/main/java/io/wcm/tooling/commons/packmgr/httpaction/BundleStatusCall.java +++ b/src/main/java/io/wcm/tooling/commons/packmgr/httpaction/BundleStatusCall.java @@ -29,6 +29,7 @@ import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; +import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -80,8 +81,13 @@ public BundleStatus execute() { } private BundleStatus toBundleStatus(String jsonString) { - BundleStatusParser parser = new BundleStatusParser(bundleStatusWhitelistBundleNames); - return parser.parse(jsonString); + try { + BundleStatusParser parser = new BundleStatusParser(bundleStatusWhitelistBundleNames); + return parser.parse(jsonString); + } + catch (JSONException ex) { + throw PackageManagerHttpActionException.forJSONException(bundleStatusURL, jsonString, ex); + } } } diff --git a/src/main/java/io/wcm/tooling/commons/packmgr/httpaction/PackageManagerInstallStatusCall.java b/src/main/java/io/wcm/tooling/commons/packmgr/httpaction/PackageManagerInstallStatusCall.java index 3d308ea..ff79590 100644 --- a/src/main/java/io/wcm/tooling/commons/packmgr/httpaction/PackageManagerInstallStatusCall.java +++ b/src/main/java/io/wcm/tooling/commons/packmgr/httpaction/PackageManagerInstallStatusCall.java @@ -27,6 +27,7 @@ import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.util.EntityUtils; +import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -79,11 +80,16 @@ private PackageManagerInstallStatus toPackageManagerInstallStatus(String jsonStr boolean finished = false; int itemCount = 0; - JSONObject json = new JSONObject(jsonString); - JSONObject status = json.optJSONObject("status"); - if (status != null) { - finished = status.optBoolean("finished"); - itemCount = status.optInt("itemCount"); + try { + JSONObject json = new JSONObject(jsonString); + JSONObject status = json.optJSONObject("status"); + if (status != null) { + finished = status.optBoolean("finished"); + itemCount = status.optInt("itemCount"); + } + } + catch (JSONException ex) { + throw PackageManagerHttpActionException.forJSONException(packageManagerInstallStatusURL, jsonString, ex); } return new PackageManagerInstallStatus(finished, itemCount);