Program: 3511
Project: 3511
Buggy source:
/** 
 * Browse the archive by the full item browse mechanism.  This produces a BrowseInfo object which contains full BrowseItem objects as its result set.
 * @param bs        the scope of the browse
 * @return          the results of the browse
 * @throws BrowseException
 */
private BrowseInfo browseByItem(BrowserScope bs) throws BrowseException {
  log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
  try {
    dao.setTable(browseIndex.getTableName());
    dao.setAscending(scope.isAscending());
    String rawValue=null;
    if (scope.hasFilterValue() && scope.isSecondLevel()) {
      String value=scope.getFilterValue();
      rawValue=value;
      value=OrderFormat.makeSortString(value,scope.getFilterValueLang(),scope.getBrowseIndex().getDataType());
      dao.setFilterValueField("String_Node_Str");
      dao.setFilterValue(value);
      dao.setFilterValuePartial(scope.getFilterValuePartial());
      dao.setFilterMappingTables(browseIndex.getDistinctTableName(),browseIndex.getMapTableName());
    }
    if (scope.inCollection() || scope.inCommunity()) {
      if (scope.inCollection()) {
        Collection col=(Collection)scope.getBrowseContainer();
        dao.setContainerTable("String_Node_Str");
        dao.setContainerIDField("String_Node_Str");
        dao.setContainerID(col.getID());
      }
 else       if (scope.inCommunity()) {
        Community com=(Community)scope.getBrowseContainer();
        dao.setContainerTable("String_Node_Str");
        dao.setContainerIDField("String_Node_Str");
        dao.setContainerID(com.getID());
      }
    }
    int offset=scope.getOffset();
    String rawFocusValue=null;
    if (offset < 1 && (scope.hasJumpToItem() || scope.hasJumpToValue() || scope.hasStartsWith())) {
      rawFocusValue=getJumpToValue();
      String focusValue=normalizeJumpToValue(rawFocusValue);
      if (scope.hasStartsWith()) {
        if (browseIndex.isDate()) {
          focusValue=focusValue + "String_Node_Str";
        }
      }
      log.debug("String_Node_Str" + focusValue);
      String focusField=browseIndex.getSortField(scope.isSecondLevel());
      if (scope.getSortBy() > 0) {
        focusField="String_Node_Str" + Integer.toString(scope.getSortBy());
      }
      offset=getOffsetForValue(focusValue);
    }
    dao.setOffset(offset);
    String orderBy=browseIndex.getSortField(scope.isSecondLevel());
    if (scope.getSortBy() > 0) {
      orderBy="String_Node_Str" + Integer.toString(scope.getSortBy());
    }
    dao.setOrderField(orderBy);
    dao.setLimit(scope.getResultsPerPage());
    List results=dao.doQuery();
    int total=getTotalResults();
    if (results.size() == 0) {
      offset=total - scope.getResultsPerPage();
      if (offset < 0)       offset=0;
      dao.setOffset(offset);
      results=dao.doQuery();
      total=getTotalResults();
    }
    BrowseInfo browseInfo=new BrowseInfo(results,offset,total,offset);
    if (offset + scope.getResultsPerPage() < total) {
      browseInfo.setNextOffset(offset + scope.getResultsPerPage());
    }
    if (offset - scope.getResultsPerPage() > -1) {
      browseInfo.setPrevOffset(offset - scope.getResultsPerPage());
    }
    browseInfo.setBrowseIndex(browseIndex);
    browseInfo.setSortOption(scope.getSortOption());
    browseInfo.setAscending(scope.isAscending());
    browseInfo.setBrowseLevel(scope.getBrowseLevel());
    browseInfo.setValue(rawValue);
    browseInfo.setFocus(rawFocusValue);
    if (scope.hasJumpToItem()) {
      browseInfo.setFocusItem(scope.getJumpToItem());
    }
    browseInfo.setStartsWith(scope.hasStartsWith());
    if (scope.inCollection() || scope.inCommunity()) {
      browseInfo.setBrowseContainer(scope.getBrowseContainer());
    }
    browseInfo.setResultsPerPage(scope.getResultsPerPage());
    browseInfo.setEtAl(scope.getEtAl());
    return browseInfo;
  }
 catch (  SQLException e) {
    log.error("String_Node_Str",e);
    throw new BrowseException(e);
  }
}

