/**
* 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.dynamic.data.lists.form.web.internal.portlet.configuration.icon;
import com.liferay.dynamic.data.lists.service.permission.DDLRecordSetPermission;
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.model.User;
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.theme.ThemeDisplay;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.WebKeys;
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 Rafael Praxedes
*/
@Component(
immediate = true,
property = {
"javax.portlet.name=" + com.liferay.dynamic.data.lists.form.web.constants.DDLFormPortletKeys.DYNAMIC_DATA_LISTS_FORM_ADMIN,
"path=/admin/view_records.jsp"
},
service = PortletConfigurationIcon.class
)
public class ExportDDLRecordSetPortletConfigurationIcon
extends BaseJSPPortletConfigurationIcon {
@Override
public String getJspPath() {
return "/admin/configuration/icon/export_record_set.jsp";
}
@Override
public String getMessage(PortletRequest portletRequest) {
return LanguageUtil.get(
getResourceBundle(getLocale(portletRequest)), "export");
}
@Override
public String getURL(
PortletRequest portletRequest, PortletResponse portletResponse) {
return "javascript:;";
}
@Override
public double getWeight() {
return 102;
}
@Override
public boolean isShow(PortletRequest portletRequest) {
long recordSetId = ParamUtil.getLong(portletRequest, "recordSetId");
if (recordSetId == 0) {
return false;
}
ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(
WebKeys.THEME_DISPLAY);
User user = themeDisplay.getUser();
if (user.isDefaultUser()) {
return false;
}
try {
return DDLRecordSetPermission.contains(
themeDisplay.getPermissionChecker(), recordSetId,
ActionKeys.VIEW);
}
catch (PortalException pe) {
// LPS-52675
if (_log.isDebugEnabled()) {
_log.debug(pe, pe);
}
return false;
}
}
@Override
public boolean isToolTip() {
return false;
}
@Override
@Reference(
target = "(osgi.web.symbolicname=com.liferay.dynamic.data.lists.form.web)",
unbind = "-"
)
public void setServletContext(ServletContext servletContext) {
super.setServletContext(servletContext);
}
private static final Log _log = LogFactoryUtil.getLog(
ExportDDLRecordSetPortletConfigurationIcon.class);
}