use of org.jdom2.Comment in project JMRI by JMRI.
the class VariableTableModel method processDecVal.
protected VariableValue processDecVal(Element child, String name, String comment, boolean readOnly, boolean infoOnly, boolean writeOnly, boolean opsOnly, String CV, String mask, String item) throws NumberFormatException {
VariableValue v;
Attribute a;
int minVal = 0;
int maxVal = 255;
if ((a = child.getAttribute("min")) != null) {
minVal = Integer.valueOf(a.getValue()).intValue();
}
if ((a = child.getAttribute("max")) != null) {
maxVal = Integer.valueOf(a.getValue()).intValue();
}
v = new DecVariableValue(name, comment, "", readOnly, infoOnly, writeOnly, opsOnly, CV, mask, minVal, maxVal, _cvModel.allCvMap(), _status, item);
return v;
}
use of org.jdom2.Comment in project gocd by gocd.
the class CommandSnippetXmlParser method parse.
public CommandSnippet parse(String xmlContent, String fileName, String relativeFilePath) {
try {
Document document = buildXmlDocument(xmlContent, CommandSnippet.class.getResource("command-snippet.xsd"));
CommandSnippetComment comment = getComment(document);
Element execTag = document.getRootElement();
String commandName = execTag.getAttributeValue("command");
List<String> arguments = new ArrayList<>();
for (Object child : execTag.getChildren()) {
Element element = (Element) child;
arguments.add(element.getValue());
}
return new CommandSnippet(commandName, arguments, comment, fileName, relativeFilePath);
} catch (Exception e) {
String errorMessage = String.format("Reason: %s", e.getMessage());
LOGGER.info("Could not load command '{}'. {}", fileName, errorMessage);
return CommandSnippet.invalid(fileName, errorMessage, new EmptySnippetComment());
}
}
use of org.jdom2.Comment in project pwm by pwm-project.
the class StoredConfigurationImpl method writeSetting.
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");
}
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 if (setting.getSyntax() == PwmSettingSyntax.NAMED_SECRET) {
final List<Element> valueElements = ((NamedSecretValue) value).toXmlValues("value", getKey());
settingElement.addContent(valueElements);
} else {
settingElement.addContent(value.toXmlValues("value", getKey()));
}
updateMetaData(settingElement, userIdentity);
} finally {
domModifyLock.writeLock().unlock();
}
}
use of org.jdom2.Comment in project pwm by pwm-project.
the class StoredConfigurationImpl method resetAllPasswordValues.
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));
}
}
}
}
final String pwdHash = this.readConfigProperty(ConfigurationProperty.PASSWORD_HASH);
if (pwdHash != null && !pwdHash.isEmpty()) {
this.writeConfigProperty(ConfigurationProperty.PASSWORD_HASH, comment);
}
}
use of org.jdom2.Comment in project jPOS by jpos.
the class TransactionManagerTest method testSnapshotThrowsNullPointerException1.
@Test
public void testSnapshotThrowsNullPointerException1() throws Throwable {
try {
transactionManager.snapshot(100L, new Comment("testTransactionManagerText"));
fail("Expected NullPointerException to be thrown");
} catch (NullPointerException ex) {
if (isJavaVersionAtMost(JAVA_14)) {
assertNull(ex.getMessage(), "ex.getMessage()");
} else {
assertEquals("Cannot invoke \"String.length()\" because \"str\" is null", ex.getMessage(), "ex.getMessage()");
}
assertNull(transactionManager.psp, "transactionManager.psp");
}
}
Aggregations