Example usage for com.liferay.portal.kernel.xml Document setXMLEncoding

List of usage examples for com.liferay.portal.kernel.xml Document setXMLEncoding

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.xml Document setXMLEncoding.

Prototype

public void setXMLEncoding(String encoding);

Source Link

Usage

From source file:com.liferay.portlet.layoutsadmin.util.SitemapImpl.java

License:Open Source License

public String getSitemap(long groupId, boolean privateLayout, ThemeDisplay themeDisplay)
        throws PortalException, SystemException {

    Document document = SAXReaderUtil.createDocument();

    document.setXMLEncoding(StringPool.UTF8);

    Element rootElement = document.addElement("urlset", "http://www.google.com/schemas/sitemap/0.84");

    List<Layout> layouts = LayoutLocalServiceUtil.getLayouts(groupId, privateLayout,
            LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);

    visitLayouts(rootElement, layouts, themeDisplay);

    return document.asXML();
}

From source file:com.liferay.portlet.softwarecatalog.service.impl.SCProductEntryLocalServiceImpl.java

License:Open Source License

public String getRepositoryXML(long groupId, String version, String baseImageURL, Date oldestDate,
        int maxNumOfVersions, Properties repoSettings) throws SystemException {

    Document doc = SAXReaderUtil.createDocument();

    doc.setXMLEncoding(StringPool.UTF8);

    Element root = doc.addElement("plugin-repository");

    Element settingsEl = root.addElement("settings");

    populateSettingsElement(settingsEl, repoSettings);

    List<SCProductEntry> productEntries = scProductEntryPersistence.findByGroupId(groupId);

    for (SCProductEntry productEntry : productEntries) {
        if (Validator.isNull(productEntry.getRepoGroupId())
                || Validator.isNull(productEntry.getRepoArtifactId())) {

            continue;
        }// w  w  w . ja v a  2s. com

        List<SCProductVersion> productVersions = scProductVersionPersistence
                .findByProductEntryId(productEntry.getProductEntryId());

        for (int i = 0; i < productVersions.size(); i++) {
            SCProductVersion productVersion = productVersions.get(i);

            if ((maxNumOfVersions > 0) && (maxNumOfVersions < (i + 1))) {
                break;
            }

            if (!productVersion.isRepoStoreArtifact()) {
                continue;
            }

            if ((oldestDate != null) && (oldestDate.after(productVersion.getModifiedDate()))) {

                continue;
            }

            if (Validator.isNotNull(version)
                    && !isVersionSupported(version, productVersion.getFrameworkVersions())) {

                continue;
            }

            Element el = root.addElement("plugin-package");

            populatePluginPackageElement(el, productEntry, productVersion, baseImageURL);
        }
    }

    return doc.asXML();
}