nus-yam/ex-repair huggingface dataset:
Program: 174766
Project: 174766
Buggy source:
/** 
 * Takes the Sort parameter as a String and parses it into a List of SortColumn objects. The format is a comma seperated list of "columnName sortDirection", e.g. "name DESC, age ASC".  It is not case sensitive and the sort direction is optional It default to sort ASCENDING.
 * @param sortParams - String passed in on the request
 * @return List<SortColumn> - the sort columns or an empty list if the params were invalid.
 */
public static List<SortColumn> getSort(String sortParams){
  if (sortParams != null) {
    StringTokenizer st=new StringTokenizer(sortParams,"String_Node_Str");
    List<SortColumn> sortedColumns=new ArrayList<SortColumn>(st.countTokens());
    while (st.hasMoreTokens()) {
      String token=st.nextToken();
      StringTokenizer columnDesc=new StringTokenizer(token,"String_Node_Str");
      if (columnDesc.countTokens() <= 2) {
        String columnName=columnDesc.nextToken();
        String sortOrder=SortColumn.ASCENDING;
        if (columnDesc.hasMoreTokens()) {
          String sortDef=columnDesc.nextToken().toUpperCase();
          if (SortColumn.ASCENDING.equals(sortDef) || SortColumn.DESCENDING.equals(sortDef)) {
            sortOrder=sortDef;
          }
 else {
            logger.debug("String_Node_Str" + sortDef + "String_Node_Str"+ SortColumn.ASCENDING+ "String_Node_Str"+ SortColumn.DESCENDING+ "String_Node_Str");
          }
        }
        sortedColumns.add(new SortColumn(columnName,SortColumn.ASCENDING.equals(sortOrder)));
      }
    }
    return sortedColumns;
  }
  return Collections.emptyList();
}

Fixed version (ground truth):
/** 
 * Takes the Sort parameter as a String and parses it into a List of SortColumn objects. The format is a comma seperated list of "columnName sortDirection", e.g. "name DESC, age ASC".  It is not case sensitive and the sort direction is optional It default to sort ASCENDING.
 * @param sortParams - String passed in on the request
 * @return - the sort columns or an empty list if the params were invalid.
 */
public static List<SortColumn> getSort(String sortParams){
  if (sortParams != null) {
    StringTokenizer st=new StringTokenizer(sortParams,"String_Node_Str");
    List<SortColumn> sortedColumns=new ArrayList<SortColumn>(st.countTokens());
    while (st.hasMoreTokens()) {
      String token=st.nextToken();
      StringTokenizer columnDesc=new StringTokenizer(token,"String_Node_Str");
      if (columnDesc.countTokens() <= 2) {
        String columnName=columnDesc.nextToken();
        String sortOrder=SortColumn.ASCENDING;
        if (columnDesc.hasMoreTokens()) {
          String sortDef=columnDesc.nextToken().toUpperCase();
          if (SortColumn.ASCENDING.equals(sortDef) || SortColumn.DESCENDING.equals(sortDef)) {
            sortOrder=sortDef;
          }
 else {
            logger.debug("String_Node_Str" + sortDef + "String_Node_Str"+ SortColumn.ASCENDING+ "String_Node_Str"+ SortColumn.DESCENDING+ "String_Node_Str");
          }
        }
        sortedColumns.add(new SortColumn(columnName,SortColumn.ASCENDING.equals(sortOrder)));
      }
    }
    return sortedColumns;
  }
  return Collections.emptyList();
}
Program: 174767
Project: 174767
Buggy source:
/** 
 * Processes the resulting resource and returns the data to be displayed
 * @param resource ResourceWithMetadata
 * @param apiResources Map<String, ResourceWithMetadata>
 * @return Either a ExecutionResult or a CollectionWithPagingInfo
 */
public static Object processResult(ResourceWithMetadata resource,Map<String,ResourceWithMetadata> apiResources){
  List<ExecutionResult> results=new ArrayList();
  if (RESOURCE_TYPE.ENTITY.equals(resource.getMetaData().getType())) {
    results.add(new ExecutionResult(resource,null));
    for (    ResourceWithMetadata aResource : apiResources.values()) {
      if (resource.getMetaData().getUniqueId().equals(aResource.getMetaData().getParentResource())) {
        results.add(new ExecutionResult(aResource,null));
      }
    }
  }
  if (results.isEmpty()) {
    return new ExecutionResult(resource,null);
  }
 else {
    return CollectionWithPagingInfo.asPaged(Paging.DEFAULT,results);
  }
}

Fixed version (ground truth):
/** 
 * Processes the resulting resource and returns the data to be displayed
 * @param resource ResourceWithMetadata
 * @return Either a ExecutionResult or a CollectionWithPagingInfo
 */
public static Object processResult(ResourceWithMetadata resource,Map<String,ResourceWithMetadata> apiResources){
  List<ExecutionResult> results=new ArrayList();
  if (RESOURCE_TYPE.ENTITY.equals(resource.getMetaData().getType())) {
    results.add(new ExecutionResult(resource,null));
    for (    ResourceWithMetadata aResource : apiResources.values()) {
      if (resource.getMetaData().getUniqueId().equals(aResource.getMetaData().getParentResource())) {
        results.add(new ExecutionResult(aResource,null));
      }
    }
  }
  if (results.isEmpty()) {
    return new ExecutionResult(resource,null);
  }
 else {
    return CollectionWithPagingInfo.asPaged(Paging.DEFAULT,results);
  }
}
Program: 174776
Project: 174776
Buggy source:
public void execute(WebScriptRequest req,WebScriptResponse res) throws IOException {
  if (!subscriptionService.isActive()) {
    res.setStatus(404);
    return;
  }
  try {
    String userId=req.getServiceMatch().getTemplateVars().get("String_Node_Str");
    Object obj=executeImpl(userId,req,res);
    if (obj instanceof JSONObject || obj instanceof JSONArray) {
      res.setContentEncoding("String_Node_Str");
      Writer writer=res.getWriter();
      if (obj instanceof JSONObject) {
        ((JSONObject)obj).write(writer);
      }
 else {
        ((JSONArray)obj).write(writer);
      }
      writer.flush();
    }
 else {
      res.setStatus(204);
    }
  }
 catch (  SubscriptionsDisabledException sde) {
    throw new WebScriptException(404,"String_Node_Str",sde);
  }
catch (  NoSuchPersonException nspe) {
    throw new WebScriptException(404,"String_Node_Str" + nspe.getUserName() + "String_Node_Str",nspe);
  }
catch (  PrivateSubscriptionListException psle) {
    throw new WebScriptException(403,"String_Node_Str",psle);
  }
catch (  JSONException je) {
    throw new WebScriptException(500,"String_Node_Str",je);
  }
}

