List of usage examples for com.liferay.portal.kernel.xml Document addElement
public Element addElement(QName qName);
From source file:com.liferay.adaptive.media.journal.internal.exportimport.data.handler.test.AMJournalArticleStagedModelDataHandlerTest.java
License:Open Source License
private String _getContent(String html) throws Exception { Document document = SAXReaderUtil.createDocument(); Element rootElement = document.addElement("root"); Element dynamicElementElement = rootElement.addElement("dynamic-element"); dynamicElementElement.addAttribute("name", "content"); dynamicElementElement.addAttribute("type", "text_area"); Element element = dynamicElementElement.addElement("dynamic-content"); element.addCDATA(html);/*from ww w . j a v a 2s . c o m*/ return document.asXML(); }
From source file:com.liferay.asset.publisher.web.internal.util.AssetPublisherWebUtil.java
License:Open Source License
private String _getAssetEntryXml(String assetEntryType, String assetEntryUuid) { String xml = null;// w w w. jav a 2 s . c om try { Document document = SAXReaderUtil.createDocument(StringPool.UTF8); Element assetEntryElement = document.addElement("asset-entry"); Element assetEntryTypeElement = assetEntryElement.addElement("asset-entry-type"); assetEntryTypeElement.addText(assetEntryType); Element assetEntryUuidElement = assetEntryElement.addElement("asset-entry-uuid"); assetEntryUuidElement.addText(assetEntryUuid); xml = document.formattedString(StringPool.BLANK); } catch (IOException ioe) { if (_log.isWarnEnabled()) { _log.warn(ioe); } } return xml; }
From source file:com.liferay.asset.publisher.web.util.AssetPublisherUtil.java
License:Open Source License
private static String _getAssetEntryXml(String assetEntryType, String assetEntryUuid) { String xml = null;//from w w w . j av a 2s . c o m try { Document document = SAXReaderUtil.createDocument(StringPool.UTF8); Element assetEntryElement = document.addElement("asset-entry"); Element assetEntryTypeElement = assetEntryElement.addElement("asset-entry-type"); assetEntryTypeElement.addText(assetEntryType); Element assetEntryUuidElement = assetEntryElement.addElement("asset-entry-uuid"); assetEntryUuidElement.addText(assetEntryUuid); xml = document.formattedString(StringPool.BLANK); } catch (IOException ioe) { if (_log.isWarnEnabled()) { _log.warn(ioe); } } return xml; }
From source file:com.liferay.calendar.lar.CalendarPortletDataHandlerImpl.java
License:Open Source License
@Override protected String doExportData(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) throws Exception { portletDataContext.addPermissions("com.liferay.portlet.calendar", portletDataContext.getScopeGroupId()); Document document = SAXReaderUtil.createDocument(); Element rootElement = document.addElement("calendar-data"); rootElement.addAttribute("group-id", String.valueOf(portletDataContext.getScopeGroupId())); Element calendarsElement = rootElement.addElement("calendars"); Element calendarBookingsElement = rootElement.addElement("calendar-bookings"); Element calendarResourcesElement = rootElement.addElement("calendar-resources"); List<CalendarResource> calendarResources = CalendarResourceLocalServiceUtil .getCalendarResources(portletDataContext.getScopeGroupId()); for (CalendarResource calendarResource : calendarResources) { if (portletDataContext.isWithinDateRange(calendarResource.getModifiedDate())) { exportCalendarResource(portletDataContext, calendarsElement, calendarBookingsElement, calendarResourcesElement, calendarResource); }//w w w . j a va 2 s . com } return document.formattedString(); }
From source file:com.liferay.calendar.web.upgrade.v1_1_0.test.UpgradePortalPreferencesTest.java
License:Open Source License
protected String getPreferences(String namespace, String name, Object value) { Document document = SAXReaderUtil.createDocument(); Element rootElement = document.addElement("portlet-preferences"); Element preferenceElement = rootElement.addElement("preference"); Element nameElement = preferenceElement.addElement("name"); nameElement.setText(namespace + "#" + name); Element valueElement = preferenceElement.addElement("value"); valueElement.setText(String.valueOf(value)); return document.asXML(); }
From source file:com.liferay.content.targeting.service.test.util.DDMTemplateTestUtil.java
License:Open Source License
public static Document createDocument(String availableLocales, String defaultLocale) { Document document = SAXReaderUtil.createDocument(); Element rootElement = document.addElement("root"); rootElement.addAttribute("available-locales", availableLocales); rootElement.addAttribute("default-locale", defaultLocale); rootElement.addElement("request"); return document; }
From source file:com.liferay.ddlform.lar.DDLFormPortletDataHandlerImpl.java
License:Open Source License
@Override protected String doExportData(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) throws Exception { portletDataContext.addPermissions("com.liferay.portlet.dynamicdatalist", portletDataContext.getScopeGroupId()); long recordSetId = GetterUtil.getLong(portletPreferences.getValue("recordSetId", null)); if (recordSetId == 0) { return StringPool.BLANK; }// ww w. j a va 2s . com Document document = SAXReaderUtil.createDocument(); Element rootElement = document.addElement("record-sets"); DDLRecordSet recordSet = DDLRecordSetLocalServiceUtil.getRecordSet(recordSetId); DDLPortletDataHandler ddlPortletDataHandler = DDLPortletDataHandlerUtil.getDDLPortletDataHandler(); ddlPortletDataHandler.exportRecordSet(portletDataContext, rootElement, recordSet); return document.formattedString(); }
From source file:com.liferay.dynamic.data.lists.exporter.impl.DDLXMLExporter.java
License:Open Source License
@Override protected byte[] doExport(long recordSetId, int status, int start, int end, OrderByComparator<DDLRecord> orderByComparator) throws Exception { DDLRecordSet recordSet = _ddlRecordSetService.getRecordSet(recordSetId); DDMStructure ddmStructure = recordSet.getDDMStructure(); List<DDMFormField> ddmFormFields = getDDMFormFields(ddmStructure); Document document = SAXReaderUtil.createDocument(); Element rootElement = document.addElement("root"); List<DDLRecord> records = _ddlRecordLocalService.getRecords(recordSetId, status, start, end, orderByComparator);//from w w w.j a v a 2 s . co m for (DDLRecord record : records) { Element fieldsElement = rootElement.addElement("fields"); DDLRecordVersion recordVersion = record.getRecordVersion(); DDMFormValues ddmFormValues = _storageEngine.getDDMFormValues(recordVersion.getDDMStorageId()); Fields fields = _ddmFormValuesToFieldsConverter.convert(ddmStructure, ddmFormValues); for (DDMFormField ddmFormField : ddmFormFields) { LocalizedValue label = ddmFormField.getLabel(); String name = ddmFormField.getName(); String value = StringPool.BLANK; if (fields.contains(name)) { Field field = fields.get(name); value = field.getRenderedValue(getLocale()); } addFieldElement(fieldsElement, label.getString(getLocale()), value); } addFieldElement(fieldsElement, LanguageUtil.get(getLocale(), "status"), getStatusMessage(recordVersion.getStatus())); } String xml = document.asXML(); return xml.getBytes(); }
From source file:com.liferay.dynamic.data.lists.internal.exporter.DDLXMLExporter.java
License:Open Source License
@Override protected byte[] doExport(long recordSetId, int status, int start, int end, OrderByComparator<DDLRecord> orderByComparator) throws Exception { DDLRecordSet recordSet = _ddlRecordSetService.getRecordSet(recordSetId); Map<String, DDMFormField> ddmFormFields = getDistinctFields(recordSetId); Document document = SAXReaderUtil.createDocument(); Element rootElement = document.addElement("root"); List<DDLRecord> records = _ddlRecordLocalService.getRecords(recordSetId, status, start, end, orderByComparator);/* w w w .j a v a 2 s . c om*/ DateTimeFormatter dateTimeFormatter = getDateTimeFormatter(); for (DDLRecord record : records) { Element fieldsElement = rootElement.addElement("fields"); DDLRecordVersion recordVersion = record.getRecordVersion(); DDMFormValues ddmFormValues = _storageEngine.getDDMFormValues(recordVersion.getDDMStorageId()); Map<String, DDMFormFieldRenderedValue> values = getRenderedValues(recordSet.getScope(), ddmFormFields.values(), ddmFormValues); for (Map.Entry<String, DDMFormField> entry : ddmFormFields.entrySet()) { DDMFormFieldRenderedValue ddmFormFieldRenderedValue = values.get(entry.getKey()); addFieldElement(ddmFormFieldRenderedValue, fieldsElement, entry); } Locale locale = getLocale(); addFieldElement(fieldsElement, LanguageUtil.get(locale, "status"), getStatusMessage(recordVersion.getStatus())); addFieldElement(fieldsElement, LanguageUtil.get(locale, "modified-date"), formatDate(recordVersion.getStatusDate(), dateTimeFormatter)); addFieldElement(fieldsElement, LanguageUtil.get(locale, "author"), recordVersion.getUserName()); } String xml = document.asXML(); return xml.getBytes(); }
From source file:com.liferay.dynamic.data.mapping.BaseDDMTestCase.java
License:Open Source License
protected Document createEmptyDocument() { Document document = SAXReaderUtil.createDocument(); Element rootElement = document.addElement("root"); rootElement.addAttribute("available-locales", "en_US"); rootElement.addAttribute("default-locale", "en_US"); return document; }