@Async public void addActivity(SocialActivity activity, SocialActivity mirrorActivity) throws PortalException, SystemException { if (ImportExportThreadLocal.isImportInProcess()) { return; } if ((activity.getActivityId() > 0) || ((mirrorActivity != null) && (mirrorActivity.getActivityId() > 0))) { throw new PortalException("Activity and mirror activity must not have primary keys set"); } SocialActivityDefinition activityDefinition = socialActivitySettingLocalService.getActivityDefinition( activity.getGroupId(), activity.getClassName(), activity.getType()); if ((activityDefinition == null) || activityDefinition.isLogActivity()) { long activityId = counterLocalService.increment(SocialActivity.class.getName()); activity.setActivityId(activityId); socialActivityPersistence.update(activity, false); if (mirrorActivity != null) { long mirrorActivityId = counterLocalService.increment(SocialActivity.class.getName()); mirrorActivity.setActivityId(mirrorActivityId); mirrorActivity.setMirrorActivityId(activity.getPrimaryKey()); socialActivityPersistence.update(mirrorActivity, false); } } socialActivityCounterLocalService.addActivityCounters(activity); }
protected boolean isLogActivity(SocialActivity activity) { if (activity.getType() == SocialActivityConstants.TYPE_DELETE) { if (activity.getParentClassPK() == 0) { return true; } return false; } SocialActivityDefinition activityDefinition = socialActivitySettingLocalService.getActivityDefinition( activity.getGroupId(), activity.getClassName(), activity.getType()); if (activityDefinition != null) { return activityDefinition.isLogActivity(); } if (activity.getType() < SocialActivityConstants.TYPE_VIEW) { return true; } return false; }