Program: 62358
Project: 62358
Buggy source:
@ApiOperation(value="String_Node_Str",notes="String_Node_Str") @RequestMapping(value="String_Node_Str",method=RequestMethod.PUT,produces=MediaType.APPLICATION_JSON_VALUE) @PreAuthorize("String_Node_Str") public RestResponse<TopologyDTO> resetDeploymentArtifact(@PathVariable String topologyId,@PathVariable String nodeTemplateName,@PathVariable String artifactId) throws IOException {
  Topology topology=topologyServiceCore.getOrFail(topologyId);
  topologyService.checkEditionAuthorizations(topology);
  topologyService.throwsErrorIfReleased(topology);
  Map<String,NodeTemplate> nodeTemplates=topologyServiceCore.getNodeTemplates(topology);
  NodeTemplate nodeTemplate=topologyServiceCore.getNodeTemplate(topologyId,nodeTemplateName,nodeTemplates);
  Map<String,DeploymentArtifact> artifacts=nodeTemplate.getArtifacts();
  if (artifacts == null) {
    throw new NotFoundException("String_Node_Str" + artifactId + "String_Node_Str");
  }
  DeploymentArtifact artifact=artifacts.get(artifactId);
  if (artifact == null) {
    throw new NotFoundException("String_Node_Str" + artifactId + "String_Node_Str");
  }
  String oldArtifactId=artifact.getArtifactRef();
  if (ArtifactRepositoryConstants.ALIEN_ARTIFACT_REPOSITORY.equals(artifact.getArtifactRepository())) {
    artifactRepository.deleteFile(oldArtifactId);
  }
  IndexedNodeType indexedNodeType=csarRepoSearch.getElementInDependencies(IndexedNodeType.class,nodeTemplate.getType(),topology.getDependencies());
  DeploymentArtifact baseArtifact=indexedNodeType.getArtifacts().get(artifactId);
  if (baseArtifact != null) {
    artifact.setArtifactRepository(null);
    artifact.setArtifactRef(baseArtifact.getArtifactRef());
    artifact.setArtifactName(baseArtifact.getArtifactName());
    topologyServiceCore.save(topology);
  }
 else {
    log.warn("String_Node_Str" + artifactId + "String_Node_Str"+ nodeTemplateName+ "String_Node_Str");
  }
  return RestResponseBuilder.<TopologyDTO>builder().data(topologyService.buildTopologyDTO(topology)).build();
}

Fixed version (ground truth):
@ApiOperation(value="String_Node_Str",notes="String_Node_Str") @RequestMapping(value="String_Node_Str",method=RequestMethod.PUT,produces=MediaType.APPLICATION_JSON_VALUE) @PreAuthorize("String_Node_Str") public RestResponse<TopologyDTO> resetDeploymentArtifact(@PathVariable String topologyId,@PathVariable String nodeTemplateName,@PathVariable String artifactId) throws IOException {
  Topology topology=topologyServiceCore.getOrFail(topologyId);
  topologyService.checkEditionAuthorizations(topology);
  topologyService.throwsErrorIfReleased(topology);
  Map<String,NodeTemplate> nodeTemplates=topologyServiceCore.getNodeTemplates(topology);
  NodeTemplate nodeTemplate=topologyServiceCore.getNodeTemplate(topologyId,nodeTemplateName,nodeTemplates);
  Map<String,DeploymentArtifact> artifacts=nodeTemplate.getArtifacts();
  if (artifacts == null) {
    throw new NotFoundException("String_Node_Str" + artifactId + "String_Node_Str");
  }
  DeploymentArtifact artifact=artifacts.get(artifactId);
  if (artifact == null) {
    throw new NotFoundException("String_Node_Str" + artifactId + "String_Node_Str");
  }
  String oldArtifactId=artifact.getArtifactRef();
  if (ArtifactRepositoryConstants.ALIEN_ARTIFACT_REPOSITORY.equals(artifact.getArtifactRepository()) && StringUtils.isNotBlank(oldArtifactId)) {
    artifactRepository.deleteFile(oldArtifactId);
  }
  IndexedNodeType indexedNodeType=csarRepoSearch.getElementInDependencies(IndexedNodeType.class,nodeTemplate.getType(),topology.getDependencies());
  DeploymentArtifact baseArtifact=indexedNodeType.getArtifacts().get(artifactId);
  if (baseArtifact != null) {
    artifact.setArtifactRepository(null);
    artifact.setArtifactRef(baseArtifact.getArtifactRef());
    artifact.setArtifactName(baseArtifact.getArtifactName());
    topologyServiceCore.save(topology);
  }
 else {
    log.warn("String_Node_Str" + artifactId + "String_Node_Str"+ nodeTemplateName+ "String_Node_Str");
  }
  return RestResponseBuilder.<TopologyDTO>builder().data(topologyService.buildTopologyDTO(topology)).build();
}