Program: 3525
Project: 3525
Buggy source:
protected void doDSPost(Context context,HttpServletRequest request,HttpServletResponse response) throws java.sql.SQLException, javax.servlet.ServletException, java.io.IOException, AuthorizeException {
  String jspPage=null;
  int myID=UIUtil.getIntParameter(request,"String_Node_Str");
  Collection myCollection=Collection.find(context,myID);
  AuthorizeManager.authorizeAction(context,myCollection,Constants.COLLECTION_ADMIN);
  String action=request.getParameter("String_Node_Str");
  if (action == null) {
    action="String_Node_Str";
  }
  String cancel=request.getParameter("String_Node_Str");
  if (cancel == null) {
    cancel="String_Node_Str";
  }
  if (action.equals("String_Node_Str") || !cancel.equals("String_Node_Str")) {
    int count_native=0;
    int count_import=0;
    Map myItems=new HashMap();
    Map myCollections=new HashMap();
    Map myCounts=new HashMap();
    ItemIterator i=myCollection.getItems();
    while (i.hasNext()) {
      Item myItem=i.next();
      Integer myKey=new Integer(myItem.getID());
      if (myItem.isOwningCollection(myCollection)) {
        count_native++;
      }
 else {
        count_import++;
      }
      Collection owningCollection=myItem.getOwningCollection();
      Integer cKey=new Integer(owningCollection.getID());
      if (myCollections.containsKey(cKey)) {
        Integer x=(Integer)myCounts.get(cKey);
        int myCount=x.intValue() + 1;
        myCounts.put(cKey,new Integer(myCount));
      }
 else {
        myCollections.put(cKey,owningCollection);
        myCounts.put(cKey,new Integer(1));
      }
      myItems.put(myKey,myItem);
    }
    myCollections.remove(new Integer(myCollection.getID()));
    request.setAttribute("String_Node_Str",myCollection);
    request.setAttribute("String_Node_Str",new Integer(count_native));
    request.setAttribute("String_Node_Str",new Integer(count_import));
    request.setAttribute("String_Node_Str",myItems);
    request.setAttribute("String_Node_Str",myCollections);
    request.setAttribute("String_Node_Str",myCounts);
    request.setAttribute("String_Node_Str",Collection.findAll(context));
    jspPage="String_Node_Str";
    JSPManager.showJSP(request,response,jspPage);
  }
 else   if (action.equals("String_Node_Str")) {
    String[] itemIDs=request.getParameterValues("String_Node_Str");
    String message="String_Node_Str";
    LinkedList removedItems=new LinkedList();
    for (int j=0; j < itemIDs.length; j++) {
      int i=Integer.parseInt(itemIDs[j]);
      removedItems.add(itemIDs[j]);
      Item myItem=Item.find(context,i);
      if (!myItem.isOwningCollection(myCollection)) {
        myCollection.removeItem(myItem);
        try {
          IndexBrowse ib=new IndexBrowse(context);
          ib.itemChanged(myItem);
        }
 catch (        BrowseException e) {
          log.error("String_Node_Str",e);
          throw new ServletException(e);
        }
      }
    }
    request.setAttribute("String_Node_Str",message);
    request.setAttribute("String_Node_Str",myCollection);
    request.setAttribute("String_Node_Str",removedItems);
    jspPage="String_Node_Str";
    JSPManager.showJSP(request,response,jspPage);
  }
 else   if (action.equals("String_Node_Str")) {
    String[] itemIDs=request.getParameterValues("String_Node_Str");
    String message="String_Node_Str";
    LinkedList addedItems=new LinkedList();
    if (itemIDs == null) {
      message="String_Node_Str";
    }
 else {
      for (int j=0; j < itemIDs.length; j++) {
        int i=Integer.parseInt(itemIDs[j]);
        Item myItem=Item.find(context,i);
        if (AuthorizeManager.authorizeActionBoolean(context,myItem,Constants.READ)) {
          if (!myItem.isOwningCollection(myCollection)) {
            myCollection.addItem(myItem);
            try {
              IndexBrowse ib=new IndexBrowse(context);
              ib.itemChanged(myItem);
            }
 catch (            BrowseException e) {
              log.error("String_Node_Str",e);
              throw new ServletException(e);
            }
            addedItems.add(itemIDs[j]);
          }
        }
      }
    }
    request.setAttribute("String_Node_Str",message);
    request.setAttribute("String_Node_Str",myCollection);
    request.setAttribute("String_Node_Str",addedItems);
    jspPage="String_Node_Str";
    JSPManager.showJSP(request,response,jspPage);
  }
 else   if (action.equals("String_Node_Str")) {
    String name=(String)request.getParameter("String_Node_Str");
    String bidx=ConfigurationManager.getProperty("String_Node_Str");
    if (bidx == null) {
      throw new ServletException("String_Node_Str");
    }
    Map items=new HashMap();
    try {
      BrowserScope bs=new BrowserScope(context);
      BrowseIndex bi=BrowseIndex.getBrowseIndex(bidx);
      bs.setBrowseIndex(bi);
      bs.setOrder(SortOption.ASCENDING);
      bs.setFilterValue(name);
      bs.setFilterValuePartial(true);
      bs.setJumpToValue(null);
      bs.setResultsPerPage(10000);
      bs.setSortBy(0);
      bs.setBrowseLevel(1);
      BrowseEngine be=new BrowseEngine(context);
      BrowseInfo results=be.browse(bs);
      Item[] browseItems=results.getItemResults(context);
      ItemIterator itr=myCollection.getItems();
      ArrayList idslist=new ArrayList();
      while (itr.hasNext()) {
        idslist.add(new Integer(itr.nextID()));
      }
      for (int i=0; i < browseItems.length; i++) {
        if (!idslist.contains(new Integer(browseItems[i].getID()))) {
          if (AuthorizeManager.authorizeActionBoolean(context,browseItems[i],Constants.READ)) {
            items.put(new Integer(browseItems[i].getID()),browseItems[i]);
          }
        }
      }
    }
 catch (    BrowseException e) {
      log.error("String_Node_Str",e);
      throw new ServletException(e);
    }
    request.setAttribute("String_Node_Str",myCollection);
    request.setAttribute("String_Node_Str",name);
    request.setAttribute("String_Node_Str",items);
    request.setAttribute("String_Node_Str",new String("String_Node_Str"));
    jspPage="String_Node_Str";
    JSPManager.showJSP(request,response,jspPage);
  }
 else   if (action.equals("String_Node_Str")) {
    int t=UIUtil.getIntParameter(request,"String_Node_Str");
    Collection targetCollection=Collection.find(context,t);
    ItemIterator i=myCollection.getItems();
    Map items=new HashMap();
    while (i.hasNext()) {
      Item myItem=i.next();
      if (myItem.isOwningCollection(targetCollection)) {
        Integer myKey=new Integer(myItem.getID());
        items.put(myKey,myItem);
      }
    }
    request.setAttribute("String_Node_Str",myCollection);
    request.setAttribute("String_Node_Str",targetCollection.getMetadata("String_Node_Str"));
    request.setAttribute("String_Node_Str",items);
    request.setAttribute("String_Node_Str",new String("String_Node_Str"));
    jspPage="String_Node_Str";
    JSPManager.showJSP(request,response,jspPage);
  }
  context.complete();
}

