Example usage for javax.xml.stream XMLStreamWriter writeAttribute

List of usage examples for javax.xml.stream XMLStreamWriter writeAttribute

Introduction

In this page you can find the example usage for javax.xml.stream XMLStreamWriter writeAttribute.

Prototype

public void writeAttribute(String localName, String value) throws XMLStreamException;

Source Link

Document

Writes an attribute to the output stream without a prefix.

Usage

From source file:org.gaul.s3proxy.S3ProxyHandler.java

private void handleGetBlobAcl(HttpServletResponse response, BlobStore blobStore, String containerName,
        String blobName) throws IOException {
    BlobAccess access = blobStore.getBlobAccess(containerName, blobName);

    try (Writer writer = response.getWriter()) {
        XMLStreamWriter xml = xmlOutputFactory.createXMLStreamWriter(writer);
        xml.writeStartDocument();//from w  w  w .j  a  v  a 2s . c om
        xml.writeStartElement("AccessControlPolicy");
        xml.writeDefaultNamespace(AWS_XMLNS);

        writeOwnerStanza(xml);

        xml.writeStartElement("AccessControlList");

        xml.writeStartElement("Grant");

        xml.writeStartElement("Grantee");
        xml.writeNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
        xml.writeAttribute("xsi:type", "CanonicalUser");

        writeSimpleElement(xml, "ID", FAKE_OWNER_ID);
        writeSimpleElement(xml, "DisplayName", FAKE_OWNER_DISPLAY_NAME);

        xml.writeEndElement();

        writeSimpleElement(xml, "Permission", "FULL_CONTROL");

        xml.writeEndElement();

        if (access == BlobAccess.PUBLIC_READ) {
            xml.writeStartElement("Grant");

            xml.writeStartElement("Grantee");
            xml.writeNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
            xml.writeAttribute("xsi:type", "Group");

            writeSimpleElement(xml, "URI", "http://acs.amazonaws.com/groups/global/AllUsers");

            xml.writeEndElement();

            writeSimpleElement(xml, "Permission", "READ");

            xml.writeEndElement();
        }

        xml.writeEndElement();

        xml.writeEndElement();
        xml.flush();
    } catch (XMLStreamException xse) {
        throw new IOException(xse);
    }
}

From source file:com.smartbear.jenkins.plugins.testcomplete.TcLogParser.java

