/**
* 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.users.admin.web.portlet.configuration.icon;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.portlet.configuration.icon.BaseJSPPortletConfigurationIcon;
import com.liferay.portal.kernel.portlet.configuration.icon.PortletConfigurationIcon;
import com.liferay.portal.kernel.security.permission.ActionKeys;
import com.liferay.portal.kernel.security.permission.PermissionChecker;
import com.liferay.portal.kernel.service.permission.PortalPermissionUtil;
import com.liferay.portal.kernel.service.permission.PortletPermissionUtil;
import com.liferay.portal.kernel.theme.ThemeDisplay;
import com.liferay.portal.kernel.util.ResourceBundleUtil;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.users.admin.constants.UsersAdminPortletKeys;
import java.util.ResourceBundle;
import javax.portlet.PortletRequest;
import javax.portlet.PortletResponse;
import javax.servlet.ServletContext;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
/**
* @author Pei-Jung Lan
*/
@Component(
immediate = true,
property = {"javax.portlet.name=" + UsersAdminPortletKeys.USERS_ADMIN},
service = PortletConfigurationIcon.class
)
public class ExportUsersPortletConfigurationIcon
extends BaseJSPPortletConfigurationIcon {
@Override
public String getJspPath() {
return "/configuration/icon/export_users.jsp";
}
@Override
public String getMessage(PortletRequest portletRequest) {
ResourceBundle resourceBundle = ResourceBundleUtil.getBundle(
"content.Language", getLocale(portletRequest), getClass());
return LanguageUtil.get(resourceBundle, "export-users");
}
@Override
public String getURL(
PortletRequest portletRequest, PortletResponse portletResponse) {
return "javascript:;";
}
@Override
public double getWeight() {
return 101;
}
@Override
public boolean isShow(PortletRequest portletRequest) {
ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(
WebKeys.THEME_DISPLAY);
PermissionChecker permissionChecker =
themeDisplay.getPermissionChecker();
if (PortalPermissionUtil.contains(
permissionChecker, ActionKeys.EXPORT_USER)) {
return true;
}
try {
return PortletPermissionUtil.contains(
permissionChecker, UsersAdminPortletKeys.USERS_ADMIN,
ActionKeys.EXPORT_USER);
}
catch (PortalException pe) {
// LPS-52675
if (_log.isDebugEnabled()) {
_log.debug(pe, pe);
}
}
return false;
}
@Override
@Reference(
target = "(osgi.web.symbolicname=com.liferay.users.admin.web)",
unbind = "-"
)
public void setServletContext(ServletContext servletContext) {
super.setServletContext(servletContext);
}
private static final Log _log = LogFactoryUtil.getLog(
ExportUsersPortletConfigurationIcon.class);
}