List of usage examples for org.dom4j Element clearContent
void clearContent();
Node
instances this branch may contain. From source file:com.thoughtworks.cruise.utils.configfile.CruiseConfigDom.java
License:Apache License
public void updateBuildFile(String pipelineName, String stageName, String jobName, String buildType, String buildFile) {//from w w w .ja v a 2s. c o m String xpath = String.format( "//pipelines/pipeline[@name='%s']/stage[@name='%s']/jobs/job[@name='%s']/tasks", pipelineName, stageName, jobName); Element element = (Element) document.selectSingleNode(xpath); element.clearContent(); Element newElement = new DefaultElement(buildType); newElement.addAttribute("buildfile", buildFile); element.add(newElement); }
From source file:cz.fi.muni.xkremser.editor.server.newObject.MonographBuilder.java
License:Open Source License
private void updateLanguages(Document doc, XPath xpath) { List<? extends Node> nodes = xpath.selectNodes(doc); for (Node languageNode : nodes) { Element languageEl = (Element) languageNode; String originalLang = languageEl.getTextTrim(); languageEl.clearContent(); languageEl.addText(transformLanguage(originalLang)); }/*from w w w. j a va2 s . c o m*/ }
From source file:cz.mzk.editor.server.newObject.MonographBuilder.java
License:Open Source License
@SuppressWarnings("unchecked") private void updateLanguages(Document doc, XPath xpath) { List<? extends Node> nodes = xpath.selectNodes(doc); for (Node languageNode : nodes) { Element languageEl = (Element) languageNode; String originalLang = languageEl.getTextTrim(); languageEl.clearContent(); languageEl.addText(transformLanguage(originalLang)); }//from w ww .j a v a2 s . c o m }
From source file:de.innovationgate.utils.net.IPv4Restriction.java
License:Apache License
/** * Writes restrictions to wga.xml. Previously existing restrictions will be erased. * @param clientRestrictions The client restrictions parent element in wga.xml * @param restrictions The restrictions to write. List of {@link IPv4Restriction} objects. */// ww w.j a v a 2 s. c o m public static void saveRestrictions(Element clientRestrictions, List restrictions) { Element restrictionsElement = clientRestrictions.element("restrictions"); //remove old rules restrictionsElement.clearContent(); Iterator restrictionsIt = restrictions.iterator(); while (restrictionsIt.hasNext()) { IPv4Restriction restriction = (IPv4Restriction) restrictionsIt.next(); restriction.addToElement(restrictionsElement); } }
From source file:de.innovationgate.wga.common.beans.LuceneIndexFileRule.java
License:Apache License
/** * Saves rules to lucene configuration in wga.xml * @param lucene The lucene configuration element * @param rules List of {@link LuceneIndexFileRule} objects to be saved *//*from ww w. j a va 2 s.co m*/ public static void saveRules(Element lucene, List rules) { Element filerules = WGUtils.getOrCreateElement(lucene, "filerules"); //remove old rules filerules.clearContent(); Iterator itemrulesIt = rules.iterator(); while (itemrulesIt.hasNext()) { LuceneIndexFileRule rule = (LuceneIndexFileRule) itemrulesIt.next(); Element ruleElement = filerules.addElement("filerule"); ruleElement.addAttribute("filesizelimit", new Integer(rule.getFileSizeLimit()).toString()); if (rule.isIncludedInAllContent()) { ruleElement.addAttribute("includedinallcontent", "true"); } else { ruleElement.addAttribute("includedinallcontent", "false"); } ruleElement.addAttribute("boost", Float.toString(rule.getBoost())); ruleElement.addText(rule.getFilePattern()); } }
From source file:de.innovationgate.wga.common.beans.LuceneIndexItemRule.java
License:Apache License
/** * Saves rules to lucene configuration in wga.xml * @param lucene The lucene configuration element * @param rules List of {@link LuceneIndexItemRule} objects to be saved *//*w w w. j av a2 s .co m*/ public static void saveRules(Element lucene, List rules) { Element itemrules = lucene.element("itemrules"); //remove old rules itemrules.clearContent(); Iterator itemrulesIt = rules.iterator(); while (itemrulesIt.hasNext()) { LuceneIndexItemRule rule = (LuceneIndexItemRule) itemrulesIt.next(); Element itemrule = itemrules.addElement("itemrule"); itemrule.addAttribute("indextype", rule.getIndexType()); itemrule.addAttribute("contenttype", rule.getContentType()); if (rule.isSortable()) { itemrule.addAttribute("sortable", "true"); } else { itemrule.addAttribute("sortable", "false"); } itemrule.addAttribute("boost", Float.toString(rule.getBoost())); itemrule.addText(rule.getItemExpression()); } }
From source file:de.innovationgate.wga.common.WGAXML.java
License:Apache License
/** * set the given information on the given contentDbElement * @param contentDbElement/* w w w . j a v a 2 s.co m*/ * @param enabled * @param dbImplClass * @param dbkey * @param title * @param domain * @param dbPath * @param defaultLogin * @param username * @param password * @return the updated contentdbElement */ public static Element setBasicContentDBInformation(Element contentDbElement, boolean enabled, boolean lazyConnect, String dbImplClass, String dbkey, String title, String domain, String dbPath, boolean defaultLogin, String username, String password) { contentDbElement.addAttribute("enabled", String.valueOf(enabled)); contentDbElement.addAttribute("lazyconnect", String.valueOf(lazyConnect)); contentDbElement.selectSingleNode("type").setText(dbImplClass); contentDbElement.selectSingleNode("dbkey").setText(dbkey.toLowerCase()); contentDbElement.selectSingleNode("dbpath").setText(dbPath); Element login = (Element) contentDbElement.selectSingleNode("login"); if (login == null) { login = contentDbElement.addElement("login"); } if (defaultLogin) { login.addAttribute("password", ""); login.addAttribute("username", ""); } else { login.addAttribute("password", Base64.encode(password.getBytes())); login.addAttribute("username", username); } login.addAttribute("encoding", "base64"); Element titleNode = contentDbElement.element("title"); titleNode.clearContent(); if (title.equals(DUMMY_CONTENTDB_TITLE) || title.trim().equals("")) { titleNode.addCDATA(""); } else { titleNode.addCDATA(title); } contentDbElement.selectSingleNode("domain").setText(domain); return contentDbElement; }
From source file:de.innovationgate.wgpublisher.lucene.LuceneIndexConfiguration.java
License:Open Source License
public void clearLastUpdated(String dbKey) { Element dbElement = fetchDBElement(dbKey); Element lastUpdateElement = dbElement.element("lastupdate"); lastUpdateElement.clearContent(); try {// ww w . j av a2 s. c om writeConfigDoc(); } catch (IOException e) { _core.getLog().error("Cannot clear lastUpdate for db '" + dbKey + "' in indexConfigFile '" + _configFile.getPath() + "'.", e); } }
From source file:org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.java
License:Apache License
/** * Add category property element if needed. *//*w w w. jav a 2 s.c om*/ private void addCategory() { if (!propsPart.getCategoryProperty().hasValue()) return; Element elem = xmlDoc.getRootElement().element(new QName(KEYWORD_CATEGORY, namespaceCoreProperties)); if (elem == null) { // Missing, we add it elem = xmlDoc.getRootElement().addElement(new QName(KEYWORD_CATEGORY, namespaceCoreProperties)); } else { elem.clearContent();// clear the old value } elem.addText(propsPart.getCategoryProperty().getValue()); }
From source file:org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.java
License:Apache License
/** * Add content status property element if needed. *///from www . j a va 2 s .c om private void addContentStatus() { if (!propsPart.getContentStatusProperty().hasValue()) return; Element elem = xmlDoc.getRootElement().element(new QName(KEYWORD_CONTENT_STATUS, namespaceCoreProperties)); if (elem == null) { // Missing, we add it elem = xmlDoc.getRootElement().addElement(new QName(KEYWORD_CONTENT_STATUS, namespaceCoreProperties)); } else { elem.clearContent();// clear the old value } elem.addText(propsPart.getContentStatusProperty().getValue()); }