@Test public void shouldReturnAMessageWhenAllArtifactsHaveBeenDeletedButArtifactsDeletedFlagHasNotBeenSet() throws Exception { HtmlRenderer renderer = new HtmlRenderer("context"); DirectoryEntries directoryEntries = new DirectoryEntries(); directoryEntries.render(renderer); Element document = getRenderedDocument(renderer); assertThat(document.getChildren().size(), is(1)); assertThat(document.getChild("p").getTextNormalize(), Matchers.containsString("Artifacts for this job instance are unavailable as they may have been or deleted externally. Re-run the stage or job to generate them again.")); }
@Test public void shouldReturnAMessageWhenAllArtifactsArePurgedIncludingCruiseOutput() throws Exception { HtmlRenderer renderer = new HtmlRenderer("context"); DirectoryEntries directoryEntries = new DirectoryEntries(); directoryEntries.setIsArtifactsDeleted(true); directoryEntries.render(renderer); Element document = getRenderedDocument(renderer); assertThat(document.getChildren().size(), is(1)); assertThat(document.getChild("p").getTextNormalize(), Matchers.containsString("Artifacts for this job instance are unavailable as they may have been or deleted externally. Re-run the stage or job to generate them again.")); }
@Test public void shouldReturnAMessageWhenThereAreNoArtifacts() throws Exception { HtmlRenderer renderer = new HtmlRenderer("context"); DirectoryEntries directoryEntries = new DirectoryEntries(); directoryEntries.add(new FolderDirectoryEntry("cruise-output", "", new DirectoryEntries())); directoryEntries.setIsArtifactsDeleted(true); directoryEntries.render(renderer); Element document = getRenderedDocument(renderer); assertThat(document.getChildren().size(), is(2)); assertThat(document.getChild("p").getTextNormalize(), Matchers.containsString("Artifacts for this job instance are unavailable as they may have been or deleted externally. Re-run the stage or job to generate them again.")); assertThat(document.getChild("ul").getChild("div").getChild("span").getChild("a").getTextNormalize(), is("cruise-output")); }
@Test public void shouldListAllArtifactsWhenArtifactsNotPurged() throws Exception { HtmlRenderer renderer = new HtmlRenderer("context"); DirectoryEntries directoryEntries = new DirectoryEntries(); directoryEntries.add(new FolderDirectoryEntry("cruise-output", "", new DirectoryEntries())); directoryEntries.add(new FolderDirectoryEntry("some-artifact", "", new DirectoryEntries())); directoryEntries.render(renderer); Element document = getRenderedDocument(renderer); assertThat(document.getChildren().size(), is(2)); Element cruiseOutputElement = (Element) document.getChildren().get(0); assertThat(cruiseOutputElement.getChild("div").getChild("span").getChild("a").getTextNormalize(), is("cruise-output")); Element artifactElement = (Element) document.getChildren().get(1); assertThat(artifactElement.getChild("div").getChild("span").getChild("a").getTextNormalize(), is("some-artifact")); }
/** * Returns the normalized textual content of the named child element, or * null if there's no such child. See <code>{@link * #getTextNormalize()}</code> for details of text normalizing. * * @param cname the name of the child * @return normalized text content for the named child, * or null if no such child */ public String getChildTextNormalize(final String cname) { final Element child = getChild(cname); if (child == null) { return null; } return child.getTextNormalize(); }
/** * Returns the normalized textual content of the named child element, or * null if there's no such child. * * @param cname * the name of the child * @param ns * the namespace of the child. A null implies Namespace.NO_NAMESPACE. * @return normalized text content for the named child, or null if no such * child */ public String getChildTextNormalize(final String cname, final Namespace ns) { final Element child = getChild(cname, ns); if (child == null) { return null; } return child.getTextNormalize(); }
/** * @return the normalized text. * @see org.jdom2.Element#getTextNormalize() */ public String getTextNormalize() { return element.getTextNormalize(); }
@Override public void setConfiguration (Element e) throws ConfigurationException { Element enabled = e.getChild("enabled"); Element disabled = e.getChild("disabled"); if (enabled != null && !"".equals(enabled.getTextNormalize())) enabledRealms = new HashSet(Arrays.asList(enabled.getTextNormalize().split(" "))); if (disabled != null && !"".equals(disabled.getTextNormalize())) disabledRealms = new HashSet(Arrays.asList(disabled.getTextNormalize().split(" ")));; }
private void readValue(Element pdsHashElement, String key, Namespace ns, boolean value) { if (pdsHashElement != null) { Element e = pdsHashElement.getChild(key, ns); if (e != null) { value = true; // no value means true String t = e.getTextNormalize(); if (t != null && t.equalsIgnoreCase("true")) value = true; if (t != null && t.equalsIgnoreCase("false")) value = false; } } pdsHash.put(key, value); }
private void readValue(Element pdsHashElement, String key, Namespace ns, boolean value) { if (pdsHashElement != null) { Element e = pdsHashElement.getChild(key, ns); if (e != null) { value = true; // no value means true String t = e.getTextNormalize(); if (t != null && t.equalsIgnoreCase("true")) value = true; if (t != null && t.equalsIgnoreCase("false")) value = false; } } pdsHash.put(key, value); }
private boolean readValue(Element pdsHashElement, String key, Namespace ns, boolean value) { if (pdsHashElement != null) { Element e = pdsHashElement.getChild(key, ns); if (e != null) { value = true; // no value means true String t = e.getTextNormalize(); if (t != null && t.equalsIgnoreCase("true")) value = true; if (t != null && t.equalsIgnoreCase("false")) value = false; } } return value; }
public List<String> getRootList(String elementName) { List<String> result = new ArrayList<>(); List<Element> rootList = rootElem.getChildren(elementName); for (Element elem : rootList) { String location = StringUtils.cleanPath(elem.getTextNormalize()); if (location.length() > 0) result.add(location); } return result; }
public List<String> getElementList(String elementName, String subElementName) { List<String> result = new ArrayList<>(); Element elem = rootElem.getChild( elementName ); if (elem == null) return result; List<Element> rootList = elem.getChildren(subElementName); for (Element elem2 : rootList) { String location = StringUtils.cleanPath(elem2.getTextNormalize()); if (location.length() > 0) result.add(location); } return result; }
protected Documentation readDocumentation(Element s) { String href = s.getAttributeValue("href", Catalog.xlinkNS); String title = s.getAttributeValue("title", Catalog.xlinkNS); String type = s.getAttributeValue("type"); // not XLink type String content = s.getTextNormalize(); URI uri = null; if (href != null) { try { uri = Catalog.resolveUri(baseURI, href); } catch (Exception e) { errlog.format(" ** Invalid documentation href = '%s' err='%s'%n", href, e.getMessage()); logger.debug(" ** Invalid documentation href = '{}' err='{}'", href, e.getMessage()); } } return new Documentation(href, uri, title, type, content); }
public static CalendarDateUnit getTimeUnit(Document doc) { Element root = doc.getRootElement(); Element timeUnitE = root.getChild("TimeUnit"); if (timeUnitE == null) return null; String cal = timeUnitE.getAttributeValue("calendar"); String timeUnitS = timeUnitE.getTextNormalize(); try { return CalendarDateUnit.of(cal, timeUnitS); } catch (Exception e) { log.error("Illegal date unit {} in FeatureDatasetCapabilitiesXML", timeUnitS); return null; } }
protected InvDocumentation readDocumentation(Element s) { String href = s.getAttributeValue("href", xlinkNS); String title = s.getAttributeValue("title", xlinkNS); String type = s.getAttributeValue("type"); // not XLink type String content = s.getTextNormalize(); // LOOK im not so sure this should be resolved! URI uriResolved = null; if (href != null) { try { uriResolved = docURI.resolve(href); } catch (Exception e) { factory.appendErr(" ** Invalid documentation href = " + href + " " + e.getMessage() + "\n"); } } return new InvDocumentation(href, uriResolved, title, type, content); }
protected InvDocumentation readDocumentation(Element s) { String href = s.getAttributeValue("href", xlinkNS); String title = s.getAttributeValue("title", xlinkNS); String type = s.getAttributeValue("type"); // not XLink type String content = s.getTextNormalize(); // LOOK im not so sure this should be resolved! URI uriResolved = null; if (href != null) { try { uriResolved = docURI.resolve(href); } catch (Exception e) { factory.appendErr(" ** Invalid documentation href = " + href + " " + e.getMessage() + "\n"); } } return new InvDocumentation(href, uriResolved, title, type, content); }
protected InvDocumentation readDocumentation(InvCatalog cat, Element s) { String href = s.getAttributeValue("href", xlinkNS); String title = s.getAttributeValue("title", xlinkNS); String type = s.getAttributeValue("type"); // not XLink type String content = s.getTextNormalize(); URI uri = null; if (href != null) { try { uri = cat.resolveUri(href); } catch (Exception e) { factory.appendErr(" ** Invalid documentation href = " + href + " " + e.getMessage() + "\n"); } } InvDocumentation doc = new InvDocumentation(href, uri, title, type, content); // LOOK XHTML ?? !! if (InvCatalogFactory.debugXML) System.out.println(" Documentation added: " + doc); return doc; }
protected InvDocumentation readDocumentation(InvCatalog cat, Element s) { String href = s.getAttributeValue("href", xlinkNS); String title = s.getAttributeValue("title", xlinkNS); String type = s.getAttributeValue("type"); // not XLink type String content = s.getTextNormalize(); URI uri = null; if (href != null) { try { uri = cat.resolveUri(href); } catch (Exception e) { factory.appendErr(" ** Invalid documentation href = " + href + " " + e.getMessage() + "\n"); } } InvDocumentation doc = new InvDocumentation(href, uri, title, type, content); // LOOK XHTML ?? !! if (InvCatalogFactory.debugXML) System.out.println(" Documentation added: " + doc); return doc; }
protected InvDocumentation readDocumentation( InvCatalog cat, Element s) { String href = s.getAttributeValue("href", xlinkNS); String title = s.getAttributeValue("title", xlinkNS); String type = s.getAttributeValue("type"); // not XLink type String content = s.getTextNormalize(); URI uri = null; if (href != null) { try { uri = cat.resolveUri(href); } catch (Exception e) { factory.appendErr(" ** Invalid documentation href = "+href+" "+e.getMessage()+"\n"); } } InvDocumentation doc = new InvDocumentation( href, uri, title, type, content); // LOOK XHTML ?? !! if (InvCatalogFactory.debugXML) System.out.println (" Documentation added: "+ doc); return doc; }