001
014
015 package com.liferay.portlet.social.service.impl;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.theme.ThemeDisplay;
020 import com.liferay.portal.util.PortalUtil;
021 import com.liferay.portlet.social.model.SocialActivity;
022 import com.liferay.portlet.social.model.SocialActivityFeedEntry;
023 import com.liferay.portlet.social.model.SocialActivityInterpreter;
024 import com.liferay.portlet.social.model.impl.SocialActivityInterpreterImpl;
025 import com.liferay.portlet.social.service.base.SocialActivityInterpreterLocalServiceBaseImpl;
026
027 import java.util.ArrayList;
028 import java.util.List;
029
030
047 public class SocialActivityInterpreterLocalServiceImpl
048 extends SocialActivityInterpreterLocalServiceBaseImpl {
049
050
055 @Override
056 public void addActivityInterpreter(
057 SocialActivityInterpreter activityInterpreter) {
058
059 _activityInterpreters.add(activityInterpreter);
060 }
061
062
067 @Override
068 public void deleteActivityInterpreter(
069 SocialActivityInterpreter activityInterpreter) {
070
071 if (activityInterpreter != null) {
072 _activityInterpreters.remove(activityInterpreter);
073 }
074 }
075
076
093 @Override
094 public SocialActivityFeedEntry interpret(
095 SocialActivity activity, ThemeDisplay themeDisplay) {
096
097 try {
098 if (activity.getUserId() == themeDisplay.getDefaultUserId()) {
099 return null;
100 }
101 }
102 catch (Exception e) {
103 _log.error(e, e);
104 }
105
106 if (activity.getMirrorActivityId() > 0) {
107 SocialActivity mirrorActivity = null;
108
109 try {
110 mirrorActivity = socialActivityLocalService.getActivity(
111 activity.getMirrorActivityId());
112 }
113 catch (Exception e) {
114 }
115
116 if (mirrorActivity != null) {
117 activity = mirrorActivity;
118 }
119 }
120
121 String className = PortalUtil.getClassName(activity.getClassNameId());
122
123 for (int i = 0; i < _activityInterpreters.size(); i++) {
124 SocialActivityInterpreterImpl activityInterpreter =
125 (SocialActivityInterpreterImpl)_activityInterpreters.get(i);
126
127 if (activityInterpreter.hasClassName(className)) {
128 SocialActivityFeedEntry activityFeedEntry =
129 activityInterpreter.interpret(activity, themeDisplay);
130
131 if (activityFeedEntry != null) {
132 activityFeedEntry.setPortletId(
133 activityInterpreter.getPortletId());
134
135 return activityFeedEntry;
136 }
137 }
138 }
139
140 return null;
141 }
142
143 private static Log _log = LogFactoryUtil.getLog(
144 SocialActivityInterpreterLocalServiceImpl.class);
145
146 private List<SocialActivityInterpreter> _activityInterpreters =
147 new ArrayList<SocialActivityInterpreter>();
148
149 }