Program: 52045
Project: 52045
Buggy source:
/** 
 * Return instance of collection with passed id. You can add more properties through expand parameter.
 * @param collectionId Id of collection in DSpace.
 * @param expand String in which is what you want to add to returned instance of collection. Options are: "all", "parentCommunityList", "parentCommunity", "items", "license" and "logo". If you want to use multiple options, it must be separated by commas.
 * @param limit Limit value for items in list in collection. Default value is 100.
 * @param offset Offset of start index in list 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 instance of collection. It can also return status codeNOT_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.Collection getCollection(@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;
  Collection collection=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);
    collection=new Collection(dspaceCollection,expand,context,limit,offset);
    context.complete();
  }
 catch (  SQLException e) {
    processException("String_Node_Str" + collectionId + "String_Node_Str"+ e,context);
  }
catch (  ContextException e) {
    processException("String_Node_Str" + collectionId + "String_Node_Str"+ e.getMessage(),context);
  }
 finally {
    processFinally(context);
  }
  log.trace("String_Node_Str" + collectionId + "String_Node_Str");
  return collection;
}

Fixed version (ground truth):
/** 
 * Return instance of collection with passed id. You can add more properties through expand parameter.
 * @param collectionId Id of collection in DSpace.
 * @param expand String in which is what you want to add to returned instance of collection. Options are: "all", "parentCommunityList", "parentCommunity", "items", "license" and "logo". If you want to use multiple options, it must be separated by commas.
 * @param limit Limit value for items in list in collection. Default value is 100.
 * @param offset Offset of start index in list 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 instance of collection. It can also return status codeNOT_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.Collection getCollection(@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;
  Collection collection=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);
    collection=new Collection(dspaceCollection,expand,context,limit,offset);
    context.complete();
  }
 catch (  SQLException e) {
    processException("String_Node_Str" + collectionId + "String_Node_Str"+ e,context);
  }
catch (  ContextException e) {
    processException("String_Node_Str" + collectionId + "String_Node_Str"+ e.getMessage(),context);
  }
 finally {
    processFinally(context);
  }
  log.trace("String_Node_Str" + collectionId + "String_Node_Str");
  return collection;
}