nus-yam/ex-repair huggingface dataset:
Program: 62209
Project: 62209
Buggy source:
private void doUpdateDeploymentTopology(DeploymentTopology deploymentTopology,Topology topology,ApplicationEnvironment environment){
  Map<String,NodeTemplate> previousNodeTemplates=deploymentTopology.getNodeTemplates();
  ReflectionUtil.mergeObject(topology,deploymentTopology,"String_Node_Str");
  topologyCompositionService.processTopologyComposition(deploymentTopology);
  deploymentInputService.processInputProperties(deploymentTopology);
  deploymentInputService.processProviderDeploymentProperties(deploymentTopology);
  deploymentNodeSubstitutionService.processNodesSubstitution(deploymentTopology,previousNodeTemplates);
  save(deploymentTopology);
}

Fixed version (ground truth):
private void doUpdateDeploymentTopology(DeploymentTopology deploymentTopology,Topology topology){
  Map<String,NodeTemplate> previousNodeTemplates=deploymentTopology.getNodeTemplates();
  ReflectionUtil.mergeObject(topology,deploymentTopology,"String_Node_Str");
  topologyCompositionService.processTopologyComposition(deploymentTopology);
  deploymentInputService.processInputProperties(deploymentTopology);
  deploymentInputService.processProviderDeploymentProperties(deploymentTopology);
  deploymentNodeSubstitutionService.processNodesSubstitution(deploymentTopology,previousNodeTemplates);
  save(deploymentTopology);
}
Program: 62210
Project: 62210
Buggy source:
private Map<String,AbstractPropertyValue> getInitialCapabilityProperties(String capabilityName,NodeTemplate nodeTemplate){
  Map<String,AbstractPropertyValue> properties=Maps.newHashMap();
  if (nodeTemplate.getCapabilities() != null && nodeTemplate.getCapabilities().get(capabilityName) != null) {
    if (nodeTemplate.getCapabilities().get(capabilityName).getProperties() != null) {
      properties=nodeTemplate.getCapabilities().get(capabilityName).getProperties();
    }
  }
  return properties;
}

Fixed version (ground truth):
private Map<String,AbstractPropertyValue> getInitialCapabilityProperties(String capabilityName,NodeTemplate nodeTemplate){
  Map<String,AbstractPropertyValue> properties=Maps.newHashMap();
  if (nodeTemplate.getCapabilities() != null && nodeTemplate.getCapabilities().get(capabilityName) != null && nodeTemplate.getCapabilities().get(capabilityName).getProperties() != null) {
    properties=nodeTemplate.getCapabilities().get(capabilityName).getProperties();
  }
  return properties;
}
Program: 62211
Project: 62211
Buggy source:
private Map<String,AbstractPropertyValue> getInitialRequirementProperties(String requirementName,NodeTemplate nodeTemplate){
  Map<String,AbstractPropertyValue> properties=Maps.newHashMap();
  if (nodeTemplate.getRequirements() != null && nodeTemplate.getRequirements().get(requirementName) != null) {
    if (nodeTemplate.getRequirements().get(requirementName).getProperties() != null) {
      properties=nodeTemplate.getRequirements().get(requirementName).getProperties();
    }
  }
  return properties;
}

Fixed version (ground truth):
private Map<String,AbstractPropertyValue> getInitialRequirementProperties(String requirementName,NodeTemplate nodeTemplate){
  Map<String,AbstractPropertyValue> properties=Maps.newHashMap();
  if (nodeTemplate.getRequirements() != null && nodeTemplate.getRequirements().get(requirementName) != null && nodeTemplate.getRequirements().get(requirementName).getProperties() != null) {
    properties=nodeTemplate.getRequirements().get(requirementName).getProperties();
  }
  return properties;
}
Program: 62212
Project: 62212
Buggy source:
private Map<String,AbstractPropertyValue> getInitialRelationshipProperties(String relationShipName,NodeTemplate nodeTemplate){
  Map<String,AbstractPropertyValue> properties=Maps.newHashMap();
  if (nodeTemplate.getRelationships() != null && nodeTemplate.getRelationships().get(relationShipName) != null) {
    if (nodeTemplate.getRelationships().get(relationShipName).getProperties() != null) {
      properties=nodeTemplate.getRelationships().get(relationShipName).getProperties();
    }
  }
  return properties;
}

Fixed version (ground truth):
private Map<String,AbstractPropertyValue> getInitialRelationshipProperties(String relationShipName,NodeTemplate nodeTemplate){
  Map<String,AbstractPropertyValue> properties=Maps.newHashMap();
  if (nodeTemplate.getRelationships() != null && nodeTemplate.getRelationships().get(relationShipName) != null && nodeTemplate.getRelationships().get(relationShipName).getProperties() != null) {
    properties=nodeTemplate.getRelationships().get(relationShipName).getProperties();
  }
  return properties;
}
Program: 62213
Project: 62213
Buggy source:
/** 
 * Checks if the type of a LocationResourceTemplate is matching the expected type.
 * @param nodeTemplate The node template to match.
 * @param candidateType The type of the candidate node.
 * @param candidate The candidate location resource.
 * @return True if the candidate type matches the node template type, false if not.
 */
private boolean isCandidateTypeValid(NodeTemplate nodeTemplate,LocationResourceTemplate candidate,NodeType candidateType){
  return candidateType.getElementId().equals(nodeTemplate.getType()) || (candidateType.getDerivedFrom() != null && candidateType.getDerivedFrom().contains(nodeTemplate.getType()));
}

Fixed version (ground truth):
/** 
 * Checks if the type of a LocationResourceTemplate is matching the expected type.
 * @param nodeTemplate The node template to match.
 * @param candidateType The type of the candidate node.
 * @return True if the candidate type matches the node template type, false if not.
 */
