List of usage examples for com.liferay.portal.kernel.template TemplateConstants LANG_TYPE_XML
String LANG_TYPE_XML
To view the source code for com.liferay.portal.kernel.template TemplateConstants LANG_TYPE_XML.
Click Source Link
From source file:com.liferay.exportimport.resources.importer.internal.util.FileSystemImporter.java
License:Open Source License
protected void addDDMStructures(String parentDDMStructureKey, String fileName, InputStream inputStream) throws Exception { String language = getDDMStructureLanguage(fileName); fileName = FileUtil.stripExtension(fileName); String name = getName(fileName); DDMStructure ddmStructure = ddmStructureLocalService.fetchStructure(groupId, portal.getClassNameId(JournalArticle.class), getKey(fileName)); if (ddmStructure != null) { if (!developerModeEnabled) { if (_log.isInfoEnabled()) { _log.info(StringBundler.concat("DDM structure with name ", name, " and version ", String.valueOf(version), " already exists")); }/*from w w w .j a v a 2 s . c o m*/ return; } if (!updateModeEnabled) { ddmStructureLocalService.deleteDDMStructure(ddmStructure); } } String content = StringUtil.read(inputStream); DDMForm ddmForm = null; if (language.equals(TemplateConstants.LANG_TYPE_XML)) { if (isJournalStructureXSD(content)) { content = journalConverter.getDDMXSD(content); } ddmxml.validateXML(content); ddmForm = ddmFormXSDDeserializer.deserialize(content); } else { ddmForm = ddmFormJSONDeserializer.deserialize(content); } DDMFormLayout ddmFormLayout = DDMUtil.getDefaultDDMFormLayout(ddmForm); setServiceContext(fileName); try { if (!updateModeEnabled || (ddmStructure == null)) { ddmStructure = ddmStructureLocalService.addStructure(userId, groupId, parentDDMStructureKey, portal.getClassNameId(JournalArticle.class), getKey(fileName), getMap(name), null, ddmForm, ddmFormLayout, JournalServiceConfigurationValues.JOURNAL_ARTICLE_STORAGE_TYPE, DDMStructureConstants.TYPE_DEFAULT, serviceContext); } else { DDMStructure parentStructure = ddmStructureLocalService.fetchStructure(groupId, portal.getClassNameId(JournalArticle.class), parentDDMStructureKey); long parentDDMStructureId = DDMStructureConstants.DEFAULT_PARENT_STRUCTURE_ID; if (parentStructure != null) { parentDDMStructureId = parentStructure.getStructureId(); } ddmStructure = ddmStructureLocalService.updateStructure(userId, ddmStructure.getStructureId(), parentDDMStructureId, getMap(name), null, ddmForm, ddmFormLayout, serviceContext); } } catch (PortalException pe) { if (_log.isWarnEnabled()) { _log.warn("Unable to import DDM structure " + fileName, pe); } throw pe; } _ddmStructureKeys.add(ddmStructure.getStructureKey()); addDDMTemplates(ddmStructure.getStructureKey(), _JOURNAL_DDM_TEMPLATES_DIR_NAME + fileName); if (Validator.isNull(parentDDMStructureKey)) { addDDMStructures(ddmStructure.getStructureKey(), _JOURNAL_DDM_STRUCTURES_DIR_NAME + fileName); } }
From source file:com.liferay.exportimport.resources.importer.internal.util.FileSystemImporter.java
License:Open Source License
protected String getDDMStructureLanguage(String fileName) { String extension = FileUtil.getExtension(fileName); if (extension.equals(TemplateConstants.LANG_TYPE_JSON) || extension.equals(TemplateConstants.LANG_TYPE_XML)) { return extension; }/*www. ja v a 2 s. c o m*/ return TemplateConstants.LANG_TYPE_XML; }