Fixed version (ground truth):
public void execute(WebScriptRequest req,WebScriptResponse res) throws IOException {
  if (!subscriptionService.isActive()) {
    res.setStatus(404);
    return;
  }
  try {
    String userId=req.getServiceMatch().getTemplateVars().get("String_Node_Str");
    Object obj=executeImpl(userId,req,res);
    if (obj instanceof JSONObject || obj instanceof JSONArray) {
      res.setContentEncoding(Charset.defaultCharset().displayName());
      Writer writer=res.getWriter();
      if (obj instanceof JSONObject) {
        ((JSONObject)obj).write(writer);
      }
 else {
        ((JSONArray)obj).write(writer);
      }
      writer.flush();
    }
 else {
      res.setStatus(204);
    }
  }
 catch (  SubscriptionsDisabledException sde) {
    throw new WebScriptException(404,"String_Node_Str",sde);
  }
catch (  NoSuchPersonException nspe) {
    throw new WebScriptException(404,"String_Node_Str" + nspe.getUserName() + "String_Node_Str",nspe);
  }
catch (  PrivateSubscriptionListException psle) {
    throw new WebScriptException(403,"String_Node_Str",psle);
  }
catch (  JSONException je) {
    throw new WebScriptException(500,"String_Node_Str",je);
  }
}
Program: 174778
Project: 174778
Buggy source:
protected <T extends Element>T fetch(IRI href,Map<String,String> args) throws Exception {
  Request get=new GetRequest(href.toString()).setArgs(args);
  Response res=sendRequest(get,200);
  Assert.assertNotNull(res);
  String xml=res.getContentAsString();
  T result=parse(new StringReader(xml));
  Assert.assertNotNull(result);
  return result;
}

Fixed version (ground truth):
protected <T extends Element>T fetch(IRI href,Map<String,String> args) throws Exception {
  Request get=new GetRequest(href.toString()).setArgs(args);
  Response res=sendRequest(get,200);
  Assert.assertNotNull(res);
  String xml=res.getContentAsString();
  T result=this.<T>parse(new StringReader(xml));
  Assert.assertNotNull(result);
  return result;
}
Program: 174779
Project: 174779
Buggy source:
@Override protected void createDocument(final WebScriptResponse res,final String store,final String path,final InputStream content){
  AuthenticationUtil.runAs(new RunAsWork<Object>(){
    @SuppressWarnings("String_Node_Str") public Object doWork() throws Exception {
      String avmPath=buildAVMPath(store,path);
      try {
        String[] parts=AVMNodeConverter.SplitBase(avmPath);
        String[] dirs=parts[0].split("String_Node_Str");
        String parentPath=dirs[0] + "String_Node_Str" + dirs[1];
        int index=2;
        while (index < dirs.length) {
          String dirPath=parentPath + "String_Node_Str" + dirs[index];
          if (avmService.lookup(-1,dirPath) == null) {
            avmService.createDirectory(parentPath,dirs[index]);
          }
          parentPath=dirPath;
          index++;
        }
        avmService.createFile(parts[0],parts[1],content);
        if (logger.isDebugEnabled())         logger.debug("String_Node_Str" + avmPath);
      }
 catch (      AccessDeniedException ae) {
        res.setStatus(Status.STATUS_UNAUTHORIZED);
      }
catch (      AVMExistsException avmErr) {
        res.setStatus(Status.STATUS_CONFLICT);
      }
      return null;
    }
  }
,AuthenticationUtil.getSystemUserName());
}

Fixed version (ground truth):
@Override protected void createDocument(final WebScriptResponse res,final String store,final String path,final InputStream content){
  AuthenticationUtil.runAs(new RunAsWork<Object>(){
    @SuppressWarnings("String_Node_Str") public Object doWork() throws Exception {
      String avmPath=buildAVMPath(store,path);
      try {
        String[] parts=AVMNodeConverter.SplitBase(avmPath);
        String[] dirs=parts[0].split("String_Node_Str");
        String parentPath=dirs[0] + "String_Node_Str" + dirs[1];
        int index=2;
        while (index < dirs.length) {
          String dirPath=parentPath + "String_Node_Str" + dirs[index];
          if (avmService.lookup(-1,dirPath) == null) {
            avmService.createDirectory(parentPath,dirs[index]);
          }
          parentPath=dirPath;
          index++;
        }
        avmService.createFile(parts[0],parts[1],content);
        if (logger.isDebugEnabled())         logger.debug("String_Node_Str" + avmPath + "String_Node_Str"+ avmService.lookup(-1,avmPath).getLength());
      }
 catch (      AccessDeniedException ae) {
        res.setStatus(Status.STATUS_UNAUTHORIZED);
      }
catch (      AVMExistsException avmErr) {
        res.setStatus(Status.STATUS_CONFLICT);
      }
      return null;
    }
  }
,AuthenticationUtil.getSystemUserName());
}
Program: 174780
Project: 174780
Buggy source:
@Override protected void updateDocument(final WebScriptResponse res,final String store,final String path,final InputStream content){
  final String avmPath=buildAVMPath(store,path);
  AVMNodeDescriptor desc=this.avmService.lookup(-1,avmPath);
  if (desc == null) {
    res.setStatus(Status.STATUS_NOT_FOUND);
    return;
  }
  AuthenticationUtil.runAs(new RunAsWork<Object>(){
    @SuppressWarnings("String_Node_Str") public Object doWork() throws Exception {
      try {
        ContentWriter writer=avmService.getContentWriter(avmPath);
        writer.putContent(content);
        if (logger.isDebugEnabled())         logger.debug("String_Node_Str" + avmPath);
      }
 catch (      AccessDeniedException ae) {
        res.setStatus(Status.STATUS_UNAUTHORIZED);
      }
      return null;
    }
  }
,AuthenticationUtil.getSystemUserName());
}

