Program: 52051
Project: 52051
Buggy source:
/** 
 * Return array of items in collection. You can add more properties to items with expand parameter.
 * @param collectionId Id of collection in DSpace.
 * @param expand String which define, what additional properties will be in returned item. Options are separeted by commas and are: "all", "metadata", "parentCollection", "parentCollectionList", "parentCommunityList" and "bitstreams".
 * @param limit Limit value for items in array. Default value is 100.
 * @param offset Offset of start index in array of items of collection. Default value is 0.
 * @param headers If you want to access to collection under logged user into context. In headers must be set header "rest-dspace-token" with passed token from login method.
 * @return Return array of items, on which has logged user permission toread. It can also return status code NOT_FOUND(404) if id of collection is incorrect or status code UNATHORIZED(401) if user has no permission to read collection.
 * @throws WebApplicationException It is thrown when was problem with database reading (SQLException) or problem with creating context(ContextException). It is thrown by NOT_FOUND and UNATHORIZED status codes, too.
 */
@GET @Path("String_Node_Str") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public org.dspace.rest.common.Item[] getCollectionItems(@PathParam("String_Node_Str") Integer collectionId,@QueryParam("String_Node_Str") String expand,@QueryParam("String_Node_Str") @DefaultValue("String_Node_Str") Integer limit,@QueryParam("String_Node_Str") @DefaultValue("String_Node_Str") Integer offset,@QueryParam("String_Node_Str") String user_ip,@QueryParam("String_Node_Str") String user_agent,@QueryParam("String_Node_Str") String xforwarderfor,@Context HttpHeaders headers,@Context HttpServletRequest request) throws WebApplicationException {
  log.info("String_Node_Str" + collectionId + "String_Node_Str");
  org.dspace.core.Context context=null;
  List<Item> items=null;
  try {
    context=createContext(getUser(headers));
    org.dspace.content.Collection dspaceCollection=findCollection(context,collectionId,org.dspace.core.Constants.READ);
    writeStats(dspaceCollection,UsageEvent.Action.VIEW,user_ip,user_agent,xforwarderfor,headers,request);
    items=new ArrayList<Item>();
    org.dspace.content.ItemIterator dspaceItems=dspaceCollection.getItems();
    for (int i=0; (dspaceItems.hasNext()) && (i < (limit + offset)); i++) {
      if (i >= offset) {
        org.dspace.content.Item dspaceItem=dspaceItems.next();
        if (AuthorizeManager.authorizeActionBoolean(context,dspaceItem,org.dspace.core.Constants.READ)) {
          items.add(new Item(dspaceItem,expand,context));
          writeStats(dspaceItem,UsageEvent.Action.VIEW,user_ip,user_agent,xforwarderfor,headers,request);
        }
      }
    }
    context.complete();
  }
 catch (  SQLException e) {
    processException("String_Node_Str" + e,context);
  }
catch (  ContextException e) {
    processException("String_Node_Str" + e.getMessage(),context);
  }
 finally {
    processFinally(context);
  }
  log.trace("String_Node_Str" + collectionId + "String_Node_Str");
  return items.toArray(new Item[0]);
}

Fixed version (ground truth):
/** 
 * Return array of items in collection. You can add more properties to items with expand parameter.
 * @param collectionId Id of collection in DSpace.
 * @param expand String which define, what additional properties will be in returned item. Options are separeted by commas and are: "all", "metadata", "parentCollection", "parentCollectionList", "parentCommunityList" and "bitstreams".
 * @param limit Limit value for items in array. Default value is 100.
 * @param offset Offset of start index in array of items of collection. Default value is 0.
 * @param headers If you want to access to collection under logged user into context. In headers must be set header "rest-dspace-token" with passed token from login method.
 * @return Return array of items, on which has logged user permission toread. It can also return status code NOT_FOUND(404) if id of collection is incorrect or status code UNATHORIZED(401) if user has no permission to read collection.
 * @throws WebApplicationException It is thrown when was problem with database reading (SQLException) or problem with creating context(ContextException). It is thrown by NOT_FOUND and UNATHORIZED status codes, too.
 */
@GET @Path("String_Node_Str") @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public org.dspace.rest.common.Item[] getCollectionItems(@PathParam("String_Node_Str") Integer collectionId,@QueryParam("String_Node_Str") String expand,@QueryParam("String_Node_Str") @DefaultValue("String_Node_Str") Integer limit,@QueryParam("String_Node_Str") @DefaultValue("String_Node_Str") Integer offset,@QueryParam("String_Node_Str") String user_ip,@QueryParam("String_Node_Str") String user_agent,@QueryParam("String_Node_Str") String xforwarderfor,@Context HttpHeaders headers,@Context HttpServletRequest request) throws WebApplicationException {
  log.info("String_Node_Str" + collectionId + "String_Node_Str");
  org.dspace.core.Context context=null;
  List<Item> items=null;
  try {
    context=createContext(getUser(headers));
    org.dspace.content.Collection dspaceCollection=findCollection(context,collectionId,org.dspace.core.Constants.READ);
    writeStats(dspaceCollection,UsageEvent.Action.VIEW,user_ip,user_agent,xforwarderfor,headers,request,context);
    items=new ArrayList<Item>();
    org.dspace.content.ItemIterator dspaceItems=dspaceCollection.getItems();
    for (int i=0; (dspaceItems.hasNext()) && (i < (limit + offset)); i++) {
      if (i >= offset) {
        org.dspace.content.Item dspaceItem=dspaceItems.next();
        if (AuthorizeManager.authorizeActionBoolean(context,dspaceItem,org.dspace.core.Constants.READ)) {
          items.add(new Item(dspaceItem,expand,context));
          writeStats(dspaceItem,UsageEvent.Action.VIEW,user_ip,user_agent,xforwarderfor,headers,request,context);
        }
      }
    }
    context.complete();
  }
 catch (  SQLException e) {
    processException("String_Node_Str" + e,context);
  }
catch (  ContextException e) {
    processException("String_Node_Str" + e.getMessage(),context);
  }
 finally {
    processFinally(context);
  }
  log.trace("String_Node_Str" + collectionId + "String_Node_Str");
  return items.toArray(new Item[0]);
}