List of usage examples for org.jdom2 Element getChildText
public String getChildText(final String cname)
From source file:org.xwiki.contrib.jira.macro.internal.source.AbstractJIRADataSource.java
License:Open Source License
/** * @param document the XML document from which to extract JIRA issues * @return the list of XML Elements for each JIRA issue, indexed in a Map with the issue id as the key *//*from www . ja va 2 s . c om*/ protected Map<String, Element> buildIssues(Document document) { Map<String, Element> issues = new LinkedHashMap<>(); for (Element item : document.getRootElement().getChild("channel").getChildren("item")) { issues.put(item.getChildText(JIRAField.KEY.getId()), item); } return issues; }
From source file:org.xwiki.contrib.nestedpagesmigrator.testframework.Example.java
License:Open Source License
private void elementToRights(Element right, Page page) { DocumentReference user = resolveDocument(right.getChildText("user")); DocumentReference group = resolveDocument(right.getChildText("group")); boolean value = "allow".equals(right.getChildText("value")); DocumentReference origin = resolveDocument(right.getChildText("origin")); if (origin == null) { origin = new DocumentReference("WebPreferences", page.getDocumentReference().getLastSpaceReference()); }//w w w. j a va2 s . c om for (String level : right.getChildText("level").split(",")) { page.addRight(new Right(user, group, level, value, origin)); } }
From source file:org.xwiki.contrib.nestedpagesmigrator.testframework.Example.java
License:Open Source License
private Page getPageFromElement(Element element) { DocumentReference reference = resolveDocument(element.getChild("fullName").getText()); DocumentReference parent = element.getChild("parent") != null ? resolveDocument(element.getChild("parent").getText()) : null;/* www .j av a 2s.c om*/ DocumentReference from = element.getChild("from") != null ? resolveDocument(element.getChild("from").getText()) : null; boolean isFailedToLoad = "true".equals(element.getAttributeValue("errorOnLoad")); DocumentReference duplicateOf = element.getChild("duplicateOf") != null ? resolveDocument(element.getChildTextTrim("duplicateOf")) : null; boolean deletePrevious = "true".equals(element.getAttributeValue("deletePrevious")); Page page = new Page(reference, parent, from, isFailedToLoad, duplicateOf, deletePrevious); Element preferences = element.getChild("preferences"); if (preferences != null) { for (Element preference : preferences.getChildren()) { String name = preference.getChildText("name"); String value = preference.getChildText("value"); DocumentReference origin = resolveDocument(preference.getChildText("origin")); if (origin == null) { origin = new DocumentReference("WebPreferences", reference.getLastSpaceReference()); } page.addPreference(new Preference(name, value, origin)); } } Element rights = element.getChild("rights"); if (rights != null) { for (Element right : rights.getChildren()) { elementToRights(right, page); } } return page; }
From source file:org.xwiki.contrib.nestedpagesmigrator.testframework.Example.java
License:Open Source License
public Collection<Preference> getGlobalPreferences() { DocumentReference origin = new DocumentReference("xwiki", "XWiki", "XWikiPreferences"); Collection<Preference> preferences = new ArrayList<>(); for (Element preference : getBefore().getChild("preferences").getChildren()) { String name = preference.getChildText("name"); String value = preference.getChildText("value"); preferences.add(new Preference(name, value, origin)); }/*from www.j ava2 s.co m*/ return preferences; }
From source file:org.xwiki.contrib.nestedpagesmigrator.testframework.Example.java
License:Open Source License
public Collection<Right> getGlobalRights() { DocumentReference origin = new DocumentReference("xwiki", "XWiki", "XWikiPreferences"); Collection<Right> rights = new ArrayList<>(); for (Element right : getBefore().getChild("rights").getChildren()) { DocumentReference user = resolveDocument(right.getChildText("user")); DocumentReference group = resolveDocument(right.getChildText("group")); boolean value = "allow".equals(right.getChildText("value")); for (String level : right.getChildText("level").split(",")) { rights.add(new Right(user, group, level, value, origin)); }//from w ww .j a va2s .c o m } return rights; }
From source file:org.xwiki.contrib.rest.users.internal.DefaultXMLRestUserConfiguration.java
License:Open Source License
@Override public String getPasswordSalt() { if (xmlConfiguration.getXML() != null) { Element usersElement = xmlConfiguration.getXML().getRootElement().getChild("users"); if (usersElement != null) { String salt = usersElement.getChildText("password-salt"); if (StringUtils.isNotBlank(salt)) { return salt; }/* w ww . j ava 2s .c o m*/ } } // Fallback is an empty salt return ""; }
From source file:org.xwiki.rendering.internal.macro.jira.displayer.field.AbstractDateJIRAFieldDisplayer.java
License:Open Source License
@Override public List<Block> displayField(String fieldName, Element issue) { List<Block> result;/*from www . j av a 2 s .c o m*/ String date = issue.getChildText(fieldName); if (date != null) { try { Date parsedDate = this.jiraDateFormat.parse(date); result = Arrays.<Block>asList(new VerbatimBlock(this.displayDateFormat.format(parsedDate), true)); } catch (ParseException e) { result = Arrays.<Block>asList(new VerbatimBlock(date, true)); } } else { result = Collections.emptyList(); } return result; }
From source file:org.xwiki.rendering.internal.macro.jira.displayer.field.KeyJIRAFieldDisplayer.java
License:Open Source License
@Override public List<Block> displayField(String fieldName, Element issue) { List<Block> result = Collections.emptyList(); String key = issue.getChildText(JIRAFields.KEY); if (key != null) { String link = issue.getChildText(JIRAFields.LINK); List<Block> labelBlocks = Arrays.<Block>asList(new VerbatimBlock(key, true)); // If the Issue is closed then display it striked-out String resolutionId = issue.getChild(JIRAFields.RESOLUTION).getAttributeValue("id"); if (!"-1".equals(resolutionId)) { // The issue is resolved labelBlocks = Arrays.<Block>asList(new FormatBlock(labelBlocks, Format.STRIKEDOUT)); }//from w w w .j a v a 2 s.c om if (link != null) { ResourceReference reference = new ResourceReference(link, ResourceType.URL); result = Arrays.<Block>asList(new LinkBlock(labelBlocks, reference, true)); } else { result = labelBlocks; } } return result; }
From source file:org.xwiki.rendering.internal.macro.jira.source.AbstractJIRADataSource.java
License:Open Source License
/** * @param document the XML document from which to extract JIRA issues * @return the list of XML Elements for each JIRA issue, indexed in a Map with the issue id as the key *///from w w w . ja v a 2 s . co m protected Map<String, Element> buildIssues(Document document) { Map<String, Element> issues = new LinkedHashMap<String, Element>(); for (Element item : document.getRootElement().getChild("channel").getChildren("item")) { issues.put(item.getChildText(JIRAFields.KEY), item); } return issues; }
From source file:org.yawlfoundation.yawl.authentication.YClient.java
License:Open Source License
public YClient(Element xml) { _userName = xml.getChildText("username"); _password = xml.getChildText("password"); _documentation = xml.getChildText("documentation"); }