Fixed version (ground truth):
@Override protected void updateDocument(final WebScriptResponse res,final String store,final String path,final InputStream content){
  final String avmPath=buildAVMPath(store,path);
  AVMNodeDescriptor desc=this.avmService.lookup(-1,avmPath);
  if (desc == null) {
    res.setStatus(Status.STATUS_NOT_FOUND);
    return;
  }
  AuthenticationUtil.runAs(new RunAsWork<Object>(){
    @SuppressWarnings("String_Node_Str") public Object doWork() throws Exception {
      try {
        ContentWriter writer=avmService.getContentWriter(avmPath);
        writer.putContent(content);
        if (logger.isDebugEnabled())         logger.debug("String_Node_Str" + avmPath + "String_Node_Str"+ avmService.lookup(-1,avmPath).getLength());
      }
 catch (      AccessDeniedException ae) {
        res.setStatus(Status.STATUS_UNAUTHORIZED);
      }
      return null;
    }
  }
,AuthenticationUtil.getSystemUserName());
}
Program: 174782
Project: 174782
Buggy source:
/** 
 * Checks specified in CMIS request parameters repository Id.
 * @param repositoryId repository id
 * @throws InvalidArgumentException repository diesn't exist
 */
protected void checkRepositoryId(String repositoryId) throws InvalidArgumentException {
  if (!this.descriptorService.getServerDescriptor().getId().equals(repositoryId)) {
    throw new InvalidArgumentException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Checks specified in CMIS request parameters repository Id.
 * @param repositoryId repository id
 * @throws InvalidArgumentException repository diesn't exist
 */
protected void checkRepositoryId(String repositoryId) throws InvalidArgumentException {
  if (!this.descriptorService.getCurrentRepositoryDescriptor().getId().equals(repositoryId)) {
    throw new InvalidArgumentException("String_Node_Str");
  }
}
Program: 174784
Project: 174784
Buggy source:
/** 
 * Gets the definition for specified object type
 * @param parameters repositoryId: repository Id; typeId: type Id;
 * @return CMIS type definition
 * @throws PermissionDeniedException
 * @throws UpdateConflictException
 * @throws ObjectNotFoundException
 * @throws OperationNotSupportedException
 * @throws TypeNotFoundException
 * @throws InvalidArgumentException
 * @throws RuntimeException
 * @throws ConstraintViolationException
 */
public GetTypeDefinitionResponse getTypeDefinition(GetTypeDefinition parameters) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException {
  if (descriptorService.getServerDescriptor().getId().equals(parameters.getRepositoryId()) == false) {
    throw new InvalidArgumentException("String_Node_Str");
  }
  GetTypeDefinitionResponse response=new GetTypeDefinitionResponse();
  response.setType(getCmisTypeDefinition(parameters.getTypeId(),true));
  return response;
}

Fixed version (ground truth):
/** 
 * Gets the definition for specified object type
 * @param parameters repositoryId: repository Id; typeId: type Id;
 * @return CMIS type definition
 * @throws PermissionDeniedException
 * @throws UpdateConflictException
 * @throws ObjectNotFoundException
 * @throws OperationNotSupportedException
 * @throws TypeNotFoundException
 * @throws InvalidArgumentException
 * @throws RuntimeException
 * @throws ConstraintViolationException
 */
public GetTypeDefinitionResponse getTypeDefinition(GetTypeDefinition parameters) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException {
  checkRepositoryId(parameters.getRepositoryId());
  GetTypeDefinitionResponse response=new GetTypeDefinitionResponse();
  response.setType(getCmisTypeDefinition(parameters.getTypeId(),true));
  return response;
}
Program: 174785
Project: 174785
Buggy source:
/** 
 * Gets a list of available repositories for this CMIS service endpoint.
 * @return collection of CmisRepositoryEntryType (repositoryId - repository Id, repositoryName: repository name, repositoryURI: Repository URI)
 * @throws RuntimeException
 * @throws InvalidArgumentException
 * @throws OperationNotSupportedException
 * @throws UpdateConflictException
 * @throws PermissionDeniedException
 */
public List<CmisRepositoryEntryType> getRepositories() throws RuntimeException, InvalidArgumentException, OperationNotSupportedException, UpdateConflictException, PermissionDeniedException {
  CmisRepositoryEntryType repositoryEntryType=new CmisRepositoryEntryType();
  Descriptor serverDescriptor=descriptorService.getServerDescriptor();
  repositoryEntryType.setRepositoryID(serverDescriptor.getId());
  repositoryEntryType.setRepositoryName(serverDescriptor.getName());
  return Collections.singletonList(repositoryEntryType);
}

Fixed version (ground truth):
/** 
 * Gets a list of available repositories for this CMIS service endpoint.
 * @return collection of CmisRepositoryEntryType (repositoryId - repository Id, repositoryName: repository name, repositoryURI: Repository URI)
 * @throws RuntimeException
 * @throws InvalidArgumentException
 * @throws OperationNotSupportedException
 * @throws UpdateConflictException
 * @throws PermissionDeniedException
 */
public List<CmisRepositoryEntryType> getRepositories() throws RuntimeException, InvalidArgumentException, OperationNotSupportedException, UpdateConflictException, PermissionDeniedException {
  CmisRepositoryEntryType repositoryEntryType=new CmisRepositoryEntryType();
  Descriptor serverDescriptor=descriptorService.getCurrentRepositoryDescriptor();
  repositoryEntryType.setRepositoryID(serverDescriptor.getId());
  repositoryEntryType.setRepositoryName(serverDescriptor.getName());
  return Collections.singletonList(repositoryEntryType);
}
Program: 174787
Project: 174787
Buggy source:
@Override protected void listDocuments(WebScriptResponse res,final String store,String path,String pattern) throws IOException {
  String avmPath=buildAVMPath(store,path);
  AVMNodeDescriptor node=this.avmService.lookup(-1,avmPath);
  if (node == null) {
    res.setStatus(Status.STATUS_NOT_FOUND);
    return;
  }
  if (pattern == null || pattern.length() == 0) {
    pattern="String_Node_Str";
  }
  String matcher=pattern.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
  final Pattern pat=Pattern.compile(matcher);
  String encPath=RepoStore.encodePathISO9075(path);
  final StringBuilder query=new StringBuilder(128);
  query.append("String_Node_Str").append(this.rootPath).append(encPath.length() != 0 ? ('/' + encPath) : "String_Node_Str").append("String_Node_Str").append(pattern);
  final Writer out=res.getWriter();
  final StoreRef avmStore=new StoreRef(StoreRef.PROTOCOL_AVM + StoreRef.URI_FILLER + store);
  AuthenticationUtil.runAs(new RunAsWork<Object>(){
    @SuppressWarnings("String_Node_Str") public Object doWork() throws Exception {
      int cropPoint=store.length() + rootPath.length() + 1;
      ResultSet resultSet=searchService.query(avmStore,SearchService.LANGUAGE_LUCENE,query.toString());
      try {
        List<NodeRef> nodes=resultSet.getNodeRefs();
        for (        NodeRef nodeRef : nodes) {
          String path=AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond();
          String name=path.substring(path.lastIndexOf('/') + 1);
          if (pat.matcher(name).matches()) {
            out.write(path.substring(cropPoint));
            out.write("String_Node_Str");
          }
        }
      }
  finally {
        resultSet.close();
      }
      return null;
    }
  }
,AuthenticationUtil.getSystemUserName());
}

Fixed version (ground truth):
@Override protected void listDocuments(WebScriptResponse res,final String store,String path,String pattern) throws IOException {
  String avmPath=buildAVMPath(store,path);
  AVMNodeDescriptor node=this.avmService.lookup(-1,avmPath);
  if (node == null) {
    res.setStatus(Status.STATUS_NOT_FOUND);
    return;
  }
  if (pattern == null || pattern.length() == 0) {
    pattern="String_Node_Str";
  }
  String matcher=pattern.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
  try {
    traverseNode(res.getWriter(),store,node,Pattern.compile(matcher),true);
  }
 catch (  AccessDeniedException ae) {
    res.setStatus(Status.STATUS_UNAUTHORIZED);
  }
 finally {
    res.getWriter().close();
  }
}
Program: 174788
Project: 174788
Buggy source:
@Override protected void createDocument(final WebScriptResponse res,final String store,final String path,final InputStream content){
  AuthenticationUtil.runAs(new RunAsWork<Object>(){
    @SuppressWarnings("String_Node_Str") public Object doWork() throws Exception {
      String avmPath=buildAVMPath(store,path);
      try {
        String[] parts=AVMNodeConverter.SplitBase(avmPath);
        String[] dirs=parts[0].split("String_Node_Str");
        String parentPath=dirs[0] + "String_Node_Str" + dirs[1];
        int index=2;
        while (index < dirs.length) {
          String dirPath=parentPath + "String_Node_Str" + dirs[index];
          if (avmService.lookup(-1,dirPath) == null) {
            avmService.createDirectory(parentPath,dirs[index]);
          }
          parentPath=dirPath;
          index++;
        }
        avmService.createFile(parts[0],parts[1],content);
        avmService.createSnapshot(store,"String_Node_Str",path);
      }
 catch (      AccessDeniedException ae) {
        res.setStatus(Status.STATUS_UNAUTHORIZED);
      }
catch (      AVMExistsException avmErr) {
        res.setStatus(Status.STATUS_CONFLICT);
      }
      return null;
    }
  }
,AuthenticationUtil.getSystemUserName());
}

Fixed version (ground truth):
@Override protected void createDocument(final WebScriptResponse res,final String store,final String path,final InputStream content){
  AuthenticationUtil.runAs(new RunAsWork<Object>(){
    @SuppressWarnings("String_Node_Str") public Object doWork() throws Exception {
      String avmPath=buildAVMPath(store,path);
      try {
        String[] parts=AVMNodeConverter.SplitBase(avmPath);
        String[] dirs=parts[0].split("String_Node_Str");
        String parentPath=dirs[0] + "String_Node_Str" + dirs[1];
        int index=2;
        while (index < dirs.length) {
          String dirPath=parentPath + "String_Node_Str" + dirs[index];
          if (avmService.lookup(-1,dirPath) == null) {
            avmService.createDirectory(parentPath,dirs[index]);
          }
          parentPath=dirPath;
          index++;
        }
        avmService.createFile(parts[0],parts[1],content);
      }
 catch (      AccessDeniedException ae) {
        res.setStatus(Status.STATUS_UNAUTHORIZED);
      }
catch (      AVMExistsException avmErr) {
        res.setStatus(Status.STATUS_CONFLICT);
      }
      return null;
    }
  }
,AuthenticationUtil.getSystemUserName());
}
Program: 174789
Project: 174789
Buggy source:
private void traverseNode(Writer out,String store,AVMNodeDescriptor node,boolean recurse) throws IOException {
  int cropPoint=store.length() + this.rootPath.length() + 1;
  SortedMap<String,AVMNodeDescriptor> listing=this.avmService.getDirectoryListing(node);
  for (  AVMNodeDescriptor n : listing.values()) {
    if (n.isFile()) {
      out.write(n.getPath().substring(cropPoint));
      out.write("String_Node_Str");
    }
 else     if (recurse && n.isDirectory()) {
      traverseNode(out,store,n,recurse);
    }
  }
}

Fixed version (ground truth):
/** 
 * Traverse a Node and recursively output the file paths it contains.
 * @param out       Writer for output - relative paths separated by newline characters
 * @param store     AVM Store name
 * @param node      The AVM Node to traverse
 * @param pattern   Optional Pattern to match filenames against
 * @param recurse   True to recurse sub-directories  
 * @throws IOException
 */
private void traverseNode(Writer out,String store,AVMNodeDescriptor node,Pattern pattern,boolean recurse) throws IOException {
  int cropPoint=store.length() + this.rootPath.length() + 1;
  SortedMap<String,AVMNodeDescriptor> listing=this.avmService.getDirectoryListing(node);
  for (  AVMNodeDescriptor n : listing.values()) {
    if (n.isFile()) {
      String path=n.getPath();
      if (pattern != null) {
        String name=path.substring(path.lastIndexOf('/') + 1);
        if (pattern.matcher(name).matches()) {
          out.write(path.substring(cropPoint));
          out.write("String_Node_Str");
        }
      }
 else {
        out.write(path.substring(cropPoint));
        out.write("String_Node_Str");
      }
    }
 else     if (recurse && n.isDirectory()) {
      traverseNode(out,store,n,pattern,recurse);
    }
  }
}
Program: 174790
Project: 174790
Buggy source:
@SuppressWarnings("String_Node_Str") public Object doWork() throws Exception {
  int cropPoint=store.length() + rootPath.length() + 1;
  ResultSet resultSet=searchService.query(avmStore,SearchService.LANGUAGE_LUCENE,query.toString());
  try {
    List<NodeRef> nodes=resultSet.getNodeRefs();
    for (    NodeRef nodeRef : nodes) {
      String path=AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond();
      String name=path.substring(path.lastIndexOf('/') + 1);
      if (pat.matcher(name).matches()) {
        out.write(path.substring(cropPoint));
        out.write("String_Node_Str");
      }
    }
  }
  finally {
    resultSet.close();
  }
  return null;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public Object doWork() throws Exception {
  try {
    avmService.removeNode(avmPath);
  }
 catch (  AccessDeniedException ae) {
    res.setStatus(Status.STATUS_UNAUTHORIZED);
  }
  return null;
}
Program: 174791
Project: 174791
Buggy source:
@Override protected void deleteDocument(final WebScriptResponse res,final String store,final String path){
  final String avmPath=buildAVMPath(store,path);
  AVMNodeDescriptor desc=this.avmService.lookup(-1,avmPath);
  if (desc == null) {
    res.setStatus(Status.STATUS_NOT_FOUND);
    return;
  }
  AuthenticationUtil.runAs(new RunAsWork<Object>(){
    @SuppressWarnings("String_Node_Str") public Object doWork() throws Exception {
      try {
        avmService.removeNode(avmPath);
        avmService.createSnapshot(store,"String_Node_Str",path);
      }
 catch (      AccessDeniedException ae) {
        res.setStatus(Status.STATUS_UNAUTHORIZED);
      }
      return null;
    }
  }
,AuthenticationUtil.getSystemUserName());
}

Fixed version (ground truth):
@Override protected void deleteDocument(final WebScriptResponse res,final String store,final String path){
  final String avmPath=buildAVMPath(store,path);
  AVMNodeDescriptor desc=this.avmService.lookup(-1,avmPath);
  if (desc == null) {
    res.setStatus(Status.STATUS_NOT_FOUND);
    return;
  }
  AuthenticationUtil.runAs(new RunAsWork<Object>(){
    @SuppressWarnings("String_Node_Str") public Object doWork() throws Exception {
      try {
        avmService.removeNode(avmPath);
      }
 catch (      AccessDeniedException ae) {
        res.setStatus(Status.STATUS_UNAUTHORIZED);
      }
      return null;
    }
  }
,AuthenticationUtil.getSystemUserName());
}
Program: 174792
Project: 174792
Buggy source:
/** 
 * @param store     the store id
 * @param path      root path relative
 * @return full AVM path to document including store and root path components
 */
private String buildAVMPath(String store,String path){
  if (path.startsWith("String_Node_Str")) {
    path=path.substring(1);
  }
  return store + "String_Node_Str" + this.rootPath+ (path != null ? encodePath(path) : "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @param store     the AVM store id
 * @param path      root path relative
 * @return full AVM path to document including store and root path components
 */
private String buildAVMPath(String store,String path){
  if (path.startsWith("String_Node_Str")) {
    path=path.substring(1);
  }
  return store + "String_Node_Str" + this.rootPath+ (path != null ? encodePath(path) : "String_Node_Str");
}
Program: 174794
Project: 174794
Buggy source:
/** 
 * Processes 'accept' response from invitee
 * @param model model to add objects to, which will be passed to the template for rendering
 * @param inviteId ID of invite
 * @param inviteeUserName user name of invitee
 * @param siteShortName short name of site for which invitee is accepting invitation to join
 */
private void acceptInvite(Map<String,Object> model,String inviteId,String inviteeUserName,String siteShortName){
  completeInviteTask(QName.createQName(WF_TASK_INVITE_PENDING,this.namespaceService),WF_TRANSITION_ACCEPT);
  if ((this.mutableAuthenticationDao.userExists(inviteeUserName)) && (this.mutableAuthenticationDao.getEnabled(inviteeUserName) == false)) {
    this.mutableAuthenticationDao.setEnabled(inviteeUserName,true);
  }
  String inviteeSiteRole=getInviteeSiteRoleFromInvite(inviteId);
  RunAsWork<Boolean> setSiteMembershipWorker=new InviteResponse.SetSiteMembershipWorker(siteShortName,inviteeUserName,inviteeSiteRole);
  AuthenticationUtil.runAs(setSiteMembershipWorker,USER_ADMIN);
  completeInviteTask(QName.createQName(WF_TASK_ACCEPT_INVITE,this.namespaceService),WF_TRANSITION_ACCEPT_INVITE_END);
  model.put(MODEL_PROP_KEY_RESPONSE,RESPONSE_ACCEPT);
  model.put(MODEL_PROP_KEY_SITE_SHORT_NAME,siteShortName);
}

Fixed version (ground truth):
/** 
 * Processes 'accept' response from invitee
 * @param model model to add objects to, which will be passed to the template for rendering
 * @param inviteId ID of invite
 * @param inviteeUserName user name of invitee
 * @param siteShortName short name of site for which invitee is accepting invitation to join
 */
private void acceptInvite(Map<String,Object> model,String inviteId,String inviteeUserName,String siteShortName){
  completeInviteTask(inviteId,QName.createQName(WF_TASK_INVITE_PENDING,this.namespaceService),WF_TRANSITION_ACCEPT);
  if ((this.mutableAuthenticationDao.userExists(inviteeUserName)) && (this.mutableAuthenticationDao.getEnabled(inviteeUserName) == false)) {
    this.mutableAuthenticationDao.setEnabled(inviteeUserName,true);
  }
  String inviteeSiteRole=InviteHelper.getInviteeSiteRoleFromInvite(inviteId,this.workflowService,this.namespaceService);
  RunAsWork<Boolean> setSiteMembershipWorker=new InviteResponse.SetSiteMembershipWorker(siteShortName,inviteeUserName,inviteeSiteRole);
  AuthenticationUtil.runAs(setSiteMembershipWorker,USER_ADMIN);
  completeInviteTask(inviteId,QName.createQName(WF_TASK_ACCEPT_INVITE,this.namespaceService),WF_TRANSITION_ACCEPT_INVITE_END);
  model.put(MODEL_PROP_KEY_RESPONSE,RESPONSE_ACCEPT);
  model.put(MODEL_PROP_KEY_SITE_SHORT_NAME,siteShortName);
}
Program: 174795
Project: 174795
Buggy source:
/** 
 * Processes 'reject' invite response from invitee
 * @param model model to add objects to, which will be passed to the template for rendering
 * @param inviteId ID of invite
 * @param inviteeUserName user name of invitee
 * @param siteShortName short name of site for which invitee is rejecting invitation to join
 */
private void rejectInvite(Map<String,Object> model,String inviteId,String inviteeUserName,String siteShortName){
  completeInviteTask(QName.createQName(WF_TASK_INVITE_PENDING,this.namespaceService),WF_TRANSITION_REJECT);
  if ((this.mutableAuthenticationDao.userExists(inviteeUserName)) && (this.mutableAuthenticationDao.getEnabled(inviteeUserName) == false)) {
    this.mutableAuthenticationDao.deleteUser(inviteeUserName);
    if (this.personService.personExists(inviteeUserName)) {
      this.personService.deletePerson(inviteeUserName);
    }
  }
  completeInviteTask(QName.createQName(WF_TASK_REJECT_INVITE,this.namespaceService),WF_TRANSITION_REJECT_INVITE_END);
  model.put(MODEL_PROP_KEY_RESPONSE,RESPONSE_REJECT);
  model.put(MODEL_PROP_KEY_SITE_SHORT_NAME,siteShortName);
}

Fixed version (ground truth):
/** 
 * Processes 'reject' invite response from invitee
 * @param model model to add objects to, which will be passed to the template for rendering
 * @param inviteId ID of invite
 * @param inviteeUserName user name of invitee
 * @param siteShortName short name of site for which invitee is rejecting invitation to join
 */
private void rejectInvite(Map<String,Object> model,String inviteId,String inviteeUserName,String siteShortName){
  completeInviteTask(inviteId,QName.createQName(WF_TASK_INVITE_PENDING,this.namespaceService),WF_TRANSITION_REJECT);
  if ((this.mutableAuthenticationDao.userExists(inviteeUserName)) && (this.mutableAuthenticationDao.getEnabled(inviteeUserName) == false)) {
    this.mutableAuthenticationDao.deleteUser(inviteeUserName);
    if (this.personService.personExists(inviteeUserName)) {
      this.personService.deletePerson(inviteeUserName);
    }
  }
  completeInviteTask(inviteId,QName.createQName(WF_TASK_REJECT_INVITE,this.namespaceService),WF_TRANSITION_REJECT_INVITE_END);
  model.put(MODEL_PROP_KEY_RESPONSE,RESPONSE_REJECT);
  model.put(MODEL_PROP_KEY_SITE_SHORT_NAME,siteShortName);
}
Program: 174796
Project: 174796
Buggy source:
/** 
 * Complete the specified Invite Workflow Task and follow the given transition upon completing the task
 * @param fullTaskName qualified name of invite workflow task to complete
 * @param transitionId the task transition to take on completion of the task (or null, for the default transition)
 */
private void completeInviteTask(QName fullTaskName,String transitionId){
  WorkflowTaskQuery wfTaskQuery=new WorkflowTaskQuery();
  wfTaskQuery.setActive(Boolean.TRUE);
  wfTaskQuery.setTaskState(WorkflowTaskState.IN_PROGRESS);
  wfTaskQuery.setTaskName(fullTaskName);
  wfTaskQuery.setProcessName(QName.createQName("String_Node_Str",this.namespaceService));
  List<WorkflowTask> wf_invite_tasks=this.workflowService.queryTasks(wfTaskQuery);
  for (  WorkflowTask workflowTask : wf_invite_tasks) {
    this.workflowService.endTask(workflowTask.id,transitionId);
  }
}

Fixed version (ground truth):
/** 
 * Complete the specified Invite Workflow Task for the invite workflow  instance associated with the given invite ID, and follow the given transition upon completing the task
 * @param inviteId the invite ID of the invite workflow instance for whichwe want to complete the given task
 * @param fullTaskName qualified name of invite workflow task to complete
 * @param transitionId the task transition to take on completion of the task (or null, for the default transition)
 */
private void completeInviteTask(String inviteId,QName fullTaskName,String transitionId){
  WorkflowTaskQuery wfTaskQuery=new WorkflowTaskQuery();
  wfTaskQuery.setProcessId(inviteId);
  wfTaskQuery.setActive(Boolean.TRUE);
  wfTaskQuery.setTaskState(WorkflowTaskState.IN_PROGRESS);
  wfTaskQuery.setTaskName(fullTaskName);
  wfTaskQuery.setProcessName(QName.createQName("String_Node_Str",this.namespaceService));
  List<WorkflowTask> wf_invite_tasks=this.workflowService.queryTasks(wfTaskQuery);
  for (  WorkflowTask workflowTask : wf_invite_tasks) {
    this.workflowService.endTask(workflowTask.id,transitionId);
  }
}
Program: 174797
Project: 174797
Buggy source:
/** 
 * Maps the current HTTP request to a path that can be used to access a content repository
 * @param request HTTP request
 * @return A content repository path
 */
public static String getRepositoryPath(HttpServletRequest request){
  String strPath=request.getPathInfo();
  if (strPath == null) {
    strPath=request.getServletPath();
  }
  if (strPath == null || strPath.length() == 0) {
    strPath=RootPath;
  }
 else   if (strPath.endsWith(DIR_SEPARATOR)) {
    strPath=strPath.substring(0,strPath.length() - 1);
  }
  if (strPath.startsWith(request.getServletPath())) {
    int len=request.getServletPath().length();
    if (strPath.length() > len)     strPath=strPath.substring(len);
 else     strPath=RootPath;
  }
  return decodeURL(strPath);
}

Fixed version (ground truth):
/** 
 * Maps the current HTTP request to a path that can be used to access a content repository
 * @param request HTTP request
 * @return A content repository path
 */
public static String getRepositoryPath(HttpServletRequest request){
  String strPath=null;
  try {
    strPath=URLDecoder.decode(request.getRequestURI(),"String_Node_Str");
  }
 catch (  Exception ex) {
  }
  String servletPath=request.getServletPath();
  int rootPos=strPath.indexOf(servletPath);
  if (rootPos != -1)   strPath=strPath.substring(rootPos);
  if (strPath == null) {
    strPath=request.getServletPath();
  }
  if (strPath == null || strPath.length() == 0) {
    strPath=RootPath;
  }
 else   if (strPath.endsWith(DIR_SEPARATOR)) {
    strPath=strPath.substring(0,strPath.length() - 1);
  }
  if (strPath.startsWith(request.getServletPath())) {
    int len=request.getServletPath().length();
    if (strPath.length() > len)     strPath=strPath.substring(len);
 else     strPath=RootPath;
  }
  return strPath;
}
Program: 174798
Project: 174798
Buggy source:
/** 
 * Returns a URL that could be used to access the given path.
 * @param request HttpServletRequest
 * @param path String
 * @param isCollection boolean
 * @return String
 */
public static String getURLForPath(HttpServletRequest request,String path,boolean isCollection){
  StringBuilder urlStr=new StringBuilder(request.getRequestURI());
  String servletPath=request.getServletPath();
  int rootPos=urlStr.indexOf(servletPath);
  if (rootPos != -1)   urlStr.setLength(rootPos + servletPath.length());
  if (urlStr.charAt(urlStr.length() - 1) != PathSeperatorChar)   urlStr.append(PathSeperator);
  if (path.equals(RootPath) == false) {
    if (path.startsWith(PathSeperator))     urlStr.append(path.substring(1));
 else     urlStr.append(path);
  }
  return urlStr.toString();
}

Fixed version (ground truth):
/** 
 * Returns a URL that could be used to access the given path.
 * @param request HttpServletRequest
 * @param path String
 * @param isCollection boolean
 * @return String
 */
public static String getURLForPath(HttpServletRequest request,String path,boolean isCollection){
  StringBuilder urlStr=new StringBuilder(request.getRequestURI());
  String servletPath=request.getServletPath();
  int rootPos=urlStr.indexOf(servletPath);
  if (rootPos != -1)   urlStr.setLength(rootPos + servletPath.length());
  if (urlStr.charAt(urlStr.length() - 1) != PathSeperatorChar)   urlStr.append(PathSeperator);
  if (path.equals(RootPath) == false) {
    if (path.startsWith(PathSeperator))     urlStr.append(path.substring(1));
 else     urlStr.append(path);
  }
  if (isCollection && urlStr.charAt(urlStr.length() - 1) != PathSeperatorChar)   urlStr.append(PathSeperator);
  String encUrlStr=null;
  try {
    encUrlStr=URLEncoder.encode(urlStr.toString(),"String_Node_Str");
  }
 catch (  UnsupportedEncodingException ex) {
    logger.error(ex);
  }
  return encUrlStr;
}
Program: 174799
Project: 174799
Buggy source:
/** 
 * @see org.alfresco.repo.webservice.content.ContentServiceSoapPort#write(org.alfresco.repo.webservice.types.Reference,byte[])
 */
public Content write(Reference node,String property,byte[] content,ContentFormat format) throws RemoteException, ContentFault {
  UserTransaction tx=null;
  try {
    tx=Utils.getUserTransaction(MessageContext.getCurrentContext());
    tx.begin();
    NodeRef nodeRef=Utils.convertToNodeRef(node,this.nodeService,this.searchService,this.namespaceService);
    ContentWriter writer=this.contentService.getWriter(nodeRef,QName.createQName(property),true);
    if (format != null) {
      writer.setEncoding(format.getEncoding());
      writer.setMimetype(format.getMimetype());
    }
    writer.putContent(new String(content));
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + nodeRef.getId());
    }
    tx.commit();
    return createContent(nodeRef,property);
  }
 catch (  Throwable e) {
    try {
      if (tx != null) {
        tx.rollback();
      }
    }
 catch (    Exception ex) {
    }
    if (logger.isDebugEnabled()) {
      logger.error("String_Node_Str",e);
    }
    throw new ContentFault(0,e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * @see org.alfresco.repo.webservice.content.ContentServiceSoapPort#write(org.alfresco.repo.webservice.types.Reference,byte[])
 */
public Content write(Reference node,String property,byte[] content,ContentFormat format) throws RemoteException, ContentFault {
  UserTransaction tx=null;
  try {
    tx=Utils.getUserTransaction(MessageContext.getCurrentContext());
    tx.begin();
    NodeRef nodeRef=Utils.convertToNodeRef(node,this.nodeService,this.searchService,this.namespaceService);
    ContentWriter writer=this.contentService.getWriter(nodeRef,QName.createQName(property),true);
    if (format != null) {
      writer.setEncoding(format.getEncoding());
      writer.setMimetype(format.getMimetype());
    }
    InputStream is=new ByteArrayInputStream(content);
    writer.putContent(is);
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + nodeRef.getId());
    }
    tx.commit();
    return createContent(nodeRef,property);
  }
 catch (  Throwable e) {
    try {
      if (tx != null) {
        tx.rollback();
      }
    }
 catch (    Exception ex) {
    }
    if (logger.isDebugEnabled()) {
      logger.error("String_Node_Str",e);
    }
    throw new ContentFault(0,e.getMessage());
  }
}
Program: 174802
Project: 174802
Buggy source:
public static QueryLanguageEnum fromValue(java.lang.String value) throws java.lang.IllegalArgumentException {
  QueryLanguageEnum enumeration=(QueryLanguageEnum)_table_.get(value);
  if (enumeration == null)   throw new java.lang.IllegalArgumentException();
  return enumeration;
}

Fixed version (ground truth):
public static QueryLanguageEnum fromValue(java.lang.String value) throws java.lang.IllegalArgumentException {
  QueryLanguageEnum enumeration=(QueryLanguageEnum)_table_.get(value);
  if (enumeration == null) {
    enumeration=lucene;
  }
  return enumeration;
}
Program: 174803
Project: 174803
Buggy source:
public static StoreEnum fromValue(java.lang.String value) throws java.lang.IllegalArgumentException {
  StoreEnum enumeration=(StoreEnum)_table_.get(value);
  if (enumeration == null)   throw new java.lang.IllegalArgumentException();
  return enumeration;
}

Fixed version (ground truth):
public static StoreEnum fromValue(java.lang.String value) throws java.lang.IllegalArgumentException {
  StoreEnum enumeration=(StoreEnum)_table_.get(value);
  if (enumeration == null) {
    enumeration=workspace;
  }
  return enumeration;
}
Program: 174804
Project: 174804
Buggy source:
@GET("String_Node_Str") void getNonceId(@Query("String_Node_Str") String controller,@Query("String_Node_Str") String method,Callback<NonceId> callback);

Fixed version (ground truth):
@GET("String_Node_Str") void getNonceId(@Query("String_Node_Str") String controller,@Query("String_Node_Str") String method,Callback<NonceIdResponse> callback);
Program: 174805
Project: 174805
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_login);
  mAuthApi=initAdapter();
  inputEmail=(EditText)findViewById(R.id.email);
  inputPassword=(EditText)findViewById(R.id.password);
  btnSignup=(Button)findViewById(R.id.btn_signup);
  btnLogin=(Button)findViewById(R.id.btn_login);
  btnReset=(Button)findViewById(R.id.btn_reset_password);
  btnLogin.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      String email=inputEmail.getText().toString();
      String password=inputPassword.getText().toString();
      if (!validateForm(inputEmail,inputPassword)) {
        return;
      }
      signIn(email,password);
    }
  }
);
  btnReset.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      startActivity(new Intent(getApplicationContext(),ResetPasswordActivity.class));
    }
  }
);
  btnSignup.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      startActivity(new Intent(getApplicationContext(),SignupActivity.class));
    }
  }
);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_login);
  mAuthApi=initAdapter();
  inputEmail=(EditText)findViewById(R.id.email);
  inputPassword=(EditText)findViewById(R.id.password);
  btnSignup=(Button)findViewById(R.id.btn_signup);
  btnLogin=(Button)findViewById(R.id.btn_login);
  btnReset=(Button)findViewById(R.id.btn_reset_password);
  btnLogin.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      String email=inputEmail.getText().toString();
      String password=inputPassword.getText().toString();
      if (!validateForm(inputEmail,inputPassword)) {
        return;
      }
      signIn(email,password);
    }
  }
);
  btnReset.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      startActivity(new Intent(getApplicationContext(),ResetPasswordActivity.class));
    }
  }
);
  btnSignup.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      startActivity(new Intent(getApplicationContext(),SignupActivity.class));
      finish();
    }
  }
);
}
Program: 174806
Project: 174806
Buggy source:
@Override public void onClick(View view){
  startActivity(new Intent(getApplicationContext(),SignupActivity.class));
}