private boolean isCandidateTypeValid(NodeTemplate nodeTemplate,NodeType candidateType){
  return candidateType.getElementId().equals(nodeTemplate.getType()) || (candidateType.getDerivedFrom() != null && candidateType.getDerivedFrom().contains(nodeTemplate.getType()));
}
Program: 62214
Project: 62214
Buggy source:
private boolean isTemplatePropertiesMatchCandidateFilters(NodeTemplate nodeTemplate,MatchingConfiguration matchingConfiguration,LocationResourceTemplate candidate,NodeType candidateType,Map<String,CapabilityType> capabilityTypes){
  if (!isTemplatePropertiesMatchCandidateFilter(nodeTemplate.getProperties(),matchingConfiguration.getProperties(),candidate.getTemplate().getProperties(),candidateType.getProperties())) {
    return false;
  }
  if (matchingConfiguration.getCapabilities() == null) {
    return true;
  }
  for (  Map.Entry<String,MatchingFilterDefinition> capabilityMatchingFilterEntry : matchingConfiguration.getCapabilities().entrySet()) {
    FilterDefinition filterDefinition=new FilterDefinition();
    Capability candidateCapability=candidate.getTemplate().getCapabilities().get(capabilityMatchingFilterEntry.getKey());
    CapabilityType capabilityType=capabilityTypes.get(candidateCapability.getType());
    Capability templateCapability=nodeTemplate.getCapabilities().get(capabilityMatchingFilterEntry.getKey());
    if (templateCapability != null && !isTemplatePropertiesMatchCandidateFilter(templateCapability.getProperties(),capabilityMatchingFilterEntry.getValue().getProperties(),candidateCapability.getProperties(),capabilityType.getProperties())) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean isTemplatePropertiesMatchCandidateFilters(NodeTemplate nodeTemplate,MatchingConfiguration matchingConfiguration,LocationResourceTemplate candidate,NodeType candidateType,Map<String,CapabilityType> capabilityTypes){
  if (!isTemplatePropertiesMatchCandidateFilter(nodeTemplate.getProperties(),matchingConfiguration.getProperties(),candidate.getTemplate().getProperties(),candidateType.getProperties())) {
    return false;
  }
  if (matchingConfiguration.getCapabilities() == null) {
    return true;
  }
  for (  Map.Entry<String,MatchingFilterDefinition> capabilityMatchingFilterEntry : matchingConfiguration.getCapabilities().entrySet()) {
    Capability candidateCapability=candidate.getTemplate().getCapabilities().get(capabilityMatchingFilterEntry.getKey());
    CapabilityType capabilityType=capabilityTypes.get(candidateCapability.getType());
    Capability templateCapability=nodeTemplate.getCapabilities().get(capabilityMatchingFilterEntry.getKey());
    if (templateCapability != null && !isTemplatePropertiesMatchCandidateFilter(templateCapability.getProperties(),capabilityMatchingFilterEntry.getValue().getProperties(),candidateCapability.getProperties(),capabilityType.getProperties())) {
      return false;
    }
  }
  return true;
}
Program: 62215
Project: 62215
Buggy source:
/** 
 * Match a node against the on demand resources provided by a location.
 * @param nodeTemplate The node template to match.
 * @param nodeType The node type that defines the type of the node template to match.
 * @param locationResources The resources configured for the location against which we are matching the nodes.
 */
private List<LocationResourceTemplate> matchedOnDemands(NodeTemplate nodeTemplate,NodeType nodeType,LocationResources locationResources,Map<String,MatchingConfiguration> matchingConfigurations){
  List<LocationResourceTemplate> matchingResults=Lists.newArrayList();
  List<LocationResourceTemplate> candidates=locationResources.getNodeTemplates();
  for (  LocationResourceTemplate candidate : candidates) {
    String candidateTypeName=candidate.getTemplate().getType();
    NodeType candidateType=locationResources.getNodeTypes().get(candidateTypeName);
    if (isValidCandidate(nodeTemplate,nodeType,candidate,candidateType,locationResources.getCapabilityTypes(),matchingConfigurations)) {
      matchingResults.add(candidate);
    }
  }
  return matchingResults;
}

Fixed version (ground truth):
/** 
 * Match a node against the on demand resources provided by a location.
 * @param nodeTemplate The node template to match.
 * @param nodeType The node type that defines the type of the node template to match.
 * @param locationResources The resources configured for the location against which we are matching the nodes.
 */
private List<LocationResourceTemplate> matchedOnDemands(NodeTemplate nodeTemplate,NodeType nodeType,LocationResources locationResources,Map<String,MatchingConfiguration> matchingConfigurations){
  List<LocationResourceTemplate> matchingResults=Lists.newArrayList();
  List<LocationResourceTemplate> candidates=locationResources.getNodeTemplates();
  for (  LocationResourceTemplate candidate : candidates) {
    String candidateTypeName=candidate.getTemplate().getType();
    NodeType candidateType=locationResources.getNodeTypes().get(candidateTypeName);
    if (isValidCandidate(nodeTemplate,candidate,candidateType,locationResources.getCapabilityTypes(),matchingConfigurations)) {
      matchingResults.add(candidate);
    }
  }
  return matchingResults;
}
Program: 62217
Project: 62217
Buggy source:
/** 
 * Checks if the type of a LocationResourceTemplate is matching the expected type.
 * @param nodeTemplate The node template to match.
 * @param nodeType The type of the node template to match.
 * @param candidateType The type of the candidate node.
 * @param candidate The candidate location resource.
 * @param capabilityTypes Map of capability types that may be used by the candidateType.
 * @return True if the candidate is a valid match for the node template.
 */
private boolean isValidCandidate(NodeTemplate nodeTemplate,NodeType nodeType,LocationResourceTemplate candidate,NodeType candidateType,Map<String,CapabilityType> capabilityTypes,Map<String,MatchingConfiguration> matchingConfigurations){
  if (!isCandidateTypeValid(nodeTemplate,candidate,candidateType)) {
    return false;
  }
  if (matchingConfigurations == null) {
    return false;
  }
  MatchingConfiguration matchingConfiguration=matchingConfigurations.get(candidateType.getElementId());
  if (matchingConfiguration == null) {
    return true;
  }
  return isTemplatePropertiesMatchCandidateFilters(nodeTemplate,matchingConfiguration,candidate,candidateType,capabilityTypes);
}

Fixed version (ground truth):
/** 
 * Checks if the type of a LocationResourceTemplate is matching the expected type.
 * @param nodeTemplate The node template to match.
 * @param candidateType The type of the candidate node.
 * @param candidate The candidate location resource.
 * @param capabilityTypes Map of capability types that may be used by the candidateType.
 * @return True if the candidate is a valid match for the node template.
 */
private boolean isValidCandidate(NodeTemplate nodeTemplate,LocationResourceTemplate candidate,NodeType candidateType,Map<String,CapabilityType> capabilityTypes,Map<String,MatchingConfiguration> matchingConfigurations){
  if (!isCandidateTypeValid(nodeTemplate,candidateType)) {
    return false;
  }
  if (matchingConfigurations == null) {
    return false;
  }
  MatchingConfiguration matchingConfiguration=matchingConfigurations.get(candidateType.getElementId());
  if (matchingConfiguration == null) {
    return true;
  }
  return isTemplatePropertiesMatchCandidateFilters(nodeTemplate,matchingConfiguration,candidate,candidateType,capabilityTypes);
}
Program: 62218
Project: 62218
Buggy source:
@Override public long getFileLength(String id){
  File f=resolveFile(id).toFile();
  try {
  }
  finally {
  }
  return resolveFile(id).toFile().length();
}

Fixed version (ground truth):
@Override public long getFileLength(String id){
  return resolveFile(id).toFile().length();
}
Program: 62219
Project: 62219
Buggy source:
@SneakyThrows private boolean isToscaFile(Path path){
  if (isYamlFile(path.getFileName())) {
    if (readFirstLine(path).startsWith("String_Node_Str")) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@SneakyThrows private boolean isToscaFile(Path path){
  if (isYamlFile(path.getFileName()) && readFirstLine(path).startsWith("String_Node_Str")) {
    return true;
  }
  return false;
}
Program: 62220
Project: 62220
Buggy source:
/** 
 * Update the deployment topology's input and save it. This should always be called when the deployment setup has changed
 * @param deploymentTopology the the deployment topology
 */
public void updateDeploymentTopologyInputsAndSave(DeploymentTopology deploymentTopology){
  ApplicationEnvironment environment=appEnvironmentServices.getOrFail(deploymentTopology.getEnvironmentId());
  Topology topology=topologyServiceCore.getOrFail(deploymentTopology.getInitialTopologyId());
  deploymentInputService.processInputProperties(deploymentTopology);
  deploymentInputService.processProviderDeploymentProperties(deploymentTopology);
  save(deploymentTopology);
}

Fixed version (ground truth):
/** 
 * Update the deployment topology's input and save it. This should always be called when the deployment setup has changed
 * @param deploymentTopology the the deployment topology
 */
public void updateDeploymentTopologyInputsAndSave(DeploymentTopology deploymentTopology){
  deploymentInputService.processInputProperties(deploymentTopology);
  deploymentInputService.processProviderDeploymentProperties(deploymentTopology);
  save(deploymentTopology);
}
Program: 62221
Project: 62221
Buggy source:
private boolean mustRemoveApplicationUserRole(Set<String> applicationRoles,List<Set<String>> allEnvironmentRoles){
  if (applicationRoles == null || applicationRoles.isEmpty()) {
    return false;
  }
  int appUserCount=applicationRoles.contains(ApplicationRole.APPLICATION_USER.toString()) ? 1 : 0;
  if (applicationRoles.size() > appUserCount) {
    return false;
  }
  for (  Set<String> environmentRoles : allEnvironmentRoles) {
    if (environmentRoles != null && environmentRoles.size() > 0) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean mustRemoveApplicationUserRole(Set<String> applicationRoles,List<Set<String>> allEnvironmentRoles){
  if (applicationRoles == null || applicationRoles.isEmpty()) {
    return false;
  }
  int appUserCount=applicationRoles.contains(ApplicationRole.APPLICATION_USER.toString()) ? 1 : 0;
  if (applicationRoles.size() > appUserCount) {
    return false;
  }
  for (  Set<String> environmentRoles : allEnvironmentRoles) {
    if (environmentRoles != null && !environmentRoles.isEmpty()) {
      return false;
    }
  }
  return true;
}
Program: 62222
Project: 62222
Buggy source:
@Override public void addRelationship(Workflow wf,String nodeId,NodeTemplate nodeTemplate,RelationshipTemplate relationshipTemplate,TopologyContext toscaTypeFinder){
  RelationshipType indexedRelationshipType=toscaTypeFinder.findElement(RelationshipType.class,relationshipTemplate.getType());
  String targetId=relationshipTemplate.getTarget();
  boolean targetIsNative=WorkflowUtils.isNativeOrSubstitutionNode(targetId,toscaTypeFinder);
  if (targetIsNative || WorkflowUtils.isOfType(indexedRelationshipType,NormativeRelationshipConstants.HOSTED_ON)) {
    String parentId=WorkflowUtils.getParentId(wf,nodeId,toscaTypeFinder);
    NodeActivityStep deletedSourceStep=WorkflowUtils.getStateStepByNode(wf,nodeId,ToscaNodeLifecycleConstants.DELETED);
    AbstractStep targetStep=null;
    if (targetIsNative) {
      targetStep=WorkflowUtils.getDelegateWorkflowStepByNode(wf,targetId);
    }
 else {
      targetStep=WorkflowUtils.getStateStepByNode(wf,parentId,ToscaNodeLifecycleConstants.STOPPING);
    }
    WorkflowUtils.linkSteps(deletedSourceStep,targetStep);
  }
 else   if (WorkflowUtils.isOfType(indexedRelationshipType,NormativeRelationshipConstants.CONNECTS_TO)) {
    String volumeId=nodeId;
    NodeActivityStep targetStep=WorkflowUtils.getStateStepByNode(wf,targetId,ToscaNodeLifecycleConstants.STOPPING);
    NodeActivityStep sourceStep=WorkflowUtils.getStateStepByNode(wf,nodeId,ToscaNodeLifecycleConstants.STOPPED);
    WorkflowUtils.linkSteps(sourceStep,targetStep);
  }
}

Fixed version (ground truth):
@Override public void addRelationship(Workflow wf,String nodeId,NodeTemplate nodeTemplate,RelationshipTemplate relationshipTemplate,TopologyContext toscaTypeFinder){
  RelationshipType indexedRelationshipType=toscaTypeFinder.findElement(RelationshipType.class,relationshipTemplate.getType());
  String targetId=relationshipTemplate.getTarget();
  boolean targetIsNative=WorkflowUtils.isNativeOrSubstitutionNode(targetId,toscaTypeFinder);
  if (targetIsNative || WorkflowUtils.isOfType(indexedRelationshipType,NormativeRelationshipConstants.HOSTED_ON)) {
    String parentId=WorkflowUtils.getParentId(wf,nodeId,toscaTypeFinder);
    NodeActivityStep deletedSourceStep=WorkflowUtils.getStateStepByNode(wf,nodeId,ToscaNodeLifecycleConstants.DELETED);
    AbstractStep targetStep=null;
    if (targetIsNative) {
      targetStep=WorkflowUtils.getDelegateWorkflowStepByNode(wf,targetId);
    }
 else {
      targetStep=WorkflowUtils.getStateStepByNode(wf,parentId,ToscaNodeLifecycleConstants.STOPPING);
    }
    WorkflowUtils.linkSteps(deletedSourceStep,targetStep);
  }
 else   if (WorkflowUtils.isOfType(indexedRelationshipType,NormativeRelationshipConstants.CONNECTS_TO)) {
    NodeActivityStep targetStep=WorkflowUtils.getStateStepByNode(wf,targetId,ToscaNodeLifecycleConstants.STOPPING);
    NodeActivityStep sourceStep=WorkflowUtils.getStateStepByNode(wf,nodeId,ToscaNodeLifecycleConstants.STOPPED);
    WorkflowUtils.linkSteps(sourceStep,targetStep);
  }
}
Program: 62224
Project: 62224
Buggy source:
@Override public void process(AbstractArtifact instance){
  ArchiveRoot archiveRoot=ParsingContextExecution.getRootObj();
  if (StringUtils.isBlank(instance.getArchiveName())) {
    instance.setArchiveName(archiveRoot.getArchive().getName());
    instance.setArchiveVersion(archiveRoot.getArchive().getVersion());
  }
  Node node=ParsingContextExecution.getObjectToNodeMap().get(instance);
  if (instance.getArtifactType() == null) {
    instance.setArtifactType(getArtifactTypeByExtension(instance.getArtifactRef(),node,archiveRoot));
  }
 else {
    referencePostProcessor.process(new ReferencePostProcessor.TypeReference(instance.getArtifactType(),ArtifactType.class));
  }
  if (instance.getArtifactRepository() != null) {
    RepositoryDefinition repositoryDefinition=archiveRoot.getRepositories() != null ? archiveRoot.getRepositories().get(instance.getArtifactRepository()) : null;
    if (repositoryDefinition == null) {
      ParsingContextExecution.getParsingErrors().add(new ParsingError(ErrorCode.UNKNOWN_REPOSITORY,"String_Node_Str",node.getStartMark(),"String_Node_Str",node.getEndMark(),instance.getArtifactRepository()));
    }
 else {
      instance.setRepositoryURL(repositoryDefinition.getUrl());
      instance.setRepositoryCredential(repositoryDefinition.getCredential() != null ? repositoryDefinition.getCredential().getValue() : null);
      instance.setRepositoryName(repositoryDefinition.getId());
      instance.setArtifactRepository(repositoryDefinition.getType());
    }
  }
}

Fixed version (ground truth):
@Override public void process(AbstractArtifact instance){
  ArchiveRoot archiveRoot=ParsingContextExecution.getRootObj();
  if (StringUtils.isBlank(instance.getArchiveName())) {
    instance.setArchiveName(archiveRoot.getArchive().getName());
    instance.setArchiveVersion(archiveRoot.getArchive().getVersion());
  }
  Node node=ParsingContextExecution.getObjectToNodeMap().get(instance);
  if (instance.getArtifactType() == null) {
    instance.setArtifactType(getArtifactTypeByExtension(instance.getArtifactRef(),node,archiveRoot));
  }
 else {
    referencePostProcessor.process(new ReferencePostProcessor.TypeReference(instance,instance.getArtifactType(),ArtifactType.class));
  }
  if (instance.getArtifactRepository() != null) {
    RepositoryDefinition repositoryDefinition=archiveRoot.getRepositories() != null ? archiveRoot.getRepositories().get(instance.getArtifactRepository()) : null;
    if (repositoryDefinition == null) {
      ParsingContextExecution.getParsingErrors().add(new ParsingError(ErrorCode.UNKNOWN_REPOSITORY,"String_Node_Str",node.getStartMark(),"String_Node_Str",node.getEndMark(),instance.getArtifactRepository()));
    }
 else {
      instance.setRepositoryURL(repositoryDefinition.getUrl());
      instance.setRepositoryCredential(repositoryDefinition.getCredential() != null ? repositoryDefinition.getCredential().getValue() : null);
      instance.setRepositoryName(repositoryDefinition.getId());
      instance.setArtifactRepository(repositoryDefinition.getType());
    }
  }
}
Program: 62225
Project: 62225
Buggy source:
@Override public void process(Map.Entry<String,Capability> instance){
  referencePostProcessor.process(new ReferencePostProcessor.TypeReference(instance.getValue().getType(),CapabilityType.class));
  CapabilityType capabilityType=ToscaContext.get(CapabilityType.class,instance.getValue().getType());
  if (capabilityType == null) {
    return;
  }
  propertyValueChecker.checkProperties(capabilityType,instance.getValue().getProperties(),instance.getKey());
}

Fixed version (ground truth):
@Override public void process(Map.Entry<String,Capability> instance){
  referencePostProcessor.process(new ReferencePostProcessor.TypeReference(instance.getValue(),instance.getValue().getType(),CapabilityType.class));
  CapabilityType capabilityType=ToscaContext.get(CapabilityType.class,instance.getValue().getType());
  if (capabilityType == null) {
    return;
  }
  propertyValueChecker.checkProperties(capabilityType,instance.getValue().getProperties(),instance.getKey());
}
Program: 62227
Project: 62227
Buggy source:
private String buildRelationShipTemplateName(RelationshipTemplate relationshipTemplate){
  String value=relationshipTemplate.getType();
  if (value.contains("String_Node_Str")) {
    value=value.substring(value.lastIndexOf("String_Node_Str") + 1);
  }
  value=StringUtils.uncapitalize(value);
  value=value + StringUtils.capitalize(relationshipTemplate.getTarget());
  return value;
}

Fixed version (ground truth):
private String buildRelationShipTemplateName(RelationshipTemplate relationshipTemplate){
  String value=relationshipTemplate.getType();
  if (value == null) {
    return value;
  }
  if (value.contains("String_Node_Str")) {
    value=value.substring(value.lastIndexOf("String_Node_Str") + 1);
  }
  value=StringUtils.uncapitalize(value);
  value=value + StringUtils.capitalize(relationshipTemplate.getTarget());
  return value;
}
Program: 62228
Project: 62228
Buggy source:
@Override public void process(TypeReference typeReference){
  for (  Class<? extends AbstractInheritableToscaType> clazz : typeReference.classes) {
    AbstractInheritableToscaType reference=ToscaContext.get(clazz,typeReference.getKey());
    if (reference != null) {
      return;
    }
  }
  Node node=ParsingContextExecution.getObjectToNodeMap().get(typeReference.getKey());
  if (node == null) {
    log.info("String_Node_Str");
  }
 else {
    ParsingContextExecution.getParsingErrors().add(new ParsingError(ErrorCode.TYPE_NOT_FOUND,"String_Node_Str",node.getStartMark(),"String_Node_Str",node.getEndMark(),typeReference.getKey()));
  }
}

Fixed version (ground truth):
@Override public void process(TypeReference typeReference){
  for (  Class<? extends AbstractInheritableToscaType> clazz : typeReference.classes) {
    AbstractInheritableToscaType reference=ToscaContext.get(clazz,typeReference.getKey());
    if (reference != null) {
      return;
    }
  }
  Node node=ParsingContextExecution.getObjectToNodeMap().get(typeReference.getKey());
  if (node == null) {
    node=ParsingContextExecution.getObjectToNodeMap().get(typeReference.getParent());
    if (node == null) {
      log.info("String_Node_Str");
    }
 else {
      ParsingContextExecution.getParsingErrors().add(new ParsingError(ErrorCode.TYPE_NOT_FOUND,"String_Node_Str",node.getStartMark(),"String_Node_Str",node.getEndMark(),typeReference.getKey()));
    }
  }
 else {
    ParsingContextExecution.getParsingErrors().add(new ParsingError(ErrorCode.TYPE_NOT_FOUND,"String_Node_Str",node.getStartMark(),"String_Node_Str",node.getEndMark(),typeReference.getKey()));
  }
}
Program: 62229
Project: 62229
Buggy source:
public TypeReference(String key,Class<? extends AbstractInheritableToscaType>... classes){
  this.key=key;
  this.classes=classes;
}

Fixed version (ground truth):
public TypeReference(Object parent,String key,Class<? extends AbstractInheritableToscaType>... classes){
  this.key=key;
  this.classes=classes;
}
Program: 62231
Project: 62231
Buggy source:
@Override public void process(Map.Entry<String,Requirement> instance){
  String definitionVersion=ParsingContextExecution.getDefinitionVersion();
switch (definitionVersion) {
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
    capabilityOrNodeReferencePostProcessor.process(new ReferencePostProcessor.TypeReference(instance.getValue().getType()));
  break;
default :
capabilityReferencePostProcessor.process(new ReferencePostProcessor.TypeReference(instance.getValue().getType()));
break;
}
CapabilityType capabilityType=ToscaContext.get(CapabilityType.class,instance.getValue().getType());
propertyValueChecker.checkProperties(capabilityType,instance.getValue().getProperties(),instance.getKey());
}

Fixed version (ground truth):
@Override public void process(Map.Entry<String,Requirement> instance){
  String definitionVersion=ParsingContextExecution.getDefinitionVersion();
switch (definitionVersion) {
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
    capabilityOrNodeReferencePostProcessor.process(new ReferencePostProcessor.TypeReference(instance,instance.getValue().getType()));
  break;
default :
capabilityReferencePostProcessor.process(new ReferencePostProcessor.TypeReference(instance,instance.getValue().getType()));
break;
}
CapabilityType capabilityType=ToscaContext.get(CapabilityType.class,instance.getValue().getType());
propertyValueChecker.checkProperties(capabilityType,instance.getValue().getProperties(),instance.getKey());
}
Program: 62232
Project: 62232
Buggy source:
@Override public void process(SubstitutionMapping instance){
  if (instance == null) {
    return;
  }
  referencePostProcessor.process(new ReferencePostProcessor.TypeReference(instance.getSubstitutionType().getElementId(),NodeType.class));
  NodeType nodeType=ToscaContext.get(NodeType.class,instance.getSubstitutionType().getElementId());
  instance.setSubstitutionType(nodeType);
}

Fixed version (ground truth):
@Override public void process(SubstitutionMapping instance){
  if (instance == null) {
    return;
  }
  referencePostProcessor.process(new ReferencePostProcessor.TypeReference(instance.getSubstitutionType(),instance.getSubstitutionType().getElementId(),NodeType.class));
  NodeType nodeType=ToscaContext.get(NodeType.class,instance.getSubstitutionType().getElementId());
  instance.setSubstitutionType(nodeType);
}
Program: 62234
Project: 62234
Buggy source:
@Override public Resource resolveResource(HttpServletRequest request,String requestPath,List<? extends Resource> locations,ResourceResolverChain chain){
  log.debug("String_Node_Str");
  ServletWebRequest webRequest=new ServletWebRequest(request);
  Map uriTemplateVars=(Map)webRequest.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE,0);
  String csarName=(String)uriTemplateVars.get("String_Node_Str");
  String csarVersion=(String)uriTemplateVars.get("String_Node_Str");
  if (csarAuthorizationFilter == null) {
    throw new NotFoundException("String_Node_Str");
  }
 else {
    csarAuthorizationFilter.checkReadAccess(new Csar(csarName,csarVersion));
  }
  return chain.resolveResource(request,csarName + "String_Node_Str" + csarVersion+ "String_Node_Str"+ requestPath,locations);
}

Fixed version (ground truth):
@Override public Resource resolveResource(HttpServletRequest request,String requestPath,List<? extends Resource> locations,ResourceResolverChain chain){
  log.debug("String_Node_Str");
  ServletWebRequest webRequest=new ServletWebRequest(request);
  Map uriTemplateVars=(Map)webRequest.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE,0);
  String csarName=(String)uriTemplateVars.get("String_Node_Str");
  String csarVersion=(String)uriTemplateVars.get("String_Node_Str");
  if (csarAuthorizationFilter == null || csarService == null) {
    throw new NotFoundException("String_Node_Str");
  }
 else {
    csarAuthorizationFilter.checkReadAccess(csarService.getOrFail(csarName,csarVersion));
  }
  return chain.resolveResource(request,csarName + "String_Node_Str" + csarVersion+ "String_Node_Str"+ requestPath,locations);
}
Program: 62235
Project: 62235
Buggy source:
@PreDestroy public void unregister(){
  log.info("String_Node_Str");
  configuration.setCsarAuthorizationFilter(null);
}

Fixed version (ground truth):
@PreDestroy public void unregister(){
  log.info("String_Node_Str");
  configuration.setCsarAuthorizationFilter(null);
  configuration.setCsarService(null);
}
Program: 62236
Project: 62236
Buggy source:
@PostConstruct public void register(){
  log.info("String_Node_Str");
  configuration.setCsarAuthorizationFilter(csarAuthorizationFilter);
}

Fixed version (ground truth):
@PostConstruct public void register(){
  log.info("String_Node_Str");
  configuration.setCsarAuthorizationFilter(csarAuthorizationFilter);
  configuration.setCsarService(csarService);
}
Program: 62238
Project: 62238
Buggy source:
/** 
 * Find replacements nodes for a node template
 * @param nodeTemplateName the node to search for replacements
 * @param topology the topology
 * @return all possible replacement types for this node
 */
@SneakyThrows(IOException.class) public NodeType[] findReplacementForNode(String nodeTemplateName,Topology topology){
  NodeTemplate nodeTemplate=topology.getNodeTemplates().get(nodeTemplateName);
  Map<String,Map<String,Set<String>>> nodeTemplatesToFilters=Maps.newHashMap();
  Entry<String,NodeTemplate> nodeTempEntry=Maps.immutableEntry(nodeTemplateName,nodeTemplate);
  NodeType indexedNodeType=toscaTypeSearchService.getRequiredElementInDependencies(NodeType.class,nodeTemplate.getType(),topology.getDependencies());
  processNodeTemplate(topology,nodeTempEntry,nodeTemplatesToFilters);
  List<SuggestionsTask> topoTasks=searchForNodeTypes(nodeTemplatesToFilters,MapUtil.newHashMap(new String[]{nodeTemplateName},new NodeType[]{indexedNodeType}));
  if (CollectionUtils.isEmpty(topoTasks)) {
    return null;
  }
  return topoTasks.get(0).getSuggestedNodeTypes();
}

Fixed version (ground truth):
/** 
 * Find replacements nodes for a node template
 * @param nodeTemplateName the node to search for replacements
 * @param topology the topology
 * @return all possible replacement types for this node
 */
@SneakyThrows(IOException.class) public NodeType[] findReplacementForNode(String nodeTemplateName,Topology topology){
  NodeTemplate nodeTemplate=topology.getNodeTemplates().get(nodeTemplateName);
  Map<String,Map<String,Set<String>>> nodeTemplatesToFilters=Maps.newHashMap();
  Entry<String,NodeTemplate> nodeTempEntry=Maps.immutableEntry(nodeTemplateName,nodeTemplate);
  NodeType indexedNodeType=toscaTypeSearchService.getRequiredElementInDependencies(NodeType.class,nodeTemplate.getType(),topology.getDependencies());
  processNodeTemplate(topology,nodeTempEntry,nodeTemplatesToFilters);
  List<SuggestionsTask> topoTasks=searchForNodeTypes(topology.getWorkspace(),nodeTemplatesToFilters,MapUtil.newHashMap(new String[]{nodeTemplateName},new NodeType[]{indexedNodeType}));
  if (CollectionUtils.isEmpty(topoTasks)) {
    return null;
  }
  return topoTasks.get(0).getSuggestedNodeTypes();
}
Program: 62239
Project: 62239
Buggy source:
/** 
 * Find replacements components for abstract nodes in a Topology
 */
@SneakyThrows({IOException.class}) public List<SuggestionsTask> findReplacementForAbstracts(Topology topology){
  Map<String,NodeType> nodeTempNameToAbstractIndexedNodeTypes=topologyServiceCore.getIndexedNodeTypesFromTopology(topology,true,true,true);
  Map<String,Map<String,Set<String>>> nodeTemplatesToFilters=Maps.newHashMap();
  for (  Map.Entry<String,NodeType> idntEntry : nodeTempNameToAbstractIndexedNodeTypes.entrySet()) {
    topologyService.processNodeTemplate(topology,Maps.immutableEntry(idntEntry.getKey(),topology.getNodeTemplates().get(idntEntry.getKey())),nodeTemplatesToFilters);
  }
  return topologyService.searchForNodeTypes(nodeTemplatesToFilters,nodeTempNameToAbstractIndexedNodeTypes);
}

Fixed version (ground truth):
/** 
 * Find replacements components for abstract nodes in a Topology
 */
@SneakyThrows({IOException.class}) public List<SuggestionsTask> findReplacementForAbstracts(Topology topology){
  Map<String,NodeType> nodeTempNameToAbstractIndexedNodeTypes=topologyServiceCore.getIndexedNodeTypesFromTopology(topology,true,true,true);
  Map<String,Map<String,Set<String>>> nodeTemplatesToFilters=Maps.newHashMap();
  for (  Map.Entry<String,NodeType> idntEntry : nodeTempNameToAbstractIndexedNodeTypes.entrySet()) {
    topologyService.processNodeTemplate(topology,Maps.immutableEntry(idntEntry.getKey(),topology.getNodeTemplates().get(idntEntry.getKey())),nodeTemplatesToFilters);
  }
  return topologyService.searchForNodeTypes(topology.getWorkspace(),nodeTemplatesToFilters,nodeTempNameToAbstractIndexedNodeTypes);
}
Program: 62241
Project: 62241
Buggy source:
@Override public void save(Csar csar){
  csar.setImportDate(new Date());
  Set<CSARDependency> mergedDependencies=null;
  if (csar.getDependencies() != null) {
    mergedDependencies=Sets.newHashSet(csar.getDependencies());
    for (    CSARDependency dependency : csar.getDependencies()) {
      Csar dependencyCsar=get(dependency.getName(),dependency.getVersion());
      if (dependencyCsar != null && dependencyCsar.getDependencies() != null) {
        mergedDependencies.addAll(dependencyCsar.getDependencies());
      }
    }
  }
  csar.setDependencies(mergedDependencies,true);
  this.csarDAO.save(csar);
}

Fixed version (ground truth):
@Override public void save(Csar csar){
  csar.setImportDate(new Date());
  Set<CSARDependency> mergedDependencies=null;
  if (csar.getDependencies() != null) {
    mergedDependencies=Sets.newHashSet(csar.getDependencies());
    for (    CSARDependency dependency : csar.getDependencies()) {
      Csar dependencyCsar=get(dependency.getName(),dependency.getVersion());
      if (dependencyCsar != null && dependencyCsar.getDependencies() != null) {
        mergedDependencies.addAll(dependencyCsar.getDependencies());
      }
    }
  }
  csar.setDependencies(mergedDependencies);
  this.csarDAO.save(csar);
}
Program: 62242
Project: 62242
Buggy source:
private void doSave() throws IOException {
  EditionContext context=EditionContextManager.get();
  if (context.getLastOperationIndex() <= context.getLastSavedOperationIndex()) {
    return;
  }
  StringBuilder commitMessage=new StringBuilder();
  for (int i=context.getLastSavedOperationIndex() + 1; i <= context.getLastOperationIndex(); i++) {
    AbstractEditorOperation operation=context.getOperations().get(i);
    IEditorOperationProcessor<?> processor=(IEditorOperationProcessor)processorMap.get(operation.getClass());
    if (processor instanceof IEditorCommitableProcessor) {
      ((IEditorCommitableProcessor)processor).beforeCommit(operation);
    }
    commitMessage.append(operation.getAuthor()).append("String_Node_Str").append(operation.commitMessage()).append("String_Node_Str");
  }
  saveYamlFile();
  Topology topology=EditionContextManager.getTopology();
  topologyServiceCore.save(topology);
  topologySubstitutionServive.updateSubstitutionType(topology,EditionContextManager.getCsar());
  repositoryService.commit(EditionContextManager.get().getCsar(),commitMessage.toString());
  context.setOperations(Lists.newArrayList(context.getOperations().subList(context.getLastOperationIndex() + 1,context.getOperations().size())));
  context.setLastOperationIndex(-1);
}

Fixed version (ground truth):
private void doSave() throws IOException {
  EditionContext context=EditionContextManager.get();
  if (context.getLastOperationIndex() <= context.getLastSavedOperationIndex()) {
    return;
  }
  StringBuilder commitMessage=new StringBuilder();
  for (int i=context.getLastSavedOperationIndex() + 1; i <= context.getLastOperationIndex(); i++) {
    AbstractEditorOperation operation=context.getOperations().get(i);
    IEditorOperationProcessor<?> processor=(IEditorOperationProcessor)processorMap.get(operation.getClass());
    if (processor instanceof IEditorCommitableProcessor) {
      ((IEditorCommitableProcessor)processor).beforeCommit(operation);
    }
    commitMessage.append(operation.getAuthor()).append("String_Node_Str").append(operation.commitMessage()).append("String_Node_Str");
  }
  saveYamlFile();
  Topology topology=EditionContextManager.getTopology();
  topologyServiceCore.save(topology);
  topologySubstitutionServive.updateSubstitutionType(topology,EditionContextManager.getCsar());
  csarService.setDependencies(topology.getId(),topology.getDependencies());
  repositoryService.commit(EditionContextManager.get().getCsar(),commitMessage.toString());
  context.setOperations(Lists.newArrayList(context.getOperations().subList(context.getLastOperationIndex() + 1,context.getOperations().size())));
  context.setLastOperationIndex(-1);
}
Program: 62244
Project: 62244
Buggy source:
@Override public void process(ChangeDependencyVersionOperation operation){
  Topology topology=EditionContextManager.getTopology();
  Set<CSARDependency> topologyDependencies=Sets.newHashSet(topology.getDependencies());
  Iterator<CSARDependency> topologyDependencyIterator=topologyDependencies.iterator();
  while (topologyDependencyIterator.hasNext()) {
    CSARDependency dependency=topologyDependencyIterator.next();
    if (dependency.getName().equals(operation.getDependencyName())) {
      topologyDependencyIterator.remove();
    }
  }
  CSARDependency newDependency=new CSARDependency(operation.getDependencyName(),operation.getDependencyVersion());
  topologyDependencies.add(newDependency);
  topology.setDependencies(topologyDependencies);
  ToscaContext.get().updateDependency(newDependency);
  Set<CSARDependency> dependencies=Sets.newHashSet(newDependency);
  List<AbstractEditorOperation> recoveringOperations=recoveryHelperService.buildRecoveryOperations(topology,dependencies);
  recoveryHelperService.processRecoveryOperations(topology,recoveringOperations);
  topologyService.rebuildDependencies(topology);
  csarService.setDependencies(topology.getId(),topology.getDependencies());
}

Fixed version (ground truth):
@Override public void process(ChangeDependencyVersionOperation operation){
  Topology topology=EditionContextManager.getTopology();
  Set<CSARDependency> topologyDependencies=Sets.newHashSet(topology.getDependencies());
  Iterator<CSARDependency> topologyDependencyIterator=topologyDependencies.iterator();
  while (topologyDependencyIterator.hasNext()) {
    CSARDependency dependency=topologyDependencyIterator.next();
    if (dependency.getName().equals(operation.getDependencyName())) {
      topologyDependencyIterator.remove();
    }
  }
  CSARDependency newDependency=new CSARDependency(operation.getDependencyName(),operation.getDependencyVersion());
  topologyDependencies.add(newDependency);
  topology.setDependencies(topologyDependencies);
  ToscaContext.get().updateDependency(newDependency);
  Set<CSARDependency> dependencies=Sets.newHashSet(newDependency);
  List<AbstractEditorOperation> recoveringOperations=recoveryHelperService.buildRecoveryOperations(topology,dependencies);
  recoveryHelperService.processRecoveryOperations(topology,recoveringOperations);
  topologyService.rebuildDependencies(topology);
}
Program: 62248
Project: 62248
Buggy source:
@Override public void process(AddSubstitutionTypeOperation operation){
  Topology topology=EditionContextManager.getTopology();
  if (Objects.equals(EditionContextManager.getCsar().getDelegateType(),ArchiveDelegateType.APPLICATION)) {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  if (topology.getSubstitutionMapping() == null) {
    topology.setSubstitutionMapping(new SubstitutionMapping());
  }
  NodeType nodeType=csarRepoSearchService.getElementInDependencies(NodeType.class,operation.getElementId(),topology.getDependencies());
  if (nodeType == null) {
    nodeType=csarRepoSearchService.findMostRecent(NodeType.class,operation.getElementId());
    Set<CSARDependency> oldDependencies=topology.getDependencies();
    topologyService.loadType(topology,nodeType);
    if (!Objects.equals(topology.getDependencies(),oldDependencies)) {
      csarService.setDependencies(topology.getId(),topology.getDependencies());
    }
  }
  topology.getSubstitutionMapping().setSubstitutionType(nodeType);
}

Fixed version (ground truth):
@Override public void process(AddSubstitutionTypeOperation operation){
  Topology topology=EditionContextManager.getTopology();
  if (Objects.equals(EditionContextManager.getCsar().getDelegateType(),ArchiveDelegateType.APPLICATION)) {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  if (topology.getSubstitutionMapping() == null) {
    topology.setSubstitutionMapping(new SubstitutionMapping());
  }
  NodeType nodeType=csarRepoSearchService.getElementInDependencies(NodeType.class,operation.getElementId(),topology.getDependencies());
  if (nodeType == null) {
    nodeType=csarRepoSearchService.findMostRecent(NodeType.class,operation.getElementId());
    Set<CSARDependency> oldDependencies=topology.getDependencies();
    topologyService.loadType(topology,nodeType);
  }
  topology.getSubstitutionMapping().setSubstitutionType(nodeType);
}
Program: 62249
Project: 62249
Buggy source:
@Override public void process(RemoveSubstitutionTypeOperation operation){
  Topology topology=EditionContextManager.getTopology();
  if (topology.getSubstitutionMapping() == null || topology.getSubstitutionMapping().getSubstitutionType() == null) {
    throw new NotFoundException("String_Node_Str");
  }
  NodeType substitutionType=topology.getSubstitutionMapping().getSubstitutionType();
  Csar csar=EditionContextManager.getCsar();
  Topology[] topologies=getTopologiesUsing(csar.getName(),csar.getName(),csar.getVersion());
  if (ArrayUtils.isNotEmpty(topologies)) {
    throw new DeleteReferencedObjectException("String_Node_Str");
  }
  Set<CSARDependency> oldDependencies=topology.getDependencies();
  topologyService.unloadType(topology,new String[]{substitutionType.getElementId()});
  if (!Objects.equals(topology.getDependencies(),oldDependencies)) {
    csarService.setDependencies(topology.getId(),topology.getDependencies());
  }
  topology.setSubstitutionMapping(null);
}

Fixed version (ground truth):
@Override public void process(RemoveSubstitutionTypeOperation operation){
  Topology topology=EditionContextManager.getTopology();
  if (topology.getSubstitutionMapping() == null || topology.getSubstitutionMapping().getSubstitutionType() == null) {
    throw new NotFoundException("String_Node_Str");
  }
  NodeType substitutionType=topology.getSubstitutionMapping().getSubstitutionType();
  Csar csar=EditionContextManager.getCsar();
  Topology[] topologies=getTopologiesUsing(csar.getName(),csar.getName(),csar.getVersion());
  if (ArrayUtils.isNotEmpty(topologies)) {
    throw new DeleteReferencedObjectException("String_Node_Str");
  }
  topologyService.unloadType(topology,new String[]{substitutionType.getElementId()});
  topology.setSubstitutionMapping(null);
}
Program: 62250
Project: 62250
Buggy source:
/** 
 * Merge the given dependencies with the current ones.
 * @param dependencies
 */
public void setDependencies(Set<CSARDependency> dependencies,boolean override){
  if (override) {
    this.dependencies=dependencies;
  }
 else {
    setDependencies(dependencies);
  }
}

Fixed version (ground truth):
/** 
 * Merge the given dependencies with the current ones.
 * @param dependencies
 */
public void setDependencies(Set<CSARDependency> dependencies){
  this.dependencies=dependencies;
}
Program: 62251
Project: 62251
Buggy source:
@Override public void checkWriteAccess(Csar csar){
  if (toscaTypeSearchService.hasTypes(csar.getName(),csar.getVersion())) {
    AuthorizationUtil.checkHasOneRoleIn(Role.COMPONENTS_MANAGER);
  }
  if (catalogService.exists(csar.getId())) {
    AuthorizationUtil.checkHasOneRoleIn(Role.ARCHITECT);
  }
}

Fixed version (ground truth):
@Override public void checkWriteAccess(Csar csar){
  if (toscaTypeSearchService.hasTypes(csar.getName(),csar.getVersion())) {
    AuthorizationUtil.checkHasOneRoleIn(Role.COMPONENTS_MANAGER);
  }
  if (topologyCatalogService.exists(csar.getId())) {
    AuthorizationUtil.checkHasOneRoleIn(Role.ARCHITECT);
  }
}
Program: 62252
Project: 62252
Buggy source:
/** 
 * Get the path of the expended directory in which the CSAR is stored.
 * @param name The name of the csar.
 * @param version The version of the CSAR
 * @return The path to the expended csar file.
 */
Path getExpandedCSAR(String name,String version);

Fixed version (ground truth):
/** 
 * Get the path of the expanded directory in which the CSAR is stored.
 * @param name The name of the csar.
 * @param version The version of the CSAR
 * @return The path to the expended csar file.
 */
Path getExpandedCSAR(String name,String version);