@Override
  public void doView(RenderRequest request, RenderResponse response)
      throws PortletException, IOException {
    PortletSession session = request.getPortletSession();
    MainSessionController mainSessionController =
        (MainSessionController)
            session.getAttribute(
                MainSessionController.MAIN_SESSION_CONTROLLER_ATT,
                PortletSession.APPLICATION_SCOPE);

    String spaceId =
        (String)
            session.getAttribute("Silverpeas_Portlet_SpaceId", PortletSession.APPLICATION_SCOPE);

    PortletPreferences pref = request.getPreferences();
    int nbPublis = 5;
    if (StringUtil.isInteger(pref.getValue("nbPublis", "5"))) {
      nbPublis = Integer.parseInt(pref.getValue("nbPublis", "5"));
    }
    int maxAge = 0;
    if (StringUtil.isInteger(pref.getValue("maxAge", "0"))) {
      maxAge = Integer.parseInt(pref.getValue("maxAge", "0"));
    }
    KmeliaTransversal kmeliaTransversal = new KmeliaTransversal(mainSessionController);
    List<PublicationDetail> publications =
        kmeliaTransversal.getUpdatedPublications(spaceId, maxAge, nbPublis);
    if (StringUtil.isDefined(spaceId)) {
      String rssUrl = getRSSUrl(mainSessionController, spaceId);
      request.setAttribute("rssUrl", rssUrl);
    }
    request.setAttribute("Publications", publications);
    include(request, response, "portlet.jsp");
  }
  /**
   * @see
   *     org.apache.portals.bridges.velocity.GenericVelocityPortlet#processAction(javax.portlet.ActionRequest,
   *     javax.portlet.ActionResponse)
   */
  public void processAction(ActionRequest request, ActionResponse actionResponse)
      throws PortletException, IOException {

    String action = request.getParameter(Settings.PARAM_ACTION);
    if (action == null) {
      action = "";
    }

    PortletSession session = request.getPortletSession();

    if (action.equalsIgnoreCase("doOpenPartner")) {
      DisplayTreeNode partnerRoot = (DisplayTreeNode) session.getAttribute("partnerRoot");
      if (partnerRoot != null) {
        DisplayTreeNode node = partnerRoot.getChild(request.getParameter("id"));
        node.setOpen(true);
        if (node.get("checked") != null) {
          Iterator it = node.getChildren().iterator();
          while (it.hasNext()) {
            DisplayTreeNode child = (DisplayTreeNode) it.next();
            child.put("checked", "true");
          }
        }
      }
    } else if (action.equalsIgnoreCase("doClosePartner")) {
      DisplayTreeNode partnerRoot = (DisplayTreeNode) session.getAttribute("partnerRoot");
      if (partnerRoot != null) {
        DisplayTreeNode node = partnerRoot.getChild(request.getParameter("id"));
        node.setOpen(false);
      }
    } else if (action.equalsIgnoreCase("doOriginalSettings")) {
      Principal principal = request.getUserPrincipal();
      IngridPersistencePrefs.setPref(
          principal.getName(), IngridPersistencePrefs.SEARCH_PARTNER, "");
      DisplayTreeNode partnerRoot = (DisplayTreeNode) session.getAttribute("partnerRoot");
      Iterator it = partnerRoot.getChildren().iterator();
      while (it.hasNext()) {
        DisplayTreeNode partnerNode = (DisplayTreeNode) it.next();
        partnerNode.setOpen(false);
        Iterator it2 = partnerNode.getChildren().iterator();
        while (it2.hasNext()) {
          DisplayTreeNode providerNode = (DisplayTreeNode) it2.next();
          providerNode.remove("checked");
        }
      }
    } else {
      // Zur Suchanfrage hinzufuegen
      DisplayTreeNode partnerRoot = (DisplayTreeNode) session.getAttribute("partnerRoot");
      String resultQuery = UtilsSearch.processSearchPartner("", partnerRoot, request);
      Principal principal = request.getUserPrincipal();
      IngridPersistencePrefs.setPref(
          principal.getName(), IngridPersistencePrefs.SEARCH_PARTNER, resultQuery);
    }
  }
  @Override
  public int doEndTag() throws JspException {
    // From portlet:defineObjects
    final RenderRequest renderRequest =
        (RenderRequest) this.pageContext.getAttribute("renderRequest");
    final RenderResponse renderResponse =
        (RenderResponse) this.pageContext.getAttribute("renderResponse");

    final PortletDelegationLocator portletDelegationLocator =
        (PortletDelegationLocator)
            renderRequest.getAttribute(PortletDelegationLocator.PORTLET_DELECATION_LOCATOR_ATTR);

    final String sessionKey = this.sessionKeyPrefix + this.fname;

    final PortletSession portletSession = renderRequest.getPortletSession();
    IPortletWindowId portletWindowId = (IPortletWindowId) portletSession.getAttribute(sessionKey);

    final PortletDelegationDispatcher portletDelegationDispatcher;
    final DelegateState delegateState;
    // No id in session, create a new dispatcher
    if (portletWindowId == null) {
      portletDelegationDispatcher =
          portletDelegationLocator.createRequestDispatcher(renderRequest, this.fname);
      portletWindowId = portletDelegationDispatcher.getPortletWindowId();
      portletSession.setAttribute(sessionKey, portletWindowId);

      final PortletMode portletMode = PortletUtils.getPortletMode(this.portletMode);
      final WindowState windowState = PortletUtils.getWindowState(this.windowState);

      delegateState = new DelegateState(portletMode, windowState);
    }
    // id in session, get the old dispatcher
    else {
      portletDelegationDispatcher =
          portletDelegationLocator.getRequestDispatcher(renderRequest, portletWindowId);
      delegateState = null;
    }

    final DelegationRequest delegationRequest = new DelegationRequest();
    delegationRequest.setDelegateState(delegateState);

    // Setup base for portlet URLs
    delegationRequest.setParentPortletMode(this.parentUrlMode);
    delegationRequest.setParentWindowState(this.parentUrlState);
    delegationRequest.setParentParameters(this.parentUrlParameters);

    final JspWriter out = this.pageContext.getOut();
    try {
      portletDelegationDispatcher.doRender(
          renderRequest,
          renderResponse,
          delegationRequest,
          new JspWriterPortletOutputHandler(out, renderResponse));
    } catch (IOException e) {
      throw new JspException(
          "Failed to execute delegate render on portlet '" + this.fname + "'", e);
    }

    return Tag.EVAL_PAGE;
  }
  public <T> boolean exists(Class<T> ssoClass) {
    String key = buildKey(ssoClass);

    PortletSession session = getSession();

    return session != null && session.getAttribute(key, PortletSession.APPLICATION_SCOPE) != null;
  }
 public Object getAttribute(String string, int i) {
   try {
     return session.getAttribute(string, i);
   } catch (IllegalStateException e) {
     throw new SessionExpiredException(e);
   }
 }
 public void removeListener(SessionListener sessionListener) {
   final ServletExternalContext.SessionListeners listeners =
       (ServletExternalContext.SessionListeners)
           portletSession.getAttribute(
               ServletExternalContext.SESSION_LISTENERS, PortletSession.APPLICATION_SCOPE);
   if (listeners != null) listeners.removeListener(sessionListener);
 }