private void convertToXML(ZipFile logArchive, TcLogInfo logInfo, XMLStreamWriter writer)
        throws ParsingException, XMLStreamException {
    writer.writeStartDocument("utf-8", "1.0");

    Node descriptionTopLevelNode = NodeUtils.getRootDocumentNodeFromArchive(logArchive, DESCRIPTION_ENTRY_NAME);
    if (descriptionTopLevelNode == null) {
        throw new ParsingException("Unable to obtain description top-level node.");
    }//from ww w  .  jav a  2s . co  m

    Node topLevelNode = NodeUtils.getRootDocumentNodeFromArchive(logArchive,
            NodeUtils.getTextProperty(descriptionTopLevelNode, "root file name"));

    if (topLevelNode == null) {
        throw new ParsingException("Unable to obtain root top-level node.");
    }

    NodeList rootNodes = topLevelNode.getChildNodes();
    Node rootOwnerNode = NodeUtils.findRootOwnerNode(rootNodes);

    if (rootOwnerNode == null) {
        throw new ParsingException("Unable to obtain root owner node.");
    }

    boolean isSuite = "{00000000-0000-0000-0000-000000000000}"
            .equals(NodeUtils.getTextProperty(rootOwnerNode, "projectkey"));

    Node rootOwnerNodeInfo = NodeUtils.getRootDocumentNodeFromArchive(logArchive,
            NodeUtils.getTextProperty(rootOwnerNode, "filename"));

    if (rootOwnerNodeInfo == null) {
        throw new ParsingException("Unable to obtain root owner node info.");
    }

    Node rootOwnerNodeInfoSummary = NodeUtils.findNamedNode(rootOwnerNodeInfo.getChildNodes(), "summary");
    boolean isSuiteOrProject = rootOwnerNodeInfoSummary != null;

    writer.writeStartElement("testsuites");

    if (isSuite) {
        List<Node> projects = NodeUtils.findChildNodes(rootOwnerNode,
                rootOwnerNode.getParentNode().getChildNodes());
        for (Node projectNode : projects) {
            Node projectNodeInfo = NodeUtils.getRootDocumentNodeFromArchive(logArchive,
                    NodeUtils.getTextProperty(projectNode, "filename"));
            Node projectNodeInfoSummary = NodeUtils.findNamedNode(projectNodeInfo, "summary");
            processProject(logArchive, projectNode, projectNodeInfoSummary, writer);
        }
    } else if (isSuiteOrProject) {
        processProject(logArchive, rootOwnerNode, rootOwnerNodeInfoSummary, writer);
    } else {
        String testCaseName = NodeUtils.getTextProperty(rootOwnerNode, "name");
        String testCaseDuration = Double.toString(logInfo.getTestDuration() / 1000f);

        writer.writeStartElement("testsuite");
        writer.writeAttribute("name", project);
        writer.writeAttribute("time", testCaseDuration);

        writer.writeStartElement("testcase");
        writer.writeAttribute("name", fixTestCaseName(testCaseName));
        writer.writeAttribute("classname", suite + "." + project);
        writer.writeAttribute("time", testCaseDuration);
        if (checkFail(NodeUtils.getTextProperty(rootOwnerNode, "status"))) {
            writer.writeStartElement("failure");

            List<String> messages = NodeUtils.getErrorMessages(rootOwnerNodeInfo);
            if (errorOnWarnings) {
                messages.addAll(NodeUtils.getWarningMessages(rootOwnerNodeInfo));
            }

            writer.writeAttribute("message", StringUtils.join(messages, "\n\n"));
            writer.writeEndElement(); //failure
        }
        writer.writeEndElement(); //testcase

        writer.writeEndElement(); //testsuite
    }

    writer.writeEndElement(); //testsuites
    writer.writeEndDocument();
}

From source file:com.amalto.core.load.io.XMLStreamUnwrapper.java

/**
 * Moves to next record in stream and stores it in {@link #stringWriter}.
 *//*from  w w  w  .  ja v  a 2  s .co m*/
private void moveToNext() {
    try {
        XMLStreamWriter writer = xmlOutputFactory.createXMLStreamWriter(stringWriter);
        boolean hasMadeChanges;
        do {
            if (!reader.hasNext()) {
                break;
            }
            hasMadeChanges = false; // Keep a state to skip line feeds
            final XMLEvent event = reader.nextEvent();
            if (event.isEndElement()) {
                level--;
            } else if (event.isStartElement()) {
                level++;
            } else if (event.isEndDocument()) {
                level--;
            }
            if (level >= RECORD_LEVEL) {
                if (event.isEndElement()) {
                    writer.writeEndElement();
                    hasMadeChanges = true;
                } else if (event.isStartElement()) {
                    final StartElement startElement = event.asStartElement();
                    final QName name = startElement.getName();
                    writer.writeStartElement(name.getNamespaceURI(), name.getLocalPart());
                    boolean isRecordRootElement = (RECORD_LEVEL == level - 1);
                    if (isRecordRootElement) {
                        for (int i = 0; i < rootNamespaceList.size(); i++) {
                            Namespace namespace = rootNamespaceList.get(i);
                            writer.writeNamespace(namespace.getPrefix(), namespace.getNamespaceURI());
                        }
                    }
                    // Declare namespaces (if any)
                    final Iterator elementNamespaces = startElement.getNamespaces();
                    while (elementNamespaces.hasNext()) {
                        Namespace elementNamespace = (Namespace) elementNamespaces.next();
                        if (isRecordRootElement) {
                            if (rootNamespaceList.size() > 0) {
                                for (int i = 0; i < rootNamespaceList.size(); i++) {
                                    Namespace namespace = rootNamespaceList.get(i);
                                    if (!namespace.getPrefix().equals(elementNamespace.getPrefix())
                                            || !namespace.getNamespaceURI()
                                                    .equals(elementNamespace.getNamespaceURI())) {
                                        writer.writeNamespace(elementNamespace.getPrefix(),
                                                elementNamespace.getNamespaceURI());
                                    }
                                }
                            } else {
                                writer.writeNamespace(elementNamespace.getPrefix(),
                                        elementNamespace.getNamespaceURI());
                            }
                        } else {
                            writer.writeNamespace(elementNamespace.getPrefix(),
                                    elementNamespace.getNamespaceURI());
                        }
                    }
                    // Write attributes
                    final Iterator attributes = startElement.getAttributes();
                    while (attributes.hasNext()) {
                        Attribute attribute = (Attribute) attributes.next();
                        QName attributeName = attribute.getName();
                        String value = attribute.getValue();
                        if (StringUtils.isEmpty(attributeName.getNamespaceURI())) {
                            writer.writeAttribute(attributeName.getLocalPart(), value);
                        } else {
                            writer.writeAttribute(attributeName.getNamespaceURI(), attributeName.getLocalPart(),
                                    value);
                        }
                    }
                    hasMadeChanges = true;
                } else if (event.isCharacters()) {
                    final String text = event.asCharacters().getData().trim();
                    if (!text.isEmpty()) {
                        writer.writeCharacters(text);
                        hasMadeChanges = true;
                    }
                }
            }
        } while (level > RECORD_LEVEL || !hasMadeChanges);
        writer.flush();
    } catch (XMLStreamException e) {
        throw new RuntimeException("Unexpected parsing exception.", e);
    }
}

