public Download getDownload(String torrentID) {
   if (torrentID.startsWith(OneSwarmConstants.BITTORRENT_MAGNET_PREFIX)) {
     torrentID = torrentID.substring(OneSwarmConstants.BITTORRENT_MAGNET_PREFIX.length());
     byte[] torrentHash = Base32.decode(torrentID);
     try {
       return pluginInterface.getDownloadManager().getDownload(torrentHash);
     } catch (DownloadException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
   return null;
 }
  public boolean removeTorrent(
      String torrentID, final boolean delete_torrent, final boolean delete_data) {
    try {
      Download d = this.getDownload(torrentID);

      if (d == null) {
        return false;
      }

      int dl_state = d.getState();

      // check if it is stopped already
      if (dl_state != Download.ST_STOPPED) {

        d.stop();
        // if not, stop it and remove when state has changed
        d.addListener(
            new DownloadListener() {

              public void positionChanged(Download download, int oldPosition, int newPosition) {}

              public void stateChanged(Download download, int old_state, int new_state) {
                if ((new_state == Download.ST_STOPPED || new_state == Download.ST_ERROR)) {
                  download.removeListener(this);
                  try {
                    deleteStoppedDownload(download, delete_torrent, delete_data);
                  } catch (DownloadException e) {
                    e.printStackTrace();
                  } catch (DownloadRemovalVetoException e) {
                    e.printStackTrace();
                  }
                }
              }
            });
      }

      deleteStoppedDownload(d, delete_torrent, delete_data);
      return true;
    } catch (DownloadException e) {
      e.printStackTrace();
    } catch (DownloadRemovalVetoException e) {
      e.printStackTrace();
    }
    return false;
  }