Program: 52055
Project: 52055
Buggy source:
/** 
 * Create subcommunity in community.
 * @param communityId Id of community in DSpace, in which will be created subcommunity.
 * @param community Community which will be added into community.
 * @param headers If you want to access to community 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 community. Or problem with creating context.
 */
@POST @Path("String_Node_Str") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public Community addCommunityCommunity(@PathParam("String_Node_Str") Integer communityId,Community community,@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" + communityId + "String_Node_Str");
  org.dspace.core.Context context=null;
  Community retCommunity=null;
  try {
    context=createContext(getUser(headers));
    org.dspace.content.Community dspaceParentCommunity=findCommunity(context,communityId,org.dspace.core.Constants.WRITE);
    writeStats(dspaceParentCommunity,UsageEvent.Action.UPDATE,user_ip,user_agent,xforwarderfor,headers,request);
    org.dspace.content.Community dspaceCommunity=org.dspace.content.Community.create(dspaceParentCommunity,context);
    dspaceCommunity.setMetadata("String_Node_Str",community.getName());
    dspaceCommunity.setMetadata(org.dspace.content.Community.COPYRIGHT_TEXT,community.getCopyrightText());
    dspaceCommunity.setMetadata(org.dspace.content.Community.INTRODUCTORY_TEXT,community.getIntroductoryText());
    dspaceCommunity.setMetadata(org.dspace.content.Community.SHORT_DESCRIPTION,community.getShortDescription());
    dspaceCommunity.setMetadata(org.dspace.content.Community.SIDEBAR_TEXT,community.getSidebarText());
    dspaceCommunity.update();
    dspaceParentCommunity.update();
    retCommunity=new Community(dspaceCommunity,"String_Node_Str",context);
    context.complete();
  }
 catch (  SQLException e) {
    processException("String_Node_Str" + communityId + "String_Node_Str"+ e,context);
  }
catch (  AuthorizeException e) {
    processException("String_Node_Str" + communityId + "String_Node_Str"+ e,context);
  }
catch (  ContextException e) {
    processException("String_Node_Str" + communityId + "String_Node_Str"+ e,context);
  }
 finally {
    processFinally(context);
  }
  log.info("String_Node_Str" + communityId + "String_Node_Str");
  return retCommunity;
}

Fixed version (ground truth):
/** 
 * Create subcommunity in community.
 * @param communityId Id of community in DSpace, in which will be created subcommunity.
 * @param community Community which will be added into community.
 * @param headers If you want to access to community 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 community. Or problem with creating context.
 */
@POST @Path("String_Node_Str") @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public Community addCommunityCommunity(@PathParam("String_Node_Str") Integer communityId,Community community,@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" + communityId + "String_Node_Str");
  org.dspace.core.Context context=null;
  Community retCommunity=null;
  try {
    context=createContext(getUser(headers));
    org.dspace.content.Community dspaceParentCommunity=findCommunity(context,communityId,org.dspace.core.Constants.WRITE);
    writeStats(dspaceParentCommunity,UsageEvent.Action.UPDATE,user_ip,user_agent,xforwarderfor,headers,request,context);
    org.dspace.content.Community dspaceCommunity=org.dspace.content.Community.create(dspaceParentCommunity,context);
    dspaceCommunity.setMetadata("String_Node_Str",community.getName());
    dspaceCommunity.setMetadata(org.dspace.content.Community.COPYRIGHT_TEXT,community.getCopyrightText());
    dspaceCommunity.setMetadata(org.dspace.content.Community.INTRODUCTORY_TEXT,community.getIntroductoryText());
    dspaceCommunity.setMetadata(org.dspace.content.Community.SHORT_DESCRIPTION,community.getShortDescription());
    dspaceCommunity.setMetadata(org.dspace.content.Community.SIDEBAR_TEXT,community.getSidebarText());
    dspaceCommunity.update();
    dspaceParentCommunity.update();
    retCommunity=new Community(dspaceCommunity,"String_Node_Str",context);
    context.complete();
  }
 catch (  SQLException e) {
    processException("String_Node_Str" + communityId + "String_Node_Str"+ e,context);
  }
catch (  AuthorizeException e) {
    processException("String_Node_Str" + communityId + "String_Node_Str"+ e,context);
  }
catch (  ContextException e) {
    processException("String_Node_Str" + communityId + "String_Node_Str"+ e,context);
  }
 finally {
    processFinally(context);
  }
  log.info("String_Node_Str" + communityId + "String_Node_Str");
  return retCommunity;
}