List of usage examples for javax.xml.stream XMLStreamWriter writeAttribute
public void writeAttribute(String localName, String value) throws XMLStreamException;
From source file:org.asimba.wa.integrationtest.saml2.model.Assertion.java
public void writeAttribute(XMLStreamWriter writer, String key, String value) throws XMLStreamException { writer.writeStartElement("saml2", "Attribute", "urn:oasis:names:tc:SAML:2.0:assertion"); writer.writeAttribute("Name", key); writer.writeAttribute("NameFormat", "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"); writer.writeStartElement("saml2", "AttributeValue", "urn:oasis:names:tc:SAML:2.0:assertion"); writer.writeNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); writer.writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "xs:string"); writer.writeCharacters(value);/*from w ww . j a va2 s . c om*/ writer.writeEndElement(); // </AttributeValue> writer.writeEndElement(); // </Attribute> }
From source file:org.asimba.wa.integrationtest.saml2.model.Assertion.java
public void writeAssertion(XMLStreamWriter writer) throws XMLStreamException { writer.writeStartElement("saml2", "Assertion", "urn:oasis:names:tc:SAML:2.0:assertion"); writer.writeNamespace("saml2", "urn:oasis:names:tc:SAML:2.0:assertion"); writer.writeAttribute("ID", getId()); writer.writeAttribute("IssueInstant", getIssueInstant()); writer.writeAttribute("Version", "2.0"); writeIssuer(writer);/*from www . j a v a 2s . c o m*/ writeSubject(writer); writeConditions(writer); writeAuthnStatement(writer); writeAttributeStatement(writer); writer.writeEndElement(); // </Assertion> }
From source file:org.asimba.wa.integrationtest.saml2.model.AuthnRequest.java
/** * Get String with the SAML2 AuthnRequest message * @param format -1=plain, 1=base64//from w w w. j a v a 2 s. c o m * @return * @throws XMLStreamException * @throws IOException */ public String getRequest(int format) throws XMLStreamException, IOException { _logger.info("For ID: " + this._id); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Deflater compresser = new Deflater(Deflater.BEST_COMPRESSION, true); DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(baos, compresser); StringWriter sw = new StringWriter(); XMLOutputFactory factory = XMLOutputFactory.newInstance(); XMLStreamWriter writer = null; // ugly but effective: if (format == base64) { writer = factory.createXMLStreamWriter(deflaterOutputStream); } else { writer = factory.createXMLStreamWriter(sw); } writer.writeStartElement("samlp", "AuthnRequest", "urn:oasis:names:tc:SAML:2.0:protocol"); writer.writeNamespace("samlp", "urn:oasis:names:tc:SAML:2.0:protocol"); writer.writeAttribute("ID", _id); writer.writeAttribute("Version", "2.0"); writer.writeAttribute("IssueInstant", this._issueInstant); writer.writeAttribute("ProtocolBinding", "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); writer.writeAttribute("AssertionConsumerServiceURL", _acsUrl); writeIssuer(writer); writeNameIDPolicy(writer); writeRequestedAuthnContext(writer); writer.writeEndElement(); writer.flush(); if (format == base64) { deflaterOutputStream.close(); byte[] bain = baos.toByteArray(); byte[] encoded = Base64.encodeBase64(bain, false); String result = new String(encoded, Charset.forName("UTF-8")); return result; } else { return sw.toString(); } }
From source file:org.asimba.wa.integrationtest.saml2.model.AuthnRequest.java
protected void writeNameIDPolicy(XMLStreamWriter writer) throws XMLStreamException { if (_requestedNameIdFormat == null) { _logger.info("Skipping NameIDPolicy in request"); return;//from ww w . ja v a2 s . com } _logger.info("Adding {} as NameIDPolicy@Format", _requestedNameIdFormat); writer.writeStartElement("samlp", "NameIDPolicy", "urn:oasis:names:tc:SAML:2.0:protocol"); writer.writeAttribute("Format", _requestedNameIdFormat); writer.writeAttribute("AllowCreate", "true"); writer.writeEndElement(); }
From source file:org.asimba.wa.integrationtest.saml2.model.AuthnRequest.java
protected void writeRequestedAuthnContext(XMLStreamWriter writer) throws XMLStreamException { if (_requestedAuthnContext == null) { _logger.info("Skipping RequestedAuthnContext in request"); return;//w ww .ja va 2s . c o m } _logger.info("Adding {} as RequestedAuthnContext@AuthnContextClassRef", _requestedAuthnContext); writer.writeStartElement("samlp", "RequestedAuthnContext", "urn:oasis:names:tc:SAML:2.0:protocol"); writer.writeAttribute("Comparison", "exact"); writer.writeStartElement("saml", "AuthnContextClassRef", "urn:oasis:names:tc:SAML:2.0:assertion"); writer.writeNamespace("saml", "urn:oasis:names:tc:SAML:2.0:assertion"); writer.writeCharacters(_requestedAuthnContext); writer.writeEndElement(); writer.writeEndElement(); }
From source file:org.asimba.wa.integrationtest.saml2.model.Response.java
protected void writeStatus(XMLStreamWriter writer) throws XMLStreamException { writer.writeStartElement("saml2p", "Status", "urn:oasis:names:tc:SAML:2.0:protocol"); writer.writeStartElement("saml2p", "StatusCode", "urn:oasis:names:tc:SAML:2.0:protocol"); writer.writeAttribute("Value", _statusCode); writer.writeEndElement();/* www .ja v a 2 s . c o m*/ writer.writeEndElement(); }
From source file:org.asimba.wa.integrationtest.saml2.model.Response.java
/** * Build response based on current state.<br/> * Only do Base64-encoding of the XML-document -- no deflating whatsoever may be done. * //from w w w. j a v a 2 s .c o m * @return * @throws XMLStreamException */ public String getResponse(int format) throws XMLStreamException { _logger.info("For ID: " + getId()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); StringWriter sw = new StringWriter(); XMLOutputFactory factory = XMLOutputFactory.newInstance(); XMLStreamWriter writer = null; // ugly but effective: if (format == base64) { writer = factory.createXMLStreamWriter(baos); } else { writer = factory.createXMLStreamWriter(sw); } writer.writeStartElement("saml2p", "Response", "urn:oasis:names:tc:SAML:2.0:protocol"); writer.writeNamespace("saml2p", "urn:oasis:names:tc:SAML:2.0:protocol"); writer.writeNamespace("xs", "http://www.w3.org/2001/XMLSchema"); writer.writeAttribute("Destination", _destination); writer.writeAttribute("ID", _id); writer.writeAttribute("InResponseTo", _inResponseTo); writer.writeAttribute("IssueInstant", _issueInstant); writer.writeAttribute("Version", "2.0"); writeIssuer(writer); writeStatus(writer); _assertion.writeAssertion(writer); writer.writeEndElement(); // SAML2 writer.flush(); if (format == base64) { byte[] bain = baos.toByteArray(); byte[] encoded = Base64.encodeBase64(bain, false); String result = new String(encoded, Charset.forName("UTF-8")); return result; } else { return sw.toString(); } }
From source file:org.corpus_tools.salt.util.VisJsVisualizer.java
private void writeHTML(File outputFolder) throws XMLStreamException, IOException { int nodeDist = 0; int sprLength = 0; double sprConstant = 0.0; try (OutputStream os = new FileOutputStream(new File(outputFolder, HTML_FILE)); FileOutputStream fos = new FileOutputStream(tmpFile)) { XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); XMLStreamWriter xmlWriter = outputFactory.createXMLStreamWriter(os, "UTF-8"); setNodeWriter(os);/*from ww w . ja v a 2 s . co m*/ setEdgeWriter(fos); xmlWriter.writeStartDocument("UTF-8", "1.0"); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement(TAG_HTML); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement(TAG_HEAD); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement(TAG_TITLE); xmlWriter.writeCharacters("Salt Document Tree"); xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement(TAG_STYLE); xmlWriter.writeAttribute(ATT_TYPE, "text/css"); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeCharacters("body {" + NEWLINE + "font: 10pt sans;" + NEWLINE + "}" + NEWLINE + "#mynetwork {" + NEWLINE + "height: 90%;" + NEWLINE + "width: 90%;" + NEWLINE + "border: 1px solid lightgray; " + NEWLINE + "text-align: center;" + NEWLINE + "}" + NEWLINE + "#loadingBar {" + NEWLINE + "position:absolute;" + NEWLINE + "top:0px;" + NEWLINE + "left:0px;" + NEWLINE + "width: 0px;" + NEWLINE + "height: 0px;" + NEWLINE + "background-color:rgba(200,200,200,0.8);" + NEWLINE + "-webkit-transition: all 0.5s ease;" + NEWLINE + "-moz-transition: all 0.5s ease;" + NEWLINE + "-ms-transition: all 0.5s ease;" + NEWLINE + "-o-transition: all 0.5s ease;" + NEWLINE + "transition: all 0.5s ease;" + NEWLINE + "opacity:1;" + NEWLINE + "}" + NEWLINE + "#wrapper {" + NEWLINE + "position:absolute;" + NEWLINE + "width: 1200px;" + NEWLINE + "height: 90%;" + NEWLINE + "}" + NEWLINE + "#text {" + NEWLINE + "position:absolute;" + NEWLINE + "top:8px;" + NEWLINE + "left:530px;" + NEWLINE + "width:30px;" + NEWLINE + "height:50px;" + NEWLINE + "margin:auto auto auto auto;" + NEWLINE + "font-size:16px;" + NEWLINE + "color: #000000;" + NEWLINE + "}" + NEWLINE + "div.outerBorder {" + NEWLINE + "position:relative;" + NEWLINE + "top:400px;" + NEWLINE + "width:600px;" + NEWLINE + "height:44px;" + NEWLINE + "margin:auto auto auto auto;" + NEWLINE + "border:8px solid rgba(0,0,0,0.1);" + NEWLINE + "background: rgb(252,252,252); /* Old browsers */" + NEWLINE + "background: -moz-linear-gradient(top, rgba(252,252,252,1) 0%, rgba(237,237,237,1) 100%); /* FF3.6+ */" + NEWLINE + "background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(252,252,252,1)), color-stop(100%,rgba(237,237,237,1))); /* Chrome,Safari4+ */" + NEWLINE + "background: -webkit-linear-gradient(top, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* Chrome10+,Safari5.1+ */" + NEWLINE + "background: -o-linear-gradient(top, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* Opera 11.10+ */" + NEWLINE + "background: -ms-linear-gradient(top, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* IE10+ */" + NEWLINE + "background: linear-gradient(to bottom, rgba(252,252,252,1) 0%,rgba(237,237,237,1) 100%); /* W3C */" + NEWLINE + "filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fcfcfc', endColorstr='#ededed',GradientType=0 ); /* IE6-9 */" + NEWLINE + "border-radius:72px;" + NEWLINE + "box-shadow: 0px 0px 10px rgba(0,0,0,0.2);" + NEWLINE + "}" + NEWLINE + "#border {" + NEWLINE + "position:absolute;" + NEWLINE + "top:10px;" + NEWLINE + "left:10px;" + NEWLINE + "width:500px;" + NEWLINE + "height:23px;" + NEWLINE + "margin:auto auto auto auto;" + NEWLINE + "box-shadow: 0px 0px 4px rgba(0,0,0,0.2);" + NEWLINE + "border-radius:10px;" + NEWLINE + "}" + NEWLINE + "#bar {" + NEWLINE + "position:absolute;" + NEWLINE + "top:0px;" + NEWLINE + "left:0px;" + NEWLINE + "width:20px;" + NEWLINE + "height:20px;" + NEWLINE + "margin:auto auto auto auto;" + NEWLINE + "border-radius:6px;" + NEWLINE + "border:1px solid rgba(30,30,30,0.05);" + NEWLINE + "background: rgb(0, 173, 246); /* Old browsers */" + NEWLINE + "box-shadow: 2px 0px 4px rgba(0,0,0,0.4);" + NEWLINE + "}" + NEWLINE); xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement(TAG_SCRIPT); xmlWriter.writeAttribute(ATT_SRC, VIS_JS_SRC); xmlWriter.writeAttribute(ATT_TYPE, "text/javascript"); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement(TAG_SCRIPT); xmlWriter.writeAttribute(ATT_SRC, JQUERY_SRC); xmlWriter.writeAttribute(ATT_TYPE, "text/javascript"); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeEmptyElement(TAG_LINK); xmlWriter.writeAttribute(ATT_HREF, VIS_CSS_SRC); xmlWriter.writeAttribute(ATT_REL, "stylesheet"); xmlWriter.writeAttribute(ATT_TYPE, "text/css"); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement(TAG_SCRIPT); xmlWriter.writeAttribute(ATT_TYPE, "text/javascript"); xmlWriter.writeCharacters(NEWLINE + "function frameSize() {" + NEWLINE + "$(document).ready(function() {" + NEWLINE + "function elementResize() {" + NEWLINE + "var browserWidth = $(window).width()*0.98;" + NEWLINE + "document.getElementById('mynetwork').style.width = browserWidth;" + NEWLINE + "}" + NEWLINE + "elementResize();" + NEWLINE + "$(window).bind(\"resize\", function(){" + NEWLINE + "elementResize();" + NEWLINE + "});" + NEWLINE + "});" + NEWLINE + "}" + NEWLINE); xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement(TAG_SCRIPT); xmlWriter.writeAttribute(ATT_TYPE, "text/javascript"); xmlWriter.writeCharacters(NEWLINE + "function start(){" + NEWLINE + "loadSaltObjectAndDraw();" + NEWLINE + "frameSize();" + NEWLINE + "}" + NEWLINE + "var nodesJson = [];" + NEWLINE + "var edgesJson = [];" + NEWLINE + "var network = null;" + NEWLINE + "function loadSaltObjectAndDraw() {" + NEWLINE + "var nodesJson = " + NEWLINE); xmlWriter.flush(); try { buildJSON(); } catch (SaltParameterException e) { throw new SaltParameterException(e.getMessage()); } catch (SaltException e) { throw new SaltException(e.getMessage()); } if (nNodes < 20) { nodeDist = 120; sprConstant = 1.2; sprLength = 120; } else if (nNodes >= 20 && nNodes < 100) { nodeDist = 150; sprConstant = 1.1; sprLength = 160; } else if (nNodes >= 100 && nNodes < 400) { nodeDist = 180; sprConstant = 0.9; sprLength = 180; } else if (nNodes >= 400 && nNodes < 800) { nodeDist = 200; sprConstant = 0.6; sprLength = 200; } else { nodeDist = 250; sprConstant = 0.3; sprLength = 230; } ; // write nodes as array nodeWriter.flush(); xmlWriter.writeCharacters(";" + NEWLINE); xmlWriter.writeCharacters("var edgesJson = " + NEWLINE); xmlWriter.flush(); // write edges as array to tmp file edgeWriter.flush(); // copy edges from tmp file ByteStreams.copy(new FileInputStream(tmpFile), os); xmlWriter.writeCharacters(";" + NEWLINE); xmlWriter.writeCharacters("var nodeDist =" + nodeDist + ";" + NEWLINE); xmlWriter.writeCharacters("draw(nodesJson, edgesJson, nodeDist);" + NEWLINE + "}" + NEWLINE + "var directionInput = document.getElementById(\"direction\");" + NEWLINE + "function destroy() {" + NEWLINE + "if (network !== null) {" + NEWLINE + "network.destroy();" + NEWLINE + "network = null;" + NEWLINE + "}" + NEWLINE + "}" + NEWLINE + NEWLINE + "function draw(nodesJson, edgesJson, nodeDist) {" + NEWLINE + "destroy();" + NEWLINE + "var connectionCount = [];" + NEWLINE + "var nodes = [];" + NEWLINE + "var edges = [];" + NEWLINE + NEWLINE + "nodes = new vis.DataSet(nodesJson);" + NEWLINE + "edges = new vis.DataSet(edgesJson);" + NEWLINE + "var container = document.getElementById('mynetwork');" + NEWLINE + "var data = {" + NEWLINE + "nodes: nodes," + NEWLINE + "edges: edges" + NEWLINE + "};" + NEWLINE + "var options = {" + NEWLINE + "nodes:{" + NEWLINE + "shape: \"box\"" + NEWLINE + "}," + NEWLINE + "edges: {" + NEWLINE + "smooth: true," + NEWLINE + "arrows: {" + NEWLINE + "to: {" + NEWLINE + "enabled: true" + NEWLINE + "}" + NEWLINE + "}" + NEWLINE + "}," + NEWLINE + "interaction: {" + NEWLINE + "navigationButtons: true," + NEWLINE + "keyboard: true" + NEWLINE + "}," + NEWLINE + "layout: {" + NEWLINE + "hierarchical:{" + NEWLINE + "direction: directionInput.value" + NEWLINE + "}" + NEWLINE + "}," + NEWLINE + "physics: {" + NEWLINE + "hierarchicalRepulsion: {" + NEWLINE + "centralGravity: 0.8," + NEWLINE + "springLength: " + sprLength + "," + NEWLINE + "springConstant: " + sprConstant + "," + NEWLINE + "nodeDistance: nodeDist," + NEWLINE + "damping: 0.04" + NEWLINE + "}," + NEWLINE + "maxVelocity: 50," + NEWLINE + "minVelocity: 1," + NEWLINE + "solver: 'hierarchicalRepulsion'," + NEWLINE + "timestep: 0.5," + NEWLINE + "stabilization: {" + NEWLINE + "iterations: 1000" + NEWLINE + "}" + NEWLINE + "}" + NEWLINE + "}" + NEWLINE + ";" + NEWLINE + "network = new vis.Network(container, data, options);" + NEWLINE); if (withPhysics == true) { xmlWriter.writeCharacters("network.on(\"stabilizationProgress\", function(params) {" + NEWLINE + "var maxWidth = 496;" + NEWLINE + "var minWidth = 20;" + NEWLINE + "var widthFactor = params.iterations/params.total;" + NEWLINE + "var width = Math.max(minWidth,maxWidth * widthFactor);" + NEWLINE + "document.getElementById('loadingBar').style.opacity = 1;" + NEWLINE + "document.getElementById('bar').style.width = width + 'px';" + NEWLINE + "document.getElementById('text').innerHTML = Math.round(widthFactor*100) + '%';" + NEWLINE + "});" + NEWLINE + "network.on(\"stabilizationIterationsDone\", function() {" + NEWLINE + "document.getElementById('text').innerHTML = '100%';" + NEWLINE + "document.getElementById('bar').style.width = '496px';" + NEWLINE + "document.getElementById('loadingBar').style.opacity = 0;" + NEWLINE + "});" + NEWLINE); } xmlWriter.writeCharacters("}" + NEWLINE); // script xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); // head xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement(TAG_BODY); xmlWriter.writeAttribute("onload", "start();"); xmlWriter.writeCharacters(NEWLINE); if (withPhysics == true) { xmlWriter.writeStartElement(TAG_DIV); xmlWriter.writeAttribute(ATT_ID, "wrapper"); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement(TAG_DIV); xmlWriter.writeAttribute(ATT_ID, "loadingBar"); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement(TAG_DIV); xmlWriter.writeAttribute(ATT_CLASS, "outerBorder"); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement(TAG_DIV); xmlWriter.writeAttribute(ATT_ID, "text"); xmlWriter.writeCharacters("0%"); xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement(TAG_DIV); xmlWriter.writeAttribute(ATT_ID, "border"); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement(TAG_DIV); xmlWriter.writeAttribute(ATT_ID, "bar"); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); } xmlWriter.writeStartElement(TAG_H2); xmlWriter.writeCharacters("Dokument-Id: " + docId); xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement(TAG_DIV); xmlWriter.writeAttribute(ATT_STYLE, TEXT_STYLE); xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement("p"); xmlWriter.writeEmptyElement(TAG_INPUT); xmlWriter.writeAttribute(ATT_TYPE, "button"); xmlWriter.writeAttribute(ATT_ID, "btn-UD"); xmlWriter.writeAttribute(ATT_VALUE, "Up-Down"); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeEmptyElement(TAG_INPUT); xmlWriter.writeAttribute(ATT_TYPE, "button"); xmlWriter.writeAttribute(ATT_ID, "btn-DU"); xmlWriter.writeAttribute(ATT_VALUE, "Down-Up"); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeEmptyElement(TAG_INPUT); xmlWriter.writeAttribute(ATT_TYPE, "hidden"); // TODO check the apostrophes xmlWriter.writeAttribute(ATT_ID, "direction"); xmlWriter.writeAttribute(ATT_VALUE, "UD"); xmlWriter.writeCharacters(NEWLINE); // p xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement(TAG_DIV); xmlWriter.writeAttribute(ATT_ID, "mynetwork"); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement(TAG_P); xmlWriter.writeAttribute(ATT_ID, "selection"); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeStartElement(TAG_SCRIPT); xmlWriter.writeAttribute(ATT_LANG, "JavaScript"); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeCharacters("var directionInput = document.getElementById(\"direction\");" + NEWLINE + "var btnUD = document.getElementById(\"btn-UD\");" + NEWLINE + "btnUD.onclick = function() {" + NEWLINE + "directionInput.value = \"UD\";" + NEWLINE + "start();" + NEWLINE + "};" + NEWLINE + "var btnDU = document.getElementById(\"btn-DU\");" + NEWLINE + "btnDU.onclick = function() {" + NEWLINE + "directionInput.value = \"DU\";" + NEWLINE + "start();" + NEWLINE + "};" + NEWLINE); xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); // div wrapper if (withPhysics == true) { xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); } // body xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); // html xmlWriter.writeEndElement(); xmlWriter.writeCharacters(NEWLINE); xmlWriter.writeEndDocument(); xmlWriter.flush(); xmlWriter.close(); nodeWriter.close(); edgeWriter.close(); } }
From source file:org.deegree.services.csw.exporthandling.EbrimGetCapabilitiesHandler.java
private void export(XMLStreamWriter writer, Set<Sections> sections, ServiceIdentificationType identification, ServiceProviderType provider) throws XMLStreamException { writer.writeStartElement(WRS_PREFIX, "Capabilities", WRS_NS); writer.writeNamespace(WRS_PREFIX, WRS_NS); writer.writeNamespace(OWS_PREFIX, OWS_NS); writer.writeNamespace(OGC_PREFIX, OGCNS); writer.writeNamespace(XLINK_PREFIX, XLN_NS); writer.writeNamespace(XSINS, XSI_PREFIX); writer.writeAttribute("version", "2.0.2"); writer.writeAttribute("schemaLocation", WRS_NS + " " + WRS_SCHEMA, XSINS); // ows:ServiceIdentification if (sections.isEmpty() || sections.contains(Sections.ServiceIdentification)) { gcHelper.exportServiceIdentification(writer, identification, "urn:ogc:serviceType:CatalogueService:2.0.2:HTTP:ebRIM", "2.0.2", "http://www.opengeospatial.org/ogcna"); }//ww w . j a v a 2 s . c om // ows:ServiceProvider if (sections.isEmpty() || sections.contains(Sections.ServiceProvider)) { exportServiceProvider100Old(writer, provider); } // ows:OperationsMetadata if (sections.isEmpty() || sections.contains(Sections.OperationsMetadata)) { exportOperationsMetadata(writer, OGCFrontController.getHttpGetURL(), OGCFrontController.getHttpPostURL(), OWS_NS); } // mandatory FilterCapabilitiesExporter.export110(writer); writer.writeEndElement(); writer.writeEndDocument(); }
From source file:org.deegree.services.csw.exporthandling.EbrimGetCapabilitiesHandler.java
protected void exportOperationsMetadata(XMLStreamWriter writer, String get, String post, String owsNS) throws XMLStreamException { writer.writeStartElement(owsNS, "OperationsMetadata"); for (String name : supportedOperations) { if (!name.equals(CSWRequestType.GetRepositoryItem.name())) { writer.writeStartElement(owsNS, "Operation"); writer.writeAttribute("name", name); exportDCP(writer, get, post, owsNS); if (name.equals(CSWRequestType.GetCapabilities.name())) { writeParam(owsNS, "AcceptVersions", "2.0.2", "1.0.0"); gcHelper.writeGetCapabilitiesParameters(writer, owsNS); writer.writeEndElement();// Operation } else if (name.equals(CSWRequestType.DescribeRecord.name())) { writeParam(owsNS, "version", "2.0.2", "1.0.0"); gcHelper.writeDescribeRecordParameters(writer, owsNS, null, outputFormats, schemaLang); writeParam(owsNS, "typeNames", "csw:Record", "rim:RegistryPackage", "rim:ExtrinsicObject", "rim:RegistryObject"); writer.writeEndElement();// Operation } else if (name.equals(CSWRequestType.GetRecords.name())) { writeParam(owsNS, "version", "2.0.2", "1.0.0"); gcHelper.writeGetRecordsParameters(writer, owsNS, new String[] { "csw:Record", "rim:RegistryPackage", "rim:ExtrinsicObject", "rim:RegistryObject" }, outputFormats, new String[] { "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" }, null); writeParam(owsNS, "CONSTRAINTLANGUAGE", "FILTER"); writeParam(owsNS, "ElementSetName", "brief", "summary", "full"); writer.writeEndElement();// Operation } else if (name.equals(CSWRequestType.GetRecordById.name())) { writeParam(owsNS, "version", "2.0.2", "1.0.0"); gcHelper.writeGetRecordByIdParameters(writer, owsNS, outputFormats, new String[] { EbrimProfile.RIM_NS }); writeParam(owsNS, "TypeName", "csw:Record", "rim:RegistryPackage", "rim:ExtrinsicObject", "rim:RegistryObject"); writer.writeEndElement();// Operation // } else if ( name.equals( CSWebRIMRequestType.GetRepositoryItem.name() ) ) { // writeParam( owsNS, "version", "2.0.2", "1.0.0" ); // writer.writeEndElement();// Operation }/*from w ww .ja v a2 s.co m*/ } } writeParam(owsNS, "service", EbrimProfile.SERVICENAME_CSW, EbrimProfile.SERVICENAME_CSW_EBRIM, EbrimProfile.SERVICENAME_WRS); // if XML and/or SOAP is supported writer.writeStartElement(owsNS, "Constraint"); writer.writeAttribute("name", "PostEncoding"); writer.writeStartElement(owsNS, "Value"); writer.writeCharacters("XML"); writer.writeEndElement();// Value writer.writeStartElement(owsNS, "Value"); writer.writeCharacters("SOAP"); writer.writeEndElement();// Value writer.writeEndElement();// Constraint writer.writeStartElement(owsNS, "Constraint"); writer.writeAttribute("name", "srsName"); writer.writeStartElement(owsNS, "Value"); writer.writeCharacters("urn:ogc:def:crs:EPSG:4326"); writer.writeEndElement();// Value writer.writeStartElement(owsNS, "Metadata"); writer.writeAttribute(CommonNamespaces.XLNNS, "type", "simple"); writer.writeAttribute(CommonNamespaces.XLNNS, "title", "EPSG geodetic parameters"); writer.writeAttribute(CommonNamespaces.XLNNS, "href", "http://www.epsg-registry.org/"); writer.writeEndElement();// Metadata writer.writeEndElement();// Constraint if (extendedCapabilities != null) { InputStream extCapabilites = null; try { extCapabilites = extendedCapabilities.openStream(); gcHelper.exportExtendedCapabilities(writer, owsNS, extCapabilites, null); } catch (IOException e) { LOG.warn("Could not open stream for extended capabilities. Ignore it!"); } finally { IOUtils.closeQuietly(extCapabilites); } } writer.writeEndElement();// OperationsMetadata }