Program: 52337
Project: 52337
Buggy source:
/** 
 * Set up the bitstream reader. See the class description for information on configuration options. FIXME: This should use the parameter "uri" rather than "handle" to be consistent with the JSPUI. Unfortunately, I have no idea how this works right now, so I'll have to do that later. It should still work for now though. --JR
 */
public void setup(SourceResolver resolver,Map objectModel,String src,Parameters par) throws ProcessingException, SAXException, IOException {
  super.setup(resolver,objectModel,src,par);
  try {
    this.request=ObjectModelHelper.getRequest(objectModel);
    this.response=ObjectModelHelper.getResponse(objectModel);
    Context context=ContextUtil.obtainContext(objectModel);
    int itemID=par.getParameterAsInteger("String_Node_Str",-1);
    int bitstreamID=par.getParameterAsInteger("String_Node_Str",-1);
    String handle=par.getParameter("String_Node_Str",null);
    int sequence=par.getParameterAsInteger("String_Node_Str",-1);
    String name=par.getParameter("String_Node_Str",null);
    Bitstream bitstream=null;
    Item item=null;
    DSpaceObject dso=null;
    if (bitstreamID > -1) {
      bitstream=Bitstream.find(context,bitstreamID);
    }
 else     if (itemID > -1) {
      item=Item.find(context,itemID);
      if (sequence > -1) {
        bitstream=findBitstreamBySequence(item,sequence);
      }
 else       if (name != null) {
        bitstream=findBitstreamByName(item,name);
      }
    }
 else     if (handle != null) {
      ResolvableIdentifier ri=IdentifierService.resolve(context,handle);
      dso=(DSpaceObject)IdentifierService.getResource(context,ri);
      if (dso instanceof Item && sequence > -1) {
        bitstream=findBitstreamBySequence((Item)dso,sequence);
      }
 else       if (dso instanceof Item && name != null) {
        bitstream=findBitstreamByName((Item)dso,name);
      }
    }
    if (bitstream == null) {
      throw new ResourceNotFoundException("String_Node_Str");
    }
    if (!AuthorizeManager.authorizeActionBoolean(context,bitstream,Constants.READ)) {
      if (this.request.getSession().getAttribute("String_Node_Str") != null) {
        String redictURL=request.getContextPath() + "String_Node_Str";
        if (item != null) {
          redictURL+=IdentifierService.getCanonicalForm(item);
        }
 else         if (dso != null) {
          redictURL+=IdentifierService.getCanonicalForm(dso);
        }
        redictURL+="String_Node_Str" + bitstream.getID();
        HttpServletResponse httpResponse=(HttpServletResponse)objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
        httpResponse.sendRedirect(redictURL);
        return;
      }
 else {
        AuthenticationUtil.interruptRequest(objectModel,AUTH_REQUIRED_HEADER,AUTH_REQUIRED_MESSAGE,null);
        String redictURL=request.getContextPath() + "String_Node_Str";
        HttpServletResponse httpResponse=(HttpServletResponse)objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
        httpResponse.sendRedirect(redictURL);
        return;
      }
    }
    this.bitstreamInputStream=bitstream.retrieve();
    this.bitstreamSize=bitstream.getSize();
    this.bitstreamMimeType=bitstream.getFormat().getMIMEType();
    this.bitstreamName=bitstream.getName();
    if (bitstreamName != null) {
      int finalSlashIndex=bitstreamName.lastIndexOf("String_Node_Str");
      if (finalSlashIndex > 0) {
        bitstreamName=bitstreamName.substring(finalSlashIndex + 1);
      }
    }
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + bitstream.getID()));
  }
 catch (  SQLException sqle) {
    throw new ProcessingException("String_Node_Str",sqle);
  }
catch (  IdentifierException e) {
    log.error("String_Node_Str",e);
    throw new ProcessingException("String_Node_Str",e);
  }
catch (  AuthorizeException ae) {
    throw new ProcessingException("String_Node_Str",ae);
  }
}

