Package org.opencustomer.db.vo.system

Examples of org.opencustomer.db.vo.system.RoleVO


    public RoleVO getByName(String name)
    {
        String _name = toLower(adjustWildcards(name));

        RoleVO role = null;

        try
        {
            StringBuilder hql = new StringBuilder();
            hql.append(" FROM ").append(getEntityClass().getName()).append(" e ");
View Full Code Here


    private final static Logger log = Logger.getLogger(PageRightsAction.class);

    @Override
    public void writeForm(PageRightsForm form, ActionMessages errors, HttpServletRequest request)
    {
        RoleVO role = (RoleVO) getPanel().getEntity();

        int[] rightIds = new int[role.getRights().size()];
        int pos = 0;
        Iterator<RightVO> it = role.getRights().iterator();
        while (it.hasNext())
        {
            RightVO right = it.next();
            rightIds[pos++] = right.getId().intValue();
        }
View Full Code Here

    }
   
    @Override
    public void readForm(PageRightsForm form, ActionMessages errors, HttpServletRequest request)
    {
        RoleVO role = (RoleVO) getPanel().getEntity();

        // entferne zuerst alle Rechte
        role.getRights().clear();
   
        for (int i = 0; i < form.getRights().length; i++)
        {
            // f�ge die neuen Rechte hinzu
            try
            {
                RightVO right = new RightDAO().getById(new Integer(form.getRights()[i]));
                role.getRights().add(right);
                if (log.isDebugEnabled())
                    log.debug("added right: " + right);
            }
            catch (HibernateException e)
            {
                log.error("could not load role for id: " + form.getRights()[i], e);
            }
        }
       
        // f�ge alle fehlenden Lese-Rechte hinzu
        HashSet<RightVO> missingRights = new HashSet<RightVO>();
        for(RightVO right : role.getRights()) {
            if(RightVO.Type.WRITE.equals(right.getType())) {
                RightVO readRight = new RightDAO().getReadRightForRightGroup(right.getRightGroup());
                if(!role.getRights().contains(readRight)) {
                    missingRights.add(readRight);
                }
            }
        }
        if(!missingRights.isEmpty()) {
            if(log.isDebugEnabled())
                log.debug("add "+missingRights.size()+" missing rights");
            role.getRights().addAll(missingRights);
        }
    }
View Full Code Here

    private static Logger log = Logger.getLogger(DeleteAction.class);

    @Override
    protected void deleteEntity(DeletePanel panel, HttpServletRequest request, HttpServletResponse response, ActionMessages errors)
    {
        RoleVO role = (RoleVO) panel.getEntity();

        if (log.isDebugEnabled())
            log.debug("delete role (ID:" + role.getId() + ")");

        try {
            new RoleDAO().delete(role);
        } catch (HibernateException e) {
            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("default.error.couldNotDeleteEntity", panel.getEntity().getId()));
View Full Code Here

    private static Logger log = Logger.getLogger(SaveAction.class);

    @Override
    protected void saveEntity(EditPanel panel, ActionMessages errors, HttpServletRequest request)
    {
        RoleVO role = (RoleVO) panel.getEntity();
        UserVO user = (UserVO) request.getSession().getAttribute(Globals.USER_KEY);
       
        try
        {
            RoleDAO dao = new RoleDAO();
            if (role.getId() == null)
            {
                if (log.isDebugEnabled())
                    log.debug("create role");
                dao.insert(role, user);
            }
            else
            {
                if (log.isDebugEnabled())
                    log.debug("save role (ID:" + role.getId() + ")");
                dao.update(role, user);
            }
        }
        catch (HibernateException e)
        {
View Full Code Here

    }
   
    @Override
    protected boolean validateData(EditPanel panel, ActionMessages errors, HttpServletRequest request)
    {
        RoleVO role = (RoleVO) panel.getEntity();

        if (role.getName() != null)
        {
            try
            {
                RoleDAO dao = new RoleDAO();

                RoleVO editRole = dao.getByName(role.getName());
                if (editRole != null && !editRole.getId().equals(role.getId())) {
                    if(editRole.isAdmin())
                        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("module.system.role.error.nameExistsInAdmin"));
                    else
                        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("module.system.role.error.nameExists"));
                }
View Full Code Here

    private static Logger log = Logger.getLogger(LoadAction.class);

    @Override
    public EditPanel createPanel(ActionMessages errors, LoadForm form, Hashtable<String, Object> attributes, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
    {
        RoleVO role = (RoleVO)attributes.get("role");
        List<UserVO> users = (List<UserVO>)attributes.get("users");

        boolean deletable = false;
        if(users.isEmpty())
            deletable = true;

        EditPanel panel = new EditPanel(Right.ADMINISTRATION_ROLE_WRITE, role);
       
        if(role.getId() == null)
            panel.setTitle(MessageUtil.message(request, "module.system.role.headLine.create"));
        else
        {
            panel.setTitle(MessageUtil.message(request, "module.system.role.headLine.edit", role.getName()));

            panel.setAttribute(DeleteAction.TEXT_TITLE, MessageUtil.message(request, "module.system.role.delete.headLine", role.getName()));
            panel.setAttribute(DeleteAction.TEXT_QUESTION, MessageUtil.message(request, "module.system.role.delete.question", role.getName()));

        }
       
        panel.addAction(Action.Type.DELETE, "/system/management/role/delete", deletable);
        panel.addAction(Action.Type.SAVE, "/system/management/role/save");
View Full Code Here

    @Override
    public void createEntity(ActionMessages errors, LoadForm form, Hashtable<String, Object> attributes, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
    {
        UserVO activeUser = (UserVO) request.getSession().getAttribute(Globals.USER_KEY);

        RoleVO role = new RoleVO();
       
        role.setAccessUser(EntityAccess.Access.WRITE_SYSTEM);
        role.setOwnerUser(activeUser.getId());
        role.setAccessGroup(EntityAccess.Access.NONE);
        role.setOwnerGroup(activeUser.getProfile().getDefaultUsergroup().getId());
        role.setAccessGlobal(EntityAccess.Access.WRITE_SYSTEM);
       
        List<UserVO> users = new ArrayList<UserVO>();

        attributes.put("role", role);
        attributes.put("users", users);
View Full Code Here

    @Override
    public void loadEntity(ActionMessages errors, LoadForm form, Hashtable<String, Object> attributes, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
    {
        try
        {
            RoleVO role = new RoleDAO().getById(form.getId());
            List<UserVO> users = new UserDAO().getForRole(role);
           
            attributes.put("role", role);
            attributes.put("users", users);
        }
View Full Code Here

    @Override
    public void readForm(PageStandardForm form, ActionMessages errors, HttpServletRequest request)
    {
        UserVO activeUser = (UserVO) request.getSession().getAttribute(Globals.USER_KEY);
        RoleVO role       = (RoleVO)getPanel().getEntity();

        role.setName(form.getName());
        if(role.getId() == null && activeUser.getProfile().getRole().isAdmin())
            role.setAdmin(form.isAdmin());
    }
View Full Code Here

TOP

Related Classes of org.opencustomer.db.vo.system.RoleVO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.