0 Replies Latest reply on Dec 30, 2010 11:38 AM by maikronian

    The Session that I set in the valve  is the same or can be shared with the portletSession with ApplicationScope?

    maikronian

      The problem that I have is that I want  to display some content.in the header layouts of my portal page.according the usergroup.

       

      This is the following snippet:


          public void invoke(Request request, Response response) throws IOException, ServletException {

       

              if (productCodes != null) {
                     if(authenticateProducts(request, response, productCodes)) {

                        String locationId = authHelper.obtainAuthorizedLocationId(request, productCodes);

                        getUserPreferences(Request request, String locationId)
                     }  
              }
          }

       

           public Map<String, Object> getUserPreferences(Request request, String locationId) {
              Session session = request.getSessionInternal(true);
               Map<String, Object> preferences = (Map<String, Object>)  session.getSession().getAttribute(USER_GROUP_PREFERENCES);
              if (preferences == null || preferences.isEmpty()) {
                  preferences = retrieveUserGroupPreferences(locationId);
                  session.getSession().setAttribute(USER_GROUP_PREFERENCES, preferences);
              }
              return preferences;
          }

       

      I tried to get the preferences from the map in a portlet as follows:

       

           Map<String, Object> preferences = (Map<String, Object>) portletSession.getAttribute(USER_GROUP_PREFERENCES,
                      PortletSession.APPLICATION_SCOPE);

       

      But I got preferences = null

       

      I  also tried a ServletFitler and I CAN share the HTTPSession with the  PortletSession,  but it seems that the layout is being executed before  the filter (which is very strange to me), so I found that the valve is  executed before anything but now that I can successfully invoke the  valve before the layout.jsp, I cannot access the attribute from the  portletsession, do you guys have any idea, I'm stuck!