Example usage for org.w3c.dom Element getLocalName

List of usage examples for org.w3c.dom Element getLocalName

Introduction

In this page you can find the example usage for org.w3c.dom Element getLocalName.

Prototype

public String getLocalName();

Source Link

Document

Returns the local part of the qualified name of this node.

Usage

From source file:io.personium.core.model.impl.fs.DavCmpFsImpl.java

@Override
@SuppressWarnings("unchecked")
public Multistatus proppatch(final Propertyupdate propUpdate, final String url) {
    long now = new Date().getTime();
    String reqUri = url;/*  w  w  w .  j a va 2  s .  c o m*/
    Multistatus ms = this.of.createMultistatus();
    Response res = this.of.createResponse();
    res.getHref().add(reqUri);

    // Lock
    Lock lock = this.lock();
    // ?
    try {
        this.load(); // ??

        if (!this.exists()) {
            // ?(??)?????404??
            throw getNotFoundException().params(this.getUrl());
        }

        Map<String, Object> propsJson = (Map<String, Object>) this.metaFile.getProperties();
        List<Prop> propsToSet = propUpdate.getPropsToSet();

        for (Prop prop : propsToSet) {
            if (null == prop) {
                throw PersoniumCoreException.Dav.XML_CONTENT_ERROR;
            }
            List<Element> lpe = prop.getAny();
            for (Element elem : lpe) {
                res.setProperty(elem, HttpStatus.SC_OK);
                String key = elem.getLocalName() + "@" + elem.getNamespaceURI();
                String value = PersoniumCoreUtils.nodeToString(elem);
                log.debug("key: " + key);
                log.debug("val: " + value);
                propsJson.put(key, value);
            }
        }

        List<Prop> propsToRemove = propUpdate.getPropsToRemove();
        for (Prop prop : propsToRemove) {
            if (null == prop) {
                throw PersoniumCoreException.Dav.XML_CONTENT_ERROR;
            }
            List<Element> lpe = prop.getAny();
            for (Element elem : lpe) {

                String key = elem.getLocalName() + "@" + elem.getNamespaceURI();
                String v = (String) propsJson.get(key);
                log.debug("Removing key: " + key);
                if (v == null) {
                    res.setProperty(elem, HttpStatus.SC_NOT_FOUND);
                } else {
                    propsJson.remove(key);
                    res.setProperty(elem, HttpStatus.SC_OK);
                }
            }
        }
        // set the last updated date
        this.metaFile.setProperties((JSONObject) propsJson);
        this.metaFile.setUpdated(now);
        this.metaFile.save();
    } finally {
        lock.release();
    }
    ms.getResponse().add(res);
    return ms;
}

From source file:de.betterform.xml.xforms.model.submission.Submission.java

private void destroyembeddedModels(Element targetElem) throws XFormsException {
    NodeList childNodes = targetElem.getChildNodes();

    for (int index = 0; index < childNodes.getLength(); index++) {
        Node node = childNodes.item(index);

        if (node.getNodeType() == Node.ELEMENT_NODE) {
            Element elementImpl = (Element) node;

            String name = elementImpl.getLocalName();
            String uri = elementImpl.getNamespaceURI();

            if (NamespaceConstants.XFORMS_NS.equals(uri) && name.equals(XFormsConstants.MODEL)) {
                Model model = (Model) elementImpl.getUserData("");
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("dispatch 'model-destruct' event to embedded model: " + model.getId());
                }/*  w w  w.  j  ava2 s  .c om*/
                String modelId = model.getId();
                // do not dispatch model-destruct to avoid problems in lifecycle
                // TODO: review: this.container.dispatch(model.getTarget(), XFormsEventNames.MODEL_DESTRUCT, null);
                model.dispose();
                this.container.removeModel(model);
                model = null;
                if (Config.getInstance().getProperty("betterform.debug-allowed").equals("true")) {
                    Map contextInfo = new HashMap(1);
                    contextInfo.put("modelId", modelId);
                    this.container.dispatch(this.target, BetterFormEventNames.MODEL_REMOVED, contextInfo);
                }

            } else {
                destroyembeddedModels(elementImpl);
            }
        }
    }
}

From source file:net.sourceforge.dita4publishers.impl.ditabos.DitaBoundedObjectSetImpl.java