Fixed version (ground truth):
protected void doDSPost(Context context,HttpServletRequest request,HttpServletResponse response) throws java.sql.SQLException, javax.servlet.ServletException, java.io.IOException, AuthorizeException {
  String jspPage=null;
  int myID=UIUtil.getIntParameter(request,"String_Node_Str");
  Collection myCollection=Collection.find(context,myID);
  AuthorizeManager.authorizeAction(context,myCollection,Constants.COLLECTION_ADMIN);
  String action=request.getParameter("String_Node_Str");
  if (action == null) {
    action="String_Node_Str";
  }
  String cancel=request.getParameter("String_Node_Str");
  if (cancel == null) {
    cancel="String_Node_Str";
  }
  if (action.equals("String_Node_Str") || !cancel.equals("String_Node_Str")) {
    int count_native=0;
    int count_import=0;
    Map myItems=new HashMap();
    Map myCollections=new HashMap();
    Map myCounts=new HashMap();
    ItemIterator i=myCollection.getItems();
    while (i.hasNext()) {
      Item myItem=i.next();
      Integer myKey=new Integer(myItem.getID());
      if (myItem.isOwningCollection(myCollection)) {
        count_native++;
      }
 else {
        count_import++;
      }
      Collection owningCollection=myItem.getOwningCollection();
      Integer cKey=new Integer(owningCollection.getID());
      if (myCollections.containsKey(cKey)) {
        Integer x=(Integer)myCounts.get(cKey);
        int myCount=x.intValue() + 1;
        myCounts.put(cKey,new Integer(myCount));
      }
 else {
        myCollections.put(cKey,owningCollection);
        myCounts.put(cKey,new Integer(1));
      }
      myItems.put(myKey,myItem);
    }
    myCollections.remove(new Integer(myCollection.getID()));
    request.setAttribute("String_Node_Str",myCollection);
    request.setAttribute("String_Node_Str",new Integer(count_native));
    request.setAttribute("String_Node_Str",new Integer(count_import));
    request.setAttribute("String_Node_Str",myItems);
    request.setAttribute("String_Node_Str",myCollections);
    request.setAttribute("String_Node_Str",myCounts);
    request.setAttribute("String_Node_Str",Collection.findAll(context));
    jspPage="String_Node_Str";
    JSPManager.showJSP(request,response,jspPage);
  }
 else   if (action.equals("String_Node_Str")) {
    String[] itemIDs=request.getParameterValues("String_Node_Str");
    String message="String_Node_Str";
    LinkedList removedItems=new LinkedList();
    for (int j=0; j < itemIDs.length; j++) {
      int i=Integer.parseInt(itemIDs[j]);
      removedItems.add(itemIDs[j]);
      Item myItem=Item.find(context,i);
      if (!myItem.isOwningCollection(myCollection)) {
        myCollection.removeItem(myItem);
        try {
          IndexBrowse ib=new IndexBrowse(context);
          ib.itemChanged(myItem);
        }
 catch (        BrowseException e) {
          log.error("String_Node_Str",e);
          throw new ServletException(e);
        }
      }
    }
    request.setAttribute("String_Node_Str",message);
    request.setAttribute("String_Node_Str",myCollection);
    request.setAttribute("String_Node_Str",removedItems);
    jspPage="String_Node_Str";
    JSPManager.showJSP(request,response,jspPage);
  }
 else   if (action.equals("String_Node_Str")) {
    String[] itemIDs=request.getParameterValues("String_Node_Str");
    String message="String_Node_Str";
    LinkedList addedItems=new LinkedList();
    if (itemIDs == null) {
      message="String_Node_Str";
    }
 else {
      for (int j=0; j < itemIDs.length; j++) {
        int i=Integer.parseInt(itemIDs[j]);
        Item myItem=Item.find(context,i);
        if (AuthorizeManager.authorizeActionBoolean(context,myItem,Constants.READ)) {
          if (!myItem.isOwningCollection(myCollection)) {
            myCollection.addItem(myItem);
            try {
              IndexBrowse ib=new IndexBrowse(context);
              ib.itemChanged(myItem);
            }
 catch (            BrowseException e) {
              log.error("String_Node_Str",e);
              throw new ServletException(e);
            }
            addedItems.add(itemIDs[j]);
          }
        }
      }
    }
    request.setAttribute("String_Node_Str",message);
    request.setAttribute("String_Node_Str",myCollection);
    request.setAttribute("String_Node_Str",addedItems);
    jspPage="String_Node_Str";
    JSPManager.showJSP(request,response,jspPage);
  }
 else   if (action.equals("String_Node_Str")) {
    String name=(String)request.getParameter("String_Node_Str");
    String bidx=ConfigurationManager.getProperty("String_Node_Str");
    if (bidx == null) {
      throw new ServletException("String_Node_Str");
    }
    Map items=new HashMap();
    try {
      BrowserScope bs=new BrowserScope(context);
      BrowseIndex bi=BrowseIndex.getBrowseIndex(bidx);
      bs.setBrowseIndex(bi);
      bs.setOrder(SortOption.ASCENDING);
      bs.setFilterValue(name);
      bs.setFilterValuePartial(true);
      bs.setJumpToValue(null);
      bs.setResultsPerPage(10000);
      bs.setBrowseLevel(1);
      BrowseEngine be=new BrowseEngine(context);
      BrowseInfo results=be.browse(bs);
      Item[] browseItems=results.getItemResults(context);
      ItemIterator itr=myCollection.getItems();
      ArrayList idslist=new ArrayList();
      while (itr.hasNext()) {
        idslist.add(new Integer(itr.nextID()));
      }
      for (int i=0; i < browseItems.length; i++) {
        if (!idslist.contains(new Integer(browseItems[i].getID()))) {
          if (AuthorizeManager.authorizeActionBoolean(context,browseItems[i],Constants.READ)) {
            items.put(new Integer(browseItems[i].getID()),browseItems[i]);
          }
        }
      }
    }
 catch (    BrowseException e) {
      log.error("String_Node_Str",e);
      throw new ServletException(e);
    }
    request.setAttribute("String_Node_Str",myCollection);
    request.setAttribute("String_Node_Str",name);
    request.setAttribute("String_Node_Str",items);
    request.setAttribute("String_Node_Str",new String("String_Node_Str"));
    jspPage="String_Node_Str";
    JSPManager.showJSP(request,response,jspPage);
  }
 else   if (action.equals("String_Node_Str")) {
    int t=UIUtil.getIntParameter(request,"String_Node_Str");
    Collection targetCollection=Collection.find(context,t);
    ItemIterator i=myCollection.getItems();
    Map items=new HashMap();
    while (i.hasNext()) {
      Item myItem=i.next();
      if (myItem.isOwningCollection(targetCollection)) {
        Integer myKey=new Integer(myItem.getID());
        items.put(myKey,myItem);
      }
    }
    request.setAttribute("String_Node_Str",myCollection);
    request.setAttribute("String_Node_Str",targetCollection.getMetadata("String_Node_Str"));
    request.setAttribute("String_Node_Str",items);
    request.setAttribute("String_Node_Str",new String("String_Node_Str"));
    jspPage="String_Node_Str";
    JSPManager.showJSP(request,response,jspPage);
  }
  context.complete();
}