From 6af45eb9d0dfd9ed9f5ffd4493f1c838bb35b606 Mon Sep 17 00:00:00 2001 From: Minwoo Jung Date: Fri, 1 Jul 2016 10:59:49 +0900 Subject: [PATCH] [#1887] add paramter for alarmRule api --- .../pinpoint/web/controller/AlarmController.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/web/src/main/java/com/navercorp/pinpoint/web/controller/AlarmController.java b/web/src/main/java/com/navercorp/pinpoint/web/controller/AlarmController.java index 64ac31de867b..fa31d6611473 100644 --- a/web/src/main/java/com/navercorp/pinpoint/web/controller/AlarmController.java +++ b/web/src/main/java/com/navercorp/pinpoint/web/controller/AlarmController.java @@ -40,11 +40,12 @@ * @author minwoo.jung */ @Controller -@RequestMapping(value="/alarmRule") +@RequestMapping(value={"/alarmRule", "/application/alarmRule"}) public class AlarmController { private final Logger logger = LoggerFactory.getLogger(this.getClass()); public final static String USER_GROUP_ID = "userGroupId"; + public final static String APPLICATION_ID = "applicationId"; @Autowired AlarmService alarmService; @@ -86,15 +87,19 @@ public Map deleteRule(@RequestBody Rule rule) { @RequestMapping(method = RequestMethod.GET) @ResponseBody - public Object getRule(@RequestParam(USER_GROUP_ID) String userGroupId) { - if (StringUtils.isEmpty(userGroupId)) { + public Object getRule(@RequestParam(value=USER_GROUP_ID, required=false) String userGroupId, @RequestParam(value=APPLICATION_ID, required=false) String applicationId) { + if (StringUtils.isEmpty(userGroupId) && StringUtils.isEmpty(applicationId)) { Map result = new HashMap<>(); result.put("errorCode", "500"); - result.put("errorMessage", "there is not userGroupId to get alarm rule"); + result.put("errorMessage", "there is not userGroupId or applicationID to get alarm rule"); return result; } - return alarmService.selectRuleByUserGroupId(userGroupId); + if (!StringUtils.isEmpty(userGroupId)) { + return alarmService.selectRuleByUserGroupId(userGroupId); + } + + return alarmService.selectRuleByApplicationId(applicationId); } @RequestMapping(method = RequestMethod.PUT)