public void deploy ( String deploymentName , InputStream content , boolean enabled , Set < String > serverGroups , boolean forceDeploy ) { if ( serverGroups == null ) { serverGroups = Collections . emptySet ( ) ; } DeploymentResult result = null ; try { DeploymentManager dm = DeploymentManager . Factory . create ( getModelControllerClient ( ) ) ; Deployment deployment = Deployment . of ( content , deploymentName ) . addServerGroups ( serverGroups ) . setEnabled ( enabled ) ; if ( forceDeploy ) { result = dm . forceDeploy ( deployment ) ; } else { result = dm . deploy ( deployment ) ; } } catch ( Exception e ) { String errMsg ; if ( serverGroups . isEmpty ( ) ) { errMsg = String . format ( "Failed to deploy [%s] (standalone mode)" , deploymentName ) ; } else { errMsg = String . format ( "Failed to deploy [%s] to server groups: %s" , deploymentName , serverGroups ) ; } throw new FailureException ( errMsg , e ) ; } if ( ! result . successful ( ) ) { String errMsg ; if ( serverGroups . isEmpty ( ) ) { errMsg = String . format ( "Failed to deploy [%s] (standalone mode)" , deploymentName ) ; } else { errMsg = String . format ( "Failed to deploy [%s] to server groups [%s]" , deploymentName , serverGroups ) ; } throw new FailureException ( errMsg + ": " + result . getFailureMessage ( ) ) ; } return ; // everything is OK }
Uploads the content to the app server s content repository and then deploys the content . If this is to be used for app servers in domain mode you have to pass in one or more server groups . If this is to be used to deploy an app in a standalone server the server groups should be empty .