Program: 52046
Project: 52046
Buggy source:
/** 
 * Update collection. It replace all properties.
 * @param collectionId Id of collection in DSpace.
 * @param collection Collection which will replace properties of actual collection.
 * @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 response 200 if was everything all right. Otherwise 400when id of community was incorrect or 401 if was problem with permission to write into collection.
 * @throws WebApplicationException It is thrown when was problem with database reading or writing. Or problem with authorization to collection. Or problem with creating context.
 */
@PUT @Path("String_Node_Str") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public Response updateCollection(@PathParam("String_Node_Str") Integer collectionId,org.dspace.rest.common.Collection collection,@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;
  try {
    context=createContext(getUser(headers));
    org.dspace.content.Collection dspaceCollection=findCollection(context,collectionId,org.dspace.core.Constants.WRITE);
    writeStats(dspaceCollection,UsageEvent.Action.UPDATE,user_ip,user_agent,xforwarderfor,headers,request);
    dspaceCollection.setMetadata("String_Node_Str",collection.getName());
    dspaceCollection.setLicense(collection.getLicense());
    dspaceCollection.setMetadata(org.dspace.content.Collection.COPYRIGHT_TEXT,collection.getCopyrightText());
    dspaceCollection.setMetadata(org.dspace.content.Collection.INTRODUCTORY_TEXT,collection.getIntroductoryText());
    dspaceCollection.setMetadata(org.dspace.content.Collection.SHORT_DESCRIPTION,collection.getShortDescription());
    dspaceCollection.setMetadata(org.dspace.content.Collection.SIDEBAR_TEXT,collection.getSidebarText());
    dspaceCollection.update();
    context.complete();
  }
 catch (  ContextException e) {
    processException("String_Node_Str" + collectionId + "String_Node_Str"+ e.getMessage(),context);
  }
catch (  SQLException e) {
    processException("String_Node_Str" + collectionId + "String_Node_Str"+ e,context);
  }
catch (  AuthorizeException e) {
    processException("String_Node_Str" + collectionId + "String_Node_Str"+ e,context);
  }
 finally {
    processFinally(context);
  }
  log.info("String_Node_Str" + collectionId + "String_Node_Str");
  return Response.ok().build();
}

Fixed version (ground truth):
/** 
 * Update collection. It replace all properties.
 * @param collectionId Id of collection in DSpace.
 * @param collection Collection which will replace properties of actual collection.
 * @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 response 200 if was everything all right. Otherwise 400when id of community was incorrect or 401 if was problem with permission to write into collection.
 * @throws WebApplicationException It is thrown when was problem with database reading or writing. Or problem with authorization to collection. Or problem with creating context.
 */
@PUT @Path("String_Node_Str") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public Response updateCollection(@PathParam("String_Node_Str") Integer collectionId,org.dspace.rest.common.Collection collection,@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;
  try {
    context=createContext(getUser(headers));
    org.dspace.content.Collection dspaceCollection=findCollection(context,collectionId,org.dspace.core.Constants.WRITE);
    writeStats(dspaceCollection,UsageEvent.Action.UPDATE,user_ip,user_agent,xforwarderfor,headers,request,context);
    dspaceCollection.setMetadata("String_Node_Str",collection.getName());
    dspaceCollection.setLicense(collection.getLicense());
    dspaceCollection.setMetadata(org.dspace.content.Collection.COPYRIGHT_TEXT,collection.getCopyrightText());
    dspaceCollection.setMetadata(org.dspace.content.Collection.INTRODUCTORY_TEXT,collection.getIntroductoryText());
    dspaceCollection.setMetadata(org.dspace.content.Collection.SHORT_DESCRIPTION,collection.getShortDescription());
    dspaceCollection.setMetadata(org.dspace.content.Collection.SIDEBAR_TEXT,collection.getSidebarText());
    dspaceCollection.update();
    context.complete();
  }
 catch (  ContextException e) {
    processException("String_Node_Str" + collectionId + "String_Node_Str"+ e.getMessage(),context);
  }
catch (  SQLException e) {
    processException("String_Node_Str" + collectionId + "String_Node_Str"+ e,context);
  }
catch (  AuthorizeException e) {
    processException("String_Node_Str" + collectionId + "String_Node_Str"+ e,context);
  }
 finally {
    processFinally(context);
  }
  log.info("String_Node_Str" + collectionId + "String_Node_Str");
  return Response.ok().build();
}