Пример #7
0
  /**
   * Get the specified session attribute in the given scope, creating and setting a new attribute if
   * no existing found. The given class needs to have a public no-arg constructor. Useful for
   * on-demand state objects in a web tier, like shopping carts.
   *
   * @param session current portlet session
   * @param name the name of the session attribute
   * @param clazz the class to instantiate for a new attribute
   * @param scope the session scope of this attribute
   * @return the value of the session attribute, newly created if not found
   * @throws IllegalArgumentException if the session attribute could not be instantiated
   */
  public static Object getOrCreateSessionAttribute(
      PortletSession session, String name, Class<?> clazz, int scope)
      throws IllegalArgumentException {

    Assert.notNull(session, "Session must not be null");
    Object sessionObject = session.getAttribute(name, scope);
    if (sessionObject == null) {
      Assert.notNull(clazz, "Class must not be null if attribute value is to be instantiated");
      try {
        sessionObject = clazz.newInstance();
      } catch (InstantiationException ex) {
        throw new IllegalArgumentException(
            "Could not instantiate class ["
                + clazz.getName()
                + "] for session attribute '"
                + name
                + "': "
                + ex.getMessage());
      } catch (IllegalAccessException ex) {
        throw new IllegalArgumentException(
            "Could not access default constructor of class ["
                + clazz.getName()
                + "] for session attribute '"
                + name
                + "': "
                + ex.getMessage());
      }
      session.setAttribute(name, sessionObject, scope);
    }
    return sessionObject;
  }
 private void sendAlert(RenderRequest request, Context context) {
   PortletSession pSession = request.getPortletSession(true);
   String str = (String) pSession.getAttribute(ALERT_MESSAGE);
   pSession.removeAttribute(ALERT_MESSAGE);
   if (str != null && str.length() > 0)
     context.put("alertMessage", validator.escapeHtml(str, false));
 }
