Example usage for org.jdom2 Comment Comment

List of usage examples for org.jdom2 Comment Comment

Introduction

In this page you can find the example usage for org.jdom2 Comment Comment.

Prototype

public Comment(String text) 

Source Link

Document

This creates the comment with the supplied text.

Usage

From source file:password.pwm.config.stored.StoredConfigurationImpl.java

License:Open Source License

public void writeSetting(final PwmSetting setting, final String profileID, final StoredValue value,
        final UserIdentity userIdentity) throws PwmUnrecoverableException {
    if (profileID == null && setting.getCategory().hasProfiles()) {
        throw new IllegalArgumentException(
                "reading of setting " + setting.getKey() + " requires a non-null profileID");
    }//from w  w w  .  j  a  v a2s . co  m
    if (profileID != null && !setting.getCategory().hasProfiles()) {
        throw new IllegalArgumentException("cannot specify profile for non-profile setting");
    }

    preModifyActions();
    changeLog.updateChangeLog(setting, profileID, value);
    domModifyLock.writeLock().lock();
    try {
        final Element settingElement = createOrGetSettingElement(document, setting, profileID);
        settingElement.removeContent();
        settingElement.setAttribute(XML_ATTRIBUTE_SYNTAX, setting.getSyntax().toString());
        settingElement.setAttribute(XML_ATTRIBUTE_SYNTAX_VERSION,
                Integer.toString(value.currentSyntaxVersion()));

        if (setting_writeLabels) {
            final Element labelElement = new Element("label");
            labelElement.addContent(setting.getLabel(PwmConstants.DEFAULT_LOCALE));
            settingElement.addContent(labelElement);
        }

        if (setting.getSyntax() == PwmSettingSyntax.PASSWORD) {
            final List<Element> valueElements = ((PasswordValue) value).toXmlValues("value", getKey());
            settingElement
                    .addContent(new Comment("Note: This value is encrypted and can not be edited directly."));
            settingElement
                    .addContent(new Comment("Please use the Configuration Manager GUI to modify this value."));
            settingElement.addContent(valueElements);
        } else if (setting.getSyntax() == PwmSettingSyntax.PRIVATE_KEY) {
            final List<Element> valueElements = ((PrivateKeyValue) value).toXmlValues("value", getKey());
            settingElement.addContent(valueElements);
        } else {
            settingElement.addContent(value.toXmlValues("value"));
        }

        updateMetaData(settingElement, userIdentity);
    } finally {
        domModifyLock.writeLock().unlock();
    }
}

From source file:password.pwm.config.StoredConfiguration.java

License:Open Source License

public void resetAllPasswordValues(final String comment) {
    for (final Iterator<SettingValueRecord> settingValueRecordIterator = new StoredValueIterator(
            false); settingValueRecordIterator.hasNext();) {
        final SettingValueRecord settingValueRecord = settingValueRecordIterator.next();
        if (settingValueRecord.getSetting().getSyntax() == PwmSettingSyntax.PASSWORD) {
            this.resetSetting(settingValueRecord.getSetting(), settingValueRecord.getProfile(), null);
            if (comment != null && !comment.isEmpty()) {
                final XPathExpression xp = XPathBuilder.xpathForSetting(settingValueRecord.getSetting(),
                        settingValueRecord.getProfile());
                final Element settingElement = (Element) xp.evaluateFirst(document);
                if (settingElement != null) {
                    settingElement.addContent(new Comment(comment));
                }//from   www .ja v  a  2 s. c  o m
            }
        }
    }
}

From source file:password.pwm.config.StoredConfiguration.java

License:Open Source License

public void writeSetting(final PwmSetting setting, final String profileID, final StoredValue value,
        final UserIdentity userIdentity) {
    if (profileID == null && setting.getCategory().hasProfiles()) {
        throw new IllegalArgumentException(
                "reading of setting " + setting.getKey() + " requires a non-null profileID");
    }//from   w  w  w  .  j a v  a 2 s . c o  m
    if (profileID != null && !setting.getCategory().hasProfiles()) {
        throw new IllegalArgumentException("cannot specify profile for non-profile setting");
    }

    preModifyActions();
    changeLog.updateChangeLog(setting, profileID, value);
    domModifyLock.writeLock().lock();
    try {
        final Element settingElement = createOrGetSettingElement(document, setting, profileID);
        settingElement.removeContent();
        settingElement.setAttribute(XML_ATTRIBUTE_SYNTAX, setting.getSyntax().toString());
        settingElement.setAttribute(XML_ATTRIBUTE_SYNTAX_VERSION,
                Integer.toString(value.currentSyntaxVersion()));

        if (setting_writeLabels) {
            final Element labelElement = new Element("label");
            labelElement.addContent(setting.getLabel(PwmConstants.DEFAULT_LOCALE));
            settingElement.addContent(labelElement);
        }

        if (setting.getSyntax() == PwmSettingSyntax.PASSWORD) {
            final List<Element> valueElements = ((PasswordValue) value).toXmlValues("value", getKey());
            settingElement
                    .addContent(new Comment("Note: This value is encrypted and can not be edited directly."));
            settingElement
                    .addContent(new Comment("Please use the Configuration Manager GUI to modify this value."));
            settingElement.addContent(valueElements);
        } else {
            settingElement.addContent(value.toXmlValues("value"));
        }

        updateMetaData(settingElement, userIdentity);
    } finally {
        domModifyLock.writeLock().unlock();
    }
}

From source file:se.miun.itm.input.model.design.Design.java

License:Open Source License

@Override
public void attachEnvironmentInfo() {
    String info = EnvironmentInfo.getInfo();
    design.addContent(new Comment(info));
}