nus-yam/ex-repair huggingface dataset:
Program: 62180
Project: 62180
Buggy source:
@ToscaContextual public void updateSubstitutionType(final Topology topology,Csar csar){
  if (topology.getSubstitutionMapping() == null || topology.getSubstitutionMapping().getSubstitutionType() == null) {
    return;
  }
  NodeType nodeType=ToscaContext.getOrFail(NodeType.class,topology.getSubstitutionMapping().getSubstitutionType());
  if (csar.getDependencies().add(csarDependencyLoader.buildDependencyBean(nodeType.getArchiveName(),nodeType.getArchiveVersion()))) {
    csarService.save(csar);
  }
  NodeType substituteNodeType=buildSubstituteNodeType(topology,csar,nodeType);
  substituteNodeType.setProperties(topology.getInputs());
  fillSubstituteAttributesFromTypeAtttributes(topology,substituteNodeType);
  fillSubstituteAttributesFromOutputProperties(topology,substituteNodeType);
  fillAttributesFromOutputCapabilitiesProperties(topology,substituteNodeType);
  fillCapabilities(topology,substituteNodeType);
  fillRequirements(topology,substituteNodeType);
  indexerService.indexInheritableElement(csar.getName(),csar.getVersion(),substituteNodeType,csar.getDependencies());
  publisher.publishEvent(new SubstitutionTypeChangedEvent(this,topology,substituteNodeType));
}

Fixed version (ground truth):
@ToscaContextual public void updateSubstitutionType(final Topology topology,Csar csar){
  if (topology.getSubstitutionMapping() == null || topology.getSubstitutionMapping().getSubstitutionType() == null) {
    return;
  }
  NodeType nodeType=ToscaContext.getOrFail(NodeType.class,topology.getSubstitutionMapping().getSubstitutionType());
  if (csar.getDependencies().add(csarDependencyLoader.buildDependencyBean(nodeType.getArchiveName(),nodeType.getArchiveVersion()))) {
    Path archiveGitPath=csarRepositry.getExpandedCSAR(csar.getName(),csar.getVersion());
    String hash=FileUtil.deepSHA1(archiveGitPath);
    csar.setHash(hash);
    csarService.save(csar);
  }
  NodeType substituteNodeType=buildSubstituteNodeType(topology,csar,nodeType);
  substituteNodeType.setProperties(topology.getInputs());
  fillSubstituteAttributesFromTypeAtttributes(topology,substituteNodeType);
  fillSubstituteAttributesFromOutputProperties(topology,substituteNodeType);
  fillAttributesFromOutputCapabilitiesProperties(topology,substituteNodeType);
  fillCapabilities(topology,substituteNodeType);
  fillRequirements(topology,substituteNodeType);
  indexerService.indexInheritableElement(csar.getName(),csar.getVersion(),substituteNodeType,csar.getDependencies());
  publisher.publishEvent(new SubstitutionTypeChangedEvent(this,topology,substituteNodeType));
}
Program: 62181
Project: 62181
Buggy source:
private void fillRequirements(Topology topology,NodeType substituteNodeType){
  if (topology.getSubstitutionMapping().getRequirements() != null) {
    for (    Map.Entry<String,SubstitutionTarget> e : topology.getSubstitutionMapping().getRequirements().entrySet()) {
      String key=e.getKey();
      String nodeName=e.getValue().getNodeTemplateName();
      String requirementName=e.getValue().getTargetId();
      NodeTemplate nodeTemplate=topology.getNodeTemplates().get(nodeName);
      NodeType nodeTemplateType=ToscaContext.getOrFail(NodeType.class,nodeTemplate.getType());
      RequirementDefinition requirementDefinition=IndexedModelUtils.getRequirementDefinitionById(nodeTemplateType.getRequirements(),requirementName);
      requirementDefinition.setId(key);
      substituteNodeType.getRequirements().add(requirementDefinition);
    }
  }
}

Fixed version (ground truth):
private void fillRequirements(Topology topology,NodeType substituteNodeType){
  if (topology.getSubstitutionMapping().getRequirements() != null) {
    for (    Map.Entry<String,SubstitutionTarget> e : topology.getSubstitutionMapping().getRequirements().entrySet()) {
      String key=e.getKey();
      String nodeName=e.getValue().getNodeTemplateName();
      String requirementName=e.getValue().getTargetId();
      NodeTemplate nodeTemplate=topology.getNodeTemplates().get(nodeName);
      NodeType nodeTemplateType=ToscaContext.getOrFail(NodeType.class,nodeTemplate.getType());
      RequirementDefinition requirementDefinition=IndexedModelUtils.getRequirementDefinitionById(nodeTemplateType.getRequirements(),requirementName);
      requirementDefinition=CloneUtil.clone(requirementDefinition);
      requirementDefinition.setId(key);
      substituteNodeType.getRequirements().add(requirementDefinition);
    }
  }
}
Program: 62182
Project: 62182
Buggy source:
private void fillCapabilities(Topology topology,NodeType substituteNodeType){
  if (topology.getSubstitutionMapping().getCapabilities() != null) {
    for (    Map.Entry<String,SubstitutionTarget> e : topology.getSubstitutionMapping().getCapabilities().entrySet()) {
      String key=e.getKey();
      String nodeName=e.getValue().getNodeTemplateName();
      String capabilityName=e.getValue().getTargetId();
      NodeTemplate nodeTemplate=topology.getNodeTemplates().get(nodeName);
      NodeType nodeTemplateType=ToscaContext.getOrFail(NodeType.class,nodeTemplate.getType());
      CapabilityDefinition capabilityDefinition=IndexedModelUtils.getCapabilityDefinitionById(nodeTemplateType.getCapabilities(),capabilityName);
      capabilityDefinition.setId(key);
      substituteNodeType.getCapabilities().add(capabilityDefinition);
    }
  }
}