Пример #9
0
  public static void authenticateEvernote(
      RenderRequest renderRequest, PortletSession portletSession, ThemeDisplay themeDisplay)
      throws OAuthException {

    HttpServletRequest request = PortalUtil.getHttpServletRequest(renderRequest);
    String authorizationUrl = StringPool.BLANK;

    try {

      OAuthService service = getOAuthService(request, themeDisplay);

      if (PortalUtil.getOriginalServletRequest(request).getParameter(OAUTH_VERIFIER) == null) {
        // Send an OAuth message to the Provider asking for a new Request
        // Token because we don't have access to the current user's account.
        Token scribeRequestToken = service.getRequestToken();

        portletSession.setAttribute(REQUEST_TOKEN, scribeRequestToken.getToken());
        portletSession.setAttribute(REQUEST_TOKEN_SECRET, scribeRequestToken.getSecret());

        authorizationUrl = EVERNOTE_SERVICE.getAuthorizationUrl(scribeRequestToken.getToken());

      } else {
        // Send an OAuth message to the Provider asking to exchange the
        // existing Request Token for an Access Token
        Token scribeRequestToken =
            new Token(
                portletSession.getAttribute(REQUEST_TOKEN).toString(),
                portletSession.getAttribute(REQUEST_TOKEN_SECRET).toString());

        Verifier scribeVerifier =
            new Verifier(
                PortalUtil.getOriginalServletRequest(request).getParameter(OAUTH_VERIFIER));

        Token scribeAccessToken = service.getAccessToken(scribeRequestToken, scribeVerifier);

        EvernoteAuth evernoteAuth =
            EvernoteAuth.parseOAuthResponse(EVERNOTE_SERVICE, scribeAccessToken.getRawResponse());

        portletSession.setAttribute(ACCESS_TOKEN, evernoteAuth.getToken());
      }

    } catch (Exception e) {
      throw new OAuthException(e);
    }

    renderRequest.setAttribute(AUTHORIZATION_URL, authorizationUrl);
  }
  @Test
  public void testGetUnsharedClient() {
    when(session.getAttribute(
            MultiRequestHttpClientServiceImpl.CLIENT_SESSION_KEY, PortletSession.PORTLET_SCOPE))
        .thenReturn(client);

    HttpClient response = service.getHttpClient(request);
    assertSame(client, response);
  }
Пример #11
0
 /**
  * Return the best available mutex for the given session: that is, an object to synchronize on for
  * the given session.
  *
  * <p>Returns the session mutex attribute if available; usually, this means that the {@link
  * org.springframework.web.util.HttpSessionMutexListener} needs to be defined in {@code web.xml}.
  * Falls back to the {@link javax.portlet.PortletSession} itself if no mutex attribute found.
  *
  * <p>The session mutex is guaranteed to be the same object during the entire lifetime of the
  * session, available under the key defined by the {@link
  * org.springframework.web.util.WebUtils#SESSION_MUTEX_ATTRIBUTE} constant. It serves as a safe
  * reference to synchronize on for locking on the current session.
  *
  * <p>In many cases, the {@link javax.portlet.PortletSession} reference itself is a safe mutex as
  * well, since it will always be the same object reference for the same active logical session.
  * However, this is not guaranteed across different servlet containers; the only 100% safe way is
  * a session mutex.
  *
  * @param session the HttpSession to find a mutex for
  * @return the mutex object (never {@code null})
  * @see org.springframework.web.util.WebUtils#SESSION_MUTEX_ATTRIBUTE
  * @see org.springframework.web.util.HttpSessionMutexListener
  */
 public static Object getSessionMutex(PortletSession session) {
   Assert.notNull(session, "Session must not be null");
   Object mutex =
       session.getAttribute(WebUtils.SESSION_MUTEX_ATTRIBUTE, PortletSession.APPLICATION_SCOPE);
   if (mutex == null) {
     mutex = session;
   }
   return mutex;
 }
Пример #12
0
 private Map<Object, Object> getSessionContext() {
   PortletSession session = request.getPortletSession();
   Map<Object, Object> store =
       (Map<Object, Object>) session.getAttribute("org.juzu.session_scope");
   if (store == null) {
     session.setAttribute("org.juzu.session_scope", store = new HashMap<Object, Object>());
   }
   return store;
 }
  @Test
  public void testGetSharedClient() {
    when(preferences.getValue(MultiRequestHttpClientServiceImpl.SHARED_SESSION_KEY, null))
        .thenReturn("sharedSession");
    when(session.getAttribute("sharedSession", PortletSession.APPLICATION_SCOPE))
        .thenReturn(client);

    HttpClient response = service.getHttpClient(request);
    assertSame(client, response);
  }
