/** * 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.portlet.configuration.icon.locator.internal; import com.liferay.portal.kernel.model.Portlet; import com.liferay.portal.kernel.portlet.configuration.icon.locator.PortletConfigurationIconLocator; import com.liferay.portal.kernel.service.PortletLocalService; import com.liferay.portal.kernel.util.ParamUtil; import com.liferay.portal.kernel.util.Validator; import java.util.Collections; import java.util.List; import java.util.Map; import javax.portlet.PortletRequest; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; /** * @author Sergio González */ @Component(immediate = true, service = PortletConfigurationIconLocator.class) public class StrutsPortletConfigurationIconLocator implements PortletConfigurationIconLocator { @Override public List<String> getDefaultViews(String portletId) { Portlet portlet = _portletLocalService.getPortletById(portletId); if (portlet == null) { return Collections.emptyList(); } Map<String, String> initParams = portlet.getInitParams(); String viewAction = initParams.get("view-action"); if (Validator.isNotNull(viewAction)) { return Collections.singletonList(viewAction); } return Collections.emptyList(); } @Override public String getPath(PortletRequest portletRequest) { return ParamUtil.getString(portletRequest, "struts_action"); } @Reference(unbind = "-") protected void setPortletLocalService( PortletLocalService portletLocalService) { _portletLocalService = portletLocalService; } private PortletLocalService _portletLocalService; }