Fixed version (ground truth):
private void fillCapabilities(Topology topology,NodeType substituteNodeType){
  if (topology.getSubstitutionMapping().getCapabilities() != null) {
    for (    Map.Entry<String,SubstitutionTarget> e : topology.getSubstitutionMapping().getCapabilities().entrySet()) {
      String key=e.getKey();
      String nodeName=e.getValue().getNodeTemplateName();
      String capabilityName=e.getValue().getTargetId();
      NodeTemplate nodeTemplate=topology.getNodeTemplates().get(nodeName);
      NodeType nodeTemplateType=ToscaContext.getOrFail(NodeType.class,nodeTemplate.getType());
      CapabilityDefinition capabilityDefinition=IndexedModelUtils.getCapabilityDefinitionById(nodeTemplateType.getCapabilities(),capabilityName);
      capabilityDefinition=CloneUtil.clone(capabilityDefinition);
      capabilityDefinition.setId(key);
      substituteNodeType.getCapabilities().add(capabilityDefinition);
    }
  }
}
Program: 62183
Project: 62183
Buggy source:
@Override public Map<String,Capability> getCompatibleCapabilityByType(NodeTemplate nodeTemplate,String type){
  Map<String,Capability> capabilities=nodeTemplate.getCapabilities();
  if (capabilities == null) {
    return Collections.emptyMap();
  }
  Map<String,Capability> targetCapabilitiesMatch=Maps.newHashMap();
  for (  Map.Entry<String,Capability> capabilityEntry : capabilities.entrySet()) {
    String capabilityTypeName=capabilityEntry.getKey();
    CapabilityType capabilityType=toscaContextFinder.find(CapabilityType.class,capabilityTypeName);
    if (ToscaNormativeUtil.isFromType(type,capabilityType)) {
      targetCapabilitiesMatch.put(capabilityTypeName,capabilityEntry.getValue());
    }
  }
  return targetCapabilitiesMatch;
}

Fixed version (ground truth):
@Override public Map<String,Capability> getCompatibleCapabilityByType(NodeTemplate nodeTemplate,String type){
  Map<String,Capability> capabilities=nodeTemplate.getCapabilities();
  if (capabilities == null) {
    return Collections.emptyMap();
  }
  Map<String,Capability> targetCapabilitiesMatch=Maps.newHashMap();
  for (  Map.Entry<String,Capability> capabilityEntry : capabilities.entrySet()) {
    String capabilityTypeName=capabilityEntry.getValue().getType();
    CapabilityType capabilityType=toscaContextFinder.find(CapabilityType.class,capabilityTypeName);
    if (ToscaNormativeUtil.isFromType(type,capabilityType)) {
      targetCapabilitiesMatch.put(capabilityEntry.getKey(),capabilityEntry.getValue());
    }
  }
  return targetCapabilitiesMatch;
}
Program: 62184
Project: 62184
Buggy source:
private void addCapabilityToNodeTemplateAndToscaContext(String type,String... derivedFrom){
  CapabilityType capabilityType=new CapabilityType();
  capabilityType.setDerivedFrom(Arrays.asList(derivedFrom));
  capabilityType.setElementId(type);
  capabilityTypeByTypeName.put(type,capabilityType);
  Capability capability=new Capability();
  capability.setType(type);
  nodeTemplate.getCapabilities().put(type,capability);
}

Fixed version (ground truth):
private void addCapabilityToNodeTemplateAndToscaContext(String name,String type,String... derivedFrom){
  CapabilityType capabilityType=new CapabilityType();
  capabilityType.setDerivedFrom(Arrays.asList(derivedFrom));
  capabilityType.setElementId(type);
  capabilityTypeByTypeName.put(type,capabilityType);
  Capability capability=new Capability();
  capability.setType(type);
  nodeTemplate.getCapabilities().put(name,capability);
}
Program: 62185
Project: 62185
Buggy source:
@Before public void setUp() throws Exception {
  service=new CapabilityMatcherService();
  service.setToscaContextFinder(toscaContextFinder);
  nodeTemplate=new NodeTemplate();
  nodeTemplate.setCapabilities(Maps.newHashMap());
  capabilityTypeByTypeName=Maps.newHashMap();
  addCapabilityToNodeTemplateAndToscaContext("String_Node_Str","String_Node_Str","String_Node_Str");
  addCapabilityToNodeTemplateAndToscaContext("String_Node_Str");
  Mockito.when(toscaContextFinder.find(Mockito.any(),Mockito.anyString())).then(invocationOnMock -> capabilityTypeByTypeName.get(invocationOnMock.getArguments()[1]));
}

