/**
   * @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);

    // check for just logged in users
    HttpSession session =
        ((RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV))
            .getRequest()
            .getSession(true);
    String loginStarted = (String) session.getAttribute(Settings.SESSION_LOGIN_STARTED);
    if (loginStarted != null && loginStarted.equals("1")) {
      session.removeAttribute(Settings.SESSION_LOGIN_STARTED);
      // do something "after login" stuff

      // initialize the session preference with persistent data from
      // personalization
      IngridSessionPreferences sessionPrefs =
          Utils.getSessionPreferences(
              request, IngridSessionPreferences.SESSION_KEY, IngridSessionPreferences.class);
      if (sessionPrefs != null) {
        Principal principal = request.getUserPrincipal();
        if (principal != null) {
          HashMap persistentSearchSettings =
              (HashMap)
                  IngridPersistencePrefs.getPref(
                      principal.getName(), IngridPersistencePrefs.SEARCH_SETTINGS);
          if (persistentSearchSettings != null) {
            sessionPrefs.putAll(persistentSearchSettings);
          }
        }
      }
    }

    String userName = request.getUserPrincipal().getName();
    User user = null;
    try {
      user = userManager.getUser(userName);
    } catch (SecurityException e) {
      e.printStackTrace();
    }

    if (user != null) {
      context.put("userAttributes", user.getInfoMap());
    }

    super.doView(request, response);
  }
示例#2
0
  public void doView(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)
      throws PortletException, IOException {
    Context context = getContext(request);
    IngridResourceBundle messages =
        new IngridResourceBundle(
            getPortletConfig().getResourceBundle(request.getLocale()), request.getLocale());
    context.put("MESSAGES", messages);

    // enable/disable providers drop down
    String selectedDS =
        SearchState.getSearchStateObjectAsString(request, Settings.PARAM_DATASOURCE);
    if (PortalConfig.getInstance().getBoolean(PortalConfig.PORTAL_SEARCH_DISPLAY_PROVIDERS)
        || selectedDS.equals(Settings.PARAMV_DATASOURCE_ENVINFO)
            && PortalConfig.getInstance()
                .getBoolean(PortalConfig.PORTAL_SEARCH_DISPLAY_PROVIDERS_ENVINFO)) {
      String partner =
          PortalConfig.getInstance().getString(PortalConfig.PORTAL_SEARCH_RESTRICT_PARTNER);
      List providers;
      if (partner == null || partner.length() == 0) {
        providers = UtilsDB.getProviders();
      } else {
        providers = UtilsDB.getProvidersFromPartnerKey(partner);
      }
      context.put("displayProviders", Boolean.TRUE);
      context.put("providers", providers);
      context.put("UtilsString", new UtilsString());

      // get selected provider
      IngridSessionPreferences sessionPrefs =
          Utils.getSessionPreferences(
              request, IngridSessionPreferences.SESSION_KEY, IngridSessionPreferences.class);
      String provider = request.getParameter(Settings.PARAM_PROVIDER);
      if (provider != null) {
        sessionPrefs.put(IngridSessionPreferences.RESTRICTING_PROVIDER, provider);
      }
      context.put(
          "selectedProviderIdent", sessionPrefs.get(IngridSessionPreferences.RESTRICTING_PROVIDER));
    }

    super.doView(request, response);
  }