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.utils.configfile.CruiseConfigDom.java

License:Apache License

public void changeLdapUriTo(String newLdapUri) {
    Element ldap = (Element) getNode("/cruise/server/security/ldap");
    ldap.attribute("uri").setValue(newLdapUri);
}

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

License:Apache License

public void changePasswordPathTo(String passwordFilePath) {
    Element passwordFile = (Element) getNode("/cruise/server/security/passwordFile");
    passwordFile.attribute("path").setValue(passwordFilePath);
}

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

License:Apache License

private void removeAttribute(Element serverTag, String attributeName) {
    serverTag.remove(serverTag.attribute(attributeName));
}

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

License:Apache License

public void modifyPipeline(String pipelineName, String node, String attribute, String attrValue) {

    Element pipeline = pipelineElement(pipelineName);
    Element trackingTool = findOrCreateAt(pipeline, 0, node);
    Attribute linkAttr = trackingTool.attribute(attribute);
    if (linkAttr == null) {
        trackingTool.add(new DefaultAttribute(attribute, attrValue));
    } else {/*from   ww w .j  a va  2 s . co m*/
        linkAttr.setValue(attrValue);
    }
}

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

License:Apache License

public void hasMaterialWithAttribs(String pipelineName, String materialType, String materialName,
        String... nameValues) {/*from   w w w. j  av  a 2 s.  c o m*/
    Element material = material(pipelineName, materialName);
    if (material == null) {
        throw new RuntimeException(
                "Could not find material of type '" + materialType + "' and name '" + materialName + "'");
    }
    for (String nameValue : nameValues) {
        String[] nameAndValue = nameValue.split(">");
        String value = nameAndValue[1];
        if ("tfs".equals(materialType) && "url".equals(nameAndValue[0])) {
            value = TfsServer.getUrl() + value;
        }
        Attribute attrib = material.attribute(nameAndValue[0]);
        if (attrib == null || !attrib.getText().equals(value)) {
            throw new RuntimeException("Could not find attribute pair: " + nameValue);
        }
    }
}

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

License:Apache License

public void invertFileFilter(String pipelineName) {
    List<Element> materials = materialsForPipeline(pipelineName);
    for (Element material : materials) {
        Attribute invertFile = material.attribute("invertFilter");
        if (invertFile == null) {
            material.add(new DefaultAttribute("invertFilter", "true"));
        } else {//ww w. ja  va  2  s.  c  o  m
            invertFile.setValue("true");
        }
    }
}

From source file:com.thoughtworks.go.server.JUnitReportGenerator.java

License:Apache License

private static void setAttr(int i, Element test, final String attr) {
    Attribute classname = test.attribute(attr);
    classname.setValue(classname.getValue() + i);
}

From source file:com.topsec.tsm.sim.sysconfig.web.SystemConfigController.java