public XmlBosMember constructBosMember(BosMember parentMember, Document doc) throws Exception {
    XmlBosMember newMember = null;/*from  w w  w .  j a va 2 s  .  c  o m*/
    Element elem = doc.getDocumentElement();
    String key = doc.getDocumentURI();
    if (key == null || "".equals(key.trim())) {
        throw new BosException(
                "Document has null or empty documentURI property. The documentURI must be set to use as the BOS member key.");
    }
    if (this.getMember(key) != null) {
        BosMember cand = this.getMember(key);
        if (!(cand instanceof XmlBosMember)) {
            throw new BosException(
                    "A BOS member with key \"" + key + "\" already exists and is not an XmlBosMember instance");
        }
        return (XmlBosMember) cand;
    }

    // FIXME: Integrate some sort of XML BOS member factory here.
    if (DitaUtil.isInDitaDocument(elem)) {
        if (DitaUtil.isDitaMap(elem)) {
            newMember = new DitaMapBosMemberImpl(this, doc);
        } else if (DitaUtil.isDitaTopic(elem)) {
            newMember = new DitaTopicBosMemberImpl(this, doc);
        } else if (DitaUtil.isDitaBase(elem)) {
            newMember = new DitaTopicBosMemberImpl(this, doc);
        } else {
            log.warn("constructBosMember(): Element \"" + elem.getLocalName()
                    + "\" is in a DITA document but is neither a map nor a topic.");
            newMember = new DitaBosMemberImpl(this, doc);
        }
    } else {
        newMember = new XmlBosMemberImpl(this, doc);
    }
    return newMember;
}

From source file:it.cnr.icar.eric.server.profile.ws.wsdl.cataloger.WSDLCatalogerEngine.java

/**
 * Catalogs XMLSchema when submitted as an ExtrinsicObject - RepositoryItem pair.
 *
 *///  w  w w.  j a  v a2s  .  com
private void catalogXMLSchemaExtrinsicObject(RegistryObjectType ro, InputSource source)
        throws CatalogingException {
    try {
        registryObjects.add(ro);
        Document document = parseXML(source);
        Element schemaElement = document.getDocumentElement();
        String documentLocalName = schemaElement.getLocalName();
        String documentNamespaceURI = schemaElement.getNamespaceURI();
        if (documentLocalName.equalsIgnoreCase("schema") && documentNamespaceURI.endsWith("XMLSchema")) {
            Attr attribute = schemaElement.getAttributeNode("targetNamespace");
            String namespaceURI = attribute.getValue();
            // Set the id for the XMLSchema EO
            updateRegistryObjectId(namespaceURI, ro, false);
            // Check if this XSD file imports another file (usually XSD)
            NodeList nodeList = schemaElement.getChildNodes();
            int length = nodeList.getLength();
            for (int i = 0; i < length; i++) {
                Node node = nodeList.item(i);
                String localName = node.getLocalName();
                if (localName != null && localName.equalsIgnoreCase("import")) {
                    // This XSD imports another file
                    NamedNodeMap importNamedNodeMap = node.getAttributes();
                    Node namespaceNode = importNamedNodeMap.getNamedItem("namespace");
                    String importNamespace = null;
                    if (namespaceNode != null) {
                        importNamespace = namespaceNode.getNodeValue();
                    }
                    String schemaLocation = null;
                    Node schemaLocationNode = importNamedNodeMap.getNamedItem("schemaLocation");
                    if (schemaLocationNode != null) {
                        schemaLocation = schemaLocationNode.getNodeValue();
                    }
                    RegistryObjectType importedObject = catalogImportStatement(ro, importNamespace,
                            schemaLocation);
                    createImportsAssociation(ro, importedObject);
                }
            }
        }
    } catch (CatalogingException e) {
        throw e;
    } catch (Exception e) {
        log.error(e, e);
        CatalogingException ce = new CatalogingException(e);
        throw ce;
    }
}

From source file:com.evolveum.midpoint.testing.model.client.sample.AbstractTestForExchangeConnector.java

protected Map<String, Object> getAttributesAsMap(ShadowType shadowType) {
    Map<String, Object> rv = new HashMap<>();

    ShadowAttributesType attributes = shadowType.getAttributes();
    for (Object item : attributes.getAny()) {
        if (item instanceof Element) {
            Element e = (Element) item;
            put(rv, e.getLocalName(), e.getTextContent());
        } else if (item instanceof JAXBElement) {
            JAXBElement je = (JAXBElement) item;
            put(rv, je.getName().getLocalPart(), je.getValue());
        } else {/*from ww w.j  a  v a 2  s  . c  o  m*/
            // nothing to do here
        }
    }
    return rv;
}

