Java tutorial
/** * 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.grow.linkedpages; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.model.Layout; import com.liferay.portal.kernel.model.User; import com.liferay.portal.kernel.theme.ThemeDisplay; import com.liferay.portal.kernel.util.WebKeys; import com.liferay.product.navigation.control.menu.BaseJSPProductNavigationControlMenuEntry; import com.liferay.product.navigation.control.menu.ProductNavigationControlMenuEntry; import com.liferay.product.navigation.control.menu.constants.ProductNavigationControlMenuCategoryKeys; import java.util.Locale; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; /** * @author Laszlo Hudak */ @Component(immediate = true, property = { "product.navigation.control.menu.category.key=" + ProductNavigationControlMenuCategoryKeys.USER, "product.navigation.control.menu.category.order:Integer=500" }, service = ProductNavigationControlMenuEntry.class) public class LinkedPagesPortletControlMenuEntry extends BaseJSPProductNavigationControlMenuEntry { @Override public String getBodyJspPath() { return "/view.jsp"; } @Override public String getIconJspPath() { return "/icon.jsp"; } @Override public String getLabel(Locale locale) { return "Linked Pages"; } @Override public boolean isShow(HttpServletRequest request) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); if (layout.isTypeControlPanel()) { return false; } if (themeDisplay.isImpersonated()) { return true; } User user = themeDisplay.getUser(); if (themeDisplay.isSignedIn() && user.isSetupComplete()) { return true; } return false; } @Override @Reference(target = "(osgi.web.symbolicname=linked.pages.portlet.project)", unbind = "-") public void setServletContext(ServletContext servletContext) { super.setServletContext(servletContext); } }