@RequestMapping("/superiorConfigRegist")
@ResponseBody//from  w w w  . j  ava  2 s. c  om
public Object superiorConfigRegist(SID sid, HttpServletRequest request) throws Exception {
    Result result = new Result(true, "??");
    String operator = request.getParameter("operator");
    String registIp = request.getParameter("registIp");
    String registName = request.getParameter("registName");
    String param = "";
    if (registIp.equals(IpAddress.getLocalIp().toString())) {
        result = new Result(false, "???");
        return result;
    }
    if (StringUtils.containsAny(registName, "<>'*?:/|\"\\")) {
        return result.buildError("?????");
    }
    Node parentNode = nodeMgrFacade.getParentNode();
    Node KernelNode = nodeMgrFacade.getKernelAuditor(false);
    try {
        if ("regist".equals(operator)) {
            if (parentNode != null) {
                return result.buildError("??");
            } else {
                //??
                param = "<Register>" + "<Ip>" + IpAddress.getLocalIp() + "</Ip>" + //?IP
                        "<Alias>" + registName + "</Alias>" + "<NodeId>" + KernelNode.getNodeId() + "</NodeId>"
                        + "<Type>register</Type>" + "</Register>";
            }
        } else if ("delete".equals(operator)) {
            if (parentNode == null) {
                return result.buildError("??");
            }
            param = "<Register>" + "<Ip>" + IpAddress.getLocalIp() + "</Ip>" + "<Type>delete</Type>"
                    + "</Register>";
        } else if ("update".equals(operator)) {
            if (parentNode == null) {
                return result.buildError("??");
            }
            try {
                nodeMgrFacade.delNode(parentNode);
                param = "<Register>" + "<Ip>" + IpAddress.getLocalIp() + "</Ip>" + "<Type>delete</Type>"
                        + "</Register>";
                String url = "https://" + parentNode.getIp() + "/resteasy/node/register";
                Map<String, String> cookies = new HashMap<String, String>();
                cookies.put("sessionid", RestUtil.getSessionId(registIp));
                String returnInfo = HttpUtil.doPostWithSSLByString(url, param, cookies, "UTF-8");
                if (StringUtils.isNotBlank(returnInfo)) {
                    log.info("?IP:" + parentNode.getIp());
                }
            } catch (ConnectException e) {
                log.warn("{}????", parentNode.getIp());
            }

            //?
            //            registNode(registIp, registName,KernelNode);
            param = "<Register>" + "<Ip>" + IpAddress.getLocalIp() + "</Ip>" + //?IP
                    "<Alias>" + registName + "</Alias>" + "<NodeId>" + KernelNode.getNodeId() + "</NodeId>"
                    + "<Type>register</Type>" + "</Register>";
        }
        String url = "https://" + registIp + "/resteasy/node/register";
        Map<String, String> cookies = new HashMap<String, String>();
        cookies.put("sessionid", RestUtil.getSessionId(registIp));
        String returnInfo = HttpUtil.doPostWithSSLByString(url, param, cookies, "UTF-8");
        if (StringUtils.isNotBlank(returnInfo)) {
            Document document = DocumentHelper.parseText(returnInfo);
            Element root = document.getRootElement();
            String successResponse = root.attribute("success").getValue();
            if ("false".equals(successResponse)) {
                Element elementMessage = root.element("Message");
                result.buildError(elementMessage.getText());
                return result;
            }
            if ("regist".equals(operator)) {
                //
                registNode(registIp, registName, KernelNode);
                log.info("?IP:" + registIp);
                result = new Result(true, "?");
                result.setResult(KernelNode.getResourceId());
            } else if ("update".equals(operator)) {
                registNode(registIp, registName, KernelNode);
                log.info("??IP:" + registIp);
                result = new Result(true, "??");
                result.setResult(KernelNode.getResourceId());
            } else {
                //
                nodeMgrFacade.delNode(parentNode);
                log.info("?IP:" + parentNode.getIp());
                result = new Result(true, "?");
            }
        } else {
            result.buildError("?");
        }
    } catch (Exception e) {
        e.printStackTrace();
        result.buildError("?");
    }
    return result;
}

From source file:com.topsec.tsm.sim.sysconfig.web.SystemConfigController.java

private static String nvlAttribute(Element element, String attributeName, int defaultValue) {
    if (element == null || element.attribute(attributeName) == null
            || "null".equals(element.attributeValue(attributeName))) {
        return String.valueOf(defaultValue);
    } else {/*  ww  w. java2s.  co m*/
        String result = element.attributeValue(attributeName);
        return result;
    }
}

From source file:com.ut.tekir.permission.PermissionRegistery.java

License:LGPL

/**
 * Verilen elementten ( permission ) actionlar toplar ve register eder.
 * @param e//from   ww  w .  ja v a 2s . com
 * @param gn
 */
private void registerPermission(Element e, String gn) {
    Attribute target = e.attribute("target");
    String t = target.getText();
    List<String> al = new ArrayList<String>();

    populateEntityActions(e, al);
    populateActions(e, al);
    populateExculedActions(e, al);

    //Tm data topland imdi map'e ekleniyor...
    PermissionGroup pg = permMap.get(gn);
    if (pg == null) {
        pg = new PermissionGroup();
        pg.setName(gn);
        permMap.put(gn, pg);
    }

    PermissionDefinition pd = new PermissionDefinition();
    pd.setTarget(t);
    pd.getActions().addAll(al);
    pg.getDefinitions().add(pd);

    log.info("Registered Permission = #0.#1#2", gn, t, al);
}