/** * 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.contacts.web.internal.social; import com.liferay.contacts.web.internal.constants.ContactsPortletKeys; 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.kernel.model.SocialActivityInterpreter; import com.liferay.social.kernel.model.SocialRelationConstants; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; /** * @author Hai Yu */ @Component( property = {"javax.portlet.name=" + ContactsPortletKeys.CONTACTS_CENTER}, service = SocialActivityInterpreter.class ) 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; } @Reference( target = "(bundle.symbolic.name=com.liferay.contacts.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; }