Search in sources :

Example 1 with CDATA

use of org.jdom2.CDATA in project pwm by pwm-project.

the class StringArrayValue method toXmlValues.

public List<Element> toXmlValues(final String valueElementName, final PwmSecurityKey pwmSecurityKey) {
    final List<Element> returnList = new ArrayList<>();
    for (final String value : this.values) {
        final Element valueElement = new Element(valueElementName);
        valueElement.addContent(new CDATA(value));
        returnList.add(valueElement);
    }
    return returnList;
}
Also used : Element(org.jdom2.Element) ArrayList(java.util.ArrayList) CDATA(org.jdom2.CDATA)

Example 2 with CDATA

use of org.jdom2.CDATA in project pwm by pwm-project.

the class VerificationMethodValue method toXmlValues.

@Override
public List<Element> toXmlValues(final String valueElementName, final PwmSecurityKey pwmSecurityKey) {
    final Element valueElement = new Element(valueElementName);
    valueElement.addContent(new CDATA(JsonUtil.serialize(value)));
    return Collections.singletonList(valueElement);
}
Also used : Element(org.jdom2.Element) CDATA(org.jdom2.CDATA)

Example 3 with CDATA

use of org.jdom2.CDATA in project gocd by gocd.

the class BuildLogElement method setTaskError.

public void setTaskError(String errorMessage) {
    Element msg = new Element("message");
    msg.addContent(new CDATA(errorMessage));
    msg.setAttribute("priority", "error");
    buildTask.addContent(msg);
}
Also used : Element(org.jdom2.Element) CDATA(org.jdom2.CDATA)

Example 4 with CDATA

use of org.jdom2.CDATA in project pwm by pwm-project.

the class StoredConfigurationImpl method writeLocaleBundleMap.

public void writeLocaleBundleMap(final String bundleName, final String keyName, final Map<String, String> localeMap) {
    ResourceBundle theBundle = null;
    for (final PwmLocaleBundle bundle : PwmLocaleBundle.values()) {
        if (bundle.getTheClass().getName().equals(bundleName)) {
            theBundle = ResourceBundle.getBundle(bundleName);
        }
    }
    if (theBundle == null) {
        LOGGER.info("ignoring unknown locale bundle for bundle=" + bundleName + ", key=" + keyName);
        return;
    }
    if (theBundle.getString(keyName) == null) {
        LOGGER.info("ignoring unknown key for bundle=" + bundleName + ", key=" + keyName);
        return;
    }
    resetLocaleBundleMap(bundleName, keyName);
    if (localeMap == null || localeMap.isEmpty()) {
        LOGGER.info("cleared locale bundle map for bundle=" + bundleName + ", key=" + keyName);
        return;
    }
    preModifyActions();
    changeLog.updateChangeLog(bundleName, keyName, localeMap);
    try {
        domModifyLock.writeLock().lock();
        final Element localeBundleElement = new Element("localeBundle");
        localeBundleElement.setAttribute("bundle", bundleName);
        localeBundleElement.setAttribute("key", keyName);
        for (final Map.Entry<String, String> entry : localeMap.entrySet()) {
            final String locale = entry.getKey();
            final String value = entry.getValue();
            final Element valueElement = new Element("value");
            if (locale != null && locale.length() > 0) {
                valueElement.setAttribute("locale", locale);
            }
            valueElement.setContent(new CDATA(value));
            localeBundleElement.addContent(valueElement);
        }
        localeBundleElement.setAttribute(XML_ATTRIBUTE_MODIFY_TIME, JavaHelper.toIsoDate(Instant.now()));
        document.getRootElement().addContent(localeBundleElement);
    } finally {
        domModifyLock.writeLock().unlock();
    }
}
Also used : PwmLocaleBundle(password.pwm.i18n.PwmLocaleBundle) Element(org.jdom2.Element) ResourceBundle(java.util.ResourceBundle) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) CDATA(org.jdom2.CDATA)

Example 5 with CDATA

use of org.jdom2.CDATA in project pwm by pwm-project.

the class LocalizedStringArrayValue method toXmlValues.

public List<Element> toXmlValues(final String valueElementName, final PwmSecurityKey pwmSecurityKey) {
    final List<Element> returnList = new ArrayList<>();
    for (final Map.Entry<String, List<String>> entry : values.entrySet()) {
        final String locale = entry.getKey();
        for (final String value : entry.getValue()) {
            final Element valueElement = new Element(valueElementName);
            valueElement.addContent(new CDATA(value));
            if (locale != null && locale.length() > 0) {
                valueElement.setAttribute("locale", locale);
            }
            returnList.add(valueElement);
        }
    }
    return returnList;
}
Also used : Element(org.jdom2.Element) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) TreeMap(java.util.TreeMap) Map(java.util.Map) CDATA(org.jdom2.CDATA)

Aggregations

CDATA (org.jdom2.CDATA)8 Element (org.jdom2.Element)8 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 TreeMap (java.util.TreeMap)4 List (java.util.List)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 ResourceBundle (java.util.ResourceBundle)1 ChallengeItemConfiguration (password.pwm.config.value.data.ChallengeItemConfiguration)1 PwmLocaleBundle (password.pwm.i18n.PwmLocaleBundle)1