Search in sources :

Example 1 with ConfigurationOverrideProcessIdentifier

use of com.liferay.imex.core.service.configuration.model.ConfigurationOverrideProcessIdentifier 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

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 Trigger (com.liferay.imex.core.api.trigger.Trigger)1 ConfigurationOverrideProcessIdentifier (com.liferay.imex.core.service.configuration.model.ConfigurationOverrideProcessIdentifier)1 Map (java.util.Map)1 Properties (java.util.Properties)1 Bundle (org.osgi.framework.Bundle)1 ServiceReference (org.osgi.framework.ServiceReference)1