Program: 89398
Project: 89398
Buggy source:
/** 
 * Parses the given request and builds an instance of RecordsManagementAuditQueryParameters to retrieve the relevant audit entries
 * @param req The request
 * @return RecordsManagementAuditQueryParameters instance
 */
protected RecordsManagementAuditQueryParameters parseQueryParameters(WebScriptRequest req){
  RecordsManagementAuditQueryParameters params=new RecordsManagementAuditQueryParameters();
  NodeRef nodeRef=null;
  Map<String,String> templateVars=req.getServiceMatch().getTemplateVars();
  String storeType=templateVars.get("String_Node_Str");
  if (storeType != null && storeType.length() > 0) {
    String storeId=templateVars.get("String_Node_Str");
    String nodeId=templateVars.get("String_Node_Str");
    nodeRef=new NodeRef(new StoreRef(storeType,storeId),nodeId);
  }
  String size=null;
  String user=null;
  String event=null;
  String from=null;
  String to=null;
  String property=null;
  if (MimetypeMap.MIMETYPE_JSON.equals(req.getContentType())) {
    try {
      JSONObject json=new JSONObject(new JSONTokener(req.getContent().getContent()));
      if (json.has(PARAM_SIZE)) {
        size=json.getString(PARAM_SIZE);
      }
      if (json.has(PARAM_USER)) {
        user=json.getString(PARAM_USER);
      }
      if (json.has(PARAM_EVENT)) {
        event=json.getString(PARAM_EVENT);
      }
      if (json.has(PARAM_FROM)) {
        from=json.getString(PARAM_FROM);
      }
      if (json.has(PARAM_TO)) {
        to=json.getString(PARAM_TO);
      }
      if (json.has(PARAM_PROPERTY)) {
        property=json.getString(PARAM_PROPERTY);
      }
    }
 catch (    IOException ioe) {
      if (logger.isWarnEnabled()) {
        logger.warn("String_Node_Str" + ioe.getMessage());
      }
    }
catch (    JSONException je) {
      if (logger.isWarnEnabled()) {
        logger.warn("String_Node_Str" + je.getMessage());
      }
    }
  }
 else {
    size=req.getParameter(PARAM_SIZE);
    user=req.getParameter(PARAM_USER);
    event=req.getParameter(PARAM_EVENT);
    from=req.getParameter(PARAM_FROM);
    to=req.getParameter(PARAM_TO);
    property=req.getParameter(PARAM_PROPERTY);
  }
  params.setNodeRef(nodeRef);
  params.setUser(user);
  params.setEvent(event);
  if (size != null && size.length() > 0) {
    try {
      params.setMaxEntries(Integer.parseInt(size));
    }
 catch (    NumberFormatException nfe) {
      if (logger.isWarnEnabled()) {
        logger.warn("String_Node_Str" + size + "String_Node_Str");
      }
    }
  }
  if (from != null && from.length() > 0) {
    try {
      SimpleDateFormat dateFormat=new SimpleDateFormat(DATE_PATTERN);
      params.setDateFrom(dateFormat.parse(from));
    }
 catch (    ParseException pe) {
      if (logger.isWarnEnabled()) {
        logger.warn("String_Node_Str" + from + "String_Node_Str"+ DATE_PATTERN);
      }
    }
  }
  if (to != null && to.length() > 0) {
    try {
      SimpleDateFormat dateFormat=new SimpleDateFormat(DATE_PATTERN);
      params.setDateTo(dateFormat.parse(to));
    }
 catch (    ParseException pe) {
      if (logger.isWarnEnabled()) {
        logger.warn("String_Node_Str" + to + "String_Node_Str"+ DATE_PATTERN);
      }
    }
  }
  if (property != null && property.length() > 0) {
    try {
      params.setProperty(QName.createQName(property,namespaceService));
    }
 catch (    InvalidQNameException iqe) {
      if (logger.isWarnEnabled())       logger.warn("String_Node_Str" + property + "String_Node_Str");
    }
  }
  return params;
}

