@ Route ( method = HttpMethod . POST , uri = "" ) public Result installBundle ( @ FormParameter ( "bundle" ) final FileItem bundle , @ FormParameter ( "start" ) @ DefaultValue ( "false" ) final boolean startIfNeeded ) { if ( bundle != null ) { return async ( new Callable < Result > ( ) { @ Override public Result call ( ) throws Exception { Bundle b ; try { b = context . installBundle ( "file/temp/" + bundle . name ( ) , bundle . stream ( ) ) ; logger ( ) . info ( "Bundle {} installed" , b . getSymbolicName ( ) ) ; } catch ( BundleException e ) { flash ( "error" , "Cannot install bundle '" + bundle . name ( ) + "' : " + e . getMessage ( ) ) ; return bundle ( ) ; } if ( startIfNeeded && ! isFragment ( b ) ) { try { b . start ( ) ; flash ( "success" , "Bundle '" + b . getSymbolicName ( ) + "' installed and started" ) ; return bundle ( ) ; } catch ( BundleException e ) { flash ( "error" , "Bundle '" + b . getSymbolicName ( ) + "' installed but " + "failed to start: " + e . getMessage ( ) ) ; return bundle ( ) ; } } else { flash ( "success" , "Bundle '" + b . getSymbolicName ( ) + "' installed." ) ; return bundle ( ) ; } } } ) ; } else { logger ( ) . error ( "No bundle to install" ) ; flash ( "error" , "Unable to install the bundle - no uploaded file" ) ; return bundle ( ) ; } }
Installs a new bundle .