Search in sources :

Example 1 with WebGroup

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

the class GroupController method saveGroup.

private ModelAndView saveGroup(HttpServletRequest request, HttpServletResponse response) throws Exception {
    HttpSession session = request.getSession(false);
    if (session != null) {
        WebGroup newGroup = (WebGroup) session.getAttribute("group.modifyGroup.jsp");
        updateGroup(request, newGroup);
        m_groupRepository.saveGroup(newGroup);
    }
    return cancel(request, response);
}
Also used : HttpSession(javax.servlet.http.HttpSession) WebGroup(org.opennms.web.group.WebGroup)

Example 2 with WebGroup

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

the class GroupController method editGroup.

private ModelAndView editGroup(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String groupName = request.getParameter("groupName");
    WebGroup group = m_groupRepository.getGroup(groupName);
    return editGroup(request, group);
}
Also used : WebGroup(org.opennms.web.group.WebGroup)

Example 3 with WebGroup

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

the class GroupController method removeDutySchedules.

private ModelAndView removeDutySchedules(HttpServletRequest request, HttpServletResponse response) throws Exception {
    HttpSession userSession = request.getSession(true);
    if (userSession != null) {
        // group.modifyGroup.jsp
        WebGroup newGroup = (WebGroup) userSession.getAttribute("group.modifyGroup.jsp");
        updateGroup(request, newGroup);
        userSession.setAttribute("group.modifyGroup.jsp", newGroup);
    }
    return new ModelAndView("admin/userGroupView/groups/modifyGroup");
}
Also used : HttpSession(javax.servlet.http.HttpSession) ModelAndView(org.springframework.web.servlet.ModelAndView) WebGroup(org.opennms.web.group.WebGroup)

Example 4 with WebGroup

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

the class SaveGroupController method handleRequestInternal.

/**
 * {@inheritDoc}
 */
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    HttpSession user = request.getSession(false);
    if (user != null) {
        WebGroup newGroup = (WebGroup) user.getAttribute("group.modifyGroup.jsp");
        m_groupRepository.saveGroup(newGroup);
    }
    return new ModelAndView("redirect:/admin/userGroupView/groups/list.jsp");
}
Also used : HttpSession(javax.servlet.http.HttpSession) ModelAndView(org.springframework.web.servlet.ModelAndView) WebGroup(org.opennms.web.group.WebGroup)

Example 5 with WebGroup

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

the class UpdateGroupController method handleRequestInternal.

/**
 * {@inheritDoc}
 */
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    HttpSession userSession = request.getSession(false);
    if (userSession != null) {
        // group.modifyGroup.jsp
        WebGroup newGroup = (WebGroup) userSession.getAttribute("group.modifyGroup.jsp");
        // get the rest of the group information from the form
        String[] users = request.getParameterValues("selectedUsers");
        newGroup.setUsers(new ArrayList<String>(Arrays.asList(users)));
        String[] selectedCategories = request.getParameterValues("selectedCategories");
        newGroup.setAuthorizedCategories(new ArrayList<String>(Arrays.asList(selectedCategories)));
        Vector<Object> newSchedule = new Vector<>();
        ChoiceFormat days = new ChoiceFormat("0#Mo|1#Tu|2#We|3#Th|4#Fr|5#Sa|6#Su");
        Collection<String> dutySchedules = newGroup.getDutySchedules();
        dutySchedules.clear();
        int dutyCount = WebSecurityUtils.safeParseInt(request.getParameter("dutySchedules"));
        for (int duties = 0; duties < dutyCount; duties++) {
            newSchedule.clear();
            String deleteFlag = request.getParameter("deleteDuty" + duties);
            // don't save any duties that were marked for deletion
            if (deleteFlag == null) {
                for (int i = 0; i < 7; i++) {
                    String curDayFlag = request.getParameter("duty" + duties + days.format(i));
                    if (curDayFlag != null) {
                        newSchedule.addElement(Boolean.TRUE);
                    } else {
                        newSchedule.addElement(Boolean.FALSE);
                    }
                }
                newSchedule.addElement(request.getParameter("duty" + duties + "Begin"));
                newSchedule.addElement(request.getParameter("duty" + duties + "End"));
                DutySchedule newDuty = new DutySchedule(newSchedule);
                dutySchedules.add(newDuty.toString());
            }
        }
        userSession.setAttribute("group.modifyGroup.jsp", newGroup);
    }
    return new ModelAndView(request.getParameter("redirect"));
}
Also used : HttpSession(javax.servlet.http.HttpSession) ChoiceFormat(java.text.ChoiceFormat) 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