Пример #14
0
 /**
  * Get SessionBean.
  *
  * @param request PortletRequest
  * @return Vlado2PortletSessionBean
  */
 private static Vlado2PortletSessionBean getSessionBean(PortletRequest request) {
   PortletSession session = request.getPortletSession();
   if (session == null) return null;
   Vlado2PortletSessionBean sessionBean =
       (Vlado2PortletSessionBean) session.getAttribute(SESSION_BEAN);
   if (sessionBean == null) {
     sessionBean = new Vlado2PortletSessionBean();
     session.setAttribute(SESSION_BEAN, sessionBean);
   }
   return sessionBean;
 }
 public static List<AnalysisStatusDTO> getBackgroundQueue() {
   PortletSession session =
       (PortletSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
   List<AnalysisStatusDTO> backgroundQueue =
       (List<AnalysisStatusDTO>) session.getAttribute("analysis.backgroundQueue");
   if (backgroundQueue == null) {
     backgroundQueue = new ArrayList<AnalysisStatusDTO>();
     session.setAttribute("analysis.backgroundQueue", backgroundQueue);
   }
   return backgroundQueue;
 }
 public void addListener(SessionListener sessionListener) {
   ServletExternalContext.SessionListeners listeners =
       (ServletExternalContext.SessionListeners)
           portletSession.getAttribute(
               ServletExternalContext.SESSION_LISTENERS, PortletSession.APPLICATION_SCOPE);
   if (listeners == null) {
     listeners = new ServletExternalContext.SessionListeners();
     portletSession.setAttribute(
         ServletExternalContext.SESSION_LISTENERS, listeners, PortletSession.APPLICATION_SCOPE);
   }
   listeners.addListener(sessionListener);
 }
  /**
   * @param request the request being processed
   * @param response the response to return
   * @param preferences the portlet preferences
   */
  @ActionMapping(params = Consts.ACTION_ENDDELEGATEMODE)
  public void doActionEndDelegationMode(
      ActionRequest request, ActionResponse response, PortletPreferences preferences, Model model)
      throws Exception {
    LogHelper log = new LogHelper(request);
    RequestMessages rqm = RequestMessages.getRequestMessages(request);
    PortletSession session = request.getPortletSession();
    try {
      log.startTimer("doActionEndDelegationMode");
      BannerPortletData data =
          (BannerPortletData)
              session.getAttribute("BannerPortletData", PortletSession.APPLICATION_SCOPE);
      if (data == null) {
        data = new BannerPortletData();
        data.loadFromRequest(request);
        data.loadFromPreferences(request, rqm);
      }
      // ProtectBlock actionEndDelegationModeBody
      logger.debug("In the doActionEndDelegationMode of ServiceCreditsDeleationView Controller ");
      log.startTimer("doActionEndDelegationMode");
      // logger.info("In the doActionEndDelegationMode,Sessin clean up triggred. "
      // +session.getAttributeMap(PortletSession.APPLICATION_SCOPE).keySet());
      logger.info(
          "Clearing all session attribute set by the ServiceCreditsDelegationView Controller : "
              + Consts.SESSION_SUBJECT_USER_MAP
              + " "
              + Consts.TEMP_SUBJECT_USER_MAP_KEY_IN_SESSION);
      session.removeAttribute(Consts.SESSION_SUBJECT_USER_MAP, PortletSession.APPLICATION_SCOPE);
      session.removeAttribute(
          Consts.TEMP_SUBJECT_USER_MAP_KEY_IN_SESSION, PortletSession.APPLICATION_SCOPE);

      // logger.info("In the doActionEndDelegationMode,Sessin clean up triggred. "
      // +session.getAttributeMap(PortletSession.APPLICATION_SCOPE).keySet());
      logger.debug("Setting the Session Cleanup flag to true");
      // request.setAttribute("spf.cleanupSession", true);
      logger.debug("Ending the Delegation session");
      logger.info("Sending redirect to ServiceCredits home page");
      PortalURL url = Utility.getServiceCreditsHomeUrl(request);
      url.setParameter("spf.cleanupSession", "true");
      response.sendRedirect(url.toString());
      logger.debug("End of doActionEndDelegationMode of ServiceCreditsDeleationView Controller ");
      // TODO Fill In Action Body
      // ProtectBlock End
      session.setAttribute("BannerPortletData", data, PortletSession.APPLICATION_SCOPE);
    } catch (Exception ex) {
      log.endTimer("doActionEndDelegationMode");
      throw ex;
    } finally {
      rqm.saveToRequest();
      session.setAttribute("ActionMode", "action", PortletSession.PORTLET_SCOPE);
      log.endTimer("doActionEndDelegationMode");
    }
  }
  protected <T> Object getOrCreate(Class<T> ssoClass, ApplicationStateCreator<T> creator) {
    PortletSession session = getSession();

    String key = buildKey(ssoClass);

    Object sso = session.getAttribute(key, PortletSession.APPLICATION_SCOPE);

    if (sso == null) {
      sso = creator.create();
      set(ssoClass, (T) sso);
    }

    return sso;
  }
  /**
   * @see
   *     org.apache.portals.bridges.velocity.GenericVelocityPortlet#doView(javax.portlet.RenderRequest,
   *     javax.portlet.RenderResponse)
   */
  public void doView(RenderRequest request, RenderResponse response)
      throws PortletException, IOException {
    Context context = getContext(request);

    IngridResourceBundle messages =
        new IngridResourceBundle(
            getPortletConfig().getResourceBundle(request.getLocale()), request.getLocale());
    context.put("MESSAGES", messages);

    PortletPreferences prefs = request.getPreferences();
    String titleKey = prefs.getValue("titleKey", "searchSettings.title.rankingAndGrouping");
    response.setTitle(messages.getString(titleKey));

    UtilsSearch.doViewForPartnerPortlet(request, context);

    Principal principal = request.getUserPrincipal();
    String partnerStr =
        (String)
            IngridPersistencePrefs.getPref(
                principal.getName(), IngridPersistencePrefs.SEARCH_PARTNER);

    if (partnerStr != null) {

      PortletSession session = request.getPortletSession();
      DisplayTreeNode partnerRoot = (DisplayTreeNode) session.getAttribute("partnerRoot");
      Iterator it = partnerRoot.getChildren().iterator();
      while (it.hasNext()) {
        DisplayTreeNode partnerNode = (DisplayTreeNode) it.next();
        if (partnerStr.indexOf(Settings.QFIELD_PARTNER.concat(":").concat(partnerNode.getId()))
                != -1
            || partnerNode.get("checked") != null) {
          partnerNode.put("checked", "true");
        } else {
          partnerNode.remove("checked");
        }
        Iterator it2 = partnerNode.getChildren().iterator();
        while (it2.hasNext()) {
          DisplayTreeNode providerNode = (DisplayTreeNode) it2.next();
          if (partnerStr.indexOf(Settings.QFIELD_PROVIDER.concat(":").concat(providerNode.getId()))
              != -1) {
            providerNode.put("checked", "true");
            partnerNode.setOpen(true);
          } else {
            providerNode.remove("checked");
          }
        }
      }
    }
    super.doView(request, response);
  }
  /**
   * Use the configured timeout to determine if the user is already authenticated to the remote
   * site.
   *
   * @param request
   * @return
   */
  protected boolean isAlreadyAuthenticated(PortletRequest request) {

    // determine if the last session access was within the timeout window
    final PortletPreferences preferences = request.getPreferences();
    final PortletSession session = request.getPortletSession();
    final Long timestamp = (Long) session.getAttribute(AUTHENTICATION_TIMESTAMP_KEY);
    if (timestamp == null) {
      return false;
    } else {
      final Long timeout =
          Long.valueOf(
              preferences.getValue(AUTHENTICATION_TIMESTAMP_KEY, String.valueOf(30 * 60 * 1000)));
      return (timestamp < System.currentTimeMillis() - timeout);
    }
  }
  protected void init(
      PortletRequest portletRequest,
      PortletResponse portletResponse,
      Bridge.PortletPhase portletPhase) {

    // Save the Bridge.PortletPhase as a request attribute so that it can be picked up by the
    // BridgeRequestAttributeListener.
    portletRequest.setAttribute(Bridge.PORTLET_LIFECYCLE_PHASE, portletPhase);

    // Save the PortletConfig as a request attribute.
    portletRequest.setAttribute(PortletConfig.class.getName(), portletConfig);

    // Save the BridgeConfig as a request attribute.
    portletRequest.setAttribute(BridgeConfig.class.getName(), bridgeConfig);

    // Initialize the bridge request scope.
    initBridgeRequestScope(portletRequest, portletResponse, portletPhase);

    // Save the BridgeRequestScope as a request attribute.
    portletRequest.setAttribute(BridgeRequestScope.class.getName(), bridgeRequestScope);

    // Save the IncongruityContext as a request attribute.
    portletRequest.setAttribute(IncongruityContext.class.getName(), incongruityContext);

    // Save the BridgeContext as a request attribute for legacy versions of ICEfaces.
    setBridgeContextAttribute(portletRequest);

    // Get the FacesContext.
    facesContext = getFacesContext(portletRequest, portletResponse, facesLifecycle);

    // If not set by a previous request, then set the default viewIdHistory for the portlet modes.
    for (String portletMode : PortletModeHelper.PORTLET_MODE_NAMES) {

      String attributeName = Bridge.VIEWID_HISTORY + "." + portletMode;
      PortletSession portletSession = portletRequest.getPortletSession();

      if (portletSession.getAttribute(attributeName) == null) {
        Map<String, String> defaultViewIdMap = ViewUtil.getDefaultViewIdMap(portletConfig);
        portletSession.setAttribute(attributeName, defaultViewIdMap.get(portletMode));
      }
    }
  }
 public static DnDCache getInstance(FacesContext context, boolean encoding) {
   if (CoreUtils.isPortletEnvironment()) {
     PortletSession portletSession =
         (PortletSession) context.getExternalContext().getSession(false);
     DnDCache cache =
         (DnDCache) portletSession.getAttribute(SESSION_KEY, PortletSession.APPLICATION_SCOPE);
     if (cache == null) {
       cache = new DnDCache();
       portletSession.setAttribute(SESSION_KEY, cache, PortletSession.APPLICATION_SCOPE);
     }
     return cache;
   } else {
     String viewId = context.getViewRoot().getViewId();
     Map map = context.getExternalContext().getSessionMap();
     DnDCache cache = (DnDCache) map.get(SESSION_KEY);
     if (cache == null) {
       cache = new DnDCache();
       map.put(SESSION_KEY, cache);
     }
     return cache;
   }
 }
  public static void init(RenderRequest request, RenderResponse response) {
    String outputEncoding = response.getCharacterEncoding();
    //        if (FacesResponseUtil.isMyFacesFacesContext(request)) {
    // for MyFaces
    // MyFaces needs this workaround code because of the implementation
    // issue..
    PortletSession session = request.getPortletSession(true);
    // FacesContext facesContext = FacesContext.getCurrentInstance();
    FacesContext facesContext = FacesResponseUtil.getMyFacesFacesContext(request);
    boolean existResonseWriter = true;
    if (facesContext == null) {
      existResonseWriter = false;
    } else {
      if (facesContext.getResponseWriter() == null) {
        existResonseWriter = false;
      }
    }

    Object oldBufferedResonseStream =
        session.getAttribute(FacesResponseConstants.BUFFERED_RESPONSE_STREAM);
    if (existResonseWriter && oldBufferedResonseStream != null) {
      ((BufferedResponseStream) oldBufferedResonseStream).recycle();
    } else {
      BufferedResponseStream bufferedResponseStream = new BufferedResponseStream(outputEncoding);
      session.setAttribute(FacesResponseConstants.BUFFERED_RESPONSE_STREAM, bufferedResponseStream);
    }
    //        } else {
    //            // for JSF implementation whice does not pass FacesContext from
    //            // processAction to render
    //            BufferedResponseStream bufferedResponseStream = new BufferedResponseStream(
    //                    outputEncoding);
    //            request.setAttribute(
    //                    FacesResponseConstants.BUFFERED_RESPONSE_STREAM,
    //                    bufferedResponseStream);
    //        }
  }
  protected void initBridgeRequestScope(
      PortletRequest portletRequest,
      PortletResponse portletResponse,
      Bridge.PortletPhase portletPhase) {

    boolean bridgeRequestScopeEnabled = true;

    if (portletPhase == Bridge.PortletPhase.RESOURCE_PHASE) {
      bridgeRequestScopeEnabled =
          PortletConfigParam.BridgeRequestScopeAjaxEnabled.getBooleanValue(portletConfig);
    }

    if (bridgeRequestScopeEnabled) {

      // Determine if there is a bridge request scope "id" saved as a render parameter. Note that in
      // order to
      // avoid collisions with bridge request scopes for other portlets, the render parameter name
      // has to be
      // namespaced with the portlet name.
      String portletName = portletConfig.getPortletName();
      String bridgeRequestScopeKey = portletName + PARAM_BRIDGE_REQUEST_SCOPE_ID;

      // If there is a render parameter value found for the "id", then return the cached bridge
      // request scope
      // associated with the "id".
      String bridgeRequestScopeId = portletRequest.getParameter(bridgeRequestScopeKey);

      if (bridgeRequestScopeId != null) {

        bridgeRequestScope = bridgeRequestScopeCache.get(bridgeRequestScopeId);

        if (bridgeRequestScope != null) {
          logger.debug(
              "Found render parameter name=[{0}] value=[{1}] and cached bridgeRequestScope=[{2}]",
              bridgeRequestScopeKey, bridgeRequestScopeId, bridgeRequestScope);
        } else {

          if (bridgeRequestScopePreserved) {
            logger.error(
                "Found render parameter name=[{0}] value=[{1}] BUT bridgeRequestScope is NOT in the cache",
                bridgeRequestScopeKey, bridgeRequestScopeId);
          }
        }
      }

      // Otherwise, if there is a portlet session attribute found for the "id", then return the
      // cached bridge
      // request scope associated with the "id". Note: This occurs after an Ajax-based
      // ResourceRequest so that
      // non-excluded request attributes can be picked up by a subsequent RenderRequest.
      if (bridgeRequestScope == null) {

        // TCK TestPage071: nonFacesResourceTest
        // TCK TestPage073: scopeAfterRedisplayResourcePPRTest
        PortletSession portletSession = portletRequest.getPortletSession();
        bridgeRequestScopeId = (String) portletSession.getAttribute(bridgeRequestScopeKey);

        if (bridgeRequestScopeId != null) {

          portletSession.removeAttribute(bridgeRequestScopeKey);

          bridgeRequestScope = bridgeRequestScopeCache.get(bridgeRequestScopeId);

          if (bridgeRequestScope != null) {

            logger.debug(
                "Found (and removed) session-attribute name=[{0}] value=[{1}] and cached bridgeRequestScope=[{2}]",
                bridgeRequestScopeKey, bridgeRequestScopeId, bridgeRequestScope);

            if (portletResponse instanceof StateAwareResponse) {
              logger.debug(
                  "Setting former session-attribute as render parameter name=[{0}] value=[{1}]",
                  bridgeRequestScopeKey, bridgeRequestScopeId);

              StateAwareResponse stateAwareResponse = (StateAwareResponse) portletResponse;
              stateAwareResponse.setRenderParameter(bridgeRequestScopeKey, bridgeRequestScopeId);
            }
          } else {

            logger.error(
                "Found session attribute name=[{0}] value=[{1}] but bridgeRequestScope is not in the cache",
                bridgeRequestScopeKey, bridgeRequestScopeId);
          }
        }
      }

      // Otherwise, return a new factory created instance.
      if (bridgeRequestScope == null) {
        bridgeRequestScope =
            BridgeRequestScopeFactory.getBridgeRequestScopeInstance(
                portletRequest, portletConfig, bridgeConfig);
      }
    }
  }
  @RequestMapping("EDIT")
  public ModelAndView renderEditView(RenderRequest request, RenderResponse response)
      throws Exception {

    ModelMap model = new ModelMap();
    final PortletPreferences prefs = request.getPreferences();
    String[] recupPrefDisplay_userTabs = prefs.getValues(WebController.PREF_TAB_USER, null);
    String[] recupPrefDisplay_managerTabs = prefs.getValues(WebController.PREF_TAB_MANAGER, null);
    String messageFile = prefs.getValue(WebController.PREF_MESSAGE_FILE, "_fr");
    String nbMaxTickets = prefs.getValue(WebController.PREF_MAX_TICKETS, "15");

    ArrayOfString managerFilters =
        domainService.getInvolvementFilters(
            (prefs.getValue(WebController.PREF_WSDL_LOCATION, null)), false);
    ArrayOfString userFilters =
        domainService.getInvolvementFilters(
            (prefs.getValue(WebController.PREF_WSDL_LOCATION, null)), true);

    ArrayList<String> userTabPrefs = new ArrayList<String>();
    ArrayList<String> managerTabPrefs = new ArrayList<String>();
    int i = 0;
    for (String userFilter : userFilters.getString()) {
      if (Arrays.asList(recupPrefDisplay_userTabs).contains(userFilter.toLowerCase())) {
        i++;
        userTabPrefs.add(String.valueOf(i).concat(".").concat(userFilter).toLowerCase());
      } else {
        userTabPrefs.add(userFilter.toLowerCase());
      }
    }
    Collections.sort(userTabPrefs);
    i = 0;
    for (String managerFilter : managerFilters.getString()) {
      if (Arrays.asList(recupPrefDisplay_managerTabs).contains(managerFilter.toLowerCase())) {
        i++;
        managerTabPrefs.add(String.valueOf(i).concat(".").concat(managerFilter).toLowerCase());
      } else {
        managerTabPrefs.add(managerFilter.toLowerCase());
      }
    }
    Collections.sort(managerTabPrefs);
    boolean userViewMode = true;
    boolean managerViewMode = false;
    boolean maxTicketsViewMode = false;
    String isManagerViewAble = "false";

    if (prefs.isReadOnly(WebController.PREF_TAB_USER)) {
      userViewMode = false;
    }
    PortletSession session = request.getPortletSession();
    if (session != null) {
      isManagerViewAble = session.getAttribute("isManagerViewAble").toString();
    }
    if ((isManagerViewAble.equalsIgnoreCase("true"))
        && (!prefs.isReadOnly(WebController.PREF_TAB_MANAGER))) {
      managerViewMode = true;
    }
    if (!prefs.isReadOnly(WebController.PREF_MAX_TICKETS)) {
      maxTicketsViewMode = true;
    }
    model.put("nbMaxTickets", nbMaxTickets);
    model.put("messageFile", messageFile);
    model.put("managerTabPrefs", managerTabPrefs);
    model.put("userTabPrefs", userTabPrefs);
    model.put("userViewMode", userViewMode);
    model.put("managerViewMode", managerViewMode);
    model.put("maxTicketsViewMode", maxTicketsViewMode);
    model.put("isManagerViewAble", isManagerViewAble);
    return new ModelAndView("edit-portlet", model);
  }
 /**
  * @see javax.servlet.http.HttpSession#getValue(String)
  * @deprecated
  */
 @Override
 @Deprecated
 public Object getValue(final String arg0) {
   return portletSession.getAttribute(arg0);
 }
 /** @see javax.servlet.http.HttpSession#getAttribute(String) */
 @Override
 public Object getAttribute(final String arg0) {
   return portletSession.getAttribute(arg0);
 }
  @Override
  public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {
    LOGGER.entering(LOG_CLASS, "main portlet render entry");

    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);

    PrintWriter writer = portletResp.getWriter();

    PortletSession ps = portletReq.getPortletSession();
    String msg =
        (String)
            ps.getAttribute(
                RESULT_ATTR_PREFIX + "DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse",
                APPLICATION_SCOPE);
    if (msg != null) {
      writer.write("<p>" + msg + "</p><br/>\n");
      ps.removeAttribute(
          RESULT_ATTR_PREFIX + "DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse",
          APPLICATION_SCOPE);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_containsHeader */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.containsHeader must return false"         */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_containsHeader", aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeRedirectURL1 */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.encodeRedirectURL must return null"       */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeRedirectURL1",
              aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeRedirectUrl */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.encodeRedirectUrl must return null"       */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeRedirectUrl",
              aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeURL1 */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.encodeURL must provide the same           */
    /* functionality as ActionResponse.encodeURL"                           */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeURL1", aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeUrl */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.encodeUrl must provide the same           */
    /* functionality as ActionResponse.encodeURL"                           */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeUrl", aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getBufferSize */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.getBufferSize must return 0"              */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getBufferSize", aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getCharacterEncoding */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.getCharacterEncoding must return null"    */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getCharacterEncoding",
              aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getContentType */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.getContentType must return null"          */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getContentType", aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getLocale */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.getLocale must return null"               */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getLocale", aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_isCommitted */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.isCommitted must return true"             */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_isCommitted", aurl);
      tb.writeTo(writer);
    }
  }
Пример #29
0
 /**
  * Read user id.
  *
  * @param session PortletSession
  * @return String
  */
 public String readUserIdentifier(PortletSession session) {
   Assertion assertion = (Assertion) session.getAttribute(AbstractCasFilter.CONST_CAS_ASSERTION);
   String user = assertion.getPrincipal().getName();
   logger.debug("CAS user in PortletSession:" + user);
   return user;
 }
Пример #30
0
 /*
  * (non-Javadoc)
  *
  * @see javax.servlet.http.HttpSession#getAttribute(java.lang.String)
  */
 public Object getAttribute(String name) {
   return portletSession.getAttribute(name);
 }