Fixed version (ground truth):
/** 
 * Parses the given request and builds an instance of RecordsManagementAuditQueryParameters to retrieve the relevant audit entries
 * @param req The request
 * @return RecordsManagementAuditQueryParameters instance
 */
protected RecordsManagementAuditQueryParameters parseQueryParameters(WebScriptRequest req){
  RecordsManagementAuditQueryParameters params=new RecordsManagementAuditQueryParameters();
  NodeRef nodeRef=null;
  Map<String,String> templateVars=req.getServiceMatch().getTemplateVars();
  String storeType=templateVars.get("String_Node_Str");
  if (storeType != null && storeType.length() > 0) {
    String storeId=templateVars.get("String_Node_Str");
    String nodeId=templateVars.get("String_Node_Str");
    nodeRef=new NodeRef(new StoreRef(storeType,storeId),nodeId);
  }
  String size=null;
  String user=null;
  String event=null;
  String from=null;
  String to=null;
  String property=null;
  if (MimetypeMap.MIMETYPE_JSON.equals(req.getContentType())) {
    try {
      JSONObject json=new JSONObject(new JSONTokener(req.getContent().getContent()));
      if (json.has(PARAM_SIZE)) {
        size=json.getString(PARAM_SIZE);
      }
      if (json.has(PARAM_USER)) {
        user=json.getString(PARAM_USER);
      }
      if (json.has(PARAM_EVENT)) {
        event=json.getString(PARAM_EVENT);
      }
      if (json.has(PARAM_FROM)) {
        from=json.getString(PARAM_FROM);
      }
      if (json.has(PARAM_TO)) {
        to=json.getString(PARAM_TO);
      }
      if (json.has(PARAM_PROPERTY)) {
        property=json.getString(PARAM_PROPERTY);
      }
    }
 catch (    IOException ioe) {
      if (logger.isWarnEnabled()) {
        logger.warn("String_Node_Str" + ioe.getMessage());
      }
    }
catch (    JSONException je) {
      if (logger.isWarnEnabled()) {
        logger.warn("String_Node_Str" + je.getMessage());
      }
    }
  }
 else {
    size=req.getParameter(PARAM_SIZE);
    user=req.getParameter(PARAM_USER);
    event=req.getParameter(PARAM_EVENT);
    from=req.getParameter(PARAM_FROM);
    to=req.getParameter(PARAM_TO);
    property=req.getParameter(PARAM_PROPERTY);
  }
  params.setNodeRef(nodeRef);
  params.setUser(user);
  params.setEvent(event);
  if (size != null && size.length() > 0) {
    try {
      params.setMaxEntries(Integer.parseInt(size));
    }
 catch (    NumberFormatException nfe) {
      if (logger.isWarnEnabled()) {
        logger.warn("String_Node_Str" + size + "String_Node_Str");
      }
    }
  }
  if (from != null && from.length() > 0) {
    try {
      SimpleDateFormat dateFormat=new SimpleDateFormat(DATE_PATTERN);
      params.setDateFrom(dateFormat.parse(from));
    }
 catch (    ParseException pe) {
      if (logger.isWarnEnabled()) {
        logger.warn("String_Node_Str" + from + "String_Node_Str"+ DATE_PATTERN);
      }
    }
  }
  if (to != null && to.length() > 0) {
    try {
      SimpleDateFormat dateFormat=new SimpleDateFormat(DATE_PATTERN);
      params.setDateTo(dateFormat.parse(to));
    }
 catch (    ParseException pe) {
      if (logger.isWarnEnabled()) {
        logger.warn("String_Node_Str" + to + "String_Node_Str"+ DATE_PATTERN);
      }
    }
  }
  if (property != null && property.length() > 0) {
    try {
      params.setProperty(QName.createQName(property,namespaceService));
    }
 catch (    InvalidQNameException iqe) {
      if (logger.isWarnEnabled()) {
        logger.warn("String_Node_Str" + property + "String_Node_Str");
      }
    }
  }
  return params;
}