Package org.rhq.enterprise.gui.legacy

Examples of org.rhq.enterprise.gui.legacy.WebUserPreferences$OperationPortletPreferences


    }

    public String toggleFavorite() {
        log.debug("toggleFavorite for " + resourceUIBean.getId());
        WebUser user = EnterpriseFacesContextUtility.getWebUser();
        WebUserPreferences preferences = user.getWebPreferences();
        WebUserPreferences.FavoriteResourcePortletPreferences favoriteResourcePreferences = preferences
            .getFavoriteResourcePortletPreferences();

        boolean isFav = favoriteResourcePreferences.isFavorite(resourceUIBean.getId());
        if (isFav) {
            favoriteResourcePreferences.removeFavorite(resourceUIBean.getId());
            log.debug("Removing favorite: " + resourceUIBean.getId());
        } else {
            favoriteResourcePreferences.addFavorite(resourceUIBean.getId());
            log.debug("Adding favorite: " + resourceUIBean.getId());
        }

        preferences.setFavoriteResourcePortletPreferences(favoriteResourcePreferences);

        favorite = !isFav;

        return null;
    }
View Full Code Here


    }

    public boolean isFavorite() {
        if (this.isFavorite == null) {
            WebUser user = EnterpriseFacesContextUtility.getWebUser();
            WebUserPreferences preferences = user.getWebPreferences();
            WebUserPreferences.FavoriteGroupPortletPreferences favorites = preferences
                .getFavoriteGroupPortletPreferences();

            this.isFavorite = favorites.isFavorite(getGroupId());
        }
View Full Code Here

    }

    public String toggleFavorite() {
        //        log.debug("toggleFavorite for " + resourceGroup);
        WebUser user = EnterpriseFacesContextUtility.getWebUser();
        WebUserPreferences preferences = user.getWebPreferences();
        WebUserPreferences.FavoriteGroupPortletPreferences favorites = preferences.getFavoriteGroupPortletPreferences();

        boolean isFav = favorites.isFavorite(getGroupId());
        if (isFav) {
            favorites.removeFavorite(getGroupId());
            //            log.debug("Removing favorite: " + resourceId);
        } else {
            favorites.addFavorite(getGroupId());
            //            log.debug("Adding favorite: " + resourceId);
        }

        preferences.setFavoriteGroupPortletPreferences(favorites);

        this.isFavorite = !isFav;

        return null;
    }
View Full Code Here

        HttpServletResponse response) throws Exception {

        PropertiesForm pForm = (PropertiesForm) form;

        WebUser user = SessionUtils.getWebUser(request.getSession());
        WebUserPreferences preferences = user.getWebPreferences();

        String forwardStr = RetCodeConstants.SUCCESS_URL;
        if (pForm.isRemoveClicked()) {
            AlertsPortletPreferences alertPrefs = preferences.getAlertsPortletPreferences();
            for (Integer doomedResourceId : pForm.getIds()) {
                alertPrefs.removeResource(doomedResourceId);
            }
            preferences.setAlertsPortletPreferences(alertPrefs);
            forwardStr = "review";
        } else if (pForm.isOkClicked()) {
            AlertsPortletPreferences alertPrefs = preferences.getAlertsPortletPreferences();
            int[] savedResourceIds = alertPrefs.asArray();
            alertPrefs = pForm.getAlertsPortletPreferences();
            alertPrefs.setResource(ArrayUtils.wrapInList(savedResourceIds));
            preferences.setAlertsPortletPreferences(alertPrefs);
        }

        if (!pForm.isDisplayOnDash()) {
            DashboardUtils.removePortlet(user, pForm.getPortletName());
        }
View Full Code Here

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
        WebUser user = SessionUtils.getWebUser(request.getSession());
        WebUserPreferences preferences = user.getWebPreferences();
        RecentlyApprovedPortletPreferences recentlyApprovedPreferences = preferences
            .getRecentlyApprovedPortletPreferences();

        RAListForm listForm = (RAListForm) form;
        String platformId = new Integer(listForm.getPlatformId()).toString();

        List<String> expandedPlatforms = recentlyApprovedPreferences.expandedPlatforms;
        if (expandedPlatforms.contains(platformId)) {
            expandedPlatforms.remove(platformId);
        } else {
            expandedPlatforms.add(platformId);
        }
        preferences.setRecentlyApprovedPortletPreferences(recentlyApprovedPreferences);

        return mapping.findForward(RetCodeConstants.SUCCESS_URL);
    }
View Full Code Here

    public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
        Log log = LogFactory.getLog(PrepareAction.class);
        PropertiesForm pForm = (PropertiesForm) form;
        WebUser user = SessionUtils.getWebUser(request.getSession());
        WebUserPreferences preferences = user.getWebPreferences();

        //this guarantees that the session dosen't contain any resources it shouldn't
        SessionUtils.removeList(request.getSession(), Constants.PENDING_RESOURCES_SES_ATTR);

        //set all the form properties
        pForm.setDisplayOnDash(true);

        AlertsPortletPreferences alertPrefs = preferences.getAlertsPortletPreferences();
        pForm.setAlertsPortletPreferences(alertPrefs);

        PageControl pageControl = WebUtility.getPageControl(request);

        ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
