Package com.adito.policyframework.forms

Examples of com.adito.policyframework.forms.AbstractResourcesForm


    }

    @SuppressWarnings("unchecked")
    private ActionForward viewAs(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response,
                                 String viewType) {
        AbstractResourcesForm resourcesForm = (AbstractResourcesForm) form;
        resourcesForm.setSelectedView(viewType);
        int navigationContext = getSessionInfo(request).getNavigationContext();
        CoreUtil.storeUIState("ui_view_" + resourcesForm.getModel().getId() + "_" + navigationContext, viewType, request, response);
        return mapping.findForward("display");
    }
View Full Code Here


     * @return forward
     * @throws Exception
     */
    public ActionForward favorite(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        AbstractResourcesForm f = (AbstractResourcesForm) form;
        ActionMessages msgs = new ActionMessages();
        User user = LogonControllerFactory.getInstance().getUser(request);
        SystemDatabase sdb = SystemDatabaseFactory.getInstance();
        if (getSessionInfo(request).getNavigationContext() != SessionInfo.USER_CONSOLE_CONTEXT) {
            throw new Exception("Favorites may only be set in the user console.");
        }       
        Resource resource = getResourceById(f.getSelectedResource());
        if(ResourceUtil.filterResourceIdsForGlobalFavorites(PolicyDatabaseFactory.getInstance().getGrantedResourcesOfType(getSessionInfo(request).getUser(),
            resource.getResourceType()), resource.getResourceType()).contains(new Integer(resource.getResourceId()))) {
            throw new Exception("Cannot set a user favorite for items that have a policy favorite.");
        }
        if (sdb.getFavorite(getResourceType().getResourceTypeId(), user, f.getSelectedResource()) != null) {
            msgs.add(Globals.ERROR_KEY, new BundleActionMessage("navigation", "addToFavorites.error.alreadyFavorite", resource
                .getResourceName()));
            saveErrors(request, msgs);
            return mapping.findForward("refresh");
        }
        sdb.addFavorite(getResourceType().getResourceTypeId(), f.getSelectedResource(), user.getPrincipalName());
        msgs.add(Globals.MESSAGES_KEY, new BundleActionMessage("navigation", "addToFavorites.message.favoriteAdded", resource
            .getResourceName()));
        saveMessages(request, msgs);
        return mapping.findForward("refresh");
    }
View Full Code Here

     * @return forward
     * @throws Exception
     */
    public ActionForward removeFavorite(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                    HttpServletResponse response) throws Exception {
        AbstractResourcesForm f = (AbstractResourcesForm) form;
        ActionMessages msgs = new ActionMessages();
        User user = LogonControllerFactory.getInstance().getUser(request);
        SystemDatabase sdb = SystemDatabaseFactory.getInstance();
        if (getSessionInfo(request).getNavigationContext() != SessionInfo.USER_CONSOLE_CONTEXT) {
            throw new Exception("Favorites may only be set in the user console.");
        }       
        Resource resource = getResourceById(f.getSelectedResource());
        if(ResourceUtil.filterResourceIdsForGlobalFavorites(PolicyDatabaseFactory.getInstance().getGrantedResourcesOfType(getSessionInfo(request).getUser(),
            resource.getResourceType()), resource.getResourceType()).contains(new Integer(resource.getResourceId()))) {
            throw new Exception("Cannot remove a user favorite from items that have a policy favorite.");
        }       
        if (sdb.getFavorite(getResourceType().getResourceTypeId(), user, f.getSelectedResource()) == null) {
            msgs.add(Globals.ERROR_KEY, new BundleActionMessage("navigation", "removeFromFavorites.error.notFavorite", resource
                .getResourceName()));
            saveErrors(request, msgs);
            return mapping.findForward("refresh");
        }
        sdb.removeFavorite(getResourceType().getResourceTypeId(), f.getSelectedResource(), user.getPrincipalName());
        msgs.add(Globals.MESSAGES_KEY, new BundleActionMessage("navigation", "removeFromFavorites.message.favoriteAdded", resource
            .getResourceName()));
        saveMessages(request, msgs);
        return mapping.findForward("refresh");
    }
View Full Code Here

TOP

Related Classes of com.adito.policyframework.forms.AbstractResourcesForm

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.