From source file:ca.uhn.fhir.parser.XmlParser.java

private void encodeResourceToXmlStreamWriter(IBaseResource theResource, XMLStreamWriter theEventWriter,
        boolean theContainedResource, IIdType theResourceId) throws XMLStreamException {
    if (!theContainedResource) {
        super.containResourcesForEncoding(theResource);
    }//from   w  ww  .  j av  a  2  s . c om

    RuntimeResourceDefinition resDef = myContext.getResourceDefinition(theResource);
    if (resDef == null) {
        throw new ConfigurationException("Unknown resource type: " + theResource.getClass());
    }

    theEventWriter.writeStartElement(resDef.getName());
    theEventWriter.writeDefaultNamespace(FHIR_NS);

    if (theResource instanceof IAnyResource) {

        // HL7.org Structures
        if (theResourceId != null) {
            writeCommentsPre(theEventWriter, theResourceId);
            writeOptionalTagWithValue(theEventWriter, "id", theResourceId.getIdPart());
            writeCommentsPost(theEventWriter, theResourceId);
        }

        encodeCompositeElementToStreamWriter(theResource, theResource, theEventWriter, theContainedResource,
                new CompositeChildElement(resDef));

    } else {

        if (myContext.getVersion().getVersion().isNewerThan(FhirVersionEnum.DSTU1)) {

            // DSTU2+

            IResource resource = (IResource) theResource;
            if (theResourceId != null) {
                writeCommentsPre(theEventWriter, theResourceId);
                writeOptionalTagWithValue(theEventWriter, "id", theResourceId.getIdPart());
                writeCommentsPost(theEventWriter, theResourceId);
            }

            InstantDt updated = (InstantDt) resource.getResourceMetadata().get(ResourceMetadataKeyEnum.UPDATED);
            IdDt resourceId = resource.getId();
            String versionIdPart = resourceId.getVersionIdPart();
            if (isBlank(versionIdPart)) {
                versionIdPart = ResourceMetadataKeyEnum.VERSION.get(resource);
            }
            List<BaseCodingDt> securityLabels = extractMetadataListNotNull(resource,
                    ResourceMetadataKeyEnum.SECURITY_LABELS);
            List<? extends IIdType> profiles = extractMetadataListNotNull(resource,
                    ResourceMetadataKeyEnum.PROFILES);
            profiles = super.getProfileTagsForEncoding(resource, profiles);

            TagList tags = getMetaTagsForEncoding((resource));

            if (super.shouldEncodeResourceMeta(resource)
                    && ElementUtil.isEmpty(versionIdPart, updated, securityLabels, tags, profiles) == false) {
                theEventWriter.writeStartElement("meta");
                writeOptionalTagWithValue(theEventWriter, "versionId", versionIdPart);
                if (updated != null) {
                    writeOptionalTagWithValue(theEventWriter, "lastUpdated", updated.getValueAsString());
                }

                for (IIdType profile : profiles) {
                    theEventWriter.writeStartElement("profile");
                    theEventWriter.writeAttribute("value", profile.getValue());
                    theEventWriter.writeEndElement();
                }
                for (BaseCodingDt securityLabel : securityLabels) {
                    theEventWriter.writeStartElement("security");
                    encodeCompositeElementToStreamWriter(resource, securityLabel, theEventWriter,
                            theContainedResource, null);
                    theEventWriter.writeEndElement();
                }
                if (tags != null) {
                    for (Tag tag : tags) {
                        if (tag.isEmpty()) {
                            continue;
                        }
                        theEventWriter.writeStartElement("tag");
                        writeOptionalTagWithValue(theEventWriter, "system", tag.getScheme());
                        writeOptionalTagWithValue(theEventWriter, "code", tag.getTerm());
                        writeOptionalTagWithValue(theEventWriter, "display", tag.getLabel());
                        theEventWriter.writeEndElement();
                    }
                }
                theEventWriter.writeEndElement();
            }

            if (theResource instanceof IBaseBinary) {
                IBaseBinary bin = (IBaseBinary) theResource;
                writeOptionalTagWithValue(theEventWriter, "contentType", bin.getContentType());
                writeOptionalTagWithValue(theEventWriter, "content", bin.getContentAsBase64());
            } else {
                encodeCompositeElementToStreamWriter(theResource, theResource, theEventWriter,
                        theContainedResource, new CompositeChildElement(resDef));
            }

        } else {

            // DSTU1
            if (theResourceId != null && theContainedResource && theResourceId.hasIdPart()) {
                theEventWriter.writeAttribute("id", theResourceId.getIdPart());
            }

            if (theResource instanceof IBaseBinary) {
                IBaseBinary bin = (IBaseBinary) theResource;
                if (bin.getContentType() != null) {
                    theEventWriter.writeAttribute("contentType", bin.getContentType());
                }
                theEventWriter.writeCharacters(bin.getContentAsBase64());
            } else {
                encodeCompositeElementToStreamWriter(theResource, theResource, theEventWriter,
                        theContainedResource, new CompositeChildElement(resDef));
            }

        }

    }

    theEventWriter.writeEndElement();
}

