Example usage for com.liferay.portal.kernel.xml Node setText

List of usage examples for com.liferay.portal.kernel.xml Node setText

Introduction

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

Prototype

public void setText(String text);

Source Link

Usage

From source file:com.beorn.onlinepayment.messaging.messageprocessor.RegisterMessageProcessor.java

License:Open Source License

private void rewriteConfigurationForLocalization(Node configParametersNode) {
    if (configParametersNode == null)
        return;/*  w  w  w.  j  av a2  s . co m*/

    List<Node> localizableNodes = configParametersNode
            .selectNodes("group/name | group/parameter/name | group/parameter/helpMessage");

    for (Node localizableNode : localizableNodes) {
        Map<Locale, String> localizationMap = getLocalizationMap(localizableNode);

        String xml = StringPool.BLANK;

        for (Entry<Locale, String> localizationMapEntry : localizationMap.entrySet()) {

            String key = localizableNode.getName();
            String value = localizationMapEntry.getValue();
            Locale locale = localizationMapEntry.getKey();
            String requestedLanguageId = LocaleUtil.toLanguageId(locale);

            xml = LocalizationUtil.updateLocalization(xml, key, value, requestedLanguageId);
        }

        for (Node childNode : localizableNode.selectNodes("*"))
            childNode.detach();

        localizableNode.setText(xml);
    }
}

From source file:com.liferay.journal.verify.JournalServiceVerifyProcess.java

License:Open Source License

protected void updateLinkToLayoutElements(long groupId, Element element) {
    Element dynamicContentElement = element.element("dynamic-content");

    Node node = dynamicContentElement.node(0);

    String text = node.getText();

    if (!text.isEmpty() && !text.endsWith(StringPool.AT + groupId)) {
        node.setText(dynamicContentElement.getStringValue() + StringPool.AT + groupId);
    }//  w w w  .  j a v a  2  s. c o  m
}

From source file:com.liferay.portlet.journalcontent.action.UpdateArticleFieldAction.java

License:Open Source License

protected void updateArticleField(HttpServletRequest request, HttpServletResponse response) throws Exception {

    long groupId = ParamUtil.getLong(request, "groupId");
    String articleId = ParamUtil.getString(request, "articleId");
    double version = ParamUtil.getDouble(request, "version");

    String containerId = ParamUtil.getString(request, "containerId");

    if (Validator.isNotNull(containerId)) {
        int x = containerId.indexOf("_");
        int y = containerId.lastIndexOf("_");

        if ((x != -1) && (y != -1)) {
            groupId = GetterUtil.getLong(containerId.substring(0, x));
            articleId = containerId.substring(x + 1, y);
            version = GetterUtil.getDouble(containerId.substring(y, containerId.length()));
        }/*  ww  w  . j av a2 s .  c om*/
    }

    String languageId = LanguageUtil.getLanguageId(request);

    String fieldName = ParamUtil.getString(request, "fieldName");
    String fieldData = ParamUtil.getString(request, "fieldData");

    if (fieldName.startsWith("journal-content-field-name-")) {
        fieldName = fieldName.substring(27, fieldName.length());
    }

    JournalArticle article = JournalArticleLocalServiceUtil.getArticle(groupId, articleId, version);

    String content = article.getContent();

    Document doc = SAXReaderUtil.read(content);

    if (_log.isDebugEnabled()) {
        _log.debug("Before\n" + content);
    }

    String path = "/root/dynamic-element[@name='" + fieldName + "']/dynamic-content[@language-id='" + languageId
            + "']";

    Node node = doc.selectSingleNode(path);

    if (node == null) {
        path = "/root/dynamic-element[@name='" + fieldName + "']/dynamic-content";

        node = doc.selectSingleNode(path);
    }

    node.setText(fieldData);

    content = DDMXMLUtil.formatXML(doc);

    if (_log.isDebugEnabled()) {
        _log.debug("After\n" + content);
    }

    JournalArticleServiceUtil.updateContent(groupId, articleId, version, content);

    ServletResponseUtil.write(response, fieldData);
}