Program: 41000
Project: 41000
Buggy source:
/** 
 * Adds logic to the BuildPlan to call a Script on a remote machine
 * @param context the TemplatePlanContext where the logical provisioning operation is called
 * @param operation the operation to call
 * @param ia the ia that implements the operation
 * @return true iff adding BPEL Fragment was successful
 */
public boolean handle(TemplatePlanContext templateContext,AbstractOperation operation,AbstractImplementationArtifact ia){
  AbstractArtifactReference scriptRef=this.fetchScriptRefFromIA(ia);
  if (scriptRef == null) {
    return false;
  }
  if (templateContext.getNodeTemplate() == null) {
    Handler.LOG.warn("String_Node_Str");
    return false;
  }
  Variable serverIpPropWrapper=null;
  for (  String serverIp : PluginUtils.getSupportedVirtualMachineIPPropertyNames()) {
    serverIpPropWrapper=templateContext.getPropertyVariable(serverIp);
    if (serverIpPropWrapper == null) {
      serverIpPropWrapper=templateContext.getPropertyVariable(serverIp,true);
      if (serverIpPropWrapper == null) {
        serverIpPropWrapper=templateContext.getPropertyVariable(serverIp,false);
      }
    }
  }
  if (serverIpPropWrapper == null) {
    Handler.LOG.warn("String_Node_Str");
    return false;
  }
  Variable sshUserVariable=null;
  for (  String vmUserName : PluginUtils.getSupportedVirtualMachineLoginUserNamePropertyNames()) {
    sshUserVariable=templateContext.getPropertyVariable(vmUserName);
    if (sshUserVariable == null) {
      sshUserVariable=templateContext.getPropertyVariable(vmUserName,true);
      if (sshUserVariable == null) {
        sshUserVariable=templateContext.getPropertyVariable(vmUserName,false);
      }
    }
  }
  if (sshUserVariable == null) {
    return false;
  }
 else {
    if (Utils.isVariableValueEmpty(sshUserVariable,templateContext)) {
      sshUserVariable=null;
    }
  }
  Variable sshKeyVariable=null;
  for (  String vmUserPassword : PluginUtils.getSupportedVirtualMachineLoginPasswordPropertyNames()) {
    sshKeyVariable=templateContext.getPropertyVariable(vmUserPassword);
    if (sshKeyVariable == null) {
      sshKeyVariable=templateContext.getPropertyVariable(vmUserPassword,true);
      if (sshKeyVariable == null) {
        sshKeyVariable=templateContext.getPropertyVariable(vmUserPassword,false);
      }
    }
  }
  if (sshKeyVariable == null) {
    return false;
  }
 else {
    if (Utils.isVariableValueEmpty(sshKeyVariable,templateContext)) {
      sshKeyVariable=null;
    }
  }
  if (sshUserVariable == null) {
    String cleanPropName=serverIpPropWrapper.getName().substring(serverIpPropWrapper.getName().lastIndexOf("String_Node_Str") + 1);
switch (cleanPropName) {
case Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_SERVERIP:
      LOG.debug("String_Node_Str");
    templateContext.addStringValueToPlanRequest("String_Node_Str");
  break;
case Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_VMIP:
LOG.debug("String_Node_Str");
templateContext.addStringValueToPlanRequest(Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_VMLOGINNAME);
break;
default :
return false;
}
}
if (sshKeyVariable == null) {
String cleanPropName=serverIpPropWrapper.getName().substring(serverIpPropWrapper.getName().lastIndexOf("String_Node_Str") + 1);
switch (cleanPropName) {
case Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_SERVERIP:
LOG.debug("String_Node_Str");
templateContext.addStringValueToPlanRequest("String_Node_Str");
break;
case Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_VMIP:
LOG.debug("String_Node_Str");
templateContext.addStringValueToPlanRequest(Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_VMLOGINPASSWORD);
break;
default :
return false;
}
}
String templateId="String_Node_Str";
for (AbstractNodeTemplate nodeTemplate : templateContext.getNodeTemplates()) {
if (PluginUtils.isSupportedUbuntuVMNodeType(nodeTemplate.getType().getId())) {
templateId=nodeTemplate.getId();
}
}
if (templateId.equals("String_Node_Str")) {
Handler.LOG.warn("String_Node_Str");
return false;
}
LOG.debug("String_Node_Str");
templateContext.addStringValueToPlanRequest("String_Node_Str");
LOG.debug("String_Node_Str");
templateContext.addStringValueToPlanRequest("String_Node_Str");
Map<String,Variable> runScriptRequestInputParams=new HashMap<String,Variable>();
Variable runShScriptStringVar=this.appendBPELAssignOperationShScript(templateContext,operation,scriptRef,ia);
String cleanPropName=serverIpPropWrapper.getName().substring(serverIpPropWrapper.getName().lastIndexOf("String_Node_Str") + 1);
switch (cleanPropName) {
case Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_SERVERIP:
runScriptRequestInputParams.put("String_Node_Str",serverIpPropWrapper);
runScriptRequestInputParams.put("String_Node_Str",sshKeyVariable);
runScriptRequestInputParams.put("String_Node_Str",sshUserVariable);
runScriptRequestInputParams.put("String_Node_Str",runShScriptStringVar);
this.invokerPlugin.handle(templateContext,templateId,true,"String_Node_Str","String_Node_Str","String_Node_Str",runScriptRequestInputParams,new HashMap<String,Variable>(),false);
break;
case Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_VMIP:
runScriptRequestInputParams.put("String_Node_Str",serverIpPropWrapper);
runScriptRequestInputParams.put("String_Node_Str",sshKeyVariable);
runScriptRequestInputParams.put("String_Node_Str",sshUserVariable);
runScriptRequestInputParams.put("String_Node_Str",runShScriptStringVar);
this.invokerPlugin.handle(templateContext,templateId,true,"String_Node_Str",Interfaces.OPENTOSCA_DECLARATIVE_INTERFACE_OPERATINGSYSTEM,"String_Node_Str",runScriptRequestInputParams,new HashMap<String,Variable>(),false);
break;
default :
return false;
}
return true;
}

