Ejemplo n.º 1
0
 protected JetspeedUser getUserFromContext() {
   JetspeedRunData rundata = getRunData();
   JetspeedUser user = null;
   if (rundata != null) {
     user = (JetspeedUser) rundata.getUser();
   }
   return user;
 }
Ejemplo n.º 2
0
 protected JetspeedRunData putUserIntoContext(JetspeedUser user) {
   JetspeedRunData rundata = getRunData();
   if (rundata != null) {
     rundata.setUser(user);
     rundata.save();
   }
   return rundata;
 }
Ejemplo n.º 3
0
  /**
   * Put custom objects in the velocity context
   *
   * @param data
   * @param name
   * @param value
   * @param parms
   * @param context
   */
  @SuppressWarnings({"rawtypes", "deprecation", "unchecked"})
  @Override
  public void buildContext(RunData rundata, String name, String value, Map parms, Context context) {
    Map entries = null;

    try {
      entries = (Map) rundata.getUser().getTemp(PsmlManagerAction.CACHED_PSML);
      if (entries == null) {
        // Initialize the query locator
        QueryLocator ql = new QueryLocator(QueryLocator.QUERY_USER);

        JetspeedRunData jdata = (JetspeedRunData) rundata;
        ql.setUser(jdata.getJetspeedUser());
        // ql.setMediaType(jdata.getCapability().getPreferredMediaType());
        entries = new Hashtable();
        Iterator i = Profiler.query(ql);
        while (i.hasNext()) {
          Profile profile = (Profile) i.next();

          String mediaType = profile.getMediaType();
          if (mediaType != null
              && mediaType.equals(jdata.getCapability().getPreferredMediaType())) {
            if (PortletUtils.canAccessProfile(rundata, profile)) {
              if (logger.isDebugEnabled()) {
                logger.debug("MyPagesListBox: refreshing user profile list: " + profile.getPath());
              }
              String title = profile.getName();
              if (profile.getRootSet() != null && profile.getRootSet().getTitle() != null) {
                title = profile.getRootSet().getTitle();
              }
              entries.put(profile, title);
            }
          }
        }

        rundata.getUser().setTemp(PsmlManagerAction.CACHED_PSML, entries);
      }

      context.put("pages", entries);
    } catch (Exception e) {
      logger.error("MyPagesListBox.buildContext", e);
    }
  }