protected List<Element> getClassElements() throws Exception { Thread currentThread = Thread.currentThread(); ClassLoader classLoader = currentThread.getContextClassLoader(); InputStream inputStream = classLoader.getResourceAsStream( "META-INF/portal-hbm.xml"); Document document = UnsecureSAXReaderUtil.read(inputStream); Element rootElement = document.getRootElement(); return rootElement.elements("class"); }
@Override public List<Element> getDefaultTemplateElements() throws Exception { String templatesConfigPath = getTemplatesConfigPath(); if (Validator.isNull(templatesConfigPath)) { return Collections.emptyList(); } Class<?> clazz = getClass(); String xml = StringUtil.read( clazz.getClassLoader(), templatesConfigPath, false); Document document = UnsecureSAXReaderUtil.read(xml); Element rootElement = document.getRootElement(); return rootElement.elements("template"); }
protected Element addImportDataRootElement( PortletDataContext portletDataContext, String data) throws DocumentException { Document document = SAXReaderUtil.read(data); Element rootElement = document.getRootElement(); portletDataContext.setImportDataRootElement(rootElement); long groupId = GetterUtil.getLong( rootElement.attributeValue("group-id")); if (groupId != 0) { portletDataContext.setSourceGroupId(groupId); } return rootElement; }
Element rootElement = document.getRootElement();
document.getRootElement()); document.getRootElement());
public static SPIConfiguration fromXMLString(String xmlString) throws DocumentException { Document document = UnsecureSAXReaderUtil.read(xmlString); Element rootElement = document.getRootElement(); String id = rootElement.elementText("id"); String javaExecutable = rootElement.elementText("javaExecutable"); String jvmArguments = rootElement.elementText("jvmArguments"); String spiAgentClassName = rootElement.elementText("spiAgentClassName"); int connectorPort = GetterUtil.getIntegerStrict( rootElement.elementText("connectorPort")); String baseDir = rootElement.elementText("baseDir"); String[] portletIds = StringUtil.split( rootElement.elementText("portletIds")); String[] servletContextNames = StringUtil.split( rootElement.elementText("servletContextNames")); long pingInterval = GetterUtil.getLongStrict( rootElement.elementText("pingInterval")); long registerTimeout = GetterUtil.getLongStrict( rootElement.elementText("registerTimeout")); long shutdownTimeout = GetterUtil.getLongStrict( rootElement.elementText("shutdownTimeout")); String extraSettings = rootElement.elementText("extraSettings"); return new SPIConfiguration( id, javaExecutable, jvmArguments, spiAgentClassName, connectorPort, baseDir, portletIds, servletContextNames, pingInterval, registerTimeout, shutdownTimeout, extraSettings); }
protected void checkStructure(Document contentDocument, DDMForm ddmForm) throws PortalException { for (DDMFormField ddmFormField : ddmForm.getDDMFormFields()) { checkStructureField(ddmFormField, contentDocument.getRootElement()); } }
protected List<Element> getDDMStructures(Locale locale) throws DocumentException { String xml = StringUtil.replace( _BASIC_WEB_CONTENT_STRUCTURE, "[$LOCALE_DEFAULT$]", locale.toString()); Document document = SAXReaderUtil.read(xml); Element rootElement = document.getRootElement(); return rootElement.elements("structure"); }
protected void replace(Document document, Map<String, String> tokens) { try { Element rootElement = document.getRootElement(); long articleGroupId = GetterUtil.getLong( tokens.get("article_group_id")); replace(rootElement, articleGroupId); } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn(e.getMessage()); } } }
protected List<Element> getDDMStructures( ClassLoader classLoader, String fileName, Locale locale) throws Exception { String xml = StringUtil.read(classLoader, fileName); xml = StringUtil.replace(xml, "[$LOCALE_DEFAULT$]", locale.toString()); Document document = UnsecureSAXReaderUtil.read(xml); Element rootElement = document.getRootElement(); return rootElement.elements("structure"); }
@Override public String getDefaultLanguageId() { Document document = null; try { document = SAXReaderUtil.read(getName()); if (document != null) { Element rootElement = document.getRootElement(); return rootElement.attributeValue("default-locale"); } } catch (Exception e) { } Locale locale = LocaleUtil.getSiteDefault(); return locale.toString(); }
/** * @deprecated As of Judson (7.1.x), with no direct replacement */ @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); }
public static String removeArticleLocale( Document document, String content, String languageId) { try { Element rootElement = document.getRootElement(); String availableLocales = rootElement.attributeValue( "available-locales"); if (availableLocales == null) { return content; } availableLocales = StringUtil.removeFromList( availableLocales, languageId); if (availableLocales.endsWith(",")) { availableLocales = availableLocales.substring( 0, availableLocales.length() - 1); } rootElement.addAttribute("available-locales", availableLocales); _removeArticleLocale(rootElement, languageId); content = XMLUtil.formatXML(document); } catch (Exception e) { _log.error(e, e); } return content; }
protected String format( User user, long groupId, JournalArticle article, String content) throws PortalException { Document document = null; try { document = SAXReaderUtil.read(content); Element rootElement = document.getRootElement(); format(user, groupId, article, rootElement); content = XMLUtil.formatXML(document); } catch (DocumentException de) { _log.error(de, de); } return content; }
protected String getDynamicContent(Document document, String elementName) { String content = null; try { Element rootElement = document.getRootElement(); for (Element element : rootElement.elements()) { String curElementName = element.attributeValue( "name", StringPool.BLANK); if (curElementName.equals(elementName)) { content = element.elementText("dynamic-content"); break; } } } catch (Exception e) { _log.error(e, e); } return GetterUtil.getString(content); }
protected Map<String, LocalizedValue> createFieldsValuesMap( String content) { try { Document document = SAXReaderUtil.read(content); Element rootElement = document.getRootElement(); Locale defaultLocale = LocaleUtil.fromLanguageId( rootElement.attributeValue("default-locale")); return createFieldsValuesMap(rootElement, defaultLocale); } catch (DocumentException de) { throw new SystemException(de); } }
protected String transformDateFieldValues(String content) throws Exception { if (!containsDateFieldType(content)) { return content; } Document document = SAXReaderUtil.read(content); Element rootElement = document.getRootElement(); List<Element> dynamicElementElements = rootElement.elements( "dynamic-element"); transformDateFieldValues(dynamicElementElements); return XMLUtil.formatXML(document); }
@Override public void writeManifestSummary( Document document, ManifestSummary manifestSummary) { Element rootElement = document.getRootElement(); Element manifestSummaryElement = rootElement.addElement( "manifest-summary"); for (String manifestSummaryKey : manifestSummary.getManifestSummaryKeys()) { Element element = manifestSummaryElement.addElement("staged-model"); element.addAttribute("manifest-summary-key", manifestSummaryKey); long modelAdditionCount = manifestSummary.getModelAdditionCount( manifestSummaryKey); if (modelAdditionCount > 0) { element.addAttribute( "addition-count", String.valueOf(modelAdditionCount)); } long modelDeletionCount = manifestSummary.getModelDeletionCount( manifestSummaryKey); if (modelDeletionCount > 0) { element.addAttribute( "deletion-count", String.valueOf(modelDeletionCount)); } } }
/** * @deprecated As of Judson (7.1.x), with no direct replacement */ @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); }
protected void filterByLanguage(Document document, String languageId) { Element rootElement = document.getRootElement(); String defaultLanguageId = LocaleUtil.toLanguageId( LocaleUtil.getSiteDefault()); String articleDefaultLanguageId = rootElement.attributeValue( "default-locale", defaultLanguageId); String[] availableLanguageIds = StringUtil.split( rootElement.attributeValue( "available-locales", articleDefaultLanguageId)); if (!ArrayUtil.contains(availableLanguageIds, languageId, true)) { filterByLanguage( rootElement, articleDefaultLanguageId, articleDefaultLanguageId); } else { filterByLanguage(rootElement, languageId, articleDefaultLanguageId); } }