Example usage for org.dom4j Element attribute

List of usage examples for org.dom4j Element attribute

Introduction

In this page you can find the example usage for org.dom4j Element attribute.

Prototype

Attribute attribute(QName qName);

Source Link

Document

DOCUMENT ME!

Usage

From source file:com.thoughtworks.cruise.MaterialRepository.java

License:Apache License

private boolean containsMaterial(String materialName, String pipeline) {
    List<Element> materials = configuration.provideDom()
            .materialsForPipeline(scenarioState.pipelineNamed(pipeline));
    for (Element material : materials) {
        if (material.attribute("materialName") == null) {
            continue;
        }//  ww w. ja  va  2  s. c  o m
        if (material.attribute("materialName").getText().equals(materialName)) {
            return true;
        }
    }
    return false;
}

From source file:com.thoughtworks.cruise.materials.AbstractRepository.java

License:Apache License

@Override
public void setUrl(Element element) {
    if (element.attribute("url") == null)
        return;// w ww.java 2 s .  com
    element.attribute("url").setValue(getUrl());
}

From source file:com.thoughtworks.cruise.materials.TfsRepository.java

License:Apache License

@Override
public void setOtherAttributes(Element element) {
    super.setOtherAttributes(element);
    if (element.attribute("username") != null) {
        element.attribute("username").setValue(TfsServer.getUsername());
    }//from w  w  w  .  j  ava 2  s .  c o  m
    if (element.attribute("password") != null) {
        element.attribute("password").setValue(TfsServer.getPassword());
    }
    if (element.attribute("domain") != null) {
        element.attribute("domain").setValue(TfsServer.getDomain());
    }
}

From source file:com.thoughtworks.cruise.page.AlreadyOnSourceXmlTab.java

License:Apache License

@com.thoughtworks.gauge.Step("Verify ldap manager password as <encryptedPassword>")
public void verifyLdapManagerPasswordAs(String encryptedPassword) throws Exception {
    CruiseConfigDom cruiseConfigDom = getCruiseConfigDom();
    Element ldap = cruiseConfigDom.getLdap();
    Assert.assertThat("Ldap configuration not found", ldap, notNullValue());
    String encryptedManagerPassword = ldap.attributeValue("encryptedManagerPassword");
    Assert.assertThat(encryptedManagerPassword, Is.is(encryptedPassword));
    Assert.assertThat(ldap.attribute("managerPassword"), Is.is(nullValue()));
}

From source file:com.thoughtworks.cruise.page.AlreadyOnSourceXmlTab.java

License:Apache License

@com.thoughtworks.gauge.Step("Verify mail host password as <encryptedPassword>")
public void verifyMailHostPasswordAs(String encryptedPassword) throws Exception {
    CruiseConfigDom cruiseConfigDom = getCruiseConfigDom();
    Element mailHost = cruiseConfigDom.getMailHost();
    Assert.assertThat("Mailhost configuration not found", mailHost, notNullValue());
    String encryptedManagerPassword = mailHost.attributeValue("encryptedPassword");
    Assert.assertThat(encryptedManagerPassword, Is.is(encryptedPassword));
    Assert.assertThat(mailHost.attribute("password"), Is.is(nullValue()));
}

From source file:com.thoughtworks.cruise.page.OnPipelineStagesFeedApi.java

License:Apache License

@com.thoughtworks.gauge.Step("Verify shows first instance of <stageName> of <pipelineName>")
public void verifyShowsFirstInstanceOfOf(String stageName, String pipelineName) throws Exception {
    String expandedPipelineName = state.pipelineNamed(pipelineName);
    CruiseResponse response = loadStageListing(expandedPipelineName);
    Document dom = DomUtil.getDomFor(response.getBody());
    Element pipelineInstanceElement = (Element) dom
            .selectSingleNode(StagesFeedXml.entryTitleXpath(expandedPipelineName, 1, stageName, 1, "Passed"));
    Assert.assertThat(pipelineInstanceElement, Matchers.is(Matchers.not(Matchers.nullValue())));
    Element pipelineLink = (Element) pipelineInstanceElement.selectSingleNode(
            "//atom:link[@rel='http://www.thoughtworks-studios.com/ns/relations/go/pipeline'][@type='application/vnd.go+xml']");
    state.knownPipelineInstanceUrl(pipelineName, pipelineLink.attribute("href"));
}

From source file:com.thoughtworks.cruise.utils.configfile.CruiseConfigDom.java

License:Apache License

public void setApprovalTypeForStage(String pipelineName, String stageName, String type) {
    Element stage = getStage(pipelineName, stageName);
    Element approval = stage.element("approval");
    if (approval == null) {
        approval = new DefaultElement("approval");
        Element jobs = stage.element("jobs");
        if (jobs != null) {
            jobs.detach();/*from   www .  j a v  a  2s.  c  o  m*/
            stage.add(approval);
            stage.add(jobs);
        } else {
            stage.add(approval);
        }
    }
    Attribute attribute = approval.attribute("type");
    if (attribute != null) {
        attribute.setValue(type);
    } else {
        approval.addAttribute("type", type);
    }
}

From source file:com.thoughtworks.cruise.utils.configfile.CruiseConfigDom.java

License:Apache License

public void setAllowOnlyKnownUsersToLogin(boolean value) {
    Element security = (Element) document.getRootElement().selectSingleNode("//security");
    if (security == null) {
        security = new DefaultElement("security");
        Element server = (Element) document.getRootElement().selectSingleNode("//server");
        server.add(security);//from  w  w  w  .  j  a v a2s. c  om
    }
    Attribute allowOnlyKnownUsers = security.attribute("allowOnlyKnownUsersToLogin");
    if (allowOnlyKnownUsers == null) {
        allowOnlyKnownUsers = new DefaultAttribute("allowOnlyKnownUsersToLogin", Boolean.toString(value));
        security.add(allowOnlyKnownUsers);
    } else {
        allowOnlyKnownUsers.setValue(Boolean.toString(value));
    }
}

From source file:com.thoughtworks.cruise.utils.configfile.CruiseConfigDom.java

License:Apache License

public Map<String, String> replacePipelineNames() {
    Map<String, String> pipelineNames = new HashMap<String, String>();
    List<Element> list = root().selectNodes("/cruise/pipelines/pipeline");
    for (Element element : list) {
        String initial = element.attribute("name").getText();
        String replaced = initial + StringUtil.shortUUID();
        for (Element pipelineElem : (List<Element>) root().selectNodes("//pipeline[@name='" + initial + "']")) {
            pipelineElem.addAttribute("name", replaced);
        }//from  w ww .ja va  2  s  .c  o m
        replaceDependentPipeline(initial, replaced);
        replacePipelineInFetchArtifact(initial, replaced);
        pipelineNames.put(initial, replaced);
    }
    return pipelineNames;
}

From source file:com.thoughtworks.cruise.utils.configfile.CruiseConfigDom.java

License:Apache License

public List<String> getPipelineNames() {
    List<String> pipelineNames = new ArrayList<String>();
    List<Element> list = root().selectNodes("/cruise/pipelines/pipeline");
    for (Element element : list) {
        pipelineNames.add(element.attribute("name").getText());
    }//from ww w.j a  v a  2 s  . c  o m
    return pipelineNames;
}