From source file:com.evolveum.midpoint.testing.model.client.sample.AbstractTestForExchangeConnector.java

protected void dumpAttributes(ShadowType shadowType) {
    ShadowAttributesType attributes = shadowType.getAttributes();
    System.out.println("Attributes for " + shadowType.getObjectClass().getLocalPart() + " "
            + getOrig(shadowType.getName()) + " {" + attributes.getAny().size() + " entries):");
    for (Object item : attributes.getAny()) {
        if (item instanceof Element) {
            Element e = (Element) item;
            System.out.println(" - " + e.getLocalName() + ": " + e.getTextContent());
        } else if (item instanceof JAXBElement) {
            JAXBElement je = (JAXBElement) item;
            String typeInfo = je.getValue() instanceof String ? ""
                    : (" (" + je.getValue().getClass().getSimpleName() + ")");
            System.out.println(" - " + je.getName().getLocalPart() + ": " + je.getValue() + typeInfo);
        } else {/*from w  ww.j a v  a  2s.  c o  m*/
            System.out.println(" - " + item);
        }
    }
}

From source file:iristk.flow.FlowCompiler.java

private String stateClass(Element elem) {
    return elem.getNamespaceURI() + "." + elem.getLocalName();
}

From source file:org.apache.cxf.cwiki.SiteExporter.java

private void checkVersion() throws ParserConfigurationException, IOException {
    Document doc = DOMUtils.createDocument();
    Element el = doc.createElementNS(SOAPNS, "ns1:getServerInfo");
    Element el2 = doc.createElement("in0");
    el.appendChild(el2);//  w w w .j  a  va 2  s . com
    el2.setTextContent(loginToken);
    doc.appendChild(el);

    doc = getDispatch().invoke(doc);
    el = DOMUtils.getFirstElement(DOMUtils.getFirstElement(doc.getDocumentElement()));
    while (el != null) {
        if ("majorVersion".equals(el.getLocalName())) {
            String major = DOMUtils.getContent(el);
            if (Integer.parseInt(major) >= 5) {
                apiVersion = 2;
                ((java.io.Closeable) dispatch).close();
                dispatch = null;
            }
        }

        el = DOMUtils.getNextElement(el);
    }
}

From source file:iristk.flow.FlowCompiler.java

private String newState(Element elem) {
    if (elem.getPrefix().equals("this")) {
        return "new " + elem.getLocalName() + "()";
    }//  w  w  w .  jav  a  2  s  . c  om
    for (Var var : flowXml.getVariables()) {
        if (var.getName().equals(elem.getPrefix()))
            return elem.getPrefix() + ".new " + elem.getLocalName() + "()";
    }
    for (Param param : flowXml.getParameters()) {
        if (param.getName().equals(elem.getPrefix()))
            return elem.getPrefix() + ".new " + elem.getLocalName() + "()";
    }
    return "new " + elem.getNamespaceURI() + "." + elem.getLocalName() + "()";
}

From source file:iristk.flow.FlowCompiler.java

private String createExpression(Element en) throws FlowCompilerException {
    String estring = "";
    estring += "<" + en.getLocalName();
    for (int j = 0; j < en.getAttributes().getLength(); j++) {
        Attr attr = (Attr) en.getAttributes().item(j);
        if (!(attr.getNamespaceURI() != null && attr.getNamespaceURI().equals("http://www.w3.org/2000/xmlns/"))
                && !attr.getLocalName().equals("xmlns") && !attr.getLocalName().equals("xsi")) {
            estring += " " + attr.getLocalName() + "=\\\"" + attr.getValue() + "\\\"";
        }//  w w w. ja v a  2 s .c  om
    }
    if (en.getChildNodes().getLength() == 0) {
        estring += "/>";
        return "\"" + estring + "\"";
    } else {
        String varName = varname("string");
        code.println("StringCreator " + varName + " = new StringCreator();");
        List<Object> children = new ArrayList<>();
        estring += ">";
        children.add(estring);
        for (int i = 0; i < en.getChildNodes().getLength(); i++) {
            children.add(en.getChildNodes().item(i));
        }
        children.add("</" + en.getLocalName() + ">");
        printActions(children, en, varName);
        return varName + ".toString()";
    }
}