Search in sources :

Example 1 with Trigger

use of com.liferay.imex.core.api.trigger.Trigger in project liferay-imex by jpdacunha.

the class TriggerTrackerService method addingService.

@Override
public Trigger addingService(ServiceReference<Trigger> serviceReference) {
    _serviceReferences.addServiceReference(serviceReference);
    Trigger trigger = _bundleContext.getService(serviceReference);
    // Calling deploy method on custom service
    trigger.deploy();
    return trigger;
}
Also used : Trigger(com.liferay.imex.core.api.trigger.Trigger)

Example 2 with Trigger

use of com.liferay.imex.core.api.trigger.Trigger 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 Trigger

use of com.liferay.imex.core.api.trigger.Trigger in project liferay-imex by jpdacunha.

the class ImexCoreServiceImpl method generateOverrideFileSystemConfigurationFiles.

@Override
public String generateOverrideFileSystemConfigurationFiles(List<String> bundleNames, boolean archive) {
    Map<String, ServiceReference<Importer>> importers = importerTrackerService.getFilteredImporters(bundleNames);
    Map<String, ServiceReference<Exporter>> exporters = exporterTrackerService.getFilteredExporters(bundleNames);
    Map<String, ServiceReference<Trigger>> triggers = triggerTrackerService.getTriggers();
    Map<String, Properties> props = configurationService.loadAllConfigurationMap(bundleNames, importers, exporters, triggers);
    ProcessIdentifierGenerator processIdentifier = new ConfigurationOverrideProcessIdentifier();
    String identifier = processIdentifier.getOrGenerateUniqueIdentifier();
    LoggingContext.put(ImexExecutionReportService.IDENTIFIER_KEY, identifier);
    reportService.getStartMessage(_log, "CFG_OVERRIDE process");
    // Initialisation répertoire de configuration
    initializeConfigurationtDirectories();
    if (props != null) {
        if (archive) {
            ImexProperties coreConfig = new ImexProperties();
            configurationService.loadCoreConfiguration(coreConfig);
            imexArchiverService.archiveCfgDirectory(coreConfig.getProperties(), processIdentifier);
        }
        Bundle coreBundle = FrameworkUtil.getBundle(this.getClass());
        String coreBundleName = coreBundle.getSymbolicName();
        mergeConfiguration(props, coreBundleName, coreBundle);
        // Merging importers
        for (Map.Entry<String, ServiceReference<Importer>> entry : importers.entrySet()) {
            ServiceReference<Importer> reference = entry.getValue();
            Bundle bundle = reference.getBundle();
            String key = entry.getKey();
            mergeConfiguration(props, key, bundle);
        }
        // Merging exporters
        for (Map.Entry<String, ServiceReference<Exporter>> entry : exporters.entrySet()) {
            ServiceReference<Exporter> reference = entry.getValue();
            Bundle bundle = reference.getBundle();
            String key = entry.getKey();
            mergeConfiguration(props, key, bundle);
        }
        // Merging triggers
        for (Map.Entry<String, ServiceReference<Trigger>> entry : triggers.entrySet()) {
            ServiceReference<Trigger> reference = entry.getValue();
            Bundle bundle = reference.getBundle();
            String key = entry.getKey();
            mergeConfiguration(props, key, bundle);
        }
    }
    reportService.getEndMessage(_log, "CFG_OVERRIDE process");
    return identifier;
}
Also used : Bundle(org.osgi.framework.Bundle) ImexProperties(com.liferay.imex.core.api.configuration.model.ImexProperties) Properties(java.util.Properties) OrderedProperties(com.liferay.imex.core.api.configuration.model.OrderedProperties) ConfigurationOverrideProcessIdentifier(com.liferay.imex.core.service.configuration.model.ConfigurationOverrideProcessIdentifier) Exporter(com.liferay.imex.core.api.exporter.Exporter) ServiceReference(org.osgi.framework.ServiceReference) ProcessIdentifierGenerator(com.liferay.imex.core.api.identifier.ProcessIdentifierGenerator) Trigger(com.liferay.imex.core.api.trigger.Trigger) ImexProperties(com.liferay.imex.core.api.configuration.model.ImexProperties) Map(java.util.Map) Importer(com.liferay.imex.core.api.importer.Importer)

Aggregations

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