/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This file is part of Liferay Social Office. Liferay Social Office is free
* software: you can redistribute it and/or modify it under the terms of the GNU
* Affero General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* Liferay Social Office 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 Affero General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* Liferay Social Office. If not, see http://www.gnu.org/licenses/agpl-3.0.html.
*/
package com.liferay.contacts.contactscenter.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.ClassResourceBundleLoader;
import com.liferay.portal.kernel.util.ResourceBundleLoader;
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.kernel.model.SocialRelationConstants;
/**
* @author Hai Yu
*/
public class ContactsCenterActivityInterpreter
extends BaseSocialActivityInterpreter {
@Override
public String[] getClassNames() {
return _CLASS_NAMES;
}
@Override
protected String getLink(
SocialActivity activity, ServiceContext serviceContext) {
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) {
if (activity.getType() != SocialRelationConstants.TYPE_BI_CONNECTION) {
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) {
if (activity.getType() == SocialRelationConstants.TYPE_BI_CONNECTION) {
return "activity-social-networking-summary-add-connection";
}
return StringPool.BLANK;
}
@Override
protected boolean hasPermissions(
PermissionChecker permissionChecker, SocialActivity activity,
String actionId, ServiceContext serviceContext) {
return true;
}
private static final String[] _CLASS_NAMES = {User.class.getName()};
private final ResourceBundleLoader _resourceBundleLoader =
new ClassResourceBundleLoader(
"content.Language", ContactsCenterActivityInterpreter.class);
}