Example usage for com.liferay.portal.util PortletCategoryUtil getPortletCategoryKey

List of usage examples for com.liferay.portal.util PortletCategoryUtil getPortletCategoryKey

Introduction

In this page you can find the example usage for com.liferay.portal.util PortletCategoryUtil getPortletCategoryKey.

Prototype

public static String getPortletCategoryKey(String legacyPortletCategoryKey) 

Source Link

Usage

From source file:com.liferay.application.list.adapter.PortletPanelAppAdapterServiceTrackerCustomizer.java

License:Open Source License

@Override
public PanelApp addingService(ServiceReference<Portlet> serviceReference) {
    String portletId = (String) serviceReference.getProperty("javax.portlet.name");

    if (Validator.isNull(portletId)) {
        return null;
    }//from ww  w .j av  a2  s.  c  om

    String controlPanelCategory = (String) serviceReference
            .getProperty("com.liferay.portlet.control-panel-entry-category");

    if (Validator.isNull(controlPanelCategory)) {
        return null;
    }

    PanelApp portletPanelAppAdapter = new PortletPanelAppAdapter(portletId);

    Dictionary<String, Object> panelAppProperties = new HashMapDictionary<>();

    panelAppProperties.put("panel.category.key",
            PortletCategoryUtil.getPortletCategoryKey(controlPanelCategory));

    Integer serviceRanking = getServiceRanking(serviceReference);

    if (serviceRanking != null) {
        panelAppProperties.put("service.ranking", serviceRanking);
    }

    ServiceRegistration<PanelApp> serviceRegistration = _bundleContext.registerService(PanelApp.class,
            portletPanelAppAdapter, panelAppProperties);

    _serviceRegistrations.put(serviceReference, serviceRegistration);

    return portletPanelAppAdapter;
}

From source file:com.liferay.application.list.deploy.hot.LegacyPortletPanelAppHotDeployListener.java

License:Open Source License

protected List<Dictionary<String, Object>> getPropertiesList(HotDeployEvent hotDeployEvent)
        throws DocumentException, IOException {

    ServletContext servletContext = hotDeployEvent.getServletContext();

    String xml = _http.URLtoString(servletContext.getResource("/WEB-INF/liferay-portlet.xml"));

    if (xml == null) {
        return Collections.emptyList();
    }/*  w w w  .  j  a  v  a  2  s.  com*/

    List<Dictionary<String, Object>> propertiesList = new ArrayList<>();

    Document document = UnsecureSAXReaderUtil.read(xml, true);

    Element rootElement = document.getRootElement();

    Iterator<Element> iterator = rootElement.elementIterator("portlet");

    while (iterator.hasNext()) {
        Element portletElement = iterator.next();

        String controlPanelEntryCategory = portletElement.elementText("control-panel-entry-category");

        if (Validator.isNull(controlPanelEntryCategory)) {
            continue;
        }

        controlPanelEntryCategory = PortletCategoryUtil.getPortletCategoryKey(controlPanelEntryCategory);

        Dictionary<String, Object> properties = new HashMapDictionary<>();

        String portletName = portletElement.elementText("portlet-name");

        String portletId = getPortletId(hotDeployEvent.getServletContextName(), portletName);

        properties.put("panel.app.portlet.id", portletId);

        properties.put("panel.category.key", controlPanelEntryCategory);

        String controlPanelEntryWeight = portletElement.elementText("control-panel-entry-weight");

        if (Validator.isNotNull(controlPanelEntryWeight)) {
            int panelAppOrder = (int) Math.ceil(GetterUtil.getDouble(controlPanelEntryWeight) * 100);

            properties.put("panel.app.order", panelAppOrder);
        }

        propertiesList.add(properties);
    }

    return propertiesList;
}