/** * 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.document.library.web.internal.portlet.configuration.icon; import com.liferay.document.library.kernel.model.DLFolderConstants; import com.liferay.document.library.web.constants.DLPortletKeys; import com.liferay.document.library.web.internal.portlet.action.ActionUtil; import com.liferay.portal.kernel.language.LanguageUtil; import com.liferay.portal.kernel.portlet.configuration.icon.BaseJSPPortletConfigurationIcon; import com.liferay.portal.kernel.portlet.configuration.icon.PortletConfigurationIcon; import com.liferay.portal.kernel.repository.model.Folder; import com.liferay.portal.kernel.security.permission.ActionKeys; import com.liferay.portal.kernel.theme.PortletDisplay; import com.liferay.portal.kernel.theme.ThemeDisplay; import com.liferay.portal.kernel.util.WebKeys; import com.liferay.portlet.documentlibrary.service.permission.DLFolderPermission; 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 Roberto Díaz */ @Component( immediate = true, property = { "javax.portlet.name=" + DLPortletKeys.DOCUMENT_LIBRARY_ADMIN, "path=/document_library/view", "path=/document_library/view_folder", "path=-" }, service = PortletConfigurationIcon.class ) public class AccessFromDesktopPortletConfigurationIcon extends BaseJSPPortletConfigurationIcon { @Override public String getJspPath() { return "/document_library/access_from_desktop.jsp"; } @Override public String getMessage(PortletRequest portletRequest) { return LanguageUtil.get( getResourceBundle(getLocale(portletRequest)), "access-from-desktop"); } @Override public String getURL( PortletRequest portletRequest, PortletResponse portletResponse) { return "javascript:;"; } @Override public double getWeight() { return 102; } @Override public boolean isShow(PortletRequest portletRequest) { try { ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute( WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); long folderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID; Folder folder = ActionUtil.getFolder(portletRequest); if (folder != null) { folderId = folder.getFolderId(); } if (DLFolderPermission.contains( themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), folderId, ActionKeys.VIEW) && portletDisplay.isWebDAVEnabled() && ((folder == null) || (folder.getRepositoryId() == themeDisplay.getScopeGroupId()))) { return true; } } catch (Exception e) { } return false; } @Override public boolean isToolTip() { return false; } @Override @Reference( target = "(osgi.web.symbolicname=com.liferay.document.library.web)", unbind = "-" ) public void setServletContext(ServletContext servletContext) { super.setServletContext(servletContext); } }