/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.social.networking.web.internal.social; import com.liferay.portal.kernel.model.User; import com.liferay.portal.kernel.security.permission.PermissionChecker; import com.liferay.portal.kernel.service.ServiceContext; import com.liferay.portal.kernel.util.AggregateResourceBundleLoader; import com.liferay.portal.kernel.util.ResourceBundleLoader; import com.liferay.portal.kernel.util.ResourceBundleLoaderUtil; import com.liferay.portal.kernel.util.StringPool; import com.liferay.social.kernel.model.BaseSocialActivityInterpreter; import com.liferay.social.kernel.model.SocialActivity; import com.liferay.social.networking.friends.social.FriendsActivityKeys; import org.osgi.service.component.annotations.Reference; /** * @author Adolfo PĂ©rez */ public abstract class BaseSocialNetworkingActivityInterpreter extends BaseSocialActivityInterpreter { @Override public String[] getClassNames() { return _CLASS_NAMES; } @Override protected String getLink( SocialActivity activity, ServiceContext serviceContext) throws Exception { return getUserName(activity.getReceiverUserId(), serviceContext); } @Override protected ResourceBundleLoader getResourceBundleLoader() { return _resourceBundleLoader; } @Override protected Object[] getTitleArguments( String groupName, SocialActivity activity, String link, String title, ServiceContext serviceContext) throws Exception { int activityType = activity.getType(); if (activityType != FriendsActivityKeys.ADD_FRIEND) { return new Object[0]; } String creatorUserName = getUserName( activity.getUserId(), serviceContext); String receiverUserName = getUserName( activity.getReceiverUserId(), serviceContext); return new Object[] {creatorUserName, receiverUserName}; } @Override protected String getTitlePattern( String groupName, SocialActivity activity) { int activityType = activity.getType(); if (activityType == FriendsActivityKeys.ADD_FRIEND) { return "activity-social-networking-summary-add-friend"; } return StringPool.BLANK; } @Override protected boolean hasPermissions( PermissionChecker permissionChecker, SocialActivity activity, String actionId, ServiceContext serviceContext) { return true; } @Reference( target = "(bundle.symbolic.name=com.liferay.social.networking.web)", unbind = "-" ) protected void setResourceBundleLoader( ResourceBundleLoader resourceBundleLoader) { _resourceBundleLoader = new AggregateResourceBundleLoader( resourceBundleLoader, ResourceBundleLoaderUtil.getPortalResourceBundleLoader()); } private static final String[] _CLASS_NAMES = {User.class.getName()}; private ResourceBundleLoader _resourceBundleLoader; }