public void undeploy(String deploymentName, Set<String> serverGroups, boolean removeContent) {
        if (serverGroups == null) {
            serverGroups = Collections.emptySet();
        }

        DeploymentResult result = null;

        try {
            DeploymentManager dm = DeploymentManager.Factory.create(getModelControllerClient());
            UndeployDescription undeployDescription = UndeployDescription.of(deploymentName)
                    .addServerGroups(serverGroups)
                    .setFailOnMissing(false)
                    .setRemoveContent(removeContent);
            result = dm.undeploy(undeployDescription);
        } catch (Exception e) {
            String errMsg;
            if (serverGroups.isEmpty()) {
                errMsg = String.format("Failed to undeploy [%s] (standalone mode)", deploymentName);
            } else {
                errMsg = String.format("Failed to undeploy [%s] from server groups: %s", deploymentName, serverGroups);
            }
            throw new FailureException(errMsg, e);
        }

        if (!result.successful()) {
            String errMsg;
            if (serverGroups.isEmpty()) {
                errMsg = String.format("Failed to undeploy [%s] (standalone mode)", deploymentName);
            } else {
                errMsg = String.format("Failed to undeploy [%s] from server groups [%s]", deploymentName,
                        serverGroups);
            }
            throw new FailureException(errMsg + ": " + result.getFailureMessage());
        }

        return; // everything is OK
    }
public void undeploy ( String deploymentName , Set < String > serverGroups , boolean removeContent ) { if ( serverGroups == null ) { serverGroups = Collections . emptySet ( ) ; } DeploymentResult result = null ; try { DeploymentManager dm = DeploymentManager . Factory . create ( getModelControllerClient ( ) ) ; UndeployDescription undeployDescription = UndeployDescription . of ( deploymentName ) . addServerGroups ( serverGroups ) . setFailOnMissing ( false ) . setRemoveContent ( removeContent ) ; result = dm . undeploy ( undeployDescription ) ; } catch ( Exception e ) { String errMsg ; if ( serverGroups . isEmpty ( ) ) { errMsg = String . format ( "Failed to undeploy [%s] (standalone mode)" , deploymentName ) ; } else { errMsg = String . format ( "Failed to undeploy [%s] from server groups: %s" , deploymentName , serverGroups ) ; } throw new FailureException ( errMsg , e ) ; } if ( ! result . successful ( ) ) { String errMsg ; if ( serverGroups . isEmpty ( ) ) { errMsg = String . format ( "Failed to undeploy [%s] (standalone mode)" , deploymentName ) ; } else { errMsg = String . format ( "Failed to undeploy [%s] from server groups [%s]" , deploymentName , serverGroups ) ; } throw new FailureException ( errMsg + ": " + result . getFailureMessage ( ) ) ; } return ; }
Undeploys an app. If an empty set of server groups is passed in, this will assume we are operating on a
standalone server.

@param deploymentName name that the app is known as
@param serverGroups the server groups where the application may already be deployed. If empty,
this will assume the app server is in STANDALONE mode.
@param removeContent if true, the content will be removed from the repository; false means the content stays.