Search in sources :

Example 6 with WebGroup

use of org.opennms.web.group.WebGroup in project opennms by OpenNMS.

the class GroupController method showGroup.

private ModelAndView showGroup(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String groupName = request.getParameter("groupName");
    if (!StringUtils.hasText(groupName)) {
        throw new ServletException("The groupName parameter is required");
    }
    WebGroup group = m_groupRepository.getGroup(groupName);
    return new ModelAndView("/admin/userGroupView/groups/groupDetail", "group", group);
}
Also used : ServletException(javax.servlet.ServletException) ModelAndView(org.springframework.web.servlet.ModelAndView) WebGroup(org.opennms.web.group.WebGroup)

Example 7 with WebGroup

use of org.opennms.web.group.WebGroup in project opennms by OpenNMS.

the class GroupController method addGroup.

private ModelAndView addGroup(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String groupName = request.getParameter("groupName");
    String groupComment = request.getParameter("groupComment");
    if (groupComment == null) {
        groupComment = "";
    }
    boolean hasGroup = false;
    try {
        hasGroup = m_groupRepository.groupExists(groupName);
    } catch (Throwable e) {
        throw new ServletException("Can't determine if group " + groupName + " already exists in groups.xml.", e);
    }
    if (hasGroup) {
        return new ModelAndView("admin/userGroupView/groups/newGroup", "action", "redo");
    } else {
        WebGroup newGroup = new WebGroup();
        newGroup.setName(groupName);
        newGroup.setComments(groupComment);
        return editGroup(request, newGroup);
    }
}
Also used : ServletException(javax.servlet.ServletException) ModelAndView(org.springframework.web.servlet.ModelAndView) WebGroup(org.opennms.web.group.WebGroup)

Example 8 with WebGroup

use of org.opennms.web.group.WebGroup in project opennms by OpenNMS.

the class GroupController method addDutySchedules.

private ModelAndView addDutySchedules(HttpServletRequest request, HttpServletResponse response) throws Exception {
    HttpSession userSession = request.getSession(true);
    if (userSession != null) {
        // group.modifyGroup.jsp
        WebGroup group = (WebGroup) userSession.getAttribute("group.modifyGroup.jsp");
        updateGroup(request, group);
        Vector<Object> newSchedule = new Vector<>();
        int dutyAddCount = WebSecurityUtils.safeParseInt(request.getParameter("numSchedules"));
        for (int j = 0; j < dutyAddCount; j++) {
            // add 7 false boolean values for each day of the week
            for (int i = 0; i < 7; i++) {
                newSchedule.addElement(Boolean.FALSE);
            }
            // add two strings for the begin and end time
            newSchedule.addElement("0");
            newSchedule.addElement("0");
            group.addDutySchedule((new DutySchedule(newSchedule)).toString());
        }
        userSession.setAttribute("group.modifyGroup.jsp", group);
    }
    return new ModelAndView("admin/userGroupView/groups/modifyGroup");
}
Also used : HttpSession(javax.servlet.http.HttpSession) ModelAndView(org.springframework.web.servlet.ModelAndView) DutySchedule(org.opennms.netmgt.config.users.DutySchedule) Vector(java.util.Vector) WebGroup(org.opennms.web.group.WebGroup)

Aggregations

WebGroup (org.opennms.web.group.WebGroup)8 ModelAndView (org.springframework.web.servlet.ModelAndView)6 HttpSession (javax.servlet.http.HttpSession)5 Vector (java.util.Vector)2 ServletException (javax.servlet.ServletException)2 DutySchedule (org.opennms.netmgt.config.users.DutySchedule)2 ChoiceFormat (java.text.ChoiceFormat)1