View Full Code Here

            if (user == null) {
                // session timed out, return prematurely
                return null;
            }

            WebUserPreferences preferences = user.getWebPreferences();

            // get the user's preferences for the alerts portlet
            AlertsPortletPreferences alertPrefs = preferences.getAlertsPortletPreferences();

            PageControl pageControl = new PageControl(0, alertPrefs.count);
            AlertManagerLocal alertManager = LookupUtil.getAlertManager();
            ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
View Full Code Here

        HttpServletResponse response) throws Exception {

        PropertiesForm pForm = (PropertiesForm) form;
        HttpSession session = request.getSession();
        WebUser user = SessionUtils.getWebUser(session);
        WebUserPreferences preferences = user.getWebPreferences();

        ActionForward forward = checkSubmit(request, mapping, form);

        if (forward != null) {
            return forward;
        }

        if (!pForm.isDisplayOnDash()) {
            DashboardUtils.removePortlet(user, pForm.getPortletName());
        }

        RecentlyApprovedPortletPreferences problemResourcePreferences = pForm.getRecentlyApprovedPortletPreferences();
        preferences.setRecentlyApprovedPortletPreferences(problemResourcePreferences);

        session.removeAttribute(Constants.USERS_SES_PORTAL);

        return mapping.findForward(RetCodeConstants.SUCCESS_URL);
    }
View Full Code Here

            if (user == null) {
                // session timed out, return prematurely
                return null;
            }

            WebUserPreferences preferences = user.getWebPreferences();
            RecentlyApprovedPortletPreferences recentlyApprovedPreferences = preferences
                .getRecentlyApprovedPortletPreferences();
            Subject subject = user.getSubject();

            // Based on the user preference, generate a timestamp of the oldest resource to display.
            long range = recentlyApprovedPreferences.hours;
            long ts = 0; // defaults to ANY time in the past
            if (range != -1) {
                // range encoded as hours (UI shows days)
                ts = System.currentTimeMillis() - (range * 60 * 60 * 1000);
            }

            platformList = DisambiguatedRecentlyAddedResourceComposite.fromResolution(resourceManager.disambiguate(
                resourceManager.findRecentlyAddedPlatforms(subject, ts, recentlyApprovedPreferences.range),
                RESOURCE_ID_EXTRACTOR, DefaultDisambiguationUpdateStrategies.getDefault()));

            Map<Integer, DisambiguatedRecentlyAddedResourceComposite> platformMap;
            platformMap = new HashMap<Integer, DisambiguatedRecentlyAddedResourceComposite>();

            for (DisambiguatedRecentlyAddedResourceComposite platform : platformList) {
                platformMap.put(platform.getOriginal().getId(), platform);
            }

            // Set the show servers flag on all expanded platforms.
            // Find the list of expanded platforms for this user and make it available to the jsp.
            List<String> removeExpandedPlatforms = new ArrayList<String>();

            for (String expandedPlatform : recentlyApprovedPreferences.expandedPlatforms) {
                Integer platformId = null;
                try {
                    platformId = Integer.valueOf(expandedPlatform);
                } catch (NumberFormatException nfe) {
                    removeExpandedPlatforms.add(expandedPlatform);
                    continue;
                }
                DisambiguatedRecentlyAddedResourceComposite miniPlatform = platformMap.get(platformId);
                if (miniPlatform != null) {
                    miniPlatform.getOriginal().setShowChildren(true);
                    miniPlatform.setChildren(DisambiguatedRecentlyAddedResourceComposite.fromResolution(
                        resourceManager.disambiguate(resourceManager
                        .findRecentlyAddedServers(subject, ts, platformId.intValue()), RESOURCE_ID_EXTRACTOR,
                        DefaultDisambiguationUpdateStrategies.getDefault())));
                } else {
                    removeExpandedPlatforms.add(expandedPlatform);
                }
            }

            // we do this just to clean up the preferences for platforms in the filter list which no longer exist
            if (removeExpandedPlatforms.size() > 0) {
                recentlyApprovedPreferences.expandedPlatforms.removeAll(removeExpandedPlatforms);
                preferences.setRecentlyApprovedPortletPreferences(recentlyApprovedPreferences);
            }

            // Make the list available to the jsp.

        } catch (Exception e) {
View Full Code Here

        List<String> pendingResourceList = new ArrayList<String>();

        if (session.getAttribute(Constants.PENDING_RESOURCES_SES_ATTR) == null) {
            // if hitting the page for the first time, load resources already associated with user via preferences
            log.debug("get pending resources from user preferences");
            WebUserPreferences preferences = user.getWebPreferences();
            pendingResourceList = preferences.getPreferenceAsList(addForm.getKey(), DashboardUtils.DASHBOARD_DELIMITER);

            if (pendingResourceList != null) {
                // otherwise, we've been here for a while but the user paged, performed changed LHS<->RHS, etc
                log.debug("put entire list of pending resources in session");
                session.setAttribute(Constants.PENDING_RESOURCES_SES_ATTR, pendingResourceList);
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.gui.legacy.WebUserPreferences$OperationPortletPreferences

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.