Fixed version (ground truth):
@Override public void onClick(View view){
  startActivity(new Intent(getApplicationContext(),SignupActivity.class));
  finish();
}
Program: 174808
Project: 174808
Buggy source:
@Override public void onClick(View v){
  String username=inputUsername.getText().toString().trim();
  String email=inputEmail.getText().toString().trim();
  String password=inputPassword.getText().toString().trim();
  if (mNonceId == null) {
    getNonceId("String_Node_Str","String_Node_Str");
  }
  if (TextUtils.isEmpty(username)) {
    inputUsername.setError("String_Node_Str");
  }
  if (TextUtils.isEmpty(email)) {
    inputEmail.setError("String_Node_Str");
    return;
  }
  if (TextUtils.isEmpty(password)) {
    inputPassword.setError("String_Node_Str");
    return;
  }
  if (password.length() < 6) {
    inputPassword.setError("String_Node_Str");
    return;
  }
  registerUser(username,email,password);
}

Fixed version (ground truth):
@Override public void onClick(View v){
  String username=inputUsername.getText().toString().trim();
  String email=inputEmail.getText().toString().trim();
  String password=inputPassword.getText().toString().trim();
  if (TextUtils.isEmpty(username)) {
    inputUsername.setError("String_Node_Str");
  }
  if (TextUtils.isEmpty(email)) {
    inputEmail.setError("String_Node_Str");
    return;
  }
  if (TextUtils.isEmpty(password)) {
    inputPassword.setError("String_Node_Str");
    return;
  }
  if (password.length() < 6) {
    inputPassword.setError("String_Node_Str");
    return;
  }
  registerUser(username,email,password);
}
Program: 174809
Project: 174809
Buggy source:
@Override protected void onStart(){
  super.onStart();
  getNonceId("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@Override protected void onStart(){
  super.onStart();
}
Program: 174810
Project: 174810
Buggy source:
@Override public void failure(RetrofitError error){
  showAuthError(R.id.error_text,"String_Node_Str");
}

Fixed version (ground truth):
@Override public void failure(RetrofitError error){
  hideProgressDialog();
  Log.e("String_Node_Str",error.getLocalizedMessage());
  showAuthError(R.id.error_text,"String_Node_Str");
}