From source file:edu.ucsd.library.dams.api.DAMSAPIServlet.java

private void sparqlQuery(String sparql, TripleStore ts, Map<String, String[]> params, String pathInfo,
        HttpServletResponse res) throws Exception {
    if (sparql == null) {
        Map err = error(SC_BAD_REQUEST, "No query specified.", null);
        output(err, params, pathInfo, res);
        return;//from w  w  w.j  a v  a2s.  c  o  m
    } else {
        log.info("sparql: " + sparql);
    }

    // sparql query
    BindingIterator objs = ts.sparqlSelect(sparql);

    // start output
    String sparqlNS = "http://www.w3.org/2005/sparql-results#";
    res.setContentType("application/sparql-results+xml");
    OutputStream out = res.getOutputStream();
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    XMLStreamWriter stream = factory.createXMLStreamWriter(out);
    stream.setDefaultNamespace(sparqlNS);
    stream.writeStartDocument();
    stream.writeStartElement("sparql");

    // output bindings
    boolean headerWritten = false;
    while (objs.hasNext()) {
        Map<String, String> binding = objs.nextBinding();

        // write header on first binding
        if (!headerWritten) {
            Iterator<String> it = binding.keySet().iterator();
            stream.writeStartElement("head");
            while (it.hasNext()) {
                String k = it.next();
                stream.writeStartElement("variable");
                stream.writeAttribute("name", k);
                stream.writeEndElement();
            }
            stream.writeEndElement();
            stream.writeStartElement("results"); // ordered='false' distinct='false'
            headerWritten = true;
        }

        stream.writeStartElement("result");
        Iterator<String> it = binding.keySet().iterator();
        while (it.hasNext()) {
            String k = it.next();
            String v = binding.get(k);
            stream.writeStartElement("binding");
            stream.writeAttribute("name", k);
            String type = null;
            if (v.startsWith("\"") && v.endsWith("\"")) {
                type = "literal";
                v = v.substring(1, v.length() - 1);
            } else if (v.startsWith("_:")) {
                type = "bnode";
                v = v.substring(2);
            } else {
                type = "uri";
            }
            stream.writeStartElement(type);
            stream.writeCharacters(v);
            stream.writeEndElement();
            stream.writeEndElement();
        }
        stream.writeEndElement();
    }

    // finish output
    stream.writeEndElement();
    stream.writeEndDocument();
    stream.flush();
    stream.close();
}

