void executeAction ( Action action ) throws PluginException { try { switch ( action . actionType ) { case DELETE : this . logger . fine ( "Deleting " + action . parameter + "..." ) ; File f = new File ( action . parameter ) ; Utils . deleteFilesRecursively ( f ) ; break ; case DOWNLOAD : this . logger . fine ( "Downloading " + action . parameter + "..." ) ; URI uri = UriUtils . urlToUri ( action . parameter ) ; File targetFile = new File ( System . getProperty ( "java.io.tmpdir" ) , TMP_FILE ) ; InputStream in = null ; try { in = uri . toURL ( ) . openStream ( ) ; Utils . copyStream ( in , targetFile ) ; } finally { Utils . closeQuietly ( in ) ; } break ; case MOVE : List < String > parts = Utils . splitNicely ( action . parameter , "->" ) ; if ( parts . size ( ) != 2 ) { this . logger . warning ( "Invalid syntax for 'move' action. " + action . parameter ) ; } else { File source = new File ( parts . get ( 0 ) ) ; File target = new File ( parts . get ( 1 ) ) ; this . logger . fine ( "Moving " + source + " to " + target + "..." ) ; if ( ! source . renameTo ( target ) ) throw new IOException ( source + " could not be moved to " + target ) ; } break ; case COPY : parts = Utils . splitNicely ( action . parameter , "->" ) ; if ( parts . size ( ) != 2 ) { this . logger . warning ( "Invalid syntax for 'copy' action. " + action . parameter ) ; } else { File source = new File ( parts . get ( 0 ) ) ; File target = new File ( parts . get ( 1 ) ) ; this . logger . fine ( "Copying " + source + " to " + target + "..." ) ; Utils . copyStream ( source , target ) ; } break ; default : this . logger . fine ( "Ignoring the action..." ) ; break ; } } catch ( Exception e ) { throw new PluginException ( e ) ; } }
Executes an action .