public void undeploy()

in src/main/java/org/apache/sling/maven/bundlesupport/deploy/method/FelixPostDeployMethod.java [80:100]


    public void undeploy(URI targetURL, String bundleSymbolicName, DeployContext context) throws IOException {
        URI postUrl = targetURL.resolve("bundles/" + bundleSymbolicName);
        context.getLog().debug("Uninstalling via POST to " + postUrl);
        final HttpPost post = new HttpPost(postUrl);
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("action", "uninstall"));
        post.setEntity(new UrlEncodedFormEntity(params));
        String response = context.getHttpClient().execute(post, new BasicHttpClientResponseHandler());
        // sanity check on response (has really the right servlet answered?)
        // must be JSON
        // (https://github.com/apache/felix-dev/blob/8e35c940a95c91f3fee09c537dbaf9665e5d027e/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java#L420_
        try {
            JsonObject jsonObject = JsonSupport.parseObject(response);
            // must contain boolean
            jsonObject.getBoolean("fragment");
        } catch (JsonException | ClassCastException | NullPointerException e) {
            throw new IOException("Unexpected response received from " + postUrl
                    + ". Maybe wrong endpoint? Must be valid JSON but was: " + response);
        }
        context.getLog().debug("Received response from " + postUrl + ": " + response);
    }