From source file:ca.uhn.fhir.parser.XmlParser.java

private void encodeBundleToWriterDstu1(Bundle theBundle, XMLStreamWriter eventWriter)
        throws XMLStreamException {
    eventWriter.writeStartElement("feed");
    eventWriter.writeDefaultNamespace(ATOM_NS);

    writeTagWithTextNode(eventWriter, "title", theBundle.getTitle());
    writeTagWithTextNode(eventWriter, "id", theBundle.getBundleId());

    writeAtomLink(eventWriter, Constants.LINK_SELF, theBundle.getLinkSelf());
    writeAtomLink(eventWriter, Constants.LINK_FIRST, theBundle.getLinkFirst());
    writeAtomLink(eventWriter, Constants.LINK_PREVIOUS, theBundle.getLinkPrevious());
    writeAtomLink(eventWriter, Constants.LINK_NEXT, theBundle.getLinkNext());
    writeAtomLink(eventWriter, Constants.LINK_LAST, theBundle.getLinkLast());
    writeAtomLink(eventWriter, Constants.LINK_FHIR_BASE, theBundle.getLinkBase());

    if (theBundle.getTotalResults().getValue() != null) {
        eventWriter.writeStartElement("os", "totalResults", OPENSEARCH_NS);
        eventWriter.writeNamespace("os", OPENSEARCH_NS);
        eventWriter.writeCharacters(theBundle.getTotalResults().getValue().toString());
        eventWriter.writeEndElement();/*w  ww . j  a v a2 s  .  c o  m*/
    }

    writeOptionalTagWithTextNode(eventWriter, "updated", theBundle.getUpdated());

    writeAuthor(eventWriter, theBundle);

    writeCategories(eventWriter, theBundle.getCategories());

    for (BundleEntry nextEntry : theBundle.getEntries()) {
        boolean deleted = false;
        if (nextEntry.getDeletedAt() != null && nextEntry.getDeletedAt().isEmpty() == false) {
            deleted = true;
            eventWriter.writeStartElement("at", "deleted-entry", TOMBSTONES_NS);
            eventWriter.writeNamespace("at", TOMBSTONES_NS);

            if (nextEntry.getDeletedResourceId().isEmpty()) {
                writeOptionalAttribute(eventWriter, "ref", nextEntry.getId().getValueAsString());
            } else {
                writeOptionalAttribute(eventWriter, "ref", nextEntry.getDeletedResourceId().getValueAsString());
            }

            writeOptionalAttribute(eventWriter, "when", nextEntry.getDeletedAt().getValueAsString());
            if (nextEntry.getDeletedByEmail().isEmpty() == false
                    || nextEntry.getDeletedByName().isEmpty() == false) {
                eventWriter.writeStartElement(TOMBSTONES_NS, "by");
                if (nextEntry.getDeletedByName().isEmpty() == false) {
                    eventWriter.writeStartElement(TOMBSTONES_NS, "name");
                    eventWriter.writeCharacters(nextEntry.getDeletedByName().getValue());
                    eventWriter.writeEndElement();
                }
                if (nextEntry.getDeletedByEmail().isEmpty() == false) {
                    eventWriter.writeStartElement(TOMBSTONES_NS, "email");
                    eventWriter.writeCharacters(nextEntry.getDeletedByEmail().getValue());
                    eventWriter.writeEndElement();
                }
                eventWriter.writeEndElement();
            }
            if (nextEntry.getDeletedComment().isEmpty() == false) {
                eventWriter.writeStartElement(TOMBSTONES_NS, "comment");
                eventWriter.writeCharacters(nextEntry.getDeletedComment().getValue());
                eventWriter.writeEndElement();
            }
        } else {
            eventWriter.writeStartElement("entry");
        }

        writeOptionalTagWithTextNode(eventWriter, "title", nextEntry.getTitle());
        if (!deleted) {
            if (nextEntry.getId().isEmpty() == false) {
                writeTagWithTextNode(eventWriter, "id", nextEntry.getId());
            } else {
                writeTagWithTextNode(eventWriter, "id", nextEntry.getResource().getId());
            }
        }
        writeOptionalTagWithTextNode(eventWriter, "updated", nextEntry.getUpdated());
        writeOptionalTagWithTextNode(eventWriter, "published", nextEntry.getPublished());

        writeAuthor(eventWriter, nextEntry);

        writeCategories(eventWriter, nextEntry.getCategories());

        if (!nextEntry.getLinkSelf().isEmpty()) {
            writeAtomLink(eventWriter, "self", nextEntry.getLinkSelf());
        }

        if (!nextEntry.getLinkAlternate().isEmpty()) {
            writeAtomLink(eventWriter, "alternate", nextEntry.getLinkAlternate());
        }

        if (!nextEntry.getLinkSearch().isEmpty()) {
            writeAtomLink(eventWriter, "search", nextEntry.getLinkSearch());
        }

        IResource resource = nextEntry.getResource();
        if (resource != null && !resource.isEmpty() && !deleted) {
            eventWriter.writeStartElement("content");
            eventWriter.writeAttribute("type", "text/xml");
            encodeResourceToXmlStreamWriter(resource, eventWriter, false, true);
            eventWriter.writeEndElement(); // content
        } else {
            ourLog.debug("Bundle entry contains null resource");
        }

        if (!nextEntry.getSummary().isEmpty()) {
            eventWriter.writeStartElement("summary");
            eventWriter.writeAttribute("type", "xhtml");
            encodeXhtml(nextEntry.getSummary(), eventWriter);
            eventWriter.writeEndElement();
        }

        eventWriter.writeEndElement(); // entry
    }

    eventWriter.writeEndElement();
    eventWriter.close();
}

