List of usage examples for org.jdom2 Element removeContent
@Override
public List<Content> removeContent()
From source file:password.pwm.config.stored.StoredConfigurationImpl.java
License:Open Source License
public void resetSetting(final PwmSetting setting, final String profileID, final UserIdentity userIdentity) { changeLog.updateChangeLog(setting, profileID, defaultValue(setting, this.getTemplateSet())); domModifyLock.writeLock().lock();//from w w w.j a v a2 s . c o m preModifyActions(); try { final Element settingElement = createOrGetSettingElement(document, setting, profileID); settingElement.removeContent(); settingElement.addContent(new Element(XML_ELEMENT_DEFAULT)); updateMetaData(settingElement, userIdentity); } finally { domModifyLock.writeLock().unlock(); } }
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"); }// ww 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 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 resetSetting(final PwmSetting setting, final String profileID, final UserIdentity userIdentity) { changeLog.updateChangeLog(setting, profileID, defaultValue(setting, this.getTemplate())); domModifyLock.writeLock().lock();//from w ww.j ava2 s . co m preModifyActions(); try { final Element settingElement = createOrGetSettingElement(document, setting, profileID); settingElement.removeContent(); settingElement.addContent(new Element(XML_ELEMENT_DEFAULT)); updateMetaData(settingElement, userIdentity); } finally { domModifyLock.writeLock().unlock(); } }
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 va 2s.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.util.TreeSorter.java
License:Open Source License
/** * take a design space tree and order it with respect to min max * dependencies, so that parameters that require a context never get * null-pointers.//from ww w.j ava2 s . co m * * @param parent * @param comparator */ @SuppressWarnings("unchecked") public static void reorganizeTree(final Element parent, final ParamEvaluationOrderComparator<Element> comparator) { List<Param<?>> params = (List<Param<?>>) (List<?>) parent.getChildren(); if (params != null && !params.isEmpty()) { List<Param<?>> paramsCopy = new ArrayList<Param<?>>(); for (Param<?> child : params) { reorganizeTree(child, comparator); paramsCopy.add(child); if (parent instanceof Param) addDependenciesToParent((Param<?>) parent, child); } parent.removeContent(); Collections.sort(paramsCopy, comparator); for (int i = 0; i < paramsCopy.size(); i++) parent.addContent(paramsCopy.get(i)); } }