/**
* 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.configuration.admin.web.internal.portlet.configuration.icon;
import com.liferay.configuration.admin.web.internal.constants.ConfigurationAdminPortletKeys;
import com.liferay.configuration.admin.web.internal.constants.ConfigurationAdminWebKeys;
import com.liferay.configuration.admin.web.internal.model.ConfigurationModel;
import com.liferay.configuration.admin.web.internal.util.ConfigurationModelIterator;
import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.kernel.portlet.LiferayPortletURL;
import com.liferay.portal.kernel.portlet.configuration.icon.BasePortletConfigurationIcon;
import com.liferay.portal.kernel.portlet.configuration.icon.PortletConfigurationIcon;
import com.liferay.portal.kernel.theme.ThemeDisplay;
import com.liferay.portal.kernel.util.Portal;
import com.liferay.portal.kernel.util.ResourceBundleLoader;
import com.liferay.portal.kernel.util.WebKeys;
import java.util.ResourceBundle;
import javax.portlet.PortletRequest;
import javax.portlet.PortletResponse;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
/**
* @author Jorge Ferrer
*/
@Component(
immediate = true,
property = {
"javax.portlet.name=" +
ConfigurationAdminPortletKeys.SYSTEM_SETTINGS,
"path=/view_factory_instances"
},
service = PortletConfigurationIcon.class
)
public class ExportFactoryInstancesIcon extends BasePortletConfigurationIcon {
@Override
public String getMessage(PortletRequest portletRequest) {
ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(
WebKeys.THEME_DISPLAY);
ResourceBundle resourceBundle =
_resourceBundleLoader.loadResourceBundle(themeDisplay.getLocale());
return LanguageUtil.get(resourceBundle, "export-entries");
}
@Override
public String getMethod() {
return "GET";
}
@Override
public String getURL(
PortletRequest portletRequest, PortletResponse portletResponse) {
LiferayPortletURL liferayPortletURL =
(LiferayPortletURL)_portal.getControlPanelPortletURL(
portletRequest, ConfigurationAdminPortletKeys.SYSTEM_SETTINGS,
PortletRequest.RESOURCE_PHASE);
ConfigurationModel factoryConfigurationModel =
(ConfigurationModel)portletRequest.getAttribute(
ConfigurationAdminWebKeys.FACTORY_CONFIGURATION_MODEL);
liferayPortletURL.setParameter(
"factoryPid", factoryConfigurationModel.getFactoryPid());
liferayPortletURL.setResourceID("export");
return liferayPortletURL.toString();
}
@Override
public double getWeight() {
return 1;
}
@Override
public boolean isShow(PortletRequest portletRequest) {
ConfigurationModelIterator configurationModelIterator =
(ConfigurationModelIterator)portletRequest.getAttribute(
ConfigurationAdminWebKeys.CONFIGURATION_MODEL_ITERATOR);
if (configurationModelIterator.getTotal() > 0) {
return true;
}
return false;
}
@Reference
private Portal _portal;
@Reference(
target = "(bundle.symbolic.name=com.liferay.configuration.admin.web)"
)
private ResourceBundleLoader _resourceBundleLoader;
}