From source file:nl.nn.adapterframework.extensions.svn.ScanTibcoSolutionPipe.java

public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
    StringWriter stringWriter = new StringWriter();
    XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance();
    XMLStreamWriter xmlStreamWriter;
    try {//from  www . ja  v a  2 s.  c  o m
        xmlStreamWriter = xmlOutputFactory.createXMLStreamWriter(stringWriter);
        xmlStreamWriter.writeStartDocument();
        xmlStreamWriter.writeStartElement("root");
        xmlStreamWriter.writeAttribute("url", getUrl());
        // xmlStreamWriter.writeAttribute("level",
        // String.valueOf(getLevel()));
        process(xmlStreamWriter, getUrl(), getLevel());
        xmlStreamWriter.writeEndDocument();
        xmlStreamWriter.flush();
        xmlStreamWriter.close();
    } catch (XMLStreamException e) {
        throw new PipeRunException(this, "XMLStreamException", e);
    } catch (DomBuilderException e) {
        throw new PipeRunException(this, "DomBuilderException", e);
    } catch (XPathExpressionException e) {
        throw new PipeRunException(this, "XPathExpressionException", e);
    }

    return new PipeRunResult(getForward(), stringWriter.getBuffer().toString());
}

From source file:nl.nn.adapterframework.extensions.svn.ScanTibcoSolutionPipe.java