Fixed version (ground truth):
/** 
 * Set up the bitstream reader. See the class description for information on configuration options. FIXME: This should use the parameter "uri" rather than "handle" to be consistent with the JSPUI. Unfortunately, I have no idea how this works right now, so I'll have to do that later. It should still work for now though. --JR
 */
public void setup(SourceResolver resolver,Map objectModel,String src,Parameters par) throws ProcessingException, SAXException, IOException {
  super.setup(resolver,objectModel,src,par);
  try {
    this.request=ObjectModelHelper.getRequest(objectModel);
    this.response=ObjectModelHelper.getResponse(objectModel);
    Context context=ContextUtil.obtainContext(objectModel);
    int itemID=par.getParameterAsInteger("String_Node_Str",-1);
    int bitstreamID=par.getParameterAsInteger("String_Node_Str",-1);
    String handle=par.getParameter("String_Node_Str",null);
    int sequence=par.getParameterAsInteger("String_Node_Str",-1);
    String name=par.getParameter("String_Node_Str",null);
    Bitstream bitstream=null;
    Item item=null;
    DSpaceObject dso=null;
    if (bitstreamID > -1) {
      bitstream=Bitstream.find(context,bitstreamID);
    }
 else     if (itemID > -1) {
      item=Item.find(context,itemID);
      if (sequence > -1) {
        bitstream=findBitstreamBySequence(item,sequence);
      }
 else       if (name != null) {
        bitstream=findBitstreamByName(item,name);
      }
    }
 else     if (handle != null) {
      ResolvableIdentifier ri=IdentifierService.resolve(context,handle);
      dso=(DSpaceObject)IdentifierService.getResource(context,ri);
      if (dso instanceof Item && sequence > -1) {
        bitstream=findBitstreamBySequence((Item)dso,sequence);
      }
 else       if (dso instanceof Item && name != null) {
        bitstream=findBitstreamByName((Item)dso,name);
      }
    }
    if (bitstream == null) {
      throw new ResourceNotFoundException("String_Node_Str");
    }
    if (!AuthorizeManager.authorizeActionBoolean(context,bitstream,Constants.READ)) {
      if (this.request.getSession().getAttribute("String_Node_Str") != null) {
        String redictURL=request.getContextPath() + "String_Node_Str";
        if (item != null) {
          redictURL+=IdentifierService.getCanonicalForm(item);
        }
 else         if (dso != null) {
          redictURL+=IdentifierService.getCanonicalForm(dso);
        }
        redictURL+="String_Node_Str" + bitstream.getID();
        HttpServletResponse httpResponse=(HttpServletResponse)objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
        httpResponse.sendRedirect(redictURL);
        return;
      }
 else {
        AuthenticationUtil.interruptRequest(objectModel,AUTH_REQUIRED_HEADER,AUTH_REQUIRED_MESSAGE,null);
        String redictURL=request.getContextPath() + "String_Node_Str";
        HttpServletResponse httpResponse=(HttpServletResponse)objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
        httpResponse.sendRedirect(redictURL);
        return;
      }
    }
    this.bitstreamInputStream=bitstream.retrieve();
    this.bitstreamSize=bitstream.getSize();
    this.bitstreamMimeType=bitstream.getFormat().getMIMEType();
    this.bitstreamName=bitstream.getName();
    if (bitstreamName != null && bitstreamName.length() > 0) {
      int finalSlashIndex=bitstreamName.lastIndexOf("String_Node_Str");
      if (finalSlashIndex > 0) {
        bitstreamName=bitstreamName.substring(finalSlashIndex + 1);
      }
    }
 else {
      bitstreamName="String_Node_Str";
    }
    log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + bitstream.getID()));
  }
 catch (  SQLException sqle) {
    throw new ProcessingException("String_Node_Str",sqle);
  }
catch (  IdentifierException e) {
    log.error("String_Node_Str",e);
    throw new ProcessingException("String_Node_Str",e);
  }
catch (  AuthorizeException ae) {
    throw new ProcessingException("String_Node_Str",ae);
  }
}