add guard about the owner

add guard about the owner
This commit is contained in:
coderfengyun 2014-08-21 14:09:52 +08:00
parent b6da61daa1
commit 3c12ea5ec5
2 changed files with 18 additions and 0 deletions

View File

@ -6,6 +6,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import antlr.collections.List;
@Controller
@RequestMapping("/")
public class HomeController extends BaseController {
@ -21,4 +23,10 @@ public class HomeController extends BaseController {
}
return "Hello [" + userName + "]";
}
@RequestMapping(value = { "/tasks" }, method = RequestMethod.GET)
@ResponseBody
public void currentTasks() {
}
}

View File

@ -18,6 +18,7 @@ import org.bench4q.master.domain.service.TestPlanService;
import org.bench4q.master.domain.service.UserService;
import org.bench4q.master.domain.service.report.ReportService;
import org.bench4q.master.exception.Bench4QException;
import org.bench4q.master.exception.Bench4QRunTimeException;
import org.bench4q.share.enums.master.TestPlanStatus;
import org.bench4q.share.models.master.MonitorModel;
import org.bench4q.share.models.master.ScriptHandleModel;
@ -308,8 +309,17 @@ public class TestPlanController extends BaseController {
throws Bench4QException {
guardHasAuthentication("You have no power to stop test plan",
"/stop/{testPlanId}");
guardIsTheOwner(testPlanId);
return buildTestPlanResponseModel(
this.getTestPlanRunner().stop(testPlanId), "",
Collections.<TestPlan> emptyList());
}
private void guardIsTheOwner(UUID testPlanId) {
if (!getPrincipal().getUserName().equals(
this.getTestPlanService().getTestPlanDBModel(testPlanId)
.getUserModel().getUserName())) {
throw new Bench4QRunTimeException("You are not the owner");
}
}
}