Fixed version (ground truth):
/** 
 * Browse the archive by the full item browse mechanism.  This produces a BrowseInfo object which contains full BrowseItem objects as its result set.
 * @param bs        the scope of the browse
 * @return          the results of the browse
 * @throws BrowseException
 */
private BrowseInfo browseByItem(BrowserScope bs) throws BrowseException {
  log.info(LogManager.getHeader(context,"String_Node_Str","String_Node_Str"));
  try {
    dao.setTable(browseIndex.getTableName());
    dao.setAscending(scope.isAscending());
    String rawValue=null;
    if (scope.hasFilterValue() && scope.isSecondLevel()) {
      String value=scope.getFilterValue();
      rawValue=value;
      value=OrderFormat.makeSortString(value,scope.getFilterValueLang(),scope.getBrowseIndex().getDataType());
      dao.setFilterValueField("String_Node_Str");
      dao.setFilterValue(value);
      dao.setFilterValuePartial(scope.getFilterValuePartial());
      dao.setFilterMappingTables(browseIndex.getDistinctTableName(),browseIndex.getMapTableName());
    }
    if (scope.inCollection() || scope.inCommunity()) {
      if (scope.inCollection()) {
        Collection col=(Collection)scope.getBrowseContainer();
        dao.setContainerTable("String_Node_Str");
        dao.setContainerIDField("String_Node_Str");
        dao.setContainerID(col.getID());
      }
 else       if (scope.inCommunity()) {
        Community com=(Community)scope.getBrowseContainer();
        dao.setContainerTable("String_Node_Str");
        dao.setContainerIDField("String_Node_Str");
        dao.setContainerID(com.getID());
      }
    }
    int offset=scope.getOffset();
    String rawFocusValue=null;
    if (offset < 1 && (scope.hasJumpToItem() || scope.hasJumpToValue() || scope.hasStartsWith())) {
      rawFocusValue=getJumpToValue();
      String focusValue=normalizeJumpToValue(rawFocusValue);
      if (scope.hasStartsWith()) {
        if (browseIndex.isDate()) {
          focusValue=focusValue + "String_Node_Str";
        }
      }
      log.debug("String_Node_Str" + focusValue);
      String focusField=browseIndex.getSortField(scope.isSecondLevel());
      if (scope.getSortBy() > 0) {
        focusField="String_Node_Str" + Integer.toString(scope.getSortBy());
      }
      offset=getOffsetForValue(focusValue);
    }
    dao.setOffset(offset);
    String orderBy=browseIndex.getSortField(scope.isSecondLevel());
    if (scope.getSortBy() > 0) {
      orderBy="String_Node_Str" + Integer.toString(scope.getSortBy());
    }
    dao.setOrderField(orderBy);
    dao.setLimit(scope.getResultsPerPage());
    int total=getTotalResults();
    List results=null;
    if (total > 0) {
      results=dao.doQuery();
      if (results.size() == 0) {
        offset=total - scope.getResultsPerPage();
        if (offset < 0)         offset=0;
        dao.setOffset(offset);
        results=dao.doQuery();
      }
    }
 else {
      results=new ArrayList();
    }
    BrowseInfo browseInfo=new BrowseInfo(results,offset,total,offset);
    if (offset + scope.getResultsPerPage() < total) {
      browseInfo.setNextOffset(offset + scope.getResultsPerPage());
    }
    if (offset - scope.getResultsPerPage() > -1) {
      browseInfo.setPrevOffset(offset - scope.getResultsPerPage());
    }
    browseInfo.setBrowseIndex(browseIndex);
    browseInfo.setSortOption(scope.getSortOption());
    browseInfo.setAscending(scope.isAscending());
    browseInfo.setBrowseLevel(scope.getBrowseLevel());
    browseInfo.setValue(rawValue);
    browseInfo.setFocus(rawFocusValue);
    if (scope.hasJumpToItem()) {
      browseInfo.setFocusItem(scope.getJumpToItem());
    }
    browseInfo.setStartsWith(scope.hasStartsWith());
    if (scope.inCollection() || scope.inCommunity()) {
      browseInfo.setBrowseContainer(scope.getBrowseContainer());
    }
    browseInfo.setResultsPerPage(scope.getResultsPerPage());
    browseInfo.setEtAl(scope.getEtAl());
    return browseInfo;
  }
 catch (  SQLException e) {
    log.error("String_Node_Str",e);
    throw new BrowseException(e);
  }
}