Search in sources :

Example 1 with TableBuilder

use of com.liferay.imex.shell.client.util.TableBuilder in project liferay-imex by jpdacunha.

the class ListExporterCommand method le.

public void le() {
    Map<String, ServiceReference<Exporter>> exporters = trackerService.getExporters();
    if (exporters != null && exporters.size() > 0) {
        TableBuilder tableBuilder = new TableBuilder();
        tableBuilder.addHeaders(COLUMN_NAMES);
        for (Map.Entry<String, ServiceReference<Exporter>> entry : exporters.entrySet()) {
            ServiceReference<Exporter> serviceReference = entry.getValue();
            String ranking = (Integer) serviceReference.getProperty(OSGIServicePropsKeys.SERVICE_RANKING) + "";
            String description = (String) serviceReference.getProperty(OSGIServicePropsKeys.IMEX_COMPONENT_DESCRIPTION);
            String priority = (String) serviceReference.getProperty(OSGIServicePropsKeys.IMEX_COMPONENT_EXECUTION_PRIORITY);
            Bundle bundle = serviceReference.getBundle();
            Exporter exporter = bundle.getBundleContext().getService(serviceReference);
            boolean supportProfile = exporter.isProfiled();
            if (bundle != null) {
                tableBuilder.addRow(ranking, bundle.getSymbolicName(), description, priority, supportProfile + "");
            }
        }
        tableBuilder.print();
    } else {
        System.out.println("No IMEX importers registered.");
    }
}
Also used : Bundle(org.osgi.framework.Bundle) TableBuilder(com.liferay.imex.shell.client.util.TableBuilder) Exporter(com.liferay.imex.core.api.exporter.Exporter) Map(java.util.Map) ServiceReference(org.osgi.framework.ServiceReference)

Example 2 with TableBuilder

use of com.liferay.imex.shell.client.util.TableBuilder in project liferay-imex by jpdacunha.

the class ListTriggerCommand method lt.

public void lt() {
    Map<String, ServiceReference<Trigger>> triggers = trackerService.getTriggers();
    if (triggers != null && triggers.size() > 0) {
        TableBuilder tableBuilder = new TableBuilder();
        tableBuilder.addHeaders(COLUMN_NAMES);
        for (Map.Entry<String, ServiceReference<Trigger>> entry : triggers.entrySet()) {
            ServiceReference<Trigger> serviceReference = entry.getValue();
            String ranking = (Integer) serviceReference.getProperty(OSGIServicePropsKeys.SERVICE_RANKING) + "";
            Bundle bundle = serviceReference.getBundle();
            Trigger trigger = bundle.getBundleContext().getService(serviceReference);
            String description = trigger.getTriggerDescription();
            String descriptiveName = trigger.getTriggerName();
            if (bundle != null) {
                tableBuilder.addRow(ranking, bundle.getSymbolicName(), descriptiveName, description);
            }
        }
        tableBuilder.print();
    } else {
        System.out.println("No IMEX triggers registered.");
    }
}
Also used : Trigger(com.liferay.imex.core.api.trigger.Trigger) Bundle(org.osgi.framework.Bundle) TableBuilder(com.liferay.imex.shell.client.util.TableBuilder) Map(java.util.Map) ServiceReference(org.osgi.framework.ServiceReference)

Example 3 with TableBuilder

use of com.liferay.imex.shell.client.util.TableBuilder in project liferay-imex by jpdacunha.

the class ListProfileCommand method lp.

public void lp() {
    ImexProperties config = new ImexProperties();
    configurationService.loadCoreConfiguration(config);
    Properties configAsProperties = config.getProperties();
    String[] supportedProfiles = CollectionUtil.getArray(configAsProperties.getProperty(ImExCorePropsKeys.MANAGES_PROFILES_LIST));
    if (supportedProfiles != null && supportedProfiles.length > 0) {
        TableBuilder tableBuilder = new TableBuilder();
        tableBuilder.addHeaders(COLUMN_NAMES);
        for (String profile : Arrays.asList(supportedProfiles)) {
            tableBuilder.addRow(profile);
        }
        tableBuilder.print();
    } else {
        System.out.println("No  supported profiles. Please see [" + ImExCorePropsKeys.MANAGES_PROFILES_LIST + "] paramater to configure profiles.");
    }
}
Also used : ImexProperties(com.liferay.imex.core.api.configuration.model.ImexProperties) ImexProperties(com.liferay.imex.core.api.configuration.model.ImexProperties) Properties(java.util.Properties) TableBuilder(com.liferay.imex.shell.client.util.TableBuilder)

Example 4 with TableBuilder

use of com.liferay.imex.shell.client.util.TableBuilder in project liferay-imex by jpdacunha.

the class ListImporterCommand method li.

public void li() {
    Map<String, ServiceReference<Importer>> importers = trackerService.getImporters();
    if (importers != null && importers.size() > 0) {
        TableBuilder tableBuilder = new TableBuilder();
        tableBuilder.addHeaders(COLUMN_NAMES);
        for (Map.Entry<String, ServiceReference<Importer>> entry : importers.entrySet()) {
            ServiceReference<Importer> serviceReference = entry.getValue();
            String ranking = (Integer) serviceReference.getProperty(OSGIServicePropsKeys.SERVICE_RANKING) + "";
            String description = (String) serviceReference.getProperty(OSGIServicePropsKeys.IMEX_COMPONENT_DESCRIPTION);
            String priority = (String) serviceReference.getProperty(OSGIServicePropsKeys.IMEX_COMPONENT_EXECUTION_PRIORITY);
            Bundle bundle = serviceReference.getBundle();
            Importer importer = bundle.getBundleContext().getService(serviceReference);
            boolean supportProfile = importer.isProfiled();
            if (bundle != null) {
                tableBuilder.addRow(ranking, bundle.getSymbolicName(), description, priority, supportProfile + "");
            }
        }
        tableBuilder.print();
    } else {
        System.out.println("No IMEX importers registered.");
    }
}
Also used : Bundle(org.osgi.framework.Bundle) TableBuilder(com.liferay.imex.shell.client.util.TableBuilder) Map(java.util.Map) ServiceReference(org.osgi.framework.ServiceReference) Importer(com.liferay.imex.core.api.importer.Importer)

Aggregations

TableBuilder (com.liferay.imex.shell.client.util.TableBuilder)4 Map (java.util.Map)3 Bundle (org.osgi.framework.Bundle)3 ServiceReference (org.osgi.framework.ServiceReference)3 ImexProperties (com.liferay.imex.core.api.configuration.model.ImexProperties)1 Exporter (com.liferay.imex.core.api.exporter.Exporter)1 Importer (com.liferay.imex.core.api.importer.Importer)1 Trigger (com.liferay.imex.core.api.trigger.Trigger)1 Properties (java.util.Properties)1