Program: 20882
Project: 20882
Buggy source:
public void handle(Request request,Response response){
  Document xml=JDUtilities.parseXmlString("String_Node_Str",false);
  response.setReturnType("String_Node_Str");
  response.setReturnStatus(Response.OK);
  if (request.getRequestUrl().equals("String_Node_Str")) {
    response.addContent(HelpPage.getHTML());
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    response.addContent(rc.getVersion());
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    response.addContent(JDUtilities.getJDTitle());
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    Property config=JDUtilities.getConfiguration();
    response.addContent("String_Node_Str");
    if (request.getParameters().containsKey("String_Node_Str")) {
      config=SubConfiguration.getConfig(request.getParameters().get("String_Node_Str").toUpperCase());
    }
    for (    Entry<String,Object> next : config.getProperties().entrySet()) {
      response.addContent(next.getKey() + "String_Node_Str" + next.getValue()+ "String_Node_Str");
    }
    response.addContent("String_Node_Str");
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    if (SubConfiguration.getConfig("String_Node_Str").getBooleanProperty(Configuration.PARAM_GLOBAL_IP_DISABLE,false)) {
      response.addContent("String_Node_Str");
    }
 else {
      response.addContent(IPCheck.getIPAddress());
    }
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    Random r=new Random();
    response.addContent(r.nextInt(255) + "String_Node_Str" + r.nextInt(255)+ "String_Node_Str"+ r.nextInt(255)+ "String_Node_Str"+ r.nextInt(255));
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    response.addContent(DownloadWatchDog.getInstance().getConnectionManager().getIncommingBandwidthUsage() / 1000);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    int value=SubConfiguration.getConfig("String_Node_Str").getIntegerProperty(Configuration.PARAM_DOWNLOAD_MAX_SPEED,0);
    response.addContent(value);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    response.addContent(DownloadWatchDog.getInstance().getDownloadStatus().toString());
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    response.addContent(JDUtilities.getConfiguration().getBooleanProperty(Configuration.PARAM_ALLOW_RECONNECT,true));
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    for (    LinkGrabberFilePackage fp : LinkGrabberController.getInstance().getPackages()) {
      Element fp_xml=addGrabberPackage(xml,fp);
      for (      DownloadLink dl : fp.getDownloadLinks()) {
        fp_xml.appendChild(addGrabberLink(xml,dl));
      }
    }
    response.addContent(JDUtilities.createXmlString(xml));
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    int counter=0;
    for (    LinkGrabberFilePackage fp : LinkGrabberController.getInstance().getPackages()) {
      counter+=fp.getDownloadLinks().size();
    }
    response.addContent(counter);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    boolean isbusy=false;
    if (LinkGrabberPanel.getLinkGrabber().isRunning())     isbusy=true;
 else     isbusy=false;
    response.addContent(isbusy);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    boolean value=GUIUtils.getConfig().getBooleanProperty(JDGuiConstants.PARAM_START_AFTER_ADDING_LINKS,true);
    response.addContent(value);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    boolean value=GUIUtils.getConfig().getBooleanProperty(JDGuiConstants.PARAM_START_AFTER_ADDING_LINKS_AUTO,true);
    response.addContent(value);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    int counter=0;
    for (    FilePackage fp : JDUtilities.getController().getPackages()) {
      counter+=fp.getDownloadLinkList().size();
    }
    response.addContent(counter);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    int counter=0;
    for (    FilePackage fp : JDUtilities.getController().getPackages()) {
      for (      DownloadLink dl : fp.getDownloadLinkList()) {
        if (dl.getLinkStatus().isPluginActive()) {
          counter++;
        }
      }
    }
    response.addContent(counter);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    int counter=0;
    for (    FilePackage fp : JDUtilities.getController().getPackages()) {
      for (      DownloadLink dl : fp.getDownloadLinkList()) {
        if (dl.getLinkStatus().hasStatus(LinkStatus.FINISHED)) {
          counter++;
        }
      }
    }
    response.addContent(counter);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    for (    FilePackage fp : JDUtilities.getController().getPackages()) {
      Element fp_xml=addFilePackage(xml,fp);
      for (      DownloadLink dl : fp.getDownloadLinkList()) {
        fp_xml.appendChild(addDownloadLink(xml,dl));
      }
    }
    response.addContent(JDUtilities.createXmlString(xml));
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    for (    FilePackage fp : JDUtilities.getController().getPackages()) {
      Element fp_xml=addFilePackage(xml,fp);
      for (      DownloadLink dl : fp.getDownloadLinkList()) {
        if (dl.getLinkStatus().isPluginActive()) {
          fp_xml.appendChild(addDownloadLink(xml,dl));
        }
      }
    }
    response.addContent(JDUtilities.createXmlString(xml));
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    for (    FilePackage fp : JDUtilities.getController().getPackages()) {
      Element fp_xml=addFilePackage(xml,fp);
      for (      DownloadLink dl : fp.getDownloadLinkList()) {
        if (dl.getLinkStatus().hasStatus(LinkStatus.FINISHED)) {
          fp_xml.appendChild(addDownloadLink(xml,dl));
        }
      }
    }
    response.addContent(JDUtilities.createXmlString(xml));
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    boolean newrc=Boolean.parseBoolean(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0));
    logger.fine("String_Node_Str" + newrc);
    if (newrc != JDUtilities.getConfiguration().getBooleanProperty(Configuration.PARAM_ALLOW_RECONNECT,true)) {
      JDUtilities.getConfiguration().setProperty(Configuration.PARAM_ALLOW_RECONNECT,newrc);
      JDUtilities.getConfiguration().save();
    }
    response.addContent("String_Node_Str" + newrc);
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    boolean newuseprem=Boolean.parseBoolean(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0));
    logger.fine("String_Node_Str" + newuseprem);
    if (newuseprem != JDUtilities.getConfiguration().getBooleanProperty(Configuration.PARAM_USE_GLOBAL_PREMIUM,true)) {
      JDUtilities.getConfiguration().setProperty(Configuration.PARAM_USE_GLOBAL_PREMIUM,newuseprem);
      JDUtilities.getConfiguration().save();
    }
    response.addContent("String_Node_Str" + newuseprem);
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    String dir=new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0);
    SubConfiguration.getConfig("String_Node_Str").setProperty(Configuration.PARAM_DOWNLOAD_DIRECTORY,dir);
    SubConfiguration.getConfig("String_Node_Str").save();
    response.addContent("String_Node_Str" + dir);
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    Integer newdllimit=Integer.parseInt(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0));
    logger.fine("String_Node_Str" + newdllimit.toString());
    SubConfiguration.getConfig("String_Node_Str").setProperty(Configuration.PARAM_DOWNLOAD_MAX_SPEED,newdllimit.toString());
    SubConfiguration.getConfig("String_Node_Str").save();
    response.addContent("String_Node_Str" + newdllimit);
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    Integer newsimdl=Integer.parseInt(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0));
    logger.fine("String_Node_Str" + newsimdl.toString());
    SubConfiguration.getConfig("String_Node_Str").setProperty(Configuration.PARAM_DOWNLOAD_MAX_SIMULTAN,newsimdl.toString());
    SubConfiguration.getConfig("String_Node_Str").save();
    response.addContent("String_Node_Str" + newsimdl);
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    boolean value=Boolean.parseBoolean(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0));
    logger.fine("String_Node_Str" + value);
    if (value != GUIUtils.getConfig().getBooleanProperty(JDGuiConstants.PARAM_START_AFTER_ADDING_LINKS,true)) {
      GUIUtils.getConfig().setProperty(JDGuiConstants.PARAM_START_AFTER_ADDING_LINKS,value);
      JDUtilities.getConfiguration().save();
    }
    response.addContent("String_Node_Str" + value);
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    boolean value=Boolean.parseBoolean(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0));
    logger.fine("String_Node_Str" + value);
    if (value != GUIUtils.getConfig().getBooleanProperty(JDGuiConstants.PARAM_START_AFTER_ADDING_LINKS_AUTO,true)) {
      GUIUtils.getConfig().setProperty(JDGuiConstants.PARAM_START_AFTER_ADDING_LINKS_AUTO,value);
      JDUtilities.getConfiguration().save();
    }
    response.addContent("String_Node_Str" + value);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    DownloadWatchDog.getInstance().startDownloads();
    response.addContent("String_Node_Str");
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    DownloadWatchDog.getInstance().pauseDownloads(!DownloadWatchDog.getInstance().isPaused());
    response.addContent("String_Node_Str");
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    DownloadWatchDog.getInstance().stopDownloads();
    response.addContent("String_Node_Str");
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    DownloadWatchDog.getInstance().toggleStartStop();
    response.addContent("String_Node_Str");
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    response.addContent("String_Node_Str");
    Reconnecter.doManualReconnect();
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    if (request.getRequestUrl().matches("String_Node_Str")) {
      JDUtilities.getConfiguration().setProperty(Configuration.PARAM_WEBUPDATE_AUTO_RESTART,true);
      SubConfiguration.getConfig("String_Node_Str").setProperty(Configuration.PARAM_WEBUPDATE_DISABLE,false);
    }
    WebUpdate.doUpdateCheck(true);
    response.addContent("String_Node_Str");
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    response.addContent("String_Node_Str");
    new Thread(new Runnable(){
      public void run(){
        try {
          Thread.sleep(5000);
        }
 catch (        InterruptedException e) {
          JDLogger.exception(e);
        }
        JDUtilities.restartJD(false);
      }
    }
).start();
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    response.addContent("String_Node_Str");
    new Thread(new Runnable(){
      public void run(){
        try {
          Thread.sleep(5000);
        }
 catch (        InterruptedException e) {
          JDLogger.exception(e);
        }
        JDUtilities.getController().exit();
      }
    }
).start();
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    ArrayList<String> links=new ArrayList<String>();
    String link=new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(1);
    for (    String tlink : HTMLParser.getHttpLinks(Encoding.urlDecode(link,false),null)) {
      links.add(tlink);
    }
    if (request.getParameters().size() > 0) {
      Iterator<String> it=request.getParameters().keySet().iterator();
      while (it.hasNext()) {
        String help=it.next();
        if (!request.getParameter(help).equals("String_Node_Str")) {
          links.add(request.getParameter(help));
        }
      }
    }
    StringBuilder ret=new StringBuilder();
    char tmp[]=new char[]{'"','\r','\n'};
    for (    String element : links) {
      ret.append('\"');
      ret.append(element.trim());
      ret.append(tmp);
    }
    link=ret.toString();
    new DistributeData(link,false).start();
    response.addContent("String_Node_Str" + link + "String_Node_Str");
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    String dlcfilestr=new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(1);
    dlcfilestr=Encoding.htmlDecode(dlcfilestr);
    if (dlcfilestr.matches("String_Node_Str")) {
      String containerFormat=new Regex(dlcfilestr,"String_Node_Str").getMatch(0);
      File container=JDUtilities.getResourceFile("String_Node_Str" + System.currentTimeMillis() + "String_Node_Str"+ containerFormat);
      try {
        Browser.download(container,dlcfilestr);
        JDController.loadContainerFile(container,false,false);
        try {
          Thread.sleep(3000);
        }
 catch (        Exception e) {
          JDLogger.exception(e);
        }
        container.delete();
      }
 catch (      Exception e) {
        JDLogger.exception(e);
      }
    }
 else {
      JDController.loadContainerFile(new File(dlcfilestr),false,false);
    }
    response.addContent("String_Node_Str" + dlcfilestr + "String_Node_Str");
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    ArrayList<DownloadLink> dllinks=new ArrayList<DownloadLink>();
    String dlcfilestr=new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(1);
    dlcfilestr=Encoding.htmlDecode(dlcfilestr);
    boolean savefromGrabber=new Regex(request.getRequestUrl(),"String_Node_Str").matches();
    if (savefromGrabber) {
      if (LinkGrabberPanel.getLinkGrabber().isRunning()) {
        response.addContent(ERROR_LINK_GRABBER_RUNNING);
      }
 else {
        ArrayList<LinkGrabberFilePackage> lgPackages=new ArrayList<LinkGrabberFilePackage>();
        ArrayList<FilePackage> packages=new ArrayList<FilePackage>();
synchronized (LinkGrabberController.ControllerLock) {
          lgPackages.addAll(LinkGrabberController.getInstance().getPackages());
          for (int i=0; i < lgPackages.size(); i++) {
            DownloadLink dl=null;
            for (            DownloadLink link : lgPackages.get(i).getDownloadLinks()) {
              dllinks.add(link);
              link.setEnabled(false);
              if (dl == null)               dl=link;
            }
            LinkGrabberPanel.getLinkGrabber().confirmPackage(lgPackages.get(i),null,i);
            packages.add(dl.getFilePackage());
          }
          JDUtilities.getController().saveDLC(new File(dlcfilestr),dllinks);
          for (          FilePackage fp : packages) {
            JDUtilities.getDownloadController().removePackage(fp);
          }
        }
      }
    }
 else {
      dllinks=JDUtilities.getDownloadController().getAllDownloadLinks();
      JDUtilities.getController().saveDLC(new File(dlcfilestr),dllinks);
    }
    response.addContent("String_Node_Str" + dlcfilestr + "String_Node_Str");
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    String[] packagenames=getHTMLDecoded(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0).split("String_Node_Str"));
    String password=new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0);
    ArrayList<LinkGrabberFilePackage> packages=LinkGrabberController.getInstance().getPackages();
    ArrayList<LinkGrabberFilePackage> packagesWithPW=new ArrayList<LinkGrabberFilePackage>();
    boolean isErrorMsg=false;
