Search in sources :

Example 1 with Redirection

use of com.thoughtworks.go.server.ui.controller.Redirection in project gocd by gocd.

the class MyGoController method removeNotificationFilter.

@RequestMapping(value = "/tab/mycruise/notification/delete", method = RequestMethod.POST)
public ModelAndView removeNotificationFilter(@RequestParam("filterId") long filterId, HttpServletRequest request) {
    try {
        Long userId = getUserId(request);
        userService.removeNotificationFilter(userId, filterId);
        return new Redirection("/mycruise/user").addParameter(MESSAGE_KEY, "Successfully deleted the notification filter.");
    } catch (Exception e) {
        return render(request, error(MESSAGE_KEY, "Failed to delete: " + e.getMessage()));
    }
}
Also used : Redirection(com.thoughtworks.go.server.ui.controller.Redirection) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with Redirection

use of com.thoughtworks.go.server.ui.controller.Redirection in project gocd by gocd.

the class MyGoController method addNotificationFilter.

@RequestMapping(value = "/tab/mycruise/notification", method = RequestMethod.POST)
public ModelAndView addNotificationFilter(@RequestParam("pipeline") String pipeline, @RequestParam("stage") String stage, @RequestParam("event") String event, @RequestParam(value = "myCheckin", required = false) Boolean myCheckin, HttpServletRequest request) {
    try {
        NotificationFilter filter = new NotificationFilter(pipeline, stage, StageEvent.valueOf(event), toBoolean(myCheckin));
        userService.addNotificationFilter(getUserId(request), filter);
        return new Redirection("/mycruise/user").addParameter(MESSAGE_KEY, "Successfully saved the notification filter.");
    } catch (Exception e) {
        HashMap<String, Object> data = new HashMap<>();
        data.put("pipeline", pipeline);
        data.put("stage", stage);
        data.put("event", event);
        data.put("myCheckin", myCheckin);
        return render(request, error(MESSAGE_KEY, "Failed to save: " + e.getMessage()), data);
    }
}
Also used : Redirection(com.thoughtworks.go.server.ui.controller.Redirection) NotificationFilter(com.thoughtworks.go.domain.NotificationFilter) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with Redirection

use of com.thoughtworks.go.server.ui.controller.Redirection in project gocd by gocd.

the class MyGoController method updateUserSetting.

@RequestMapping(value = "/tab/mycruise/user", method = RequestMethod.POST)
public ModelAndView updateUserSetting(@RequestParam("email") String email, @RequestParam("matchers") String matchers, @RequestParam(value = "emailme", required = false) Boolean emailMe, HttpServletRequest request) {
    try {
        User user = userService.load(getUserId(request));
        user.setEmail(email);
        user.setEmailMe(toBoolean(emailMe));
        user.setMatcher(matchers);
        userService.saveOrUpdate(user);
        return new Redirection("/mycruise/user").addParameter(MESSAGE_KEY, "Successfully saved the settings");
    } catch (Exception e) {
        return render(request, error(MESSAGE_KEY, "Failed to save: " + e.getMessage()));
    }
}
Also used : User(com.thoughtworks.go.domain.User) Redirection(com.thoughtworks.go.server.ui.controller.Redirection) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Redirection (com.thoughtworks.go.server.ui.controller.Redirection)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 NotificationFilter (com.thoughtworks.go.domain.NotificationFilter)1 User (com.thoughtworks.go.domain.User)1