Esempio n. 1
0
 /** {@inheritDoc} */
 @Override
 public void spaceDescriptionEdited(SpaceLifeCycleEvent event) {
   final String activityMessage =
       "Description has been updated to: " + event.getSpace().getDescription();
   Map<String, String> templateParams = new LinkedHashMap<String, String>();
   templateParams.put(SPACE_DESCRIPTION_PARAM, event.getSpace().getDescription());
   templateParams.put(
       BaseActivityProcessorPlugin.TEMPLATE_PARAM_TO_PROCESS, SPACE_DESCRIPTION_PARAM);
   recordActivity(event, activityMessage, SPACE_DESCRIPTION_EDITED_TITLE_ID, templateParams);
   LOG.debug("Description has been updated ");
 }
Esempio n. 2
0
  /** {@inheritDoc} */
  @Override
  public void spaceRenamed(SpaceLifeCycleEvent event) {
    final String activityMessage = "Name has been updated to: " + event.getSpace().getDisplayName();
    Map<String, String> templateParams = new LinkedHashMap<String, String>();
    templateParams.put(SPACE_DISPLAY_NAME_PARAM, event.getSpace().getDisplayName());
    templateParams.put(
        BaseActivityProcessorPlugin.TEMPLATE_PARAM_TO_PROCESS, SPACE_DISPLAY_NAME_PARAM);
    recordActivity(event, activityMessage, SPACE_RENAMED_TITLE_ID, templateParams);
    LOG.debug("Name has been updated ");

    // Update description at the same time of rename space
    if (UpdatedField.DESCRIPTION.equals(event.getSpace().getField())) {
      spaceDescriptionEdited(event);
    }
  }
Esempio n. 3
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());
  }
Esempio n. 4
0
 /** {@inheritDoc} */
 @Override
 public void applicationAdded(SpaceLifeCycleEvent event) {
   LOG.debug(
       "application <strong>"
           + event.getTarget()
           + "</strong> was added in space "
           + event.getSpace().getDisplayName());
 }
Esempio n. 5
0
 /** {@inheritDoc} */
 @Override
 public void applicationRemoved(SpaceLifeCycleEvent event) {
   LOG.debug(
       "application "
           + event.getTarget()
           + " was removed in space "
           + event.getSpace().getDisplayName());
 }
Esempio n. 6
0
  /** {@inheritDoc} */
  @Override
  public void spaceAccessEdited(SpaceLifeCycleEvent event) {
    Space space = event.getSpace();

    // Update space's activity
    Identity spaceIdentity =
        identityManager.getOrCreateIdentity(
            SpaceIdentityProvider.NAME, space.getPrettyName(), false);
    String spaceActivityId =
        getStorage()
            .getProfileActivityId(spaceIdentity.getProfile(), Profile.AttachedActivityType.SPACE);
    if (spaceActivityId != null) {
      ExoSocialActivity activity =
          (ExoSocialActivityImpl) activityManager.getActivity(spaceActivityId);
      if (activity != null) {
        if (Space.HIDDEN.equals(space.getVisibility())) {
          activity.isHidden(true);
        }
        if (Space.PRIVATE.equals(space.getVisibility())) {
          activity.isHidden(false);
        }
        activityManager.updateActivity(activity);
      }
    }

    // Update user space activity of all member of space
    String[] members = space.getMembers();
    for (String member : members) {
      Identity identity =
          identityManager.getOrCreateIdentity(OrganizationIdentityProvider.NAME, member, false);
      String userSpaceActivityId =
          getStorage()
              .getProfileActivityId(identity.getProfile(), Profile.AttachedActivityType.RELATION);
      if (userSpaceActivityId != null) {
        ExoSocialActivity activity =
            (ExoSocialActivityImpl) activityManager.getActivity(userSpaceActivityId);
        if (activity != null) {
          int numberOfSpacesOfMember =
              getSpaceStorage().getNumberOfMemberPublicSpaces(identity.getRemoteId());
          Map<String, String> templateParams = activity.getTemplateParams();
          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);
          }
          activityManager.updateActivity(activity);
        }
      }
    }
  }
Esempio n. 7
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());
 }
Esempio n. 8
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());
  }
Esempio n. 9
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);
  }
Esempio n. 10
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);
   }
 }
Esempio n. 11
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);
      }
    }
  }
Esempio n. 12
0
 /** {@inheritDoc} */
 @Override
 public void spaceRemoved(SpaceLifeCycleEvent event) {
   LOG.debug("space " + event.getSpace().getDisplayName() + " was removed!");
 }
 private void reindex(SpaceLifeCycleEvent event) {
   IndexingService indexingService = CommonsUtils.getService(IndexingService.class);
   indexingService.reindex(SpaceIndexingServiceConnector.TYPE, event.getSpace().getId());
 }
 @Override
 public void spaceRemoved(SpaceLifeCycleEvent event) {
   IndexingService indexingService = CommonsUtils.getService(IndexingService.class);
   indexingService.unindex(SpaceIndexingServiceConnector.TYPE, event.getSpace().getId());
   LOG.debug("Handle un-index for removing space !");
 }
 @Override
 public void spaceCreated(SpaceLifeCycleEvent event) {
   IndexingService indexingService = CommonsUtils.getService(IndexingService.class);
   indexingService.index(SpaceIndexingServiceConnector.TYPE, event.getSpace().getId());
   LOG.debug("Handled create index for newly created space!");
 }