refactor removeAgent(hostName) to removeAgent(id)
This commit is contained in:
parent
b9fb1c0aa4
commit
daa8992d0a
|
@ -58,14 +58,14 @@ public class AgentController extends BaseController {
|
|||
|
||||
@RequestMapping(value = "/removeAgentFromPool", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public AgentResponseModel removeAgentFromPool(@RequestParam String hostName) {
|
||||
public AgentResponseModel removeAgentFromPool(@RequestParam int agentId) {
|
||||
|
||||
if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) {
|
||||
return _setAgentResponseModel(false,
|
||||
"you don't have the power to remove agent from pool!", null);
|
||||
}
|
||||
synchronized (this.getAgentService().getAgentLock()) {
|
||||
if (!this.getAgentService().removeAgentFromPool(hostName)) {
|
||||
if (!this.getAgentService().removeAgentFromPool(agentId)) {
|
||||
return _setAgentResponseModel(false,
|
||||
"remove agent from DB fails in removeAgentFromPool",
|
||||
null);
|
||||
|
|
|
@ -96,13 +96,12 @@ public class AgentService {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean removeAgentFromPool(String hostNameString) {
|
||||
public boolean removeAgentFromPool(int agentId) {
|
||||
Session session = this.getSessionHelper().openSession();
|
||||
Transaction transaction = session.beginTransaction();
|
||||
try {
|
||||
Agent agent = (Agent) session.createCriteria(Agent.class)
|
||||
.add(Restrictions.eq("hostName", hostNameString))
|
||||
.uniqueResult();
|
||||
.add(Restrictions.eq("id", agentId)).uniqueResult();
|
||||
if (agent == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue