Java Code Examples for org.apache.axiom.om.OMFactory#createOMText()
The following examples show how to use
org.apache.axiom.om.OMFactory#createOMText() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractChartJrxmlHandler.java From carbon-commons with Apache License 2.0 | 6 votes |
private void setCategoryAxisLabel(String chartText, String chartPlotText, ChartReportDTO chartReport) throws JaxenException { AXIOMXPath xpathExpression = new AXIOMXPath("//a:title//a:" + chartText + "//a:" + chartPlotText + "//a:categoryAxisLabelExpression"); xpathExpression.addNamespace("a", "http://jasperreports.sourceforge.net/jasperreports"); OMElement documentElement = document.getOMDocumentElement(); List nodeList = xpathExpression.selectNodes(documentElement); OMElement label = (OMElement) nodeList.get(0); label.setText(""); OMFactory factory = document.getOMFactory(); OMText cdataField = factory.createOMText(label, "\"" + chartReport.getxAxisLabel() + "\"", OMText.CDATA_SECTION_NODE); label.addChild(cdataField); }
Example 2
Source File: ESBJAVA4909MultipartRelatedTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
public void sendUsingMTOM(String fileName, String targetEPR) throws IOException { final String EXPECTED = "<m0:uploadFileUsingMTOMResponse xmlns:m0=\"http://services.samples\"><m0:response>" + "<m0:image>PHByb3h5PkFCQzwvcHJveHk+</m0:image></m0:response></m0:uploadFileUsingMTOMResponse>"; OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0"); OMElement payload = factory.createOMElement("uploadFileUsingMTOM", ns); OMElement request = factory.createOMElement("request", ns); OMElement image = factory.createOMElement("image", ns); FileDataSource fileDataSource = new FileDataSource(new File(fileName)); DataHandler dataHandler = new DataHandler(fileDataSource); OMText textData = factory.createOMText(dataHandler, true); image.addChild(textData); request.addChild(image); payload.addChild(request); ServiceClient serviceClient = new ServiceClient(); Options options = new Options(); options.setTo(new EndpointReference(targetEPR)); options.setAction("urn:uploadFileUsingMTOM"); options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE); options.setCallTransportCleanup(true); serviceClient.setOptions(options); OMElement response = serviceClient.sendReceive(payload); Assert.assertTrue(response.toString().contains(EXPECTED), "Attachment is missing in the response"); }
Example 3
Source File: CallOutMediatorWithMTOMTestCase.java From micro-integrator with Apache License 2.0 | 6 votes |
public void sendUsingMTOM(String fileName, String targetEPR) throws IOException { OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0"); OMElement payload = factory.createOMElement("uploadFileUsingMTOM", ns); OMElement request = factory.createOMElement("request", ns); OMElement image = factory.createOMElement("image", ns); FileDataSource fileDataSource = new FileDataSource(new File(fileName)); DataHandler dataHandler = new DataHandler(fileDataSource); OMText textData = factory.createOMText(dataHandler, true); image.addChild(textData); request.addChild(image); payload.addChild(request); ServiceClient serviceClient = new ServiceClient(); Options options = new Options(); options.setTo(new EndpointReference(targetEPR)); options.setAction("urn:uploadFileUsingMTOM"); options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE); options.setCallTransportCleanup(true); serviceClient.setOptions(options); OMElement response = serviceClient.sendReceive(payload); Assert.assertTrue(response.toString().contains( "<m:testMTOM xmlns:m=\"http://services.samples/xsd\">" + "<m:test1>testMTOM</m:test1></m:testMTOM>")); }
Example 4
Source File: SOAPClient.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * Sends a SOAP message with MTOM attachment and returns response as a OMElement. * * @param fileName name of file to be sent as an attachment * @param targetEPR service url * @param soapAction SOAP Action to set. Specify with "urn:" * @return OMElement response from BE service * @throws AxisFault in case of an invocation failure */ public OMElement sendSOAPMessageWithAttachment(String fileName, String targetEPR, String soapAction) throws AxisFault { OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0"); OMElement payload = factory.createOMElement("uploadFileUsingMTOM", ns); OMElement request = factory.createOMElement("request", ns); OMElement image = factory.createOMElement("image", ns); FileDataSource fileDataSource = new FileDataSource(new File(fileName)); DataHandler dataHandler = new DataHandler(fileDataSource); OMText textData = factory.createOMText(dataHandler, true); image.addChild(textData); request.addChild(image); payload.addChild(request); ServiceClient serviceClient = new ServiceClient(); Options options = new Options(); options.setTo(new EndpointReference(targetEPR)); options.setAction(soapAction); options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE); options.setCallTransportCleanup(true); serviceClient.setOptions(options); return serviceClient.sendReceive(payload); }
Example 5
Source File: TableTemplateJrxmlHandler.java From carbon-commons with Apache License 2.0 | 6 votes |
private void updateTableHeaderNames() throws JaxenException { AXIOMXPath xpathExpression = new AXIOMXPath("//a:title//a:band//a:componentElement//b:table//b:column" + "//b:columnHeader//a:text"); xpathExpression.addNamespace("a", "http://jasperreports.sourceforge.net/jasperreports"); xpathExpression.addNamespace("b", "http://jasperreports.sourceforge.net/jasperreports/components"); OMElement documentElement = document.getOMDocumentElement(); List nodeList = xpathExpression.selectNodes(documentElement); for (int i = 0; i < nodeList.size(); i++) { OMElement textElement = (OMElement) nodeList.get(i); textElement.setText(""); OMFactory factory = document.getOMFactory(); OMText cdataField = factory.createOMText(textElement, tableReport.getColumns()[i].getColumnHeaderName(), OMText.CDATA_SECTION_NODE); textElement.addChild(cdataField); } }
Example 6
Source File: CallOutMediatorWithMTOMTestCase.java From product-ei with Apache License 2.0 | 6 votes |
public void sendUsingMTOM(String fileName, String targetEPR) throws IOException { OMFactory factory = OMAbstractFactory.getOMFactory(); OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0"); OMElement payload = factory.createOMElement("uploadFileUsingMTOM", ns); OMElement request = factory.createOMElement("request", ns); OMElement image = factory.createOMElement("image", ns); FileDataSource fileDataSource = new FileDataSource(new File(fileName)); DataHandler dataHandler = new DataHandler(fileDataSource); OMText textData = factory.createOMText(dataHandler, true); image.addChild(textData); request.addChild(image); payload.addChild(request); ServiceClient serviceClient = new ServiceClient(); Options options = new Options(); options.setTo(new EndpointReference(targetEPR)); options.setAction("urn:uploadFileUsingMTOM"); options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE); options.setCallTransportCleanup(true); serviceClient.setOptions(options); OMElement response = serviceClient.sendReceive(payload); Assert.assertTrue(response.toString().contains( "<m:testMTOM xmlns:m=\"http://services.samples/xsd\">" + "<m:test1>testMTOM</m:test1></m:testMTOM>")); }
Example 7
Source File: TableTemplateJrxmlHandler.java From carbon-commons with Apache License 2.0 | 6 votes |
private void updateTableFooterNames() throws JaxenException { AXIOMXPath xpathExpression = new AXIOMXPath("//a:title//a:band//a:componentElement//b:table//b:column" + "//b:columnFooter//a:text"); xpathExpression.addNamespace("a", "http://jasperreports.sourceforge.net/jasperreports"); xpathExpression.addNamespace("b", "http://jasperreports.sourceforge.net/jasperreports/components"); OMElement documentElement = document.getOMDocumentElement(); List nodeList = xpathExpression.selectNodes(documentElement); for (int i = 0; i < nodeList.size(); i++) { OMElement textElement = (OMElement) nodeList.get(i); textElement.setText(""); OMFactory factory = document.getOMFactory(); OMText cdataField = factory.createOMText(textElement, tableReport.getColumns()[i].getColumnFooterName(), OMText.CDATA_SECTION_NODE); textElement.addChild(cdataField); } }
Example 8
Source File: FIXClient.java From product-ei with Apache License 2.0 | 5 votes |
private OMElement getHeader(OMFactory factory) { OMElement header = factory.createOMElement("header", null); OMElement msgType = factory.createOMElement("field", null); msgType.addAttribute(factory.createOMAttribute("id", null, "35")); factory.createOMText(msgType, "D"); header.addChild(msgType); OMElement sendingTime = factory.createOMElement("field", null); sendingTime.addAttribute(factory.createOMAttribute("id", null, "52")); factory.createOMText(sendingTime, new Date().toString()); header.addChild(sendingTime); return header; }
Example 9
Source File: AbstractChartJrxmlHandler.java From carbon-commons with Apache License 2.0 | 5 votes |
private void handleChartSubTitle(String chartText) throws JaxenException { AXIOMXPath xpathExpression = new AXIOMXPath("//a:title//a:band//a:" + chartText + "//a:chart//a:chartSubtitle//a:subtitleExpression"); xpathExpression.addNamespace("a", "http://jasperreports.sourceforge.net/jasperreports"); OMElement documentElement = document.getOMDocumentElement(); List nodeList = xpathExpression.selectNodes(documentElement); OMElement element = (OMElement) nodeList.get(0); element.setText(""); OMFactory factory = document.getOMFactory(); OMText cdataField = factory.createOMText(element, "\"" + chart.getSubTitle() + "\"", OMText.CDATA_SECTION_NODE); element.addChild(cdataField); }
Example 10
Source File: AbstractChartJrxmlHandler.java From carbon-commons with Apache License 2.0 | 5 votes |
private void handleChartTitle(String chartText) throws JaxenException { AXIOMXPath xpathExpression = new AXIOMXPath("//a:title//a:band//a:" + chartText + "//a:chart//a:chartTitle//a:titleExpression"); xpathExpression.addNamespace("a", "http://jasperreports.sourceforge.net/jasperreports"); OMElement documentElement = document.getOMDocumentElement(); List nodeList = xpathExpression.selectNodes(documentElement); OMElement element = (OMElement) nodeList.get(0); element.setText(""); OMFactory factory = document.getOMFactory(); OMText cdataField = factory.createOMText(element, "\"" + chart.getTitle() + "\"", OMText.CDATA_SECTION_NODE); element.addChild(cdataField); }
Example 11
Source File: FIXClient.java From product-ei with Apache License 2.0 | 5 votes |
private static OMElement getBody(OMFactory factory, String text, String mode, String qtyValue) { OMElement body = factory.createOMElement("body", null); OMElement clordID = factory.createOMElement("field", null); clordID.addAttribute(factory.createOMAttribute("id", null, "11")); factory.createOMText(clordID, "122333"); body.addChild(clordID); OMElement handleIns = factory.createOMElement("field", null); handleIns.addAttribute(factory.createOMAttribute("id", null, "21")); factory.createOMText(handleIns, "1"); body.addChild(handleIns); OMElement qty = factory.createOMElement("field", null); qty.addAttribute(factory.createOMAttribute("id", null, "38")); factory.createOMText(qty, qtyValue); body.addChild(qty); OMElement ordType = factory.createOMElement("field", null); ordType.addAttribute(factory.createOMAttribute("id", null, "40")); factory.createOMText(ordType, "1"); body.addChild(ordType); OMElement side = factory.createOMElement("field", null); side.addAttribute(factory.createOMAttribute("id", null, "54")); factory.createOMText(side, mode); body.addChild(side); OMElement symbol = factory.createOMElement("field", null); symbol.addAttribute(factory.createOMAttribute("id", null, "55")); factory.createOMText(symbol, text); body.addChild(symbol); OMElement timeInForce = factory.createOMElement("field", null); timeInForce.addAttribute(factory.createOMAttribute("id", null, "59")); factory.createOMText(timeInForce, "0"); body.addChild(timeInForce); return body; }
Example 12
Source File: FIXClient.java From product-ei with Apache License 2.0 | 5 votes |
private static OMElement getHeader(OMFactory factory) { OMElement header = factory.createOMElement("header", null); OMElement msgType = factory.createOMElement("field", null); msgType.addAttribute(factory.createOMAttribute("id", null, "35")); factory.createOMText(msgType, "D"); header.addChild(msgType); OMElement sendingTime = factory.createOMElement("field", null); sendingTime.addAttribute(factory.createOMAttribute("id", null, "52")); factory.createOMText(sendingTime, new Date().toString()); header.addChild(sendingTime); return header; }
Example 13
Source File: FIXClient.java From product-ei with Apache License 2.0 | 5 votes |
private OMElement getBody(OMFactory factory, String text, String mode, String qtyValue) { OMElement body = factory.createOMElement("body", null); OMElement clordID = factory.createOMElement("field", null); clordID.addAttribute(factory.createOMAttribute("id", null, "11")); factory.createOMText(clordID, "122333"); body.addChild(clordID); OMElement handleIns = factory.createOMElement("field", null); handleIns.addAttribute(factory.createOMAttribute("id", null, "21")); factory.createOMText(handleIns, "1"); body.addChild(handleIns); OMElement qty = factory.createOMElement("field", null); qty.addAttribute(factory.createOMAttribute("id", null, "38")); factory.createOMText(qty, qtyValue); body.addChild(qty); OMElement ordType = factory.createOMElement("field", null); ordType.addAttribute(factory.createOMAttribute("id", null, "40")); factory.createOMText(ordType, "1"); body.addChild(ordType); OMElement side = factory.createOMElement("field", null); side.addAttribute(factory.createOMAttribute("id", null, "54")); factory.createOMText(side, mode); body.addChild(side); OMElement symbol = factory.createOMElement("field", null); symbol.addAttribute(factory.createOMAttribute("id", null, "55")); factory.createOMText(symbol, text); body.addChild(symbol); OMElement timeInForce = factory.createOMElement("field", null); timeInForce.addAttribute(factory.createOMAttribute("id", null, "59")); factory.createOMText(timeInForce, "0"); body.addChild(timeInForce); return body; }
Example 14
Source File: FIXClient.java From micro-integrator with Apache License 2.0 | 5 votes |
private OMElement getHeader(OMFactory factory) { OMElement header = factory.createOMElement("header", null); OMElement msgType = factory.createOMElement("field", null); msgType.addAttribute(factory.createOMAttribute("id", null, "35")); factory.createOMText(msgType, "D"); header.addChild(msgType); OMElement sendingTime = factory.createOMElement("field", null); sendingTime.addAttribute(factory.createOMAttribute("id", null, "52")); factory.createOMText(sendingTime, new Date().toString()); header.addChild(sendingTime); return header; }
Example 15
Source File: FIXClient.java From micro-integrator with Apache License 2.0 | 5 votes |
private static OMElement getBody(OMFactory factory, String text, String mode, String qtyValue) { OMElement body = factory.createOMElement("body", null); OMElement clordID = factory.createOMElement("field", null); clordID.addAttribute(factory.createOMAttribute("id", null, "11")); factory.createOMText(clordID, "122333"); body.addChild(clordID); OMElement handleIns = factory.createOMElement("field", null); handleIns.addAttribute(factory.createOMAttribute("id", null, "21")); factory.createOMText(handleIns, "1"); body.addChild(handleIns); OMElement qty = factory.createOMElement("field", null); qty.addAttribute(factory.createOMAttribute("id", null, "38")); factory.createOMText(qty, qtyValue); body.addChild(qty); OMElement ordType = factory.createOMElement("field", null); ordType.addAttribute(factory.createOMAttribute("id", null, "40")); factory.createOMText(ordType, "1"); body.addChild(ordType); OMElement side = factory.createOMElement("field", null); side.addAttribute(factory.createOMAttribute("id", null, "54")); factory.createOMText(side, mode); body.addChild(side); OMElement symbol = factory.createOMElement("field", null); symbol.addAttribute(factory.createOMAttribute("id", null, "55")); factory.createOMText(symbol, text); body.addChild(symbol); OMElement timeInForce = factory.createOMElement("field", null); timeInForce.addAttribute(factory.createOMAttribute("id", null, "59")); factory.createOMText(timeInForce, "0"); body.addChild(timeInForce); return body; }
Example 16
Source File: FIXClient.java From micro-integrator with Apache License 2.0 | 5 votes |
private static OMElement getHeader(OMFactory factory) { OMElement header = factory.createOMElement("header", null); OMElement msgType = factory.createOMElement("field", null); msgType.addAttribute(factory.createOMAttribute("id", null, "35")); factory.createOMText(msgType, "D"); header.addChild(msgType); OMElement sendingTime = factory.createOMElement("field", null); sendingTime.addAttribute(factory.createOMAttribute("id", null, "52")); factory.createOMText(sendingTime, new Date().toString()); header.addChild(sendingTime); return header; }
Example 17
Source File: FIXClient.java From micro-integrator with Apache License 2.0 | 5 votes |
private static OMElement getBody(OMFactory factory, String text, String mode, String qtyValue) { OMElement body = factory.createOMElement("body", null); OMElement clordID = factory.createOMElement("field", null); clordID.addAttribute(factory.createOMAttribute("id", null, "11")); factory.createOMText(clordID, "122333"); body.addChild(clordID); OMElement handleIns = factory.createOMElement("field", null); handleIns.addAttribute(factory.createOMAttribute("id", null, "21")); factory.createOMText(handleIns, "1"); body.addChild(handleIns); OMElement qty = factory.createOMElement("field", null); qty.addAttribute(factory.createOMAttribute("id", null, "38")); factory.createOMText(qty, qtyValue); body.addChild(qty); OMElement ordType = factory.createOMElement("field", null); ordType.addAttribute(factory.createOMAttribute("id", null, "40")); factory.createOMText(ordType, "1"); body.addChild(ordType); OMElement side = factory.createOMElement("field", null); side.addAttribute(factory.createOMAttribute("id", null, "54")); factory.createOMText(side, mode); body.addChild(side); OMElement symbol = factory.createOMElement("field", null); symbol.addAttribute(factory.createOMAttribute("id", null, "55")); factory.createOMText(symbol, text); body.addChild(symbol); OMElement timeInForce = factory.createOMElement("field", null); timeInForce.addAttribute(factory.createOMAttribute("id", null, "59")); factory.createOMText(timeInForce, "0"); body.addChild(timeInForce); return body; }
Example 18
Source File: AbstractChartJrxmlHandler.java From carbon-commons with Apache License 2.0 | 5 votes |
private void setValueExpr(String YField, OMElement categorySeriesElement, String yExpressionText) throws JaxenException { Iterator iter = categorySeriesElement.getChildrenWithName(new QName(yExpressionText)); OMElement aValueExpr = (OMElement) iter.next(); aValueExpr.setText(""); OMFactory factory = document.getOMFactory(); OMText cdataField = factory.createOMText(aValueExpr, "$F{" + YField + "}", OMText.CDATA_SECTION_NODE); aValueExpr.addChild(cdataField); }
Example 19
Source File: FIXClient.java From micro-integrator with Apache License 2.0 | 5 votes |
private OMElement getBody(OMFactory factory, String text, String mode, String qtyValue) { OMElement body = factory.createOMElement("body", null); OMElement clordID = factory.createOMElement("field", null); clordID.addAttribute(factory.createOMAttribute("id", null, "11")); factory.createOMText(clordID, "122333"); body.addChild(clordID); OMElement handleIns = factory.createOMElement("field", null); handleIns.addAttribute(factory.createOMAttribute("id", null, "21")); factory.createOMText(handleIns, "1"); body.addChild(handleIns); OMElement qty = factory.createOMElement("field", null); qty.addAttribute(factory.createOMAttribute("id", null, "38")); factory.createOMText(qty, qtyValue); body.addChild(qty); OMElement ordType = factory.createOMElement("field", null); ordType.addAttribute(factory.createOMAttribute("id", null, "40")); factory.createOMText(ordType, "1"); body.addChild(ordType); OMElement side = factory.createOMElement("field", null); side.addAttribute(factory.createOMAttribute("id", null, "54")); factory.createOMText(side, mode); body.addChild(side); OMElement symbol = factory.createOMElement("field", null); symbol.addAttribute(factory.createOMAttribute("id", null, "55")); factory.createOMText(symbol, text); body.addChild(symbol); OMElement timeInForce = factory.createOMElement("field", null); timeInForce.addAttribute(factory.createOMAttribute("id", null, "59")); factory.createOMText(timeInForce, "0"); body.addChild(timeInForce); return body; }
Example 20
Source File: DataServiceFault.java From micro-integrator with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) public static OMElement extractFaultMessage(Throwable throwable) { if (throwable instanceof DataServiceFault) { if (throwable.getCause() instanceof XMLStreamException) { return extractFaultMessage(((XMLStreamException) throwable.getCause()).getNestedException()); } OMFactory fac = OMAbstractFactory.getOMFactory(); OMElement root = fac.createOMElement(new QName( DBConstants.WSO2_DS_NAMESPACE, DBConstants.DS_FAULT_ELEMENT)); OMNamespace ns = root.getNamespace(); for (Map.Entry<String, Object> rootEntry : ((DataServiceFault) throwable).getPropertyMap().entrySet()) { OMElement keyElement = fac.createOMElement(rootEntry.getKey(), ns); if (rootEntry.getValue() instanceof Map) { for (Map.Entry dataServiceEntry : (Set<Map.Entry>) ((Map) rootEntry.getValue()).entrySet()) { OMElement dataServiceKeyElement = fac.createOMElement( dataServiceEntry.getKey().toString(), ns); OMText dataServiceValueElement = fac.createOMText( dataServiceKeyElement, dataServiceEntry.getValue().toString()); dataServiceKeyElement.addChild(dataServiceValueElement); keyElement.addChild(dataServiceKeyElement); } } else { OMText valueElement = fac.createOMText( keyElement, rootEntry.getValue().toString()); keyElement.addChild(valueElement); } root.addChild(keyElement); } return root; } else if (throwable instanceof XMLStreamException) { return extractFaultMessage(((XMLStreamException) throwable).getNestedException()); } else if (throwable != null) { Throwable cause = throwable.getCause(); if (cause != null) { return extractFaultMessage(cause); } else { return null; } } else { return null; } }