コード例 #1
0
 /** {@inheritDoc} */
 @Override
 public void applicationRemoved(SpaceLifeCycleEvent event) {
   LOG.debug(
       "application "
           + event.getTarget()
           + " was removed in space "
           + event.getSpace().getDisplayName());
 }
コード例 #2
0
 /** {@inheritDoc} */
 @Override
 public void applicationAdded(SpaceLifeCycleEvent event) {
   LOG.debug(
       "application <strong>"
           + event.getTarget()
           + "</strong> was added in space "
           + event.getSpace().getDisplayName());
 }
コード例 #3
0
 /** {@inheritDoc} */
 @Override
 public void revokedLead(SpaceLifeCycleEvent event) {
   Space space = event.getSpace();
   final String activityMessage =
       "@" + event.getTarget() + " has been revoked as space's manager.";
   Map<String, String> templateParams = new LinkedHashMap<String, String>();
   templateParams.put(USER_NAME_PARAM, "@" + event.getTarget());
   templateParams.put(BaseActivityProcessorPlugin.TEMPLATE_PARAM_TO_PROCESS, USER_NAME_PARAM);
   recordActivity(
       new SpaceLifeCycleEvent(space, space.getEditor(), Type.REVOKED_LEAD),
       activityMessage,
       MANAGER_REVOKED_TITLE_ID,
       templateParams);
   LOG.debug(
       "user "
           + event.getTarget()
           + " has been revoked as space's manage "
           + event.getSpace().getDisplayName());
 }
コード例 #4
0
  /** {@inheritDoc} */
  @Override
  public void joined(SpaceLifeCycleEvent event) {
    final String activityMessage = "Has joined the space.";
    Map<String, String> templateParams = new LinkedHashMap<String, String>();

    //
    recordActivity(event, activityMessage, USER_JOINED_TITLE_ID, templateParams);

    LOG.debug("user " + event.getTarget() + " joined space " + event.getSpace().getDisplayName());
  }
コード例 #5
0
  /** {@inheritDoc} */
  @Override
  public void spaceCreated(SpaceLifeCycleEvent event) {
    Space space = event.getSpace();
    final String activityMessage = "Has joined the space.";
    Map<String, String> templateParams = new LinkedHashMap<String, String>();

    templateParams.put(SPACE_DISPLAY_NAME_PARAM, space.getDisplayName());
    templateParams.put(USER_NAME_PARAM, "@" + event.getTarget());
    templateParams.put(BaseActivityProcessorPlugin.TEMPLATE_PARAM_TO_PROCESS, USER_NAME_PARAM);
    recordActivity(event, activityMessage, SPACE_CREATED_TITLE_ID, templateParams);
  }
コード例 #6
0
  /** {@inheritDoc} */
  @Override
  public void left(SpaceLifeCycleEvent event) {
    final String activityMessage = "Has left the space.";
    Map<String, String> templateParams = new LinkedHashMap<String, String>();
    recordActivity(event, activityMessage, MEMBER_LEFT_TITLE_ID, templateParams);

    // update user space activity for space
    final String userSpaceActivityMessage =
        "I left " + event.getSpace().getDisplayName() + " space";
    // keep to process with old already existing activities when users left spaces
    recordActivityForUserSpace(
        event, userSpaceActivityMessage, USER_SPACE_JOINED_TITLE_ID, templateParams, false);

    LOG.debug(
        "user " + event.getTarget() + " has left of space " + event.getSpace().getDisplayName());
  }