public void process(XMLStreamWriter xmlStreamWriter, String cUrl, int cLevel)
        throws XMLStreamException, DomBuilderException, XPathExpressionException {
    String html;/*from  w  ww .ja  v a 2 s .  c  o m*/
    try {
        html = getHtml(cUrl);
    } catch (Exception e) {
        error(xmlStreamWriter, "error occured during getting html", e, true);
        html = null;
    }
    if (html != null) {
        Collection<String> c = XmlUtils.evaluateXPathNodeSet(html, "html/body/ul/li/a/@href");
        if (c != null) {
            for (Iterator<String> it = c.iterator(); it.hasNext();) {
                String token = it.next();
                if (token.equals("../")) {
                    // skip reference to parent directory
                } else if (cLevel == 0 && !token.equals("BW/") && !token.equals("SOA/")) {
                    skipDir(xmlStreamWriter, token);
                    // } else if (cLevel == 1 &&
                    // !token.startsWith("Customer")) {
                    // skipDir(xmlStreamWriter, token);
                } else if (cLevel == 2 && (token.equals("branches/") || token.equals("tags/"))
                        && c.contains("trunk/")) {
                    skipDir(xmlStreamWriter, token);
                } else if (cLevel == 3 && !token.equals("src/") && c.contains("src/")
                        && !token.equals("release/")) {
                    skipDir(xmlStreamWriter, token);
                    // } else if (cLevel == 5 && token.endsWith("/")) {
                    // skipDir(xmlStreamWriter, token);
                } else {
                    String newUrl = cUrl + token;
                    boolean dir = false;
                    if (token.endsWith("/")) {
                        dir = true;
                    }
                    if (dir) {
                        xmlStreamWriter.writeStartElement("dir");
                        xmlStreamWriter.writeAttribute("name", skipLastCharacter(token));
                        // xmlStreamWriter.writeAttribute("level",
                        // String.valueOf(cLevel + 1));
                        if (cLevel == 1 || cLevel == 4) {
                            addCommit(xmlStreamWriter, newUrl);
                        }
                        process(xmlStreamWriter, newUrl, cLevel + 1);
                    } else {
                        xmlStreamWriter.writeStartElement("file");
                        xmlStreamWriter.writeAttribute("name", token);
                        if (cLevel > 5) {
                            if (token.endsWith(".jmsDest")) {
                                addFileContent(xmlStreamWriter, newUrl, "jmsDest");
                            }
                            if (token.endsWith(".jmsDestConf")) {
                                addFileContent(xmlStreamWriter, newUrl, "jmsDestConf");
                            }
                            if (token.endsWith(".composite")) {
                                addFileContent(xmlStreamWriter, newUrl, "composite");
                            }
                            if (token.endsWith(".process")) {
                                addFileContent(xmlStreamWriter, newUrl, "process");
                            }
                            if (token.equals("defaultVars.substvar")) {
                                addFileContent(xmlStreamWriter, newUrl, "substVar");
                            }
                        }
                    }
                    xmlStreamWriter.writeEndElement();
                }
            }
        }
    }
}

From source file:nl.nn.adapterframework.extensions.svn.ScanTibcoSolutionPipe.java

private void skipDir(XMLStreamWriter xmlStreamWriter, String token) throws XMLStreamException {
    xmlStreamWriter.writeStartElement("dir");
    xmlStreamWriter.writeAttribute("name", skipLastCharacter(token));
    xmlStreamWriter.writeAttribute("skip", "true");
    xmlStreamWriter.writeEndElement();/*  w w  w  .  j a  va 2  s.c  om*/
}

From source file:nl.nn.adapterframework.extensions.svn.ScanTibcoSolutionPipe.java

private void addCommit(XMLStreamWriter xmlStreamWriter, String urlString) throws XMLStreamException {
    xmlStreamWriter.writeStartElement("commit");
    try {/*w  ww  .  jav  a2 s . c  o  m*/
        String logReport = SvnUtils.getLogReport(urlString);
        String creator = XmlUtils.evaluateXPathNodeSetFirstElement(logReport,
                "log-report/log-item/creator-displayname");
        xmlStreamWriter.writeAttribute("creator", creator);
        String date = XmlUtils.evaluateXPathNodeSetFirstElement(logReport, "log-report/log-item/date");
        xmlStreamWriter.writeAttribute("date", date);
    } catch (Exception e) {
        error(xmlStreamWriter, "error occured during adding commit info", e, false);
    }
    xmlStreamWriter.writeEndElement();
}