Search in sources :

Example 1 with RawExporterProcessIdentifierGeneratorWrapper

use of com.liferay.imex.core.service.exporter.model.RawExporterProcessIdentifierGeneratorWrapper in project liferay-imex by jpdacunha.

the class ImexExportServiceImpl method executeRawExport.

private void executeRawExport(ExporterProcessIdentifierGenerator rootIdentifier, boolean debug) throws ImexException, IOException {
    ImexProperties config = new ImexProperties();
    configurationService.loadCoreConfiguration(config);
    Properties coreConfigAsProperties = config.getProperties();
    boolean rawExportEnabled = GetterUtil.getBoolean(coreConfigAsProperties.get(ImExCorePropsKeys.RAW_CONTENT_EXPORTER_ENABLED));
    if (rawExportEnabled) {
        ProcessIdentifierGenerator identifier = new RawExporterProcessIdentifierGeneratorWrapper(rootIdentifier);
        String randomAlphanumeric = RandomStringUtils.randomAlphanumeric(4);
        File tempDir = Files.createTempDirectory(randomAlphanumeric).toFile();
        if (!tempDir.exists()) {
            throw new ImexException("Failed to create directory " + tempDir);
        }
        File exportDir = initializeRawExportDirectory();
        reportService.getStartMessage(_log, "Raw export process (human readable format)", 1);
        // Since this a synchronized list
        synchronized (rawExportContentList) {
            for (ExporterRawContent content : rawExportContentList) {
                writeRawContentInDir(tempDir, content, debug);
            }
        }
        imexArchiverService.archiveAndClean(coreConfigAsProperties, tempDir, exportDir, identifier);
        FileUtil.deltree(tempDir);
        rawExportContentList.clear();
        reportService.getEndMessage(_log, "Raw export process", 1);
    } else {
        if (rawExportContentList.size() > 0) {
            reportService.getDisabled(_log, "raw content export");
            reportService.getMessage(_log, "See [" + ImExCorePropsKeys.RAW_CONTENT_EXPORTER_ENABLED + "] to enable this feature", 4);
        }
    }
}
Also used : ImexException(com.liferay.imex.core.util.exception.ImexException) ExporterProcessIdentifierGenerator(com.liferay.imex.core.service.exporter.model.ExporterProcessIdentifierGenerator) ProcessIdentifierGenerator(com.liferay.imex.core.api.identifier.ProcessIdentifierGenerator) RawExporterProcessIdentifierGeneratorWrapper(com.liferay.imex.core.service.exporter.model.RawExporterProcessIdentifierGeneratorWrapper) ExporterRawContent(com.liferay.imex.core.api.exporter.model.ExporterRawContent) ImexProperties(com.liferay.imex.core.api.configuration.model.ImexProperties) ImexProperties(com.liferay.imex.core.api.configuration.model.ImexProperties) Properties(java.util.Properties) File(java.io.File)

Aggregations

ImexProperties (com.liferay.imex.core.api.configuration.model.ImexProperties)1 ExporterRawContent (com.liferay.imex.core.api.exporter.model.ExporterRawContent)1 ProcessIdentifierGenerator (com.liferay.imex.core.api.identifier.ProcessIdentifierGenerator)1 ExporterProcessIdentifierGenerator (com.liferay.imex.core.service.exporter.model.ExporterProcessIdentifierGenerator)1 RawExporterProcessIdentifierGeneratorWrapper (com.liferay.imex.core.service.exporter.model.RawExporterProcessIdentifierGeneratorWrapper)1 ImexException (com.liferay.imex.core.util.exception.ImexException)1 File (java.io.File)1 Properties (java.util.Properties)1