コード例 #7
0
 /**
  * Records an activity based on space lifecyle event and the activity object.
  *
  * @param event the space lifecyle event
  * @param activityMessage the message of activity object
  * @param titleId the title of activity (comment)
  * @param templateParams
  */
 private void recordActivity(
     SpaceLifeCycleEvent event,
     String activityMessage,
     String titleId,
     Map<String, String> templateParams) {
   Space space = event.getSpace();
   Identity spaceIdentity =
       identityManager.getOrCreateIdentity(
           SpaceIdentityProvider.NAME, space.getPrettyName(), false);
   Identity identity =
       identityManager.getOrCreateIdentity(
           OrganizationIdentityProvider.NAME, event.getTarget(), false);
   String activityId =
       getStorage()
           .getProfileActivityId(spaceIdentity.getProfile(), Profile.AttachedActivityType.SPACE);
   if (activityId != null) {
     try {
       if (!"Has left the space.".equals(activityMessage)) {
         ExoSocialActivity comment =
             createComment(activityMessage, titleId, null, SPACE_APP_ID, identity, templateParams);
         ExoSocialActivity activity =
             (ExoSocialActivityImpl) activityManager.getActivity(activityId);
         activityManager.saveComment(activity, comment);
       }
     } catch (Exception e) {
       LOG.debug("Run in case of activity deleted and reupdate");
       activityId = null;
     }
   }
   if (activityId == null) {
     ExoSocialActivity activity = new ExoSocialActivityImpl();
     activity.setType(SPACE_PROFILE_ACTIVITY);
     activity.setTitle("1 Member");
     if (Space.HIDDEN.equals(space.getVisibility())) {
       activity.isHidden(true);
     }
     activityManager.saveActivityNoReturn(spaceIdentity, activity);
     getStorage()
         .updateProfileActivityId(
             spaceIdentity, activity.getId(), Profile.AttachedActivityType.SPACE);
     if (SPACE_CREATED_TITLE_ID.equals(titleId)) titleId = USER_JOINED_TITLE_ID;
     ExoSocialActivity comment =
         createComment(activityMessage, titleId, null, SPACE_APP_ID, identity, templateParams);
     activityManager.saveComment(activity, comment);
   }
 }
コード例 #8
0
  /**
   * Records an activity for user space based on space lifecyle event and the activity object.
   *
   * @param event the space life-cycle event
   * @param activityMessage the message of activity object
   * @param titleId the title of activity (comment)
   * @param templateParams
   */
  private void recordActivityForUserSpace(
      SpaceLifeCycleEvent event,
      String userSpaceActivityMessage,
      String titleId,
      Map<String, String> templateParams,
      boolean isJoined) {
    Space space = event.getSpace();
    if (space.getVisibility().equals(Space.HIDDEN)) {
      return;
    }
    Identity identity =
        identityManager.getOrCreateIdentity(
            OrganizationIdentityProvider.NAME, event.getTarget(), false);
    String activityId =
        getStorage()
            .getProfileActivityId(identity.getProfile(), Profile.AttachedActivityType.RELATION);

    // not go to create new with these kind of activities
    if (activityId == null) {
      return;
    }

    int numberOfSpacesOfMember =
        getSpaceStorage().getNumberOfMemberPublicSpaces(identity.getRemoteId());

    //
    ExoSocialActivity activity = null;
    if (activityId != null) {
      activity = (ExoSocialActivityImpl) activityManager.getActivity(activityId);
    }

    if (activity == null) {
      return;
    }

    templateParams.put(NUMBER_OF_PUBLIC_SPACE, String.valueOf(numberOfSpacesOfMember));
    templateParams.put(
        BaseActivityProcessorPlugin.TEMPLATE_PARAM_TO_PROCESS, NUMBER_OF_PUBLIC_SPACE);
    activity.setTemplateParams(templateParams);

    if (numberOfSpacesOfMember > 1) {
      activity.setTitle("I now member of " + numberOfSpacesOfMember + " spaces");
      activity.setTitleId(USER_JOINED_PUBLIC_SPACES_TITLE_ID);
    } else {
      activity.setTitle("I now member of " + numberOfSpacesOfMember + " space");
      activity.setTitleId(USER_JOINED_PUBLIC_SPACE_TITLE_ID);
    }

    if (activityId != null) {
      if (isJoined) {
        try {
          // Create comment when user join space
          ExoSocialActivity comment =
              createComment(
                  userSpaceActivityMessage,
                  titleId,
                  event.getSpace().getDisplayName(),
                  USER_ACTIVITIES_FOR_SPACE,
                  identity,
                  new LinkedHashMap<String, String>());
          activityManager.updateActivity(activity);
          activityManager.saveComment(activity, comment);
        } catch (Exception e) {
          LOG.debug("Run in case of activity deleted");
          activityId = null;
        }
      } else { // for Spec then left space have no affect on comments
        //
        activityManager.updateActivity(activity);
      }
    }
  }