use of com.liferay.imex.core.api.exporter.model.ExporterRawContent 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);
}
}
}
use of com.liferay.imex.core.api.exporter.model.ExporterRawContent in project liferay-imex by jpdacunha.
the class WcDDMExporter method writeTemplate.
private void writeTemplate(Group group, Locale locale, List<ExporterRawContent> rawContentToExport, File structureDir, String groupName, DDMTemplate ddmTemplate) throws Exception {
ImExTemplate imexTemplate = new ImExTemplate(ddmTemplate);
processor.write(imexTemplate, structureDir, FileNames.getTemplateFileName(ddmTemplate, locale, processor.getFileExtension()));
String rawFileName = FileNames.getGroupTemplateFileName(ddmTemplate, group, locale, StringPool.PERIOD + imexTemplate.getLangType());
rawContentToExport.add(new ExporterRawContent(rawFileName, imexTemplate.getData()));
}
use of com.liferay.imex.core.api.exporter.model.ExporterRawContent in project liferay-imex by jpdacunha.
the class AdtExporter method doExport.
public void doExport(Properties config, Group group, File groupsDir, Locale locale, boolean debug, String classType, List<ExporterRawContent> rawContentToExport) throws ImexException {
if (group != null) {
long classNameId = classNameLocalService.getClassNameId(classType);
List<DDMTemplate> adts = dDMTemplateLocalService.getTemplates(group.getGroupId(), classNameId);
if (adts != null && adts.size() > 0) {
File groupDir = initializeSingleGroupDirectory(groupsDir, group);
if (groupDir != null) {
if (groupDir.exists()) {
// Iterate over structures
for (DDMTemplate ddmTemplate : adts) {
File adtDir = initializeSingleAdtExportDirectory(groupDir, classType);
if (adtDir != null) {
if (adtDir.exists()) {
try {
String groupName = GroupUtil.getGroupName(group, locale);
ImExAdt imexAdt = new ImExAdt(ddmTemplate, classType);
processor.write(imexAdt, adtDir, FileNames.getAdtFileName(ddmTemplate, locale, processor.getFileExtension()));
String rawFileName = FileNames.getGroupAdtFileName(ddmTemplate, group, locale, StringPool.PERIOD + imexAdt.getLangType());
rawContentToExport.add(new ExporterRawContent(rawFileName, imexAdt.getData()));
reportService.getOK(_log, groupName, "ADT : " + ddmTemplate.getName(locale) + ", type : " + classType);
} catch (Exception e) {
reportService.getError(_log, ddmTemplate.getName(locale), e);
if (debug) {
_log.error(e, e);
}
}
} else {
reportService.getDNE(_log, adtDir.getAbsolutePath());
}
} else {
_log.error("adtDir is null ...");
}
}
} else {
reportService.getDNE(_log, groupDir.getAbsolutePath());
}
} else {
_log.error("groupDir is null ...");
}
} else {
reportService.getEmpty(_log, group, locale, classType);
}
} else {
_log.error("Skipping null group ...");
}
}
use of com.liferay.imex.core.api.exporter.model.ExporterRawContent in project liferay-imex by jpdacunha.
the class WcDDMExporter method writeStructure.
private void writeStructure(Group group, Locale locale, List<ExporterRawContent> rawContentToExport, DDMStructure ddmStructure, File structureDir) throws Exception {
ImExStructure imexStructure = new ImExStructure(ddmStructure);
processor.write(imexStructure, structureDir, FileNames.getStructureFileName(ddmStructure, locale, processor.getFileExtension()));
String rawFileName = FileNames.getGroupStructureFileName(ddmStructure, group, locale, FileUtil.JSON_EXTENSION);
rawContentToExport.add(new ExporterRawContent(rawFileName, imexStructure.getData()));
}
Aggregations