synchronized (LinkGrabberController.ControllerLock) {
      outer:       for (      String packagename : packagenames) {
        for (        LinkGrabberFilePackage pack : packages) {
          if (packagename.equals(pack.getName())) {
            pack.setPassword(password);
            packagesWithPW.add(pack);
            LinkGrabberController.getInstance().throwRefresh();
            continue outer;
          }
        }
        if (!isErrorMsg) {
          response.addContent("String_Node_Str" + packagename + "String_Node_Str");
          isErrorMsg=true;
        }
      }
    }
    if (packagesWithPW.size() > 0) {
      response.addContent("String_Node_Str" + password + "String_Node_Str");
      for (int i=0; i < packagesWithPW.size(); i++) {
        if (i != 0)         response.addContent("String_Node_Str");
        response.addContent("String_Node_Str" + packagesWithPW.get(i).getName() + "String_Node_Str");
      }
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    if (LinkGrabberPanel.getLinkGrabber().isRunning()) {
      response.addContent(ERROR_LINK_GRABBER_RUNNING);
    }
 else {
      ArrayList<LinkGrabberFilePackage> srcPackages=new ArrayList<LinkGrabberFilePackage>();
      String[] packagenames=getHTMLDecoded(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0).split("String_Node_Str"));
synchronized (LinkGrabberController.ControllerLock) {
        LinkGrabberFilePackage destPackage=LinkGrabberController.getInstance().getFPwithName(packagenames[0]);
        if (destPackage == null) {
          response.addContent("String_Node_Str" + packagenames[0] + "String_Node_Str");
        }
 else {
          for (          LinkGrabberFilePackage pack : LinkGrabberController.getInstance().getPackages()) {
            for (            String src : packagenames) {
              if ((pack.getName().equals(src)) && (pack != destPackage)) {
                srcPackages.add(pack);
              }
            }
          }
          for (          LinkGrabberFilePackage pack : srcPackages) {
            destPackage.addAll(pack.getDownloadLinks());
            LinkGrabberController.getInstance().removePackage(pack);
          }
          if (srcPackages.size() > 0) {
            if (srcPackages.size() < packagenames.length - 1) {
              response.addContent("String_Node_Str");
            }
            response.addContent("String_Node_Str" + srcPackages.size() + "String_Node_Str"+ packagenames[0]+ "String_Node_Str");
            for (int i=0; i < srcPackages.size(); ++i) {
              if (i != 0)               response.addContent("String_Node_Str");
              response.addContent("String_Node_Str" + srcPackages.get(i).getName() + "String_Node_Str");
            }
          }
 else {
            response.addContent("String_Node_Str" + packagenames[0] + "String_Node_Str");
          }
        }
      }
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    if (LinkGrabberPanel.getLinkGrabber().isRunning()) {
      response.addContent(ERROR_LINK_GRABBER_RUNNING);
    }
 else {
      String[] packagenames=getHTMLDecoded(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0).split("String_Node_Str"));
synchronized (LinkGrabberController.ControllerLock) {
        LinkGrabberFilePackage destPackage=LinkGrabberController.getInstance().getFPwithName(packagenames[0]);
        if (destPackage == null) {
          response.addContent("String_Node_Str" + packagenames[0] + "String_Node_Str");
        }
 else {
          destPackage.setName(packagenames[1]);
          LinkGrabberController.getInstance().throwRefresh();
          response.addContent("String_Node_Str" + packagenames[0] + "String_Node_Str"+ packagenames[1]+ "String_Node_Str");
        }
      }
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    if (LinkGrabberPanel.getLinkGrabber().isRunning()) {
      response.addContent(ERROR_LINK_GRABBER_RUNNING);
    }
 else {
      ArrayList<LinkGrabberFilePackage> packages=new ArrayList<LinkGrabberFilePackage>();
synchronized (LinkGrabberController.ControllerLock) {
        packages.addAll(LinkGrabberController.getInstance().getPackages());
        for (int i=0; i < packages.size(); i++) {
          LinkGrabberPanel.getLinkGrabber().confirmPackage(packages.get(i),null,i);
        }
        response.addContent("String_Node_Str");
      }
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    if (LinkGrabberPanel.getLinkGrabber().isRunning()) {
      response.addContent(ERROR_LINK_GRABBER_RUNNING);
    }
 else {
      ArrayList<LinkGrabberFilePackage> addedlist=new ArrayList<LinkGrabberFilePackage>();
      ArrayList<LinkGrabberFilePackage> packages=new ArrayList<LinkGrabberFilePackage>();
      String[] packagenames=getHTMLDecoded(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0).split("String_Node_Str"));
synchronized (LinkGrabberController.ControllerLock) {
        packages.addAll(LinkGrabberController.getInstance().getPackages());
        for (int i=0; i < packages.size(); i++) {
          LinkGrabberFilePackage fp=packages.get(i);
          for (          String name : packagenames) {
            if (name.equalsIgnoreCase(fp.getName())) {
              LinkGrabberPanel.getLinkGrabber().confirmPackage(fp,null,i);
              addedlist.add(fp);
            }
          }
        }
        response.addContent("String_Node_Str");
        for (int i=0; i < addedlist.size(); i++) {
          if (i != 0)           response.addContent("String_Node_Str");
          response.addContent("String_Node_Str" + addedlist.get(i).getName() + "String_Node_Str");
        }
      }
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    if (LinkGrabberPanel.getLinkGrabber().isRunning()) {
      response.addContent(ERROR_LINK_GRABBER_RUNNING);
    }
 else {
      ArrayList<String> delLinks=new ArrayList<String>();
      ArrayList<String> delPackages=new ArrayList<String>();
      String[] types=getHTMLDecoded(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0).split("String_Node_Str"));
synchronized (LinkGrabberController.ControllerLock) {
        ArrayList<LinkGrabberFilePackage> packages=new ArrayList<LinkGrabberFilePackage>();
        packages.addAll(LinkGrabberController.getInstance().getPackages());
        response.addContent("String_Node_Str");
        for (int i=0; i < types.length; ++i) {
          if (i != 0)           response.addContent("String_Node_Str");
          if (types[i].equals(LINK_TYPE_OFFLINE) || types[i].equals(LINK_TYPE_AVAIL)) {
            response.addContent(types[i]);
          }
 else {
            response.addContent("String_Node_Str" + types[i] + "String_Node_Str");
          }
        }
        for (        LinkGrabberFilePackage fp : packages) {
          ArrayList<DownloadLink> links=new ArrayList<DownloadLink>(fp.getDownloadLinks());
          for (          DownloadLink link : links) {
            for (            String type : types) {
              if ((type.equals(LINK_TYPE_OFFLINE) && link.getAvailableStatus().equals(AvailableStatus.FALSE)) || (type.equals(LINK_TYPE_AVAIL) && link.getLinkStatus().hasStatus(LinkStatus.ERROR_ALREADYEXISTS))) {
                fp.remove(link);
                delLinks.add(link.getDownloadURL());
              }
            }
          }
          if (fp.getDownloadLinks().size() == 0) {
            delPackages.add(fp.getName());
          }
        }
        response.addContent("String_Node_Str" + delLinks.size() + "String_Node_Str"+ delLinks+ "String_Node_Str"+ delPackages.size()+ "String_Node_Str"+ delPackages+ "String_Node_Str");
      }
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    if (LinkGrabberPanel.getLinkGrabber().isRunning()) {
      response.addContent(ERROR_LINK_GRABBER_RUNNING);
    }
 else {
      ArrayList<LinkGrabberFilePackage> packages=new ArrayList<LinkGrabberFilePackage>();
synchronized (LinkGrabberController.ControllerLock) {
        packages.addAll(LinkGrabberController.getInstance().getPackages());
        for (        LinkGrabberFilePackage fp : packages) {
          LinkGrabberController.getInstance().removePackage(fp);
        }
        response.addContent("String_Node_Str");
      }
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    String[] packagenames=getHTMLDecoded(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0).split("String_Node_Str"));
    if (LinkGrabberPanel.getLinkGrabber().isRunning()) {
      response.addContent(ERROR_LINK_GRABBER_RUNNING);
    }
 else {
      ArrayList<LinkGrabberFilePackage> packages=new ArrayList<LinkGrabberFilePackage>();
      ArrayList<LinkGrabberFilePackage> removelist=new ArrayList<LinkGrabberFilePackage>();
synchronized (LinkGrabberController.ControllerLock) {
        packages.addAll(LinkGrabberController.getInstance().getPackages());
        for (int i=0; i < packages.size(); i++) {
          LinkGrabberFilePackage fp=packages.get(i);
          for (          String name : packagenames) {
            if (name.equalsIgnoreCase(fp.getName())) {
              LinkGrabberController.getInstance().removePackage(fp);
              removelist.add(fp);
            }
          }
        }
        response.addContent("String_Node_Str");
        for (int i=0; i < removelist.size(); i++) {
          if (i != 0)           response.addContent("String_Node_Str");
          response.addContent("String_Node_Str" + removelist.get(i).getName() + "String_Node_Str");
        }
      }
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    if (LinkGrabberPanel.getLinkGrabber().isRunning()) {
      response.addContent(ERROR_LINK_GRABBER_RUNNING);
    }
 else {
      Regex reg=new Regex(request.getRequestUrl(),"String_Node_Str");
      if (reg.getMatch(0) == null || reg.getMatch(1) == null) {
        response.addContent(ERROR_MALFORMED_REQUEST);
        return;
      }
      String dest_package_name=Encoding.htmlDecode(reg.getMatch(0));
      ArrayList<DownloadLink> links=new ArrayList<DownloadLink>();
      for (      String tlink : HTMLParser.getHttpLinks(Encoding.urlDecode(reg.getMatch(1),false),null)) {
        links.addAll(new DistributeData(tlink).findLinks());
      }
      boolean packageWasAvailable=false;
      int numLinksMoved=0;
      int numPackagesDeleted=0;
synchronized (LinkGrabberController.ControllerLock) {
        LinkGrabberFilePackage dest_package=null;
        for (        LinkGrabberFilePackage pack : LinkGrabberController.getInstance().getPackages()) {
          if (pack.getName().equalsIgnoreCase(dest_package_name)) {
            dest_package=pack;
            packageWasAvailable=true;
          }
        }
        if (dest_package == null) {
          dest_package=new LinkGrabberFilePackage(dest_package_name);
          dest_package.setComment("String_Node_Str");
        }
        List<LinkGrabberFilePackage> availPacks=LinkGrabberController.getInstance().getPackages();
        for (int k=0; k < availPacks.size(); ++k) {
          LinkGrabberFilePackage pack=availPacks.get(k);
          for (int i=0; i < pack.size(); ++i) {
            if (pack == dest_package) {
              continue;
            }
            DownloadLink packLink=pack.get(i);
            for (            DownloadLink userLink : links) {
              if (packLink.compareTo(userLink) == 0) {
                pack.remove(i);
                --i;
                dest_package.add(packLink);
                ++numLinksMoved;
                if (pack.size() == 0) {
                  --k;
                }
                break;
              }
            }
          }
        }
        if (packageWasAvailable == false && dest_package.size() > 0) {
          LinkGrabberController.getInstance().addPackage(dest_package);
        }
      }
      if (numLinksMoved > 0) {
        response.addContent(numLinksMoved + "String_Node_Str" + (packageWasAvailable ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str"+ dest_package_name+ "String_Node_Str"+ numPackagesDeleted+ "String_Node_Str");
      }
 else {
        response.addContent("String_Node_Str");
      }
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    ArrayList<FilePackage> packages=new ArrayList<FilePackage>();
    packages.addAll(DownloadController.getInstance().getPackages());
    for (    FilePackage fp : packages) {
      DownloadController.getInstance().removePackage(fp);
    }
    response.addContent("String_Node_Str");
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    ArrayList<FilePackage> packages=new ArrayList<FilePackage>();
    ArrayList<FilePackage> removelist=new ArrayList<FilePackage>();
    String[] packagenames=getHTMLDecoded(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0).split("String_Node_Str"));
    packages.addAll(DownloadController.getInstance().getPackages());
    for (int i=0; i < packages.size(); i++) {
      FilePackage fp=packages.get(i);
      for (      String name : packagenames) {
        if (name.equalsIgnoreCase(fp.getName())) {
          DownloadController.getInstance().removePackage(fp);
          removelist.add(fp);
        }
      }
    }
    response.addContent("String_Node_Str");
    for (int i=0; i < removelist.size(); i++) {
      if (i != 0)       response.addContent("String_Node_Str");
      response.addContent("String_Node_Str" + removelist.get(i).getName() + "String_Node_Str");
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    ArrayList<String> links=new ArrayList<String>();
    String link=new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0);
    for (    String tlink : HTMLParser.getHttpLinks(Encoding.urlDecode(link,false),null)) {
      links.add(tlink);
    }
    if (request.getParameters().size() > 0) {
      Iterator<String> it=request.getParameters().keySet().iterator();
      while (it.hasNext()) {
        String help=it.next();
        if (!request.getParameter(help).equals("String_Node_Str")) {
          links.add(request.getParameter(help));
        }
      }
    }
    ArrayList<DownloadLink> dls=new ArrayList<DownloadLink>();
    for (    String chklink : links) {
      dls=new DistributeData(chklink,false).findLinks();
      Element element=xml.createElement("String_Node_Str");
      xml.getFirstChild().appendChild(element);
      element.setAttribute("String_Node_Str",chklink);
      for (      DownloadLink dl : dls) {
        dl.getAvailableStatus();
        LinkGrabberFilePackage pack=LinkGrabberController.getInstance().getGeneratedPackage(dl);
        dl.getFilePackage().setName(pack.getName());
        element.appendChild(addGrabberLink(xml,dl));
      }
    }
    response.addContent(JDUtilities.createXmlString(xml));
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    OptionalPluginWrapper plg=JDUtilities.getOptionalPlugin("String_Node_Str");
    if (plg != null && plg.isLoaded() && plg.isEnabled()) {
      for (      File script : JDScriptLauncher.getScripts()) {
        Element script_xml=addScriptName(xml,script);
        script_xml.appendChild(addScriptPath(xml,script));
      }
      response.addContent(JDUtilities.createXmlString(xml));
    }
 else {
      response.addContent("String_Node_Str");
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    OptionalPluginWrapper plg=JDUtilities.getOptionalPlugin("String_Node_Str");
    String scriptname=null;
    scriptname=new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0);
    if (plg != null && plg.isLoaded() && plg.isEnabled()) {
      if (JDScriptLauncher.launch(scriptname)) {
        response.addContent("String_Node_Str" + scriptname + "String_Node_Str");
      }
 else {
        response.addContent("String_Node_Str" + scriptname + "String_Node_Str");
      }
    }
 else {
      response.addContent("String_Node_Str");
    }
  }
 else {
    response.addContent(ERROR_MALFORMED_REQUEST);
  }
}

Fixed version (ground truth):
public void handle(Request request,Response response){
  Document xml=JDUtilities.parseXmlString("String_Node_Str",false);
  response.setReturnType("String_Node_Str");
  response.setReturnStatus(Response.OK);
  if (request.getRequestUrl().equals("String_Node_Str")) {
    response.addContent(HelpPage.getHTML());
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    response.addContent(rc.getVersion());
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    response.addContent(JDUtilities.getJDTitle());
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    Property config=JDUtilities.getConfiguration();
    response.addContent("String_Node_Str");
    if (request.getParameters().containsKey("String_Node_Str")) {
      config=SubConfiguration.getConfig(request.getParameters().get("String_Node_Str").toUpperCase());
    }
    for (    Entry<String,Object> next : config.getProperties().entrySet()) {
      response.addContent(next.getKey() + "String_Node_Str" + next.getValue()+ "String_Node_Str");
    }
    response.addContent("String_Node_Str");
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    if (SubConfiguration.getConfig("String_Node_Str").getBooleanProperty(Configuration.PARAM_GLOBAL_IP_DISABLE,false)) {
      response.addContent("String_Node_Str");
    }
 else {
      response.addContent(IPCheck.getIPAddress());
    }
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    Random r=new Random();
    response.addContent(r.nextInt(255) + "String_Node_Str" + r.nextInt(255)+ "String_Node_Str"+ r.nextInt(255)+ "String_Node_Str"+ r.nextInt(255));
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    response.addContent(DownloadWatchDog.getInstance().getConnectionManager().getIncommingBandwidthUsage() / 1000);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    int value=SubConfiguration.getConfig("String_Node_Str").getIntegerProperty(Configuration.PARAM_DOWNLOAD_MAX_SPEED,0);
    response.addContent(value);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    response.addContent(DownloadWatchDog.getInstance().getDownloadStatus().toString());
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    response.addContent(JDUtilities.getConfiguration().getBooleanProperty(Configuration.PARAM_ALLOW_RECONNECT,true));
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    for (    LinkGrabberFilePackage fp : LinkGrabberController.getInstance().getPackages()) {
      Element fp_xml=addGrabberPackage(xml,fp);
      for (      DownloadLink dl : fp.getDownloadLinks()) {
        fp_xml.appendChild(addGrabberLink(xml,dl));
      }
    }
    response.addContent(JDUtilities.createXmlString(xml));
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    int counter=0;
    for (    LinkGrabberFilePackage fp : LinkGrabberController.getInstance().getPackages()) {
      counter+=fp.getDownloadLinks().size();
    }
    response.addContent(counter);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    boolean isbusy=false;
    if (LinkGrabberPanel.getLinkGrabber().isRunning())     isbusy=true;
 else     isbusy=false;
    response.addContent(isbusy);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    boolean value=GUIUtils.getConfig().getBooleanProperty(JDGuiConstants.PARAM_START_AFTER_ADDING_LINKS,true);
    response.addContent(value);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    boolean value=GUIUtils.getConfig().getBooleanProperty(JDGuiConstants.PARAM_START_AFTER_ADDING_LINKS_AUTO,true);
    response.addContent(value);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    int counter=0;
    for (    FilePackage fp : JDUtilities.getController().getPackages()) {
      counter+=fp.getDownloadLinkList().size();
    }
    response.addContent(counter);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    int counter=0;
    for (    FilePackage fp : JDUtilities.getController().getPackages()) {
      for (      DownloadLink dl : fp.getDownloadLinkList()) {
        if (dl.getLinkStatus().isPluginActive()) {
          counter++;
        }
      }
    }
    response.addContent(counter);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    int counter=0;
    for (    FilePackage fp : JDUtilities.getController().getPackages()) {
      for (      DownloadLink dl : fp.getDownloadLinkList()) {
        if (dl.getLinkStatus().hasStatus(LinkStatus.FINISHED)) {
          counter++;
        }
      }
    }
    response.addContent(counter);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    for (    FilePackage fp : JDUtilities.getController().getPackages()) {
      Element fp_xml=addFilePackage(xml,fp);
      for (      DownloadLink dl : fp.getDownloadLinkList()) {
        fp_xml.appendChild(addDownloadLink(xml,dl));
      }
    }
    response.addContent(JDUtilities.createXmlString(xml));
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    for (    FilePackage fp : JDUtilities.getController().getPackages()) {
      Element fp_xml=addFilePackage(xml,fp);
      for (      DownloadLink dl : fp.getDownloadLinkList()) {
        if (dl.getLinkStatus().isPluginActive()) {
          fp_xml.appendChild(addDownloadLink(xml,dl));
        }
      }
    }
    response.addContent(JDUtilities.createXmlString(xml));
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    for (    FilePackage fp : JDUtilities.getController().getPackages()) {
      Element fp_xml=addFilePackage(xml,fp);
      for (      DownloadLink dl : fp.getDownloadLinkList()) {
        if (dl.getLinkStatus().hasStatus(LinkStatus.FINISHED)) {
          fp_xml.appendChild(addDownloadLink(xml,dl));
        }
      }
    }
    response.addContent(JDUtilities.createXmlString(xml));
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    boolean newrc=Boolean.parseBoolean(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0));
    logger.fine("String_Node_Str" + newrc);
    if (newrc != JDUtilities.getConfiguration().getBooleanProperty(Configuration.PARAM_ALLOW_RECONNECT,true)) {
      JDUtilities.getConfiguration().setProperty(Configuration.PARAM_ALLOW_RECONNECT,newrc);
      JDUtilities.getConfiguration().save();
    }
    response.addContent("String_Node_Str" + newrc);
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    boolean newuseprem=Boolean.parseBoolean(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0));
    logger.fine("String_Node_Str" + newuseprem);
    if (newuseprem != JDUtilities.getConfiguration().getBooleanProperty(Configuration.PARAM_USE_GLOBAL_PREMIUM,true)) {
      JDUtilities.getConfiguration().setProperty(Configuration.PARAM_USE_GLOBAL_PREMIUM,newuseprem);
      JDUtilities.getConfiguration().save();
    }
    response.addContent("String_Node_Str" + newuseprem);
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    String dir=new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0);
    SubConfiguration.getConfig("String_Node_Str").setProperty(Configuration.PARAM_DOWNLOAD_DIRECTORY,dir);
    SubConfiguration.getConfig("String_Node_Str").save();
    response.addContent("String_Node_Str" + dir);
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    Integer newdllimit=Integer.parseInt(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0));
    logger.fine("String_Node_Str" + newdllimit.toString());
    SubConfiguration.getConfig("String_Node_Str").setProperty(Configuration.PARAM_DOWNLOAD_MAX_SPEED,newdllimit.toString());
    SubConfiguration.getConfig("String_Node_Str").save();
    response.addContent("String_Node_Str" + newdllimit);
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    Integer newsimdl=Integer.parseInt(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0));
    logger.fine("String_Node_Str" + newsimdl.toString());
    SubConfiguration.getConfig("String_Node_Str").setProperty(Configuration.PARAM_DOWNLOAD_MAX_SIMULTAN,newsimdl.toString());
    SubConfiguration.getConfig("String_Node_Str").save();
    response.addContent("String_Node_Str" + newsimdl);
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    boolean value=Boolean.parseBoolean(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0));
    logger.fine("String_Node_Str" + value);
    if (value != GUIUtils.getConfig().getBooleanProperty(JDGuiConstants.PARAM_START_AFTER_ADDING_LINKS,true)) {
      GUIUtils.getConfig().setProperty(JDGuiConstants.PARAM_START_AFTER_ADDING_LINKS,value);
      JDUtilities.getConfiguration().save();
    }
    response.addContent("String_Node_Str" + value);
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    boolean value=Boolean.parseBoolean(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0));
    logger.fine("String_Node_Str" + value);
    if (value != GUIUtils.getConfig().getBooleanProperty(JDGuiConstants.PARAM_START_AFTER_ADDING_LINKS_AUTO,true)) {
      GUIUtils.getConfig().setProperty(JDGuiConstants.PARAM_START_AFTER_ADDING_LINKS_AUTO,value);
      JDUtilities.getConfiguration().save();
    }
    response.addContent("String_Node_Str" + value);
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    DownloadWatchDog.getInstance().startDownloads();
    response.addContent("String_Node_Str");
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    DownloadWatchDog.getInstance().pauseDownloads(!DownloadWatchDog.getInstance().isPaused());
    response.addContent("String_Node_Str");
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    DownloadWatchDog.getInstance().stopDownloads();
    response.addContent("String_Node_Str");
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    DownloadWatchDog.getInstance().toggleStartStop();
    response.addContent("String_Node_Str");
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    response.addContent("String_Node_Str");
    Reconnecter.doManualReconnect();
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    if (request.getRequestUrl().matches("String_Node_Str")) {
      JDUtilities.getConfiguration().setProperty(Configuration.PARAM_WEBUPDATE_AUTO_RESTART,true);
      SubConfiguration.getConfig("String_Node_Str").setProperty(Configuration.PARAM_WEBUPDATE_DISABLE,false);
    }
    WebUpdate.doUpdateCheck(true);
    response.addContent("String_Node_Str");
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    response.addContent("String_Node_Str");
    new Thread(new Runnable(){
      public void run(){
        try {
          Thread.sleep(5000);
        }
 catch (        InterruptedException e) {
          JDLogger.exception(e);
        }
        JDUtilities.restartJD(false);
      }
    }
).start();
  }
 else   if (request.getRequestUrl().equals("String_Node_Str")) {
    response.addContent("String_Node_Str");
    new Thread(new Runnable(){
      public void run(){
        try {
          Thread.sleep(5000);
        }
 catch (        InterruptedException e) {
          JDLogger.exception(e);
        }
        JDUtilities.getController().exit();
      }
    }
).start();
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    ArrayList<String> links=new ArrayList<String>();
    String link=new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0);
    for (    String tlink : HTMLParser.getHttpLinks(Encoding.urlDecode(link,false),null)) {
      links.add(tlink);
    }
    if (request.getParameters().size() > 0) {
      Iterator<String> it=request.getParameters().keySet().iterator();
      while (it.hasNext()) {
        String help=it.next();
        if (!request.getParameter(help).equals("String_Node_Str")) {
          links.add(request.getParameter(help));
        }
      }
    }
    StringBuilder ret=new StringBuilder();
    char tmp[]=new char[]{'"','\r','\n'};
    for (    String element : links) {
      ret.append('\"');
      ret.append(element.trim());
      ret.append(tmp);
    }
    link=ret.toString();
    new DistributeData(link,false).start();
    response.addContent("String_Node_Str" + link + "String_Node_Str");
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    String dlcfilestr=new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0);
    dlcfilestr=Encoding.htmlDecode(dlcfilestr);
    if (dlcfilestr.matches("String_Node_Str")) {
      String containerFormat=new Regex(dlcfilestr,"String_Node_Str").getMatch(0);
      File container=JDUtilities.getResourceFile("String_Node_Str" + System.currentTimeMillis() + "String_Node_Str"+ containerFormat);
      try {
        Browser.download(container,dlcfilestr);
        JDController.loadContainerFile(container,false,false);
        try {
          Thread.sleep(3000);
        }
 catch (        Exception e) {
          JDLogger.exception(e);
        }
        container.delete();
      }
 catch (      Exception e) {
        JDLogger.exception(e);
      }
    }
 else {
      JDController.loadContainerFile(new File(dlcfilestr),false,false);
    }
    response.addContent("String_Node_Str" + dlcfilestr + "String_Node_Str");
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    ArrayList<DownloadLink> dllinks=new ArrayList<DownloadLink>();
    String dlcfilestr=new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(1);
    dlcfilestr=Encoding.htmlDecode(dlcfilestr);
    boolean savefromGrabber=new Regex(request.getRequestUrl(),"String_Node_Str").matches();
    if (savefromGrabber) {
      if (LinkGrabberPanel.getLinkGrabber().isRunning()) {
        response.addContent(ERROR_LINK_GRABBER_RUNNING);
      }
 else {
        ArrayList<LinkGrabberFilePackage> lgPackages=new ArrayList<LinkGrabberFilePackage>();
        ArrayList<FilePackage> packages=new ArrayList<FilePackage>();
synchronized (LinkGrabberController.ControllerLock) {
          lgPackages.addAll(LinkGrabberController.getInstance().getPackages());
          for (int i=0; i < lgPackages.size(); i++) {
            DownloadLink dl=null;
            for (            DownloadLink link : lgPackages.get(i).getDownloadLinks()) {
              dllinks.add(link);
              link.setEnabled(false);
              if (dl == null)               dl=link;
            }
            LinkGrabberPanel.getLinkGrabber().confirmPackage(lgPackages.get(i),null,i);
            packages.add(dl.getFilePackage());
          }
          JDUtilities.getController().saveDLC(new File(dlcfilestr),dllinks);
          for (          FilePackage fp : packages) {
            JDUtilities.getDownloadController().removePackage(fp);
          }
        }
      }
    }
 else {
      dllinks=JDUtilities.getDownloadController().getAllDownloadLinks();
      JDUtilities.getController().saveDLC(new File(dlcfilestr),dllinks);
    }
    response.addContent("String_Node_Str" + dlcfilestr + "String_Node_Str");
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    String[] packagenames=getHTMLDecoded(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0).split("String_Node_Str"));
    String password=new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0);
    ArrayList<LinkGrabberFilePackage> packages=LinkGrabberController.getInstance().getPackages();
    ArrayList<LinkGrabberFilePackage> packagesWithPW=new ArrayList<LinkGrabberFilePackage>();
    boolean isErrorMsg=false;