Fixed version (ground truth):
@Before public void setUp() throws Exception {
  service=new CapabilityMatcherService();
  service.setToscaContextFinder(toscaContextFinder);
  nodeTemplate=new NodeTemplate();
  nodeTemplate.setCapabilities(Maps.newHashMap());
  capabilityTypeByTypeName=Maps.newHashMap();
  addCapabilityToNodeTemplateAndToscaContext("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  addCapabilityToNodeTemplateAndToscaContext("String_Node_Str","String_Node_Str");
  Mockito.when(toscaContextFinder.find(Mockito.any(),Mockito.anyString())).then(invocationOnMock -> capabilityTypeByTypeName.get(invocationOnMock.getArguments()[1]));
}
Program: 62186
Project: 62186
Buggy source:
private static void injectInputIntoOperations(String name,AbstractPropertyValue value,Map<String,Operation> operations){
  if (MapUtils.isEmpty(operations)) {
    return;
  }
  if (value != null && !(value instanceof ScalarPropertyValue)) {
    return;
  }
  String inputName=name.toUpperCase();
  operations.forEach((operationName,operation) -> {
    if (operation.getInputParameters() == null) {
      operation.setInputParameters(Maps.newHashMap());
    }
    operation.getInputParameters().putIfAbsent(inputName,value);
  }
);
}

Fixed version (ground truth):
private static void injectInputIntoOperations(String name,AbstractPropertyValue value,Map<String,Operation> operations){
  if (MapUtils.isEmpty(operations)) {
    return;
  }
  if (value != null && !(value instanceof ScalarPropertyValue)) {
    return;
  }
 else   if (value == null) {
    value=new ScalarPropertyValue();
  }
  String inputName=name.toUpperCase();
  AbstractPropertyValue finalValue=value;
  operations.forEach((operationName,operation) -> {
    if (operation.getInputParameters() == null) {
      operation.setInputParameters(Maps.newHashMap());
    }
    operation.getInputParameters().putIfAbsent(inputName,finalValue);
  }
);
}
Program: 62187
Project: 62187
Buggy source:
/** 
 * Set the value for the size (maximum number of elements to return in the request).
 * @param size Maximum number of elements to return in the request. If null will be set to 50. Cannot be more than 100.
 */
public void setSize(Integer size){
  if (size == null) {
    this.size=Constants.DEFAULT_ES_SEARCH_SIZE;
  }
 else   if (size > Constants.MAX_ES_SEARCH_SIZE) {
    this.size=Constants.MAX_ES_SEARCH_SIZE;
  }
 else {
    this.size=size;
  }
}

Fixed version (ground truth):
/** 
 * Set the value for the size (maximum number of elements to return in the request).
 * @param size Maximum number of elements to return in the request. If null will be set to 50. Cannot be more than 100.
 */
public void setSize(Integer size){
  if (size == null) {
    this.size=AlienConstants.DEFAULT_ES_SEARCH_SIZE;
  }
 else   if (size > AlienConstants.MAX_ES_SEARCH_SIZE) {
    this.size=AlienConstants.MAX_ES_SEARCH_SIZE;
  }
 else {
    this.size=size;
  }
}
Program: 62188
Project: 62188
Buggy source:
/** 
 * Set the value for the size (maximum number of elements to return in the request).
 * @param size Maximum number of elements to return in the request. If null will be set to 50. Cannot be more than 100.
 */
public void setSize(Integer size){
  if (size == null) {
    this.size=Constants.DEFAULT_ES_SEARCH_SIZE;
  }
 else   if (size > Constants.MAX_ES_SEARCH_SIZE) {
    this.size=Constants.MAX_ES_SEARCH_SIZE;
  }
 else {
    this.size=size;
  }
}

Fixed version (ground truth):
/** 
 * Set the value for the size (maximum number of elements to return in the request).
 * @param size Maximum number of elements to return in the request. If null will be set to 50. Cannot be more than 100.
 */
public void setSize(Integer size){
  if (size == null) {
    this.size=AlienConstants.DEFAULT_ES_SEARCH_SIZE;
  }
 else   if (size > AlienConstants.MAX_ES_SEARCH_SIZE) {
    this.size=AlienConstants.MAX_ES_SEARCH_SIZE;
  }
 else {
    this.size=size;
  }
}
Program: 62189
Project: 62189
Buggy source:
/** 
 * Delete a version and the related topologies.
 * @param id The id of the version to delete.
 */
public boolean delete(String id){
  ApplicationEnvironment environmentToDelete=getOrFail(id);
  boolean isDeployed=isDeployed(id);
  if (isDeployed) {
    throw new DeleteDeployedException("String_Node_Str" + id + "String_Node_Str");
  }
  deploymentTopologyService.deleteByEnvironmentId(id);
  applicationContext.publishEvent(new BeforeEnvironmentDeletedEvent(this,environmentToDelete.getId()));
  alienDAO.delete(ApplicationEnvironment.class,id);
  applicationContext.publishEvent(new DeleteEnvironmentEvent(this,environmentToDelete,deploymentService.getAllOrchestratorIdsAndOrchestratorDeploymentId(id)));
  return true;
}

Fixed version (ground truth):
/** 
 * Delete a version and the related topologies.
 * @param id The id of the version to delete.
 */
public boolean delete(String id){
  ApplicationEnvironment applicationEnvironment=getOrFail(id);
  boolean isDeployed=isDeployed(id);
  if (isDeployed) {
    throw new DeleteDeployedException("String_Node_Str" + id + "String_Node_Str");
  }
  publisher.publishEvent(new BeforeApplicationEnvironmentDeleted(this,applicationEnvironment.getApplicationId(),applicationEnvironment.getId()));
  alienDAO.delete(ApplicationEnvironment.class,id);
  publisher.publishEvent(new AfterApplicationEnvironmentDeleted(this,applicationEnvironment.getApplicationId(),applicationEnvironment.getId()));
  return true;
}
Program: 62190
Project: 62190
Buggy source:
@Override public String parse(Node node,ParsingContextExecution context){
  ArchiveRoot archiveRoot=(ArchiveRoot)context.getParent();
  String toscaDefinitionVersion=ParserUtils.getScalar(node,context);
  if (toscaDefinitionVersion != null) {
    CSARDependency dependency=ToscaNormativeImports.IMPORTS.get(toscaDefinitionVersion);
    if (dependency != null) {
      Set<CSARDependency> dependencies=archiveRoot.getArchive().getDependencies();
      if (dependencies == null) {
        dependencies=new HashSet<>();
        archiveRoot.getArchive().setDependencies(dependencies);
      }
      ToscaContext.get().addDependency(dependency);
      dependencies.add(dependency);
    }
  }
  return toscaDefinitionVersion;
}

Fixed version (ground truth):
@Override public String parse(Node node,ParsingContextExecution context){
  ArchiveRoot archiveRoot=(ArchiveRoot)context.getParent();
  String toscaDefinitionVersion=ParserUtils.getScalar(node,context);
  if (toscaDefinitionVersion != null) {
    CSARDependency dependency=ToscaNormativeImports.IMPORTS.get(toscaDefinitionVersion);
    if (dependency != null) {
      if (ToscaNormativeImports.TOSCA_NORMATIVE_TYPES.equals(dependency.getName())) {
        if (recursiveCall.get() == null) {
          recursiveCall.set(true);
        }
 else {
          return toscaDefinitionVersion;
        }
      }
      Set<CSARDependency> dependencies=archiveRoot.getArchive().getDependencies();
      if (dependencies == null) {
        dependencies=new HashSet<>();
        archiveRoot.getArchive().setDependencies(dependencies);
      }
      ToscaContext.get().addDependency(dependency);
      dependencies.add(dependency);
      recursiveCall.remove();
    }
  }
  return toscaDefinitionVersion;
}
Program: 62191
Project: 62191
Buggy source:
/** 
 * Deployment configuration has been changed, in this case must re-synchronize the deployment topology
 * @param deploymentTopology the deployment topology to update
 */
public void updateDeploymentTopology(DeploymentTopology deploymentTopology){
  ApplicationEnvironment environment=appEnvironmentServices.getOrFail(deploymentTopology.getEnvironmentId());
  Topology topology=topologyServiceCore.getOrFail(deploymentTopology.getInitialTopologyId());
  doUpdateDeploymentTopology(deploymentTopology,topology);
}

Fixed version (ground truth):
/** 
 * Deployment configuration has been changed, in this case must re-synchronize the deployment topology
 * @param deploymentTopology the deployment topology to update
 */
public void updateDeploymentTopology(DeploymentTopology deploymentTopology){
  Topology topology=topologyServiceCore.getOrFail(deploymentTopology.getInitialTopologyId());
  doUpdateDeploymentTopology(deploymentTopology,topology);
}
Program: 62192
Project: 62192
Buggy source:
/** 
 * Compute a list of transitive dependency conflicts from the Context.
 * @param context the EditionContext of the Topology being built.
 * @return a list of dependency conflicts.
 */
private List<DependencyConflictDTO> getDependencyConflictDTOs(EditionContext context){
  final Set<CSARDependency> dependencies=context.getToscaContext().getDependencies();
  Map<CSARDependency,Set<CSARDependency>> dependencyConflictMap=new HashMap<>();
  dependencies.forEach(source -> {
    final Set<CSARDependency> transitives=Optional.ofNullable(ToscaContext.get().getArchive(source.getName(),source.getVersion()).getDependencies()).orElse(Collections.emptySet()).stream().filter((o) -> !dependencies.contains(o)).collect(Collectors.toSet());
    if (!transitives.isEmpty()) {
      dependencyConflictMap.put(source,transitives);
    }
  }
);
  final ArrayList<DependencyConflictDTO> dependencyConflicts=new ArrayList<>();
  dependencyConflictMap.forEach((source,conflicts) -> conflicts.forEach(conflict -> {
    String actualVersion=dependencies.stream().filter(d -> d.getName().equals(conflict.getName())).findFirst().map(CSARDependency::getVersion).orElse("String_Node_Str");
    dependencyConflicts.add(new DependencyConflictDTO(source.getName(),conflict.getName() + "String_Node_Str" + conflict.getVersion(),actualVersion));
  }
));
  return dependencyConflicts;
}

Fixed version (ground truth):
/** 
 * Compute a list of transitive dependency conflicts from the Context.
 * @param context the EditionContext of the Topology being built.
 * @return a list of dependency conflicts.
 */
private List<DependencyConflictDTO> getDependencyConflictDTOs(EditionContext context){
  final Set<CSARDependency> dependencies=context.getToscaContext().getDependencies();
  Map<CSARDependency,Set<CSARDependency>> dependencyConflictMap=new HashMap<>();
  dependencies.forEach(source -> {
    final Set<CSARDependency> transitives=Optional.ofNullable(ToscaContext.get().getArchive(source.getName(),source.getVersion()).getDependencies()).orElse(Collections.emptySet()).stream().filter(o -> !dependencies.contains(o)).collect(Collectors.toSet());
    if (!transitives.isEmpty()) {
      dependencyConflictMap.put(source,transitives);
    }
  }
);
  final ArrayList<DependencyConflictDTO> dependencyConflicts=new ArrayList<>();
  dependencyConflictMap.forEach((source,conflicts) -> conflicts.forEach(conflict -> {
    String actualVersion=dependencies.stream().filter(d -> d.getName().equals(conflict.getName())).findFirst().map(CSARDependency::getVersion).orElse("String_Node_Str");
    dependencyConflicts.add(new DependencyConflictDTO(source.getName(),conflict.getName() + "String_Node_Str" + conflict.getVersion(),actualVersion));
  }
));
  return dependencyConflicts;
}
Program: 62193
Project: 62193
Buggy source:
/** 
 * Handle group roles on the targeted application
 * @param applicationId
 * @param groupId
 */
private void handleRemoveGrpRoleOnApplication(String applicationId,String groupId){
  Application application=applicationService.getOrFail(applicationId);
  Set<String> applicationRoles=application.getGroupRoles() != null ? application.getGroupRoles().get(groupId) : new HashSet<>();
  List<Set<String>> environmentRoles=Arrays.stream(applicationEnvironmentService.getByApplicationId(applicationId)).map(applicationEnvironment -> (applicationEnvironment.getGroupRoles() != null ? applicationEnvironment.getGroupRoles().get(groupId) : null)).filter(roles -> roles != null).collect(Collectors.toList());
  if (mustRemoveApplicationUserRole(applicationRoles,environmentRoles)) {
    resourceRoleService.removeGroupRole(application,groupId,ApplicationRole.APPLICATION_USER.toString());
  }
}

Fixed version (ground truth):
/** 
 * Handle group roles on the targeted application
 * @param applicationId
 * @param groupId
 */
private void handleRemoveGrpRoleOnApplication(String applicationId,String groupId){
  Application application=applicationService.getOrFail(applicationId);
  Set<String> applicationRoles=application.getGroupRoles() != null ? application.getGroupRoles().get(groupId) : new HashSet<>();
  List<Set<String>> environmentRoles=Arrays.stream(applicationEnvironmentService.getByApplicationId(applicationId)).map(applicationEnvironment -> applicationEnvironment.getGroupRoles() != null ? applicationEnvironment.getGroupRoles().get(groupId) : null).filter(roles -> roles != null).collect(Collectors.toList());
  if (mustRemoveApplicationUserRole(applicationRoles,environmentRoles)) {
    resourceRoleService.removeGroupRole(application,groupId,ApplicationRole.APPLICATION_USER.toString());
  }
}
Program: 62194
Project: 62194
Buggy source:
/** 
 * Handle remove roles on the targeted application
 * @param applicationId
 * @param username
 */
private void handleRemoveUserRoleOnApplication(String applicationId,String username){
  Application application=applicationService.getOrFail(applicationId);
  Set<String> applicationRoles=application.getUserRoles() != null ? application.getUserRoles().get(username) : new HashSet<>();
  List<Set<String>> environmentRoles=Arrays.stream(applicationEnvironmentService.getByApplicationId(applicationId)).map(applicationEnvironment -> (applicationEnvironment.getUserRoles() != null ? applicationEnvironment.getUserRoles().get(username) : null)).filter(roles -> roles != null).collect(Collectors.toList());
  if (mustRemoveApplicationUserRole(applicationRoles,environmentRoles)) {
    resourceRoleService.removeUserRole(application,username,ApplicationRole.APPLICATION_USER.toString());
  }
}

Fixed version (ground truth):
/** 
 * Handle remove roles on the targeted application
 * @param applicationId
 * @param username
 */
private void handleRemoveUserRoleOnApplication(String applicationId,String username){
  Application application=applicationService.getOrFail(applicationId);
  Set<String> applicationRoles=application.getUserRoles() != null ? application.getUserRoles().get(username) : new HashSet<>();
  List<Set<String>> environmentRoles=Arrays.stream(applicationEnvironmentService.getByApplicationId(applicationId)).map(applicationEnvironment -> applicationEnvironment.getUserRoles() != null ? applicationEnvironment.getUserRoles().get(username) : null).filter(roles -> roles != null).collect(Collectors.toList());
  if (mustRemoveApplicationUserRole(applicationRoles,environmentRoles)) {
    resourceRoleService.removeUserRole(application,username,ApplicationRole.APPLICATION_USER.toString());
  }
}
Program: 62195
Project: 62195
Buggy source:
/** 
 * Refresh the documentation
 */
public void refresh(){
  List plugins=Orderings.pluginOrdering().sortedCopy(this.documentationPluginsManager.documentationPlugins());
  log.info("String_Node_Str",Integer.valueOf(plugins.size()));
  Iterator var3=plugins.iterator();
  while (var3.hasNext()) {
    DocumentationPlugin each=(DocumentationPlugin)var3.next();
    DocumentationType documentationType=each.getDocumentationType();
    if (each.isEnabled()) {
      this.scanDocumentation(this.buildContext(each));
    }
 else {
      log.info("String_Node_Str",documentationType.getName(),documentationType.getVersion());
    }
  }
}

Fixed version (ground truth):
/** 
 * Refresh the documentation
 */
public void refresh(){
  List plugins=Orderings.pluginOrdering().sortedCopy(this.documentationPluginsManager.documentationPlugins());
  logger.info("String_Node_Str",Integer.valueOf(plugins.size()));
  Iterator var3=plugins.iterator();
  while (var3.hasNext()) {
    DocumentationPlugin each=(DocumentationPlugin)var3.next();
    DocumentationType documentationType=each.getDocumentationType();
    if (each.isEnabled()) {
      this.scanDocumentation(this.buildContext(each));
    }
 else {
      logger.info("String_Node_Str",documentationType.getName(),documentationType.getVersion());
    }
  }
}
Program: 62196
Project: 62196
Buggy source:
private void fillAttributesFromOutputCapabilitiesProperties(Topology topology,NodeType substituteNodeType){
  Map<String,IValue> attributes=substituteNodeType.getAttributes();
  Map<String,Map<String,Set<String>>> outputCapabilityProperties=topology.getOutputCapabilityProperties();
  if (outputCapabilityProperties != null) {
    for (    Map.Entry<String,Map<String,Set<String>>> ocpe : outputCapabilityProperties.entrySet()) {
      String nodeName=ocpe.getKey();
      NodeTemplate nodeTemplate=topology.getNodeTemplates().get(nodeName);
      for (      Map.Entry<String,Set<String>> cpe : ocpe.getValue().entrySet()) {
        String capabilityName=cpe.getKey();
        String capabilityTypeName=nodeTemplate.getCapabilities().get(capabilityName).getType();
        CapabilityType capabilityType=ToscaContext.getOrFail(CapabilityType.class,capabilityTypeName);
        for (        String propertyName : cpe.getValue()) {
          PropertyDefinition pd=capabilityType.getProperties().get(propertyName);
          if (pd != null && !attributes.containsKey(propertyName)) {
            attributes.put(propertyName,pd);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void fillAttributesFromOutputCapabilitiesProperties(Topology topology,NodeType substituteNodeType){
  Map<String,Map<String,Set<String>>> outputCapabilityProperties=topology.getOutputCapabilityProperties();
  if (outputCapabilityProperties != null) {
    for (    Map.Entry<String,Map<String,Set<String>>> ocpe : outputCapabilityProperties.entrySet()) {
      String nodeName=ocpe.getKey();
      NodeTemplate nodeTemplate=topology.getNodeTemplates().get(nodeName);
      for (      Map.Entry<String,Set<String>> cpe : ocpe.getValue().entrySet()) {
        String capabilityName=cpe.getKey();
        String capabilityTypeName=nodeTemplate.getCapabilities().get(capabilityName).getType();
        CapabilityType capabilityType=ToscaContext.getOrFail(CapabilityType.class,capabilityTypeName);
        for (        String propertyName : cpe.getValue()) {
          PropertyDefinition pd=capabilityType.getProperties().get(propertyName);
          addAttributeFromPropertyDefinition(pd,propertyName,substituteNodeType);
        }
      }
    }
  }
}
Program: 62197
Project: 62197
Buggy source:
private void fillSubstituteAttributesFromOutputProperties(Topology topology,NodeType substituteNodeType){
  Map<String,IValue> attributes=substituteNodeType.getAttributes();
  Map<String,Set<String>> outputProperties=topology.getOutputProperties();
  if (outputProperties != null) {
    for (    Map.Entry<String,Set<String>> ope : outputProperties.entrySet()) {
      String nodeName=ope.getKey();
      NodeTemplate nodeTemplate=topology.getNodeTemplates().get(nodeName);
      NodeType nodeTemplateType=ToscaContext.getOrFail(NodeType.class,nodeTemplate.getType());
      for (      String propertyName : ope.getValue()) {
        PropertyDefinition pd=nodeTemplateType.getProperties().get(propertyName);
        if (pd != null && !attributes.containsKey(propertyName)) {
          if (ToscaType.isSimple(pd.getType())) {
            AttributeDefinition attributeDefinition=new AttributeDefinition();
            attributeDefinition.setType(pd.getType());
            attributeDefinition.setDescription(pd.getDescription());
            if (pd.getDefault() != null && pd.getDefault() instanceof ScalarPropertyValue) {
              attributeDefinition.setDefault(((ScalarPropertyValue)pd.getDefault()).getValue());
            }
            attributes.put(propertyName,attributeDefinition);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void fillSubstituteAttributesFromOutputProperties(Topology topology,NodeType substituteNodeType){
  Map<String,Set<String>> outputProperties=topology.getOutputProperties();
  if (outputProperties != null) {
    for (    Map.Entry<String,Set<String>> ope : outputProperties.entrySet()) {
      String nodeName=ope.getKey();
      NodeTemplate nodeTemplate=topology.getNodeTemplates().get(nodeName);
      NodeType nodeTemplateType=ToscaContext.getOrFail(NodeType.class,nodeTemplate.getType());
      for (      String propertyName : ope.getValue()) {
        PropertyDefinition pd=nodeTemplateType.getProperties().get(propertyName);
        addAttributeFromPropertyDefinition(pd,propertyName,substituteNodeType);
      }
    }
  }
}
Program: 62198
Project: 62198
Buggy source:
private void fillSubstituteAttributesFromOutputProperties(Topology topology,NodeType substituteNodeType){
  Map<String,IValue> attributes=substituteNodeType.getAttributes();
  Map<String,Set<String>> outputProperties=topology.getOutputProperties();
  if (outputProperties != null) {
    for (    Map.Entry<String,Set<String>> ope : outputProperties.entrySet()) {
      String nodeName=ope.getKey();
      NodeTemplate nodeTemplate=topology.getNodeTemplates().get(nodeName);
      NodeType nodeTemplateType=ToscaContext.getOrFail(NodeType.class,nodeTemplate.getType());
      for (      String propertyName : ope.getValue()) {
        PropertyDefinition pd=nodeTemplateType.getProperties().get(propertyName);
        if (ToscaType.isSimple(pd.getType())) {
          AttributeDefinition attributeDefinition=new AttributeDefinition();
          attributeDefinition.setType(pd.getType());
          attributeDefinition.setDescription(pd.getDescription());
          if (pd.getDefault() != null && pd.getDefault() instanceof ScalarPropertyValue) {
            attributeDefinition.setDefault(((ScalarPropertyValue)pd.getDefault()).getValue());
          }
          if (pd != null && !attributes.containsKey(propertyName)) {
            attributes.put(propertyName,pd);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void fillSubstituteAttributesFromOutputProperties(Topology topology,NodeType substituteNodeType){
  Map<String,IValue> attributes=substituteNodeType.getAttributes();
  Map<String,Set<String>> outputProperties=topology.getOutputProperties();
  if (outputProperties != null) {
    for (    Map.Entry<String,Set<String>> ope : outputProperties.entrySet()) {
      String nodeName=ope.getKey();
      NodeTemplate nodeTemplate=topology.getNodeTemplates().get(nodeName);
      NodeType nodeTemplateType=ToscaContext.getOrFail(NodeType.class,nodeTemplate.getType());
      for (      String propertyName : ope.getValue()) {
        PropertyDefinition pd=nodeTemplateType.getProperties().get(propertyName);
        if (pd != null && !attributes.containsKey(propertyName)) {
          if (ToscaType.isSimple(pd.getType())) {
            AttributeDefinition attributeDefinition=new AttributeDefinition();
            attributeDefinition.setType(pd.getType());
            attributeDefinition.setDescription(pd.getDescription());
            if (pd.getDefault() != null && pd.getDefault() instanceof ScalarPropertyValue) {
              attributeDefinition.setDefault(((ScalarPropertyValue)pd.getDefault()).getValue());
            }
            attributes.put(propertyName,attributeDefinition);
          }
        }
      }
    }
  }
}
Program: 62199
Project: 62199
Buggy source:
/** 
 * Delete all environments related to an application
 * @param applicationId The application id
 * @throws alien4cloud.paas.exception.OrchestratorDisabledException
 */
public void deleteByApplication(String applicationId) throws OrchestratorDisabledException {
  List<String> deployedEnvironments=Lists.newArrayList();
  ApplicationEnvironment[] environments=getByApplicationId(applicationId);
  for (  ApplicationEnvironment environment : environments) {
    if (!this.isDeployed(environment.getId())) {
      delete(environment.getId());
    }
 else {
      deployedEnvironments.add(environment.getId());
    }
  }
  if (deployedEnvironments.size() > 0) {
    log.error("String_Node_Str",deployedEnvironments.toString());
  }
}

Fixed version (ground truth):
/** 
 * Delete all environments related to an application
 * @param applicationId The application id
 */
public void deleteByApplication(String applicationId){
  List<String> deployedEnvironments=Lists.newArrayList();
  ApplicationEnvironment[] environments=getByApplicationId(applicationId);
  for (  ApplicationEnvironment environment : environments) {
    if (!this.isDeployed(environment.getId())) {
      delete(environment.getId());
    }
 else {
      deployedEnvironments.add(environment.getId());
    }
  }
  if (!deployedEnvironments.isEmpty()) {
    log.error("String_Node_Str",deployedEnvironments.toString());
  }
}
Program: 62200
Project: 62200
Buggy source:
/** 
 * Get the environment status regarding the linked topology and cloud
 * @param environment to determine the status
 * @return {@link DeploymentStatus}
 * @throws alien4cloud.paas.exception.OrchestratorDisabledException
 */
public DeploymentStatus getStatus(ApplicationEnvironment environment) throws Exception {
  final Deployment deployment=getActiveDeployment(environment.getId());
  if (deployment == null) {
    return DeploymentStatus.UNDEPLOYED;
  }
  final SettableFuture<DeploymentStatus> statusSettableFuture=SettableFuture.create();
  deploymentRuntimeStateService.getDeploymentStatus(deployment,new IPaaSCallback<DeploymentStatus>(){
    @Override public void onSuccess(    DeploymentStatus data){
      statusSettableFuture.set(data);
    }
    @Override public void onFailure(    Throwable throwable){
      statusSettableFuture.setException(throwable);
    }
  }
);
  DeploymentStatus currentStatus=statusSettableFuture.get();
  if (DeploymentStatus.UNDEPLOYED.equals(currentStatus)) {
    deploymentService.markUndeployed(deployment);
  }
  return currentStatus;
}

Fixed version (ground truth):
/** 
 * Get the environment status regarding the linked topology and cloud
 * @param environment to determine the status
 * @return {@link DeploymentStatus}
 * @throws alien4cloud.paas.exception.OrchestratorDisabledException
 */
public DeploymentStatus getStatus(ApplicationEnvironment environment) throws ExecutionException, InterruptedException {
  final Deployment deployment=getActiveDeployment(environment.getId());
  if (deployment == null) {
    return DeploymentStatus.UNDEPLOYED;
  }
  final SettableFuture<DeploymentStatus> statusSettableFuture=SettableFuture.create();
  deploymentRuntimeStateService.getDeploymentStatus(deployment,new IPaaSCallback<DeploymentStatus>(){
    @Override public void onSuccess(    DeploymentStatus data){
      statusSettableFuture.set(data);
    }
    @Override public void onFailure(    Throwable throwable){
      statusSettableFuture.setException(throwable);
    }
  }
);
  DeploymentStatus currentStatus=statusSettableFuture.get();
  if (DeploymentStatus.UNDEPLOYED.equals(currentStatus)) {
    deploymentService.markUndeployed(deployment);
  }
  return currentStatus;
}
Program: 62201
Project: 62201
Buggy source:
/** 
 * Delete an existing application from it's id. This method ensures first that there is no running deployment of the application.
 * @param applicationId The id of the application to remove.
 * @return True if the application has been removed, false if not.
 * @throws alien4cloud.paas.exception.OrchestratorDisabledException
 */
public boolean delete(String applicationId) throws OrchestratorDisabledException {
  if (alienDAO.count(Deployment.class,null,fromKeyValueCouples("String_Node_Str",applicationId,"String_Node_Str",null)) > 0) {
    return false;
  }
  applicationVersionService.deleteByApplication(applicationId);
  applicationEnvironmentService.deleteByApplication(applicationId);
  publisher.publishEvent(new BeforeApplicationDeletedEvent(this,applicationId));
  alienDAO.delete(Application.class,applicationId);
  return true;
}

Fixed version (ground truth):
/** 
 * Delete an existing application from it's id. This method ensures first that there is no running deployment of the application.
 * @param applicationId The id of the application to remove.
 * @return True if the application has been removed, false if not.
 */
public boolean delete(String applicationId){
  if (alienDAO.count(Deployment.class,null,fromKeyValueCouples("String_Node_Str",applicationId,"String_Node_Str",null)) > 0) {
    return false;
  }
  applicationVersionService.deleteByApplication(applicationId);
  applicationEnvironmentService.deleteByApplication(applicationId);
  publisher.publishEvent(new BeforeApplicationDeletedEvent(this,applicationId));
  alienDAO.delete(Application.class,applicationId);
  return true;
}
Program: 62202
Project: 62202
Buggy source:
private List<CsarDependenciesBean> sort(Map<CSARDependency,CsarDependenciesBean> elements){
  List<CsarDependenciesBean> sortedCsars=Lists.newArrayList();
  List<CsarDependenciesBean> independents=Lists.newArrayList();
  for (  Map.Entry<CSARDependency,CsarDependenciesBean> entry : elements.entrySet()) {
    CsarDependenciesBean csar=entry.getValue();
    if (csar.getDependencies() == null) {
      independents.add(csar);
    }
 else {
      List<CSARDependency> toClears=Lists.newArrayList();
      for (      CSARDependency dependent : csar.getDependencies()) {
        CsarDependenciesBean providedDependency=elements.get(dependent);
        if (providedDependency == null) {
          toClears.add(dependent);
        }
 else {
          providedDependency.getDependents().add(entry.getValue());
        }
      }
      for (      CSARDependency toClear : toClears) {
        csar.getDependencies().remove(toClear);
      }
      if (csar.getDependencies().isEmpty()) {
        independents.add(csar);
      }
    }
  }
  while (independents.size() > 0) {
    CsarDependenciesBean independent=independents.remove(0);
    elements.remove(independent.getSelf());
    sortedCsars.add(independent);
    for (    CsarDependenciesBean dependent : independent.getDependents()) {
      dependent.getDependencies().remove(independent.getSelf());
      if (dependent.getDependencies().isEmpty()) {
        independents.add(dependent);
      }
    }
  }
  if (elements.size() > 0) {
  }
  return sortedCsars;
}

Fixed version (ground truth):
private List<CsarDependenciesBean> sort(Map<CSARDependency,CsarDependenciesBean> elements){
  List<CsarDependenciesBean> sortedCsars=Lists.newArrayList();
  List<CsarDependenciesBean> independents=Lists.newArrayList();
  for (  Map.Entry<CSARDependency,CsarDependenciesBean> entry : elements.entrySet()) {
    CsarDependenciesBean csar=entry.getValue();
    if (csar.getDependencies() == null) {
      independents.add(csar);
    }
 else {
      List<CSARDependency> toClears=Lists.newArrayList();
      for (      CSARDependency dependent : csar.getDependencies()) {
        CsarDependenciesBean providedDependency=elements.get(dependent);
        if (providedDependency == null) {
          toClears.add(dependent);
        }
 else {
          providedDependency.getDependents().add(entry.getValue());
        }
      }
      for (      CSARDependency toClear : toClears) {
        csar.getDependencies().remove(toClear);
      }
      if (csar.getDependencies().isEmpty()) {
        independents.add(csar);
      }
    }
  }
  while (!independents.isEmpty()) {
    CsarDependenciesBean independent=independents.remove(0);
    elements.remove(independent.getSelf());
    sortedCsars.add(independent);
    for (    CsarDependenciesBean dependent : independent.getDependents()) {
      dependent.getDependencies().remove(independent.getSelf());
      if (dependent.getDependencies().isEmpty()) {
        independents.add(dependent);
      }
    }
  }
  if (elements.size() > 0) {
  }
  return sortedCsars;
}
Program: 62203
Project: 62203
Buggy source:
private List<ParsingResult<Csar>> processImport(CsarGitRepository csarGitRepository,CsarGitCheckoutLocation csarGitCheckoutLocation,String gitHash){
  Path archiveZipRoot=tempZipDirPath.resolve(csarGitRepository.getId());
  Path archiveGitRoot=tempDirPath.resolve(csarGitRepository.getId());
  Set<Path> archivePaths=csarFinderService.prepare(archiveGitRoot,archiveZipRoot,csarGitCheckoutLocation.getSubPath());
  List<ParsingResult<Csar>> parsingResult=Lists.newArrayList();
  try {
    Map<CSARDependency,CsarDependenciesBean> csarDependenciesBeans=uploadService.preParsing(archivePaths,parsingResult);
    List<CsarDependenciesBean> sorted=sort(csarDependenciesBeans);
    for (    CsarDependenciesBean csarBean : sorted) {
      if (csarGitCheckoutLocation.getLastImportedHash() != null && csarGitCheckoutLocation.getLastImportedHash().equals(gitHash)) {
        if (csarService.get(csarBean.getSelf().getName(),csarBean.getSelf().getVersion()) != null) {
          continue;
        }
      }
      ParsingResult<Csar> result=uploadService.upload(csarBean.getPath(),CSARSource.GIT,AlienConstants.GLOBAL_WORKSPACE_ID);
      parsingResult.add(result);
    }
    return parsingResult;
  }
 catch (  ParsingException e) {
    throw new GitException("String_Node_Str",e);
  }
catch (  AlreadyExistException e) {
    return parsingResult;
  }
catch (  CSARUsedInActiveDeployment e) {
    return parsingResult;
  }
catch (  ToscaTypeAlreadyDefinedInOtherCSAR e) {
    return parsingResult;
  }
}

Fixed version (ground truth):
private List<ParsingResult<Csar>> processImport(CsarGitRepository csarGitRepository,CsarGitCheckoutLocation csarGitCheckoutLocation,String gitHash){
  Path archiveZipRoot=tempZipDirPath.resolve(csarGitRepository.getId());
  Path archiveGitRoot=tempDirPath.resolve(csarGitRepository.getId());
  Set<Path> archivePaths=csarFinderService.prepare(archiveGitRoot,archiveZipRoot,csarGitCheckoutLocation.getSubPath());
  List<ParsingResult<Csar>> parsingResult=Lists.newArrayList();
  try {
    Map<CSARDependency,CsarDependenciesBean> csarDependenciesBeans=uploadService.preParsing(archivePaths,parsingResult);
    List<CsarDependenciesBean> sorted=sort(csarDependenciesBeans);
    for (    CsarDependenciesBean csarBean : sorted) {
      if (csarGitCheckoutLocation.getLastImportedHash() != null && csarGitCheckoutLocation.getLastImportedHash().equals(gitHash) && csarService.get(csarBean.getSelf().getName(),csarBean.getSelf().getVersion()) != null) {
        continue;
      }
      ParsingResult<Csar> result=uploadService.upload(csarBean.getPath(),CSARSource.GIT,AlienConstants.GLOBAL_WORKSPACE_ID);
      parsingResult.add(result);
    }
    return parsingResult;
  }
 catch (  ParsingException e) {
    throw new GitException("String_Node_Str",e);
  }
catch (  AlreadyExistException|ToscaTypeAlreadyDefinedInOtherCSAR|CSARUsedInActiveDeployment e) {
    return parsingResult;
  }
}
Program: 62205
Project: 62205
Buggy source:
/** 
 * Check that the property is not already defined in a source
 * @param sourcePropertyValue null or an already defined Property Value.
 * @param messageSource The named source to add in the exception message in case of failure.
 */
private void buildConstaintException(AbstractPropertyValue sourcePropertyValue,PropertyDefinition propertyDefinition,String messageSource,String propertyName,Object propertyValue) throws ConstraintViolationException {
  if (sourcePropertyValue != null) {
    try {
      EqualConstraint constraint=new EqualConstraint();
      if (sourcePropertyValue instanceof ScalarPropertyValue) {
        constraint.setEqual(((ScalarPropertyValue)sourcePropertyValue).getValue());
      }
      ConstraintUtil.ConstraintInformation information=ConstraintUtil.getConstraintInformation(constraint);
      throw new ConstraintViolationException("String_Node_Str" + messageSource + "String_Node_Str",null,information);
    }
 catch (    IntrospectionException e) {
      log.info("String_Node_Str" + propertyName + "String_Node_Str"+ propertyValue+ "String_Node_Str",e);
      throw new ConstraintTechnicalException("String_Node_Str" + propertyName + "String_Node_Str"+ propertyValue+ "String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
/** 
 * Check that the property is not already defined in a source
 * @param sourcePropertyValue null or an already defined Property Value.
 * @param messageSource The named source to add in the exception message in case of failure.
 */
private void buildConstaintException(AbstractPropertyValue sourcePropertyValue,String messageSource,String propertyName,Object propertyValue) throws ConstraintViolationException {
  if (sourcePropertyValue != null) {
    try {
      EqualConstraint constraint=new EqualConstraint();
      if (sourcePropertyValue instanceof ScalarPropertyValue) {
        constraint.setEqual(((ScalarPropertyValue)sourcePropertyValue).getValue());
      }
      ConstraintUtil.ConstraintInformation information=ConstraintUtil.getConstraintInformation(constraint);
      throw new ConstraintViolationException("String_Node_Str" + messageSource + "String_Node_Str",null,information);
    }
 catch (    IntrospectionException e) {
      log.info("String_Node_Str" + propertyName + "String_Node_Str"+ propertyValue+ "String_Node_Str",e);
      throw new ConstraintTechnicalException("String_Node_Str" + propertyName + "String_Node_Str"+ propertyValue+ "String_Node_Str",e);
    }
  }
}
Program: 62206
Project: 62206
Buggy source:
/** 
 * Deployment configuration has been changed, in this case must re-synchronize the deployment topology
 * @param deploymentTopology the deployment topology to update
 */
public void updateDeploymentTopology(DeploymentTopology deploymentTopology){
  ApplicationEnvironment environment=appEnvironmentServices.getOrFail(deploymentTopology.getEnvironmentId());
  Topology topology=topologyServiceCore.getOrFail(deploymentTopology.getInitialTopologyId());
  doUpdateDeploymentTopology(deploymentTopology,topology,environment);
}

Fixed version (ground truth):
/** 
 * Deployment configuration has been changed, in this case must re-synchronize the deployment topology
 * @param deploymentTopology the deployment topology to update
 */
public void updateDeploymentTopology(DeploymentTopology deploymentTopology){
  ApplicationEnvironment environment=appEnvironmentServices.getOrFail(deploymentTopology.getEnvironmentId());
  Topology topology=topologyServiceCore.getOrFail(deploymentTopology.getInitialTopologyId());
  doUpdateDeploymentTopology(deploymentTopology,topology);
}
Program: 62207
Project: 62207
Buggy source:
private DeploymentTopology generateDeploymentTopology(String id,ApplicationEnvironment environment,Topology topology,DeploymentTopology deploymentTopology){
  deploymentTopology.setVersionId(environment.getCurrentVersionId());
  deploymentTopology.setEnvironmentId(environment.getId());
  deploymentTopology.setInitialTopologyId(topology.getId());
  deploymentTopology.setId(id);
  doUpdateDeploymentTopology(deploymentTopology,topology,environment);
  return deploymentTopology;
}

Fixed version (ground truth):
private DeploymentTopology generateDeploymentTopology(String id,ApplicationEnvironment environment,Topology topology,DeploymentTopology deploymentTopology){
  deploymentTopology.setVersionId(environment.getCurrentVersionId());
  deploymentTopology.setEnvironmentId(environment.getId());
  deploymentTopology.setInitialTopologyId(topology.getId());
  deploymentTopology.setId(id);
  doUpdateDeploymentTopology(deploymentTopology,topology);
  return deploymentTopology;
}