コード例 #1
0
  private int getActivitiesUpdatedNum(boolean hasRefresh) {
    if (this.postActivity) {
      resetCookies();
      this.postActivity = false;

      return 0;
    }

    //
    UIActivitiesLoader activitiesLoader = getChild(UIActivitiesLoader.class);
    ActivitiesRealtimeListAccess activitiesListAccess =
        (ActivitiesRealtimeListAccess) activitiesLoader.getActivityListAccess();

    String mode = DisplayMode.ALL_ACTIVITIES.toString();
    ActivityFilterType.ACTIVITY_FEED
        .oldFromSinceTime(Utils.getLastVisited(Utils.OLD_FROM, mode))
        .fromSinceTime(Utils.getLastVisited(Utils.FROM, mode))
        .toSinceTime(Utils.getLastVisited(Utils.TO, mode))
        .lastNumberOfUpdated(getLastUpdatedNum(mode));

    //
    mode = DisplayMode.CONNECTIONS.toString();
    ActivityFilterType.CONNECTIONS_ACTIVITIES
        .oldFromSinceTime(Utils.getLastVisited(Utils.OLD_FROM, mode))
        .fromSinceTime(Utils.getLastVisited(Utils.FROM, mode))
        .toSinceTime(Utils.getLastVisited(Utils.TO, mode))
        .lastNumberOfUpdated(getLastUpdatedNum(mode));

    //
    mode = DisplayMode.MY_ACTIVITIES.toString();
    ActivityFilterType.USER_ACTIVITIES
        .oldFromSinceTime(Utils.getLastVisited(Utils.OLD_FROM, mode))
        .fromSinceTime(Utils.getLastVisited(Utils.FROM, mode))
        .toSinceTime(Utils.getLastVisited(Utils.TO, mode))
        .lastNumberOfUpdated(getLastUpdatedNum(mode));

    //
    mode = DisplayMode.MY_SPACE.toString();
    ActivityFilterType.USER_SPACE_ACTIVITIES
        .oldFromSinceTime(Utils.getLastVisited(Utils.OLD_FROM, mode))
        .fromSinceTime(Utils.getLastVisited(Utils.FROM, mode))
        .toSinceTime(Utils.getLastVisited(Utils.TO, mode))
        .lastNumberOfUpdated(getLastUpdatedNum(mode));

    ActivityUpdateFilter updatedFilter = new ActivityUpdateFilter(hasRefresh);

    int gotNumber = activitiesListAccess.getNumberOfUpdated(updatedFilter);

    //
    if (gotNumber == 0 && hasRefresh) {
      // only in case lastUpdatedNumber > 0 then reset cookies
      long lastNumber = getLastUpdatedNum(selectedDisplayMode.toString());
      if (lastNumber > 0) {
        resetCookies();
      }
    }

    return gotNumber;
  }
コード例 #2
0
 public void setSelectedDisplayMode(DisplayMode displayMode) {
   selectedDisplayMode = displayMode;
   getChild(UIDropDownControl.class).setValue(selectedDisplayMode.toString());
   try {
     // init();
   } catch (Exception e) {
     LOG.error("Failed to init()");
   }
 }
コード例 #3
0
  private long getLastUpdatedNum(String mode) {
    String cookieKey =
        String.format(Utils.LAST_UPDATED_ACTIVITIES_NUM, mode, Utils.getViewerRemoteId());
    String strValue = Utils.getCookies(cookieKey);
    boolean refreshPage = Utils.isRefreshPage();

    if (strValue == null || (refreshPage == false && mode.equals(selectedDisplayMode.toString()))) {
      return 0;
    }

    return Long.parseLong(strValue);
  }
コード例 #4
0
 private void setSelectedMode(UIDropDownControl uiDropDownControl) {
   if (selectedDisplayMode != null) {
     uiDropDownControl.setValue(selectedDisplayMode.toString());
   }
 }
コード例 #5
0
  /**
   * initialize
   *
   * @throws Exception
   */
  public void init() throws Exception {
    Validate.notNull(ownerName, "ownerName must not be null.");
    Validate.notNull(viewerName, "viewerName must not be null.");
    //
    synchronized (locker) {
      removeChild(UIActivitiesLoader.class);
      activitiesLoader = addChild(UIActivitiesLoader.class, null, "UIActivitiesLoader");
    }
    //
    String activityId = Utils.getActivityID();
    if (activityId != null && activityId.length() > 0) {
      activitiesLoader.setPostContext(PostContext.SINGLE);
    } else {
      activitiesLoader.setPostContext(PostContext.USER);
    }

    // Check if current display page is My Activity Stream
    String currentUserName = URLUtils.getCurrentUser();
    if (currentUserName != null) {
      selectedDisplayMode = DisplayMode.OWNER_STATUS;
    }

    activitiesLoader.setLoadingCapacity(ACTIVITY_PER_PAGE);
    activitiesLoader.setOwnerName(ownerName);
    activitiesLoader.setSelectedDisplayMode(selectedDisplayMode.toString());

    //
    //    UIActivitiesContainer activitiesContainer =
    // activitiesLoader.getChild(UIActivitiesContainer.class);

    //
    Identity ownerIdentity =
        Utils.getIdentityManager()
            .getOrCreateIdentity(OrganizationIdentityProvider.NAME, ownerName, false);

    ActivityManager activityManager = Utils.getActivityManager();
    ListAccess<ExoSocialActivity> activitiesListAccess = null;

    switch (this.selectedDisplayMode) {
      case MY_ACTIVITIES:
        activitiesListAccess = activityManager.getActivitiesWithListAccess(ownerIdentity);
        activitiesLoader.setActivityListAccess(activitiesListAccess);
        break;
      case OWNER_STATUS:
        if (isActivityStreamOwner == false) {
          Identity viewerIdentity =
              Utils.getIdentityManager()
                  .getOrCreateIdentity(OrganizationIdentityProvider.NAME, viewerName, false);
          activitiesListAccess =
              activityManager.getActivitiesWithListAccess(ownerIdentity, viewerIdentity);
          activitiesLoader.setActivityListAccess(activitiesListAccess);
        } else {
          activitiesListAccess = activityManager.getActivitiesWithListAccess(ownerIdentity);
          activitiesLoader.setActivityListAccess(activitiesListAccess);
        }

        break;
      case CONNECTIONS:
        activitiesListAccess =
            activityManager.getActivitiesOfConnectionsWithListAccess(ownerIdentity);
        activitiesLoader.setActivityListAccess(activitiesListAccess);
        break;
      case MY_SPACE:
        activitiesListAccess =
            activityManager.getActivitiesOfUserSpacesWithListAccess(ownerIdentity);
        activitiesLoader.setActivityListAccess(activitiesListAccess);
        break;
      default:
        activitiesListAccess = activityManager.getActivityFeedWithListAccess(ownerIdentity);
        activitiesLoader.setActivityListAccess(activitiesListAccess);
        break;
    }

    //
    String lastVisitedModeCookieKey =
        String.format(Utils.ACTIVITY_STREAM_TAB_SELECTED_COOKIED, Utils.getViewerRemoteId());
    String lastVisitedMode = Utils.getCookies(lastVisitedModeCookieKey);

    this.notChangedMode =
        lastVisitedMode == null
            ? true
            : this.selectedDisplayMode.toString().equals(lastVisitedMode.trim());

    // setNumberOfUpdatedActivities(getActivigetActivitiesUpdatedNumtiesUpdatedNum(notChangedMode));
    setNumberOfUpdatedActivities(0);

    //
    activitiesLoader.init();
  }