Search in sources :

Example 51 with PortletPreferences

use of javax.portlet.PortletPreferences in project uPortal by Jasig.

the class JspInvokerPortletController method addSecurityRoleChecksToModel.

/**
 * Run through the list of configured security roles and add an "is"+Rolename to the model. The
 * security roles must also be defined with a <code>&lt;security-role-ref&gt;</code> element in
 * the portlet.xml.
 *
 * @param req Portlet request
 * @param model Model object to add security indicators to
 */
private void addSecurityRoleChecksToModel(PortletRequest req, Map<String, Object> model) {
    PortletPreferences prefs = req.getPreferences();
    String[] securityRoles = prefs.getValues(PREF_SECURITY_ROLE_NAMES, new String[] {});
    for (int i = 0; i < securityRoles.length; i++) {
        model.put("is" + securityRoles[i].replace(" ", "_"), req.isUserInRole(securityRoles[i]));
    }
}
Also used : PortletPreferences(javax.portlet.PortletPreferences)

Example 52 with PortletPreferences

use of javax.portlet.PortletPreferences in project uPortal by Jasig.

the class JspInvokerPortletController method getPreferences.

private Map<String, List<String>> getPreferences(PortletRequest req) {
    // default
    Map<String, List<String>> rslt = new HashMap<String, List<String>>();
    PortletPreferences prefs = req.getPreferences();
    List<String> names = Collections.list(prefs.getNames());
    for (String name : names) {
        if (!name.startsWith(CONTROLLER_PREFERENCE_PREFIX)) {
            // Pass it along in the model
            List<String> values = Arrays.asList(prefs.getValues(name, new String[] {}));
            rslt.put(name, values);
        }
    }
    logger.debug("Invoking with preferences={}", rslt);
    return rslt;
}
Also used : HashMap(java.util.HashMap) List(java.util.List) PortletPreferences(javax.portlet.PortletPreferences)

Example 53 with PortletPreferences

use of javax.portlet.PortletPreferences in project uPortal by Jasig.

the class RoleBasedBackgroundSetSelectionStrategy method getImageCaptions.

@Override
public String[] getImageCaptions(PortletRequest req) {
    PreferenceNames names = PreferenceNames.getInstance(req);
    PortletPreferences prefs = req.getPreferences();
    return prefs.getValues(names.IMAGE_CAPTIONS_PREFERENCE_NAME, null);
}
Also used : PortletPreferences(javax.portlet.PortletPreferences)

Example 54 with PortletPreferences

use of javax.portlet.PortletPreferences in project uPortal by Jasig.

the class RoleBasedBackgroundSetSelectionStrategy method getImageSet.

@Override
public String[] getImageSet(PortletRequest req) {
    final PreferenceNames names = PreferenceNames.getInstance(req);
    final PortletPreferences prefs = req.getPreferences();
    final String[] images = prefs.getValues(names.getImageSetPreferenceName(), EMPTY_STRING_ARRAY);
    for (int i = 0; i < images.length; i++) {
        images[i] = evaluateImagePath(images[i]);
    }
    return images;
}
Also used : PortletPreferences(javax.portlet.PortletPreferences)

Example 55 with PortletPreferences

use of javax.portlet.PortletPreferences in project uPortal by Jasig.

the class RoleBasedBackgroundSetSelectionStrategy method getSelectedImage.

@Override
public String getSelectedImage(PortletRequest req) {
    // No evaluation required (already processed)
    PreferenceNames names = PreferenceNames.getInstance(req);
    PortletPreferences prefs = req.getPreferences();
    return prefs.getValue(names.getSelectedBackgroundImagePreferenceName(), null);
}
Also used : PortletPreferences(javax.portlet.PortletPreferences)

Aggregations

PortletPreferences (javax.portlet.PortletPreferences)59 HashMap (java.util.HashMap)12 RenderMapping (org.springframework.web.portlet.bind.annotation.RenderMapping)10 ModelAndView (org.springframework.web.portlet.ModelAndView)9 List (java.util.List)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 PortletRequest (javax.portlet.PortletRequest)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 IPerson (org.apereo.portal.security.IPerson)5 ResourceMapping (org.springframework.web.portlet.bind.annotation.ResourceMapping)5 KBArticle (com.liferay.knowledgebase.model.KBArticle)4 Map (java.util.Map)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ArrayList (java.util.ArrayList)3 LinkedHashMap (java.util.LinkedHashMap)3 AdminSubscriptionSender (com.liferay.knowledgebase.admin.util.AdminSubscriptionSender)2 KBFolder (com.liferay.knowledgebase.model.KBFolder)2 BaseUpgradePortletPreferences (com.liferay.portal.kernel.upgrade.BaseUpgradePortletPreferences)2 Portlet (com.liferay.portal.model.Portlet)2 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)2