Source:
<code>public AgentOptions heartBeat(String tname, String hname, String agentN, String huuid) { RESTAssert.assertNotEmpty(hname); RESTAssert.assertNotEmpty(tname); RESTAssert.assertNotEmpty(agentN); RESTAssert.assertNotEmpty(huuid); EAgent agent = this.dAgent.findAgentByName(agentN); if (agent == null) { agent = this.createNewAgent(agentN, null); } EHost host = this.getHost(hname, tname, huuid); if(host == null){ host = this.createNewHost(hname, this.dtemplate.findByName(tname)); String uuid = UUID.randomUUID().toString(); <START> host.setUuid(uuid); <END> } DateTime now = new DateTime(); host.setLastSeen(now.getMillis()); host.setAgent(agent); host = this.dhost.save(host); EAgentOption options = this.dagentoptions.findByTemplate(host.getTemplate()); if (options == null) { options = new EAgentOption(); options.setTemplate(host.getTemplate()); options = this.dagentoptions.save(options); } AgentOptions result = MAConverter.fromModel(options); result.setTemplateName(host.getTemplate().getName()); boolean onceExecuted = false; if (options.getDoSshKeys() == TaskState.ONCE) { if (host.getExecutedSSH()) { result.setDoSshKeys(TaskState.OFF); } else { onceExecuted = true; host.setExecutedSSH(true); } } if (options.getDoPackageManagement() == TaskState.ONCE) { if (host.getExecutedPkg()) { result.setDoPackageManagement(TaskState.OFF); } else { onceExecuted = true; host.setExecutedPkg(true); } } if (options.getDoFileManagement() == TaskState.ONCE) { if (host.getExecutedFiles()) { result.setDoFileManagement(TaskState.OFF); } else { onceExecuted = true; host.setExecutedFiles(true); } } if (onceExecuted) { this.dhost.save(host); } result.setUuid(host.getUuid()); return result; }</code><technical_language>getHost method in this if clause..</technical_language>

Target:
public AgentOptions heartBeat(String tname, String hname, String agentN, String huuid) { RESTAssert.assertNotEmpty(hname); RESTAssert.assertNotEmpty(tname); RESTAssert.assertNotEmpty(agentN); RESTAssert.assertNotEmpty(huuid); EAgent agent = this.dAgent.findAgentByName(agentN); if (agent == null) { agent = this.createNewAgent(agentN, null); } EHost host = this.dhost.findByUuid(huuid); if(host == null){ host = this.createNewHost(hname, this.dtemplate.findByName(tname)); } if(host == null){ host = this.createNewHost(hname, this.dtemplate.findByName(tname)); String uuid = UUID.randomUUID().toString(); host.setUuid(uuid); } DateTime now = new DateTime(); host.setLastSeen(now.getMillis()); host.setAgent(agent); host = this.dhost.save(host); EAgentOption options = this.dagentoptions.findByTemplate(host.getTemplate()); if (options == null) { options = new EAgentOption(); options.setTemplate(host.getTemplate()); options = this.dagentoptions.save(options); } AgentOptions result = MAConverter.fromModel(options); result.setTemplateName(host.getTemplate().getName()); boolean onceExecuted = false; if (options.getDoSshKeys() == TaskState.ONCE) { if (host.getExecutedSSH()) { result.setDoSshKeys(TaskState.OFF); } else { onceExecuted = true; host.setExecutedSSH(true); } } if (options.getDoPackageManagement() == TaskState.ONCE) { if (host.getExecutedPkg()) { result.setDoPackageManagement(TaskState.OFF); } else { onceExecuted = true; host.setExecutedPkg(true); } } if (options.getDoFileManagement() == TaskState.ONCE) { if (host.getExecutedFiles()) { result.setDoFileManagement(TaskState.OFF); } else { onceExecuted = true; host.setExecutedFiles(true); } } if (onceExecuted) { this.dhost.save(host); } result.setUuid(host.getUuid()); return result; }