synchronized (LinkGrabberController.ControllerLock) {
      outer:       for (      String packagename : packagenames) {
        for (        LinkGrabberFilePackage pack : packages) {
          if (packagename.equals(pack.getName())) {
            pack.setPassword(password);
            packagesWithPW.add(pack);
            LinkGrabberController.getInstance().throwRefresh();
            continue outer;
          }
        }
        if (!isErrorMsg) {
          response.addContent("String_Node_Str" + packagename + "String_Node_Str");
          isErrorMsg=true;
        }
      }
    }
    if (packagesWithPW.size() > 0) {
      response.addContent("String_Node_Str" + password + "String_Node_Str");
      for (int i=0; i < packagesWithPW.size(); i++) {
        if (i != 0)         response.addContent("String_Node_Str");
        response.addContent("String_Node_Str" + packagesWithPW.get(i).getName() + "String_Node_Str");
      }
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    if (LinkGrabberPanel.getLinkGrabber().isRunning()) {
      response.addContent(ERROR_LINK_GRABBER_RUNNING);
    }
 else {
      ArrayList<LinkGrabberFilePackage> srcPackages=new ArrayList<LinkGrabberFilePackage>();
      String[] packagenames=getHTMLDecoded(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0).split("String_Node_Str"));
synchronized (LinkGrabberController.ControllerLock) {
        LinkGrabberFilePackage destPackage=LinkGrabberController.getInstance().getFPwithName(packagenames[0]);
        if (destPackage == null) {
          response.addContent("String_Node_Str" + packagenames[0] + "String_Node_Str");
        }
 else {
          for (          LinkGrabberFilePackage pack : LinkGrabberController.getInstance().getPackages()) {
            for (            String src : packagenames) {
              if ((pack.getName().equals(src)) && (pack != destPackage)) {
                srcPackages.add(pack);
              }
            }
          }
          for (          LinkGrabberFilePackage pack : srcPackages) {
            destPackage.addAll(pack.getDownloadLinks());
            LinkGrabberController.getInstance().removePackage(pack);
          }
          if (srcPackages.size() > 0) {
            if (srcPackages.size() < packagenames.length - 1) {
              response.addContent("String_Node_Str");
            }
            response.addContent("String_Node_Str" + srcPackages.size() + "String_Node_Str"+ packagenames[0]+ "String_Node_Str");
            for (int i=0; i < srcPackages.size(); ++i) {
              if (i != 0)               response.addContent("String_Node_Str");
              response.addContent("String_Node_Str" + srcPackages.get(i).getName() + "String_Node_Str");
            }
          }
 else {
            response.addContent("String_Node_Str" + packagenames[0] + "String_Node_Str");
          }
        }
      }
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    if (LinkGrabberPanel.getLinkGrabber().isRunning()) {
      response.addContent(ERROR_LINK_GRABBER_RUNNING);
    }
 else {
      String[] packagenames=getHTMLDecoded(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0).split("String_Node_Str"));
synchronized (LinkGrabberController.ControllerLock) {
        LinkGrabberFilePackage destPackage=LinkGrabberController.getInstance().getFPwithName(packagenames[0]);
        if (destPackage == null) {
          response.addContent("String_Node_Str" + packagenames[0] + "String_Node_Str");
        }
 else {
          destPackage.setName(packagenames[1]);
          LinkGrabberController.getInstance().throwRefresh();
          response.addContent("String_Node_Str" + packagenames[0] + "String_Node_Str"+ packagenames[1]+ "String_Node_Str");
        }
      }
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    if (LinkGrabberPanel.getLinkGrabber().isRunning()) {
      response.addContent(ERROR_LINK_GRABBER_RUNNING);
    }
 else {
      ArrayList<LinkGrabberFilePackage> packages=new ArrayList<LinkGrabberFilePackage>();
synchronized (LinkGrabberController.ControllerLock) {
        packages.addAll(LinkGrabberController.getInstance().getPackages());
        for (int i=0; i < packages.size(); i++) {
          LinkGrabberPanel.getLinkGrabber().confirmPackage(packages.get(i),null,i);
        }
        response.addContent("String_Node_Str");
      }
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    if (LinkGrabberPanel.getLinkGrabber().isRunning()) {
      response.addContent(ERROR_LINK_GRABBER_RUNNING);
    }
 else {
      ArrayList<LinkGrabberFilePackage> addedlist=new ArrayList<LinkGrabberFilePackage>();
      ArrayList<LinkGrabberFilePackage> packages=new ArrayList<LinkGrabberFilePackage>();
      String[] packagenames=getHTMLDecoded(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0).split("String_Node_Str"));
synchronized (LinkGrabberController.ControllerLock) {
        packages.addAll(LinkGrabberController.getInstance().getPackages());
        for (int i=0; i < packages.size(); i++) {
          LinkGrabberFilePackage fp=packages.get(i);
          for (          String name : packagenames) {
            if (name.equalsIgnoreCase(fp.getName())) {
              LinkGrabberPanel.getLinkGrabber().confirmPackage(fp,null,i);
              addedlist.add(fp);
            }
          }
        }
        response.addContent("String_Node_Str");
        for (int i=0; i < addedlist.size(); i++) {
          if (i != 0)           response.addContent("String_Node_Str");
          response.addContent("String_Node_Str" + addedlist.get(i).getName() + "String_Node_Str");
        }
      }
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    if (LinkGrabberPanel.getLinkGrabber().isRunning()) {
      response.addContent(ERROR_LINK_GRABBER_RUNNING);
    }
 else {
      ArrayList<String> delLinks=new ArrayList<String>();
      ArrayList<String> delPackages=new ArrayList<String>();
      String[] types=getHTMLDecoded(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0).split("String_Node_Str"));
synchronized (LinkGrabberController.ControllerLock) {
        ArrayList<LinkGrabberFilePackage> packages=new ArrayList<LinkGrabberFilePackage>();
        packages.addAll(LinkGrabberController.getInstance().getPackages());
        response.addContent("String_Node_Str");
        for (int i=0; i < types.length; ++i) {
          if (i != 0)           response.addContent("String_Node_Str");
          if (types[i].equals(LINK_TYPE_OFFLINE) || types[i].equals(LINK_TYPE_AVAIL)) {
            response.addContent(types[i]);
          }
 else {
            response.addContent("String_Node_Str" + types[i] + "String_Node_Str");
          }
        }
        for (        LinkGrabberFilePackage fp : packages) {
          ArrayList<DownloadLink> links=new ArrayList<DownloadLink>(fp.getDownloadLinks());
          for (          DownloadLink link : links) {
            for (            String type : types) {
              if ((type.equals(LINK_TYPE_OFFLINE) && link.getAvailableStatus().equals(AvailableStatus.FALSE)) || (type.equals(LINK_TYPE_AVAIL) && link.getLinkStatus().hasStatus(LinkStatus.ERROR_ALREADYEXISTS))) {
                fp.remove(link);
                delLinks.add(link.getDownloadURL());
              }
            }
          }
          if (fp.getDownloadLinks().size() == 0) {
            delPackages.add(fp.getName());
          }
        }
        response.addContent("String_Node_Str" + delLinks.size() + "String_Node_Str"+ delLinks+ "String_Node_Str"+ delPackages.size()+ "String_Node_Str"+ delPackages+ "String_Node_Str");
      }
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    if (LinkGrabberPanel.getLinkGrabber().isRunning()) {
      response.addContent(ERROR_LINK_GRABBER_RUNNING);
    }
 else {
      ArrayList<LinkGrabberFilePackage> packages=new ArrayList<LinkGrabberFilePackage>();
synchronized (LinkGrabberController.ControllerLock) {
        packages.addAll(LinkGrabberController.getInstance().getPackages());
        for (        LinkGrabberFilePackage fp : packages) {
          LinkGrabberController.getInstance().removePackage(fp);
        }
        response.addContent("String_Node_Str");
      }
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    String[] packagenames=getHTMLDecoded(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0).split("String_Node_Str"));
    if (LinkGrabberPanel.getLinkGrabber().isRunning()) {
      response.addContent(ERROR_LINK_GRABBER_RUNNING);
    }
 else {
      ArrayList<LinkGrabberFilePackage> packages=new ArrayList<LinkGrabberFilePackage>();
      ArrayList<LinkGrabberFilePackage> removelist=new ArrayList<LinkGrabberFilePackage>();
synchronized (LinkGrabberController.ControllerLock) {
        packages.addAll(LinkGrabberController.getInstance().getPackages());
        for (int i=0; i < packages.size(); i++) {
          LinkGrabberFilePackage fp=packages.get(i);
          for (          String name : packagenames) {
            if (name.equalsIgnoreCase(fp.getName())) {
              LinkGrabberController.getInstance().removePackage(fp);
              removelist.add(fp);
            }
          }
        }
        response.addContent("String_Node_Str");
        for (int i=0; i < removelist.size(); i++) {
          if (i != 0)           response.addContent("String_Node_Str");
          response.addContent("String_Node_Str" + removelist.get(i).getName() + "String_Node_Str");
        }
      }
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    if (LinkGrabberPanel.getLinkGrabber().isRunning()) {
      response.addContent(ERROR_LINK_GRABBER_RUNNING);
    }
 else {
      Regex reg=new Regex(request.getRequestUrl(),"String_Node_Str");
      if (reg.getMatch(0) == null || reg.getMatch(1) == null) {
        response.addContent(ERROR_MALFORMED_REQUEST);
        return;
      }
      String dest_package_name=Encoding.htmlDecode(reg.getMatch(0));
      ArrayList<DownloadLink> links=new ArrayList<DownloadLink>();
      for (      String tlink : HTMLParser.getHttpLinks(Encoding.urlDecode(reg.getMatch(1),false),null)) {
        links.addAll(new DistributeData(tlink).findLinks());
      }
      boolean packageWasAvailable=false;
      int numLinksMoved=0;
      int numPackagesDeleted=0;
synchronized (LinkGrabberController.ControllerLock) {
        LinkGrabberFilePackage dest_package=null;
        for (        LinkGrabberFilePackage pack : LinkGrabberController.getInstance().getPackages()) {
          if (pack.getName().equalsIgnoreCase(dest_package_name)) {
            dest_package=pack;
            packageWasAvailable=true;
          }
        }
        if (dest_package == null) {
          dest_package=new LinkGrabberFilePackage(dest_package_name);
          dest_package.setComment("String_Node_Str");
        }
        List<LinkGrabberFilePackage> availPacks=LinkGrabberController.getInstance().getPackages();
        for (int k=0; k < availPacks.size(); ++k) {
          LinkGrabberFilePackage pack=availPacks.get(k);
          for (int i=0; i < pack.size(); ++i) {
            if (pack == dest_package) {
              continue;
            }
            DownloadLink packLink=pack.get(i);
            for (            DownloadLink userLink : links) {
              if (packLink.compareTo(userLink) == 0) {
                pack.remove(i);
                --i;
                dest_package.add(packLink);
                ++numLinksMoved;
                if (pack.size() == 0) {
                  --k;
                }
                break;
              }
            }
          }
        }
        if (packageWasAvailable == false && dest_package.size() > 0) {
          LinkGrabberController.getInstance().addPackage(dest_package);
        }
      }
      if (numLinksMoved > 0) {
        response.addContent(numLinksMoved + "String_Node_Str" + (packageWasAvailable ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str"+ dest_package_name+ "String_Node_Str"+ numPackagesDeleted+ "String_Node_Str");
      }
 else {
        response.addContent("String_Node_Str");
      }
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    ArrayList<FilePackage> packages=new ArrayList<FilePackage>();
    packages.addAll(DownloadController.getInstance().getPackages());
    for (    FilePackage fp : packages) {
      DownloadController.getInstance().removePackage(fp);
    }
    response.addContent("String_Node_Str");
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    ArrayList<FilePackage> packages=new ArrayList<FilePackage>();
    ArrayList<FilePackage> removelist=new ArrayList<FilePackage>();
    String[] packagenames=getHTMLDecoded(new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0).split("String_Node_Str"));
    packages.addAll(DownloadController.getInstance().getPackages());
    for (int i=0; i < packages.size(); i++) {
      FilePackage fp=packages.get(i);
      for (      String name : packagenames) {
        if (name.equalsIgnoreCase(fp.getName())) {
          DownloadController.getInstance().removePackage(fp);
          removelist.add(fp);
        }
      }
    }
    response.addContent("String_Node_Str");
    for (int i=0; i < removelist.size(); i++) {
      if (i != 0)       response.addContent("String_Node_Str");
      response.addContent("String_Node_Str" + removelist.get(i).getName() + "String_Node_Str");
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    ArrayList<String> links=new ArrayList<String>();
    String link=new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0);
    for (    String tlink : HTMLParser.getHttpLinks(Encoding.urlDecode(link,false),null)) {
      links.add(tlink);
    }
    if (request.getParameters().size() > 0) {
      Iterator<String> it=request.getParameters().keySet().iterator();
      while (it.hasNext()) {
        String help=it.next();
        if (!request.getParameter(help).equals("String_Node_Str")) {
          links.add(request.getParameter(help));
        }
      }
    }
    ArrayList<DownloadLink> dls=new ArrayList<DownloadLink>();
    for (    String chklink : links) {
      dls=new DistributeData(chklink,false).findLinks();
      Element element=xml.createElement("String_Node_Str");
      xml.getFirstChild().appendChild(element);
      element.setAttribute("String_Node_Str",chklink);
      for (      DownloadLink dl : dls) {
        dl.getAvailableStatus();
        LinkGrabberFilePackage pack=LinkGrabberController.getInstance().getGeneratedPackage(dl);
        dl.getFilePackage().setName(pack.getName());
        element.appendChild(addGrabberLink(xml,dl));
      }
    }
    response.addContent(JDUtilities.createXmlString(xml));
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    OptionalPluginWrapper plg=JDUtilities.getOptionalPlugin("String_Node_Str");
    if (plg != null && plg.isLoaded() && plg.isEnabled()) {
      for (      File script : JDScriptLauncher.getScripts()) {
        Element script_xml=addScriptName(xml,script);
        script_xml.appendChild(addScriptPath(xml,script));
      }
      response.addContent(JDUtilities.createXmlString(xml));
    }
 else {
      response.addContent("String_Node_Str");
    }
  }
 else   if (request.getRequestUrl().matches("String_Node_Str")) {
    OptionalPluginWrapper plg=JDUtilities.getOptionalPlugin("String_Node_Str");
    String scriptname=null;
    scriptname=new Regex(request.getRequestUrl(),"String_Node_Str").getMatch(0);
    if (plg != null && plg.isLoaded() && plg.isEnabled()) {
      if (JDScriptLauncher.launch(scriptname)) {
        response.addContent("String_Node_Str" + scriptname + "String_Node_Str");
      }
 else {
        response.addContent("String_Node_Str" + scriptname + "String_Node_Str");
      }
    }
 else {
      response.addContent("String_Node_Str");
    }
  }
 else {
    response.addContent(ERROR_MALFORMED_REQUEST);
  }
}