List of usage examples for com.liferay.portal.kernel.metadata RawMetadataProcessorUtil getFields
public static Map<String, Field[]> getFields()
From source file:com.liferay.document.library.internal.instance.lifecycle.AddDefaultDocumentLibraryStructuresPortalInstanceLifecycleListener.java
License:Open Source License
protected void addDLRawMetadataStructures(long userId, long groupId, ServiceContext serviceContext) throws Exception { Locale locale = _portal.getSiteDefaultLocale(groupId); String xsd = buildDLRawMetadataXML(RawMetadataProcessorUtil.getFields(), locale); Document document = UnsecureSAXReaderUtil.read(new StringReader(xsd)); Element rootElement = document.getRootElement(); List<Element> structureElements = rootElement.elements("structure"); for (Element structureElement : structureElements) { String name = structureElement.elementText("name"); String description = structureElement.elementText("description"); Element structureElementRootElement = structureElement.element("root"); String structureElementRootXML = structureElementRootElement.asXML(); DDMStructure ddmStructure = _ddmStructureLocalService.fetchStructure(groupId, _portal.getClassNameId(RawMetadataProcessor.class), name); DDMForm ddmForm = _ddmFormXSDDeserializer.deserialize(structureElementRootXML); if (ddmStructure != null) { ddmStructure.setDDMForm(ddmForm); _ddmStructureLocalService.updateDDMStructure(ddmStructure); } else {/*from w w w. j a v a 2 s. c o m*/ Map<Locale, String> nameMap = new HashMap<>(); nameMap.put(locale, name); Map<Locale, String> descriptionMap = new HashMap<>(); descriptionMap.put(locale, description); DDMFormLayout ddmFormLayout = _ddm.getDefaultDDMFormLayout(ddmForm); _ddmStructureLocalService.addStructure(userId, groupId, DDMStructureConstants.DEFAULT_PARENT_STRUCTURE_ID, _portal.getClassNameId(RawMetadataProcessor.class), name, nameMap, descriptionMap, ddmForm, ddmFormLayout, StorageType.JSON.toString(), DDMStructureConstants.TYPE_DEFAULT, serviceContext); } } }