Fixed version (ground truth):
/** 
 * Adds logic to the BuildPlan to call a Script on a remote machine
 * @param context the TemplatePlanContext where the logical provisioning operation is called
 * @param operation the operation to call
 * @param ia the ia that implements the operation
 * @return true iff adding BPEL Fragment was successful
 */
public boolean handle(TemplatePlanContext templateContext,AbstractOperation operation,AbstractImplementationArtifact ia){
  AbstractArtifactReference scriptRef=this.fetchScriptRefFromIA(ia);
  if (scriptRef == null) {
    return false;
  }
  List<AbstractNodeTemplate> nodes=new ArrayList<AbstractNodeTemplate>();
  Utils.getNodesFromNodeToSink(templateContext.getNodeTemplate(),nodes);
  nodes.add(templateContext.getNodeTemplate());
  AbstractNodeTemplate ubuntuNodeTemplate=null;
  String templateId="String_Node_Str";
  for (  AbstractNodeTemplate nodeTemplate : nodes) {
    if (PluginUtils.isSupportedUbuntuVMNodeType(nodeTemplate.getType().getId())) {
      ubuntuNodeTemplate=nodeTemplate;
      templateId=nodeTemplate.getId();
    }
  }
  if (templateId.equals("String_Node_Str")) {
    Handler.LOG.warn("String_Node_Str");
    return false;
  }
  if (templateContext.getNodeTemplate() == null) {
    Handler.LOG.warn("String_Node_Str");
    return false;
  }
  Variable serverIpPropWrapper=null;
  for (  String serverIp : PluginUtils.getSupportedVirtualMachineIPPropertyNames()) {
    serverIpPropWrapper=templateContext.getPropertyVariable(ubuntuNodeTemplate,serverIp);
    if (serverIpPropWrapper == null) {
      serverIpPropWrapper=templateContext.getPropertyVariable(serverIp,true);
      if (serverIpPropWrapper == null) {
        serverIpPropWrapper=templateContext.getPropertyVariable(serverIp,false);
      }
    }
  }
  if (serverIpPropWrapper == null) {
    Handler.LOG.warn("String_Node_Str");
    return false;
  }
  Variable sshUserVariable=null;
  for (  String vmUserName : PluginUtils.getSupportedVirtualMachineLoginUserNamePropertyNames()) {
    sshUserVariable=templateContext.getPropertyVariable(ubuntuNodeTemplate,vmUserName);
    if (sshUserVariable == null) {
      sshUserVariable=templateContext.getPropertyVariable(vmUserName,true);
      if (sshUserVariable == null) {
        sshUserVariable=templateContext.getPropertyVariable(vmUserName,false);
      }
    }
  }
  if (sshUserVariable == null) {
    return false;
  }
 else {
    if (Utils.isVariableValueEmpty(sshUserVariable,templateContext)) {
      sshUserVariable=null;
    }
  }
  Variable sshKeyVariable=null;
  for (  String vmUserPassword : PluginUtils.getSupportedVirtualMachineLoginPasswordPropertyNames()) {
    sshKeyVariable=templateContext.getPropertyVariable(ubuntuNodeTemplate,vmUserPassword);
    if (sshKeyVariable == null) {
      sshKeyVariable=templateContext.getPropertyVariable(vmUserPassword,true);
      if (sshKeyVariable == null) {
        sshKeyVariable=templateContext.getPropertyVariable(vmUserPassword,false);
      }
    }
  }
  if (sshKeyVariable == null) {
    return false;
  }
 else {
    if (Utils.isVariableValueEmpty(sshKeyVariable,templateContext)) {
      sshKeyVariable=null;
    }
  }
  if (sshUserVariable == null) {
    String cleanPropName=serverIpPropWrapper.getName().substring(serverIpPropWrapper.getName().lastIndexOf("String_Node_Str") + 1);
switch (cleanPropName) {
case Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_SERVERIP:
      LOG.debug("String_Node_Str");
    templateContext.addStringValueToPlanRequest("String_Node_Str");
  break;
case Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_VMIP:
LOG.debug("String_Node_Str");
templateContext.addStringValueToPlanRequest(Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_VMLOGINNAME);
break;
default :
return false;
}
}
if (sshKeyVariable == null) {
String cleanPropName=serverIpPropWrapper.getName().substring(serverIpPropWrapper.getName().lastIndexOf("String_Node_Str") + 1);
switch (cleanPropName) {
case Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_SERVERIP:
LOG.debug("String_Node_Str");
templateContext.addStringValueToPlanRequest("String_Node_Str");
break;
case Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_VMIP:
LOG.debug("String_Node_Str");
templateContext.addStringValueToPlanRequest(Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_VMLOGINPASSWORD);
break;
default :
return false;
}
}
LOG.debug("String_Node_Str");
templateContext.addStringValueToPlanRequest("String_Node_Str");
LOG.debug("String_Node_Str");
templateContext.addStringValueToPlanRequest("String_Node_Str");
Map<String,Variable> runScriptRequestInputParams=new HashMap<String,Variable>();
Variable runShScriptStringVar=this.appendBPELAssignOperationShScript(templateContext,operation,scriptRef,ia);
String cleanPropName=serverIpPropWrapper.getName().substring(serverIpPropWrapper.getName().lastIndexOf("String_Node_Str") + 1);
switch (cleanPropName) {
case Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_SERVERIP:
runScriptRequestInputParams.put("String_Node_Str",serverIpPropWrapper);
runScriptRequestInputParams.put("String_Node_Str",sshKeyVariable);
runScriptRequestInputParams.put("String_Node_Str",sshUserVariable);
runScriptRequestInputParams.put("String_Node_Str",runShScriptStringVar);
this.invokerPlugin.handle(templateContext,templateId,true,"String_Node_Str","String_Node_Str","String_Node_Str",runScriptRequestInputParams,new HashMap<String,Variable>(),false);
break;
case Properties.OPENTOSCA_DECLARATIVE_PROPERTYNAME_VMIP:
runScriptRequestInputParams.put("String_Node_Str",serverIpPropWrapper);
runScriptRequestInputParams.put("String_Node_Str",sshKeyVariable);
runScriptRequestInputParams.put("String_Node_Str",sshUserVariable);
runScriptRequestInputParams.put("String_Node_Str",runShScriptStringVar);
this.invokerPlugin.handle(templateContext,templateId,true,"String_Node_Str",Interfaces.OPENTOSCA_DECLARATIVE_INTERFACE_OPERATINGSYSTEM,"String_Node_Str",runScriptRequestInputParams,new HashMap<String,Variable>(),false);
break;
default :
return false;
}
return true;
}