List of usage examples for com.liferay.portal.kernel.xml SAXReaderUtil read
public static Document read(URL url) throws DocumentException
From source file:com.liferay.journal.internal.upgrade.v0_0_5.UpgradeJournal.java
License:Open Source License
protected List<Element> getDDMStructures(Locale locale) throws DocumentException { String xml = getContent("basic-web-content-structure.xml"); xml = StringUtil.replace(xml, "[$LOCALE_DEFAULT$]", locale.toString()); Document document = SAXReaderUtil.read(xml); Element rootElement = document.getRootElement(); return rootElement.elements("structure"); }
From source file:com.liferay.journal.internal.upgrade.v0_0_5.UpgradeJournal.java
License:Open Source License
protected String transformDateFieldValues(String content) throws Exception { if (!containsDateFieldType(content)) { return content; }/* w w w. java 2 s . c om*/ Document document = SAXReaderUtil.read(content); Element rootElement = document.getRootElement(); List<Element> dynamicElementElements = rootElement.elements("dynamic-element"); transformDateFieldValues(dynamicElementElements); return XMLUtil.formatXML(document); }
From source file:com.liferay.journal.internal.upgrade.v0_0_6.UpgradeImageTypeContentAttributes.java
License:Open Source License
protected String addImageContentAttributes(String content) throws Exception { Document contentDocument = SAXReaderUtil.read(content); contentDocument = contentDocument.clone(); XPath xPath = SAXReaderUtil.createXPath("//dynamic-element[@type='image']"); List<Node> imageNodes = xPath.selectNodes(contentDocument); for (Node imageNode : imageNodes) { Element imageEl = (Element) imageNode; List<Element> dynamicContentEls = imageEl.elements("dynamic-content"); String id = null;/*from w w w. j a v a 2 s . com*/ for (Element dynamicContentEl : dynamicContentEls) { id = dynamicContentEl.attributeValue("id"); dynamicContentEl.addAttribute("alt", StringPool.BLANK); dynamicContentEl.addAttribute("name", id); dynamicContentEl.addAttribute("title", id); dynamicContentEl.addAttribute("type", "journal"); } if (Validator.isNotNull(id)) { imageEl.addAttribute("instance-id", getImageInstanceId(id)); } } return contentDocument.formattedString(); }
From source file:com.liferay.journal.internal.upgrade.v1_0_0.UpgradeImageTypeContentAttributes.java
License:Open Source License
protected String addImageContentAttributes(String content) throws Exception { Document contentDocument = SAXReaderUtil.read(content); contentDocument = contentDocument.clone(); XPath xPath = SAXReaderUtil.createXPath("//dynamic-element[@type='image']"); List<Node> imageNodes = xPath.selectNodes(contentDocument); for (Node imageNode : imageNodes) { Element imageEl = (Element) imageNode; List<Element> dynamicContentEls = imageEl.elements("dynamic-content"); for (Element dynamicContentEl : dynamicContentEls) { String id = dynamicContentEl.attributeValue("id"); dynamicContentEl.addAttribute("alt", StringPool.BLANK); dynamicContentEl.addAttribute("name", id); dynamicContentEl.addAttribute("title", id); dynamicContentEl.addAttribute("type", "journal"); }/*from w w w .ja va2 s . co m*/ } return contentDocument.formattedString(); }
From source file:com.liferay.journal.internal.upgrade.v1_1_0.UpgradeDocumentLibraryTypeContent.java
License:Open Source License
protected String convertContent(String content) throws Exception { Document contentDocument = SAXReaderUtil.read(content); contentDocument = contentDocument.clone(); XPath xPath = SAXReaderUtil.createXPath("//dynamic-element[@type='document_library']"); List<Node> imageNodes = xPath.selectNodes(contentDocument); for (Node imageNode : imageNodes) { Element imageEl = (Element) imageNode; List<Element> dynamicContentEls = imageEl.elements("dynamic-content"); for (Element dynamicContentEl : dynamicContentEls) { String data = getDocumentLibraryValue(dynamicContentEl.getText()); dynamicContentEl.clearContent(); dynamicContentEl.addCDATA(data); }/*from w w w . jav a2s.c o m*/ } return contentDocument.formattedString(); }
From source file:com.liferay.journal.internal.upgrade.v1_1_0.UpgradeImageTypeContent.java
License:Open Source License
protected String convertTypeImageElements(long userId, long groupId, String content, long resourcePrimKey) throws Exception { Document contentDocument = SAXReaderUtil.read(content); contentDocument = contentDocument.clone(); XPath xPath = SAXReaderUtil.createXPath("//dynamic-element[@type='image']"); List<Node> imageNodes = xPath.selectNodes(contentDocument); for (Node imageNode : imageNodes) { Element imageEl = (Element) imageNode; List<Element> dynamicContentEls = imageEl.elements("dynamic-content"); for (Element dynamicContentEl : dynamicContentEls) { String id = dynamicContentEl.attributeValue("id"); if (Validator.isNull(id)) { continue; }// w w w . ja va2 s . com long folderId = getFolderId(userId, groupId, resourcePrimKey); FileEntry fileEntry = getFileEntry(groupId, folderId, id); if (fileEntry == null) { continue; } JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); jsonObject.put("alt", StringPool.BLANK); jsonObject.put("groupId", fileEntry.getGroupId()); jsonObject.put("name", fileEntry.getFileName()); jsonObject.put("resourcePrimKey", resourcePrimKey); jsonObject.put("title", fileEntry.getTitle()); jsonObject.put("type", "journal"); jsonObject.put("uuid", fileEntry.getUuid()); dynamicContentEl.clearContent(); dynamicContentEl.addCDATA(jsonObject.toString()); } } return contentDocument.formattedString(); }
From source file:com.liferay.journal.internal.util.impl.JournalConverterImpl.java
License:Open Source License
@Override public Fields getDDMFields(DDMStructure ddmStructure, String content) throws PortalException { try {//w w w .j a va 2s .c om return getDDMFields(ddmStructure, SAXReaderUtil.read(content)); } catch (DocumentException de) { throw new PortalException(de); } }
From source file:com.liferay.journal.internal.util.impl.JournalConverterImpl.java
License:Open Source License
/** * @deprecated As of 4.0.0, with no direct replacement *///from w w w . j a v a2 s.co m @Deprecated @Override public String getDDMXSD(String journalXSD, Locale defaultLocale) throws Exception { Document document = SAXReaderUtil.read(journalXSD); Element rootElement = document.getRootElement(); rootElement.addAttribute("available-locales", defaultLocale.toString()); rootElement.addAttribute("default-locale", defaultLocale.toString()); List<Element> dynamicElementElements = rootElement.elements("dynamic-element"); for (Element dynamicElementElement : dynamicElementElements) { updateJournalXSDDynamicElement(dynamicElementElement, defaultLocale.toString()); } return XMLUtil.formatXML(document); }
From source file:com.liferay.journal.internal.util.impl.JournalConverterImpl.java
License:Open Source License
/** * @deprecated As of 4.0.0, with no direct replacement *///from ww w .j a va 2 s. c om @Deprecated @Override public String getJournalXSD(String ddmXSD) throws Exception { Document document = SAXReaderUtil.read(ddmXSD); Element rootElement = document.getRootElement(); String defaultLanguageId = rootElement.attributeValue("default-locale"); removeAttribute(rootElement, "available-locales"); removeAttribute(rootElement, "default-locale"); List<Element> dynamicElementElements = rootElement.elements("dynamic-element"); for (Element dynamicElementElement : dynamicElementElements) { updateDDMXSDDynamicElement(dynamicElementElement, defaultLanguageId); } return XMLUtil.formatXML(document); }
From source file:com.liferay.journal.model.impl.JournalArticleImpl.java
License:Open Source License
/** * @deprecated As of 4.0.0, replaced by {@link #getContentByLocale(Document, * String)}// w w w.j a v a 2 s . c om */ @Deprecated public static String getContentByLocale(String content, boolean templateDriven, String languageId) { try { return getContentByLocale(SAXReaderUtil.read(content), languageId); } catch (DocumentException de) { if (_log.isWarnEnabled()) { _log.warn(de, de); } return content; } }