List of usage examples for org.dom4j Element getNamespacePrefix
String getNamespacePrefix();
String
is returned. From source file:org.jivesoftware.openfire.server.ServerDialback.java
License:Open Source License
/** * Returns a new {@link IncomingServerSession} with a domain validated by the Authoritative * Server. New domains may be added to the returned IncomingServerSession after they have * been validated. See/*from w w w .j a v a 2s . co m*/ * {@link LocalIncomingServerSession#validateSubsequentDomain(org.dom4j.Element)}. The remote * server will be able to send packets through this session whose domains were previously * validated.<p> * * When acting as an Authoritative Server this method will verify the requested key * and will return null since the underlying TCP connection will be closed after sending the * response to the Receiving Server.<p> * * @param reader reader of DOM documents on the connection to the remote server. * @return an IncomingServerSession that was previously validated against the remote server. * @throws IOException if an I/O error occurs while communicating with the remote server. * @throws XmlPullParserException if an error occurs while parsing XML packets. */ public LocalIncomingServerSession createIncomingSession(XMPPPacketReader reader) throws IOException, XmlPullParserException { XmlPullParser xpp = reader.getXPPParser(); StringBuilder sb; if ("jabber:server:dialback".equals(xpp.getNamespace("db"))) { Log.debug("ServerDialback: Processing incoming session."); StreamID streamID = sessionManager.nextStreamID(); sb = new StringBuilder(); sb.append("<stream:stream"); sb.append(" xmlns:stream=\"http://etherx.jabber.org/streams\""); sb.append(" xmlns=\"jabber:server\" xmlns:db=\"jabber:server:dialback\""); sb.append(" id=\""); sb.append(streamID.toString()); sb.append("\">"); connection.deliverRawText(sb.toString()); try { Element doc = reader.parseDocument().getRootElement(); if ("db".equals(doc.getNamespacePrefix()) && "result".equals(doc.getName())) { String hostname = doc.attributeValue("from"); String recipient = doc.attributeValue("to"); Log.debug("ServerDialback: RS - Validating remote domain for incoming session from {} to {}", hostname, recipient); if (validateRemoteDomain(doc, streamID)) { Log.debug( "ServerDialback: RS - Validation of remote domain for incoming session from {} to {} was successful.", hostname, recipient); // Create a server Session for the remote server LocalIncomingServerSession session = sessionManager.createIncomingServerSession(connection, streamID, hostname); // Add the validated domain as a valid domain session.addValidatedDomain(hostname); // Set the domain or subdomain of the local server used when // validating the session session.setLocalDomain(recipient); return session; } else { Log.debug( "ServerDialback: RS - Validation of remote domain for incoming session from {} to {} was not successful.", hostname, recipient); return null; } } else if ("db".equals(doc.getNamespacePrefix()) && "verify".equals(doc.getName())) { // When acting as an Authoritative Server the Receiving Server will send a // db:verify packet for verifying a key that was previously sent by this // server when acting as the Originating Server verifyReceivedKey(doc, connection); // Close the underlying connection connection.close(); String verifyFROM = doc.attributeValue("from"); String id = doc.attributeValue("id"); Log.debug("ServerDialback: AS - Connection closed for host: " + verifyFROM + " id: " + id); return null; } else { Log.debug( "ServerDialback: Received an invalid/unknown packet while trying to process an incoming session: {}", doc.asXML()); // The remote server sent an invalid/unknown packet connection.deliverRawText(new StreamError(StreamError.Condition.invalid_xml).toXML()); // Close the underlying connection connection.close(); return null; } } catch (Exception e) { Log.error("An error occured while creating a server session", e); // Close the underlying connection connection.close(); return null; } } else { Log.debug( "ServerDialback: Received a stanza in an invalid namespace while trying to process an incoming session: {}", xpp.getNamespace("db")); connection.deliverRawText(new StreamError(StreamError.Condition.invalid_namespace).toXML()); // Close the underlying connection connection.close(); return null; } }
From source file:org.orbeon.oxf.processor.tamino.dom4j.TDOM4JXMLOutputter.java
License:Open Source License
/** * <p>//from w ww . ja v a 2 s . c o m * Print out an <code>{@link Element}</code>, including * its <code>{@link Attribute}</code>s, and its value, and all * contained (child) elements etc. * </p> * * @param element <code>Element</code> to output. * @param out <code>Writer</code> to write to. **/ public void output(Element element, Writer out) throws IOException { /****** Original Source *******/ // If this is the root element we could pre-initialize the // namespace stack with the namespaces //printElement(element, out, indentLevel, new TDOM4JNamespaceStack()); /******************************/ TDOM4JNamespaceStack namespaces = new TDOM4JNamespaceStack(); Document document = element.getDocument(); Element rootElement = (document != null) ? document.getRootElement() : null; // If element is not root element or prefix of root element is not "ino" then add ino namespace to stack if (element != rootElement || !rootElement.getNamespacePrefix().equals(TInoNamespace.PREFIX)) { //System.err.println( "Adding ino namespace!" ); Namespace inoNamespace = Namespace.get(TInoNamespace.getInstance().getPrefix(), TInoNamespace.getInstance().getUri()); namespaces.push(inoNamespace); } //System.out.println( "Getting Parent Namespaces!" ); namespaces = getParentNamespaces(element.getParent(), namespaces); printElement(element, out, indentLevel, namespaces); }
From source file:org.pentaho.di.trans.steps.getxmldata.GetXMLData.java
License:Apache License
public void prepareNSMap(Element l) { @SuppressWarnings("unchecked") List<Namespace> namespacesList = l.declaredNamespaces(); for (Namespace ns : namespacesList) { if (ns.getPrefix().trim().length() == 0) { data.NAMESPACE.put("pre" + data.NSPath.size(), ns.getURI()); String path = ""; Element element = l; while (element != null) { if (element.getNamespacePrefix() != null && element.getNamespacePrefix().length() > 0) { path = GetXMLDataMeta.N0DE_SEPARATOR + element.getNamespacePrefix() + ":" + element.getName() + path; } else { path = GetXMLDataMeta.N0DE_SEPARATOR + element.getName() + path; }/*from w ww. java2 s . c om*/ element = element.getParent(); } data.NSPath.add(path); } else { data.NAMESPACE.put(ns.getPrefix(), ns.getURI()); } } @SuppressWarnings("unchecked") List<Element> elementsList = l.elements(); for (Element e : elementsList) { prepareNSMap(e); } }
From source file:org.suren.autotest.web.framework.code.DefaultXmlDataSourceGenerator.java
License:Apache License
/** * @param ele//w w w .j av a 2s. c om * @param pageClsStr2 */ private void updateXmlDataSourceByEle(Element ele, String dsResource, String pagePackage, String pageClsStr) { Document doc = docMap.get(dsResource); if (doc == null) { doc = prepareDoc(dsResource); docMap.put(dsResource, doc); } SimpleNamespaceContext simpleNamespaceContext = new SimpleNamespaceContext(); simpleNamespaceContext.addNamespace("ns", "http://datasource.surenpi.com"); XPath xpath = new DefaultXPath("/ns:dataSources"); xpath.setNamespaceContext(simpleNamespaceContext); Element dataSourcesEle = doc.getRootElement(); dataSourcesEle.addAttribute("pagePackage", pagePackage); //? if (StringUtils.isNotBlank(pagePackage)) { pagePackage = (pagePackage.trim()); xpath = new DefaultXPath("/ns:dataSources[@pagePackage='" + pagePackage + "']/ns:dataSource[@pageClass='" + pageClsStr + "']"); xpath.setNamespaceContext(simpleNamespaceContext); } else { xpath = new DefaultXPath("/ns:dataSources/ns:dataSource[@pageClass='" + pageClsStr + "']"); xpath.setNamespaceContext(simpleNamespaceContext); } Element dataSourceEle = (Element) xpath.selectSingleNode(doc); if (dataSourceEle == null) { String prefix = dataSourcesEle.getNamespacePrefix(); if (StringUtils.isBlank("")) { String parentName = dataSourcesEle.getName(); if (parentName.contains(":")) { prefix = parentName.split(":")[0]; } } if (StringUtils.isNotBlank(prefix)) { prefix = prefix + ":"; } dataSourceEle = dataSourcesEle.addElement(prefix + "dataSource"); dataSourceEle.addAttribute("pageClass", pageClsStr); } //?? if (StringUtils.isNotBlank(pagePackage)) { pagePackage = (pagePackage.trim()); xpath = new DefaultXPath("/ns:dataSources[@pagePackage='" + pagePackage + "']/ns:dataSource[@pageClass='" + pageClsStr + "']/ns:page[1]"); xpath.setNamespaceContext(simpleNamespaceContext); } else { xpath = new DefaultXPath("/ns:dataSources/ns:dataSource[@pageClass='" + pageClsStr + "']/ns:page[1]"); xpath.setNamespaceContext(simpleNamespaceContext); } Element pageEle = (Element) xpath.selectSingleNode(dataSourceEle); if (pageEle == null) { String prefix = dataSourceEle.getNamespacePrefix(); if (StringUtils.isNotBlank(prefix)) { prefix = prefix + ":"; } pageEle = dataSourceEle.addElement(prefix + "page"); } ele.accept(new PageFieldVisitor(pageEle, pagePackage, pageClsStr)); }
From source file:org.suren.autotest.web.framework.code.DefaultXmlSuiteRunnerGenerator.java
License:Apache License
/** * @param ele//from w ww .j a v a2s .com */ private void updateXmlDataSourceByEle(Element ele, String pagePackage, String pageClsStr) { SimpleDateFormat dateFormat = new SimpleDateFormat(); suiteRunnerDoc.addComment("Auto created by AutoTest, " + dateFormat.format(new Date())); SimpleNamespaceContext simpleNamespaceContext = new SimpleNamespaceContext(); simpleNamespaceContext.addNamespace("ns", "http://suite.surenpi.com"); XPath xpath = new DefaultXPath("/ns:suite"); xpath.setNamespaceContext(simpleNamespaceContext); //? Element dataSourcesEle = suiteRunnerDoc.getRootElement();//(Element) xpath.selectSingleNode(suiteRunnerDoc); if (dataSourcesEle == null) { String prefix = "suren"; dataSourcesEle = suiteRunnerDoc.addElement(prefix + ":suite"); dataSourcesEle.addNamespace(prefix, "http://suite.surenpi.com"); dataSourcesEle.addAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); dataSourcesEle.addAttribute("xsi:schemaLocation", "http://suite.surenpi.com " + "http://surenpi.com/schema/suite/autotest.web.framework.suite.xsd "); dataSourcesEle.addAttribute("pageConfig", this.srcCoding); dataSourcesEle.addAttribute("pagePackage", pagePackage); } xpath = new DefaultXPath("/ns:suite/ns:page[@class='" + pageClsStr + "']"); xpath.setNamespaceContext(simpleNamespaceContext); Element dataSourceEle = (Element) xpath.selectSingleNode(suiteRunnerDoc); if (dataSourceEle == null) { String prefix = dataSourcesEle.getNamespacePrefix(); if (StringUtils.isBlank("")) { String parentName = dataSourcesEle.getName(); if (parentName.contains(":")) { prefix = parentName.split(":")[0]; } } if (StringUtils.isNotBlank(prefix)) { prefix = prefix + ":"; } dataSourceEle = dataSourcesEle.addElement(prefix + "page"); dataSourceEle.addAttribute("class", pageClsStr); } //?? xpath = new DefaultXPath("/ns:suite/ns:page[@class='" + pageClsStr + "']/ns:actions[1]"); xpath.setNamespaceContext(simpleNamespaceContext); Element pageEle = (Element) xpath.selectSingleNode(dataSourceEle); if (pageEle == null) { String prefix = dataSourceEle.getNamespacePrefix(); if (StringUtils.isNotBlank(prefix)) { prefix = prefix + ":"; } pageEle = dataSourceEle.addElement(prefix + "actions"); } ele.accept(new PageFieldVisitor(pageEle)); }
From source file:zuora.ots_login_0_1.OTS_Login.java
License:Apache License
public void tFileInputXML_2Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tFileInputXML_2_SUBPROCESS_STATE", 0); final boolean execStat = this.execStat; String iterateId = ""; String currentComponent = ""; java.util.Map<String, Object> resourceMap = new java.util.HashMap<String, Object>(); try {// w w w. j av a 2 s . c om String currentMethodName = new java.lang.Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; row2Struct row2 = new row2Struct(); stage_OKStruct stage_OK = new stage_OKStruct(); /** * [tMysqlOutput_3 begin ] start */ ok_Hash.put("tMysqlOutput_3", false); start_Hash.put("tMysqlOutput_3", System.currentTimeMillis()); currentComponent = "tMysqlOutput_3"; int tos_count_tMysqlOutput_3 = 0; int nb_line_tMysqlOutput_3 = 0; int nb_line_update_tMysqlOutput_3 = 0; int nb_line_inserted_tMysqlOutput_3 = 0; int nb_line_deleted_tMysqlOutput_3 = 0; int nb_line_rejected_tMysqlOutput_3 = 0; int deletedCount_tMysqlOutput_3 = 0; int updatedCount_tMysqlOutput_3 = 0; int insertedCount_tMysqlOutput_3 = 0; int rejectedCount_tMysqlOutput_3 = 0; String tableName_tMysqlOutput_3 = "ots_job_state"; boolean whetherReject_tMysqlOutput_3 = false; java.util.Calendar calendar_tMysqlOutput_3 = java.util.Calendar.getInstance(); calendar_tMysqlOutput_3.set(1, 0, 1, 0, 0, 0); long year1_tMysqlOutput_3 = calendar_tMysqlOutput_3.getTime().getTime(); calendar_tMysqlOutput_3.set(10000, 0, 1, 0, 0, 0); long year10000_tMysqlOutput_3 = calendar_tMysqlOutput_3.getTime().getTime(); long date_tMysqlOutput_3; java.sql.Connection conn_tMysqlOutput_3 = null; String dbProperties_tMysqlOutput_3 = "noDatetimeStringSync=true"; String url_tMysqlOutput_3 = null; if (dbProperties_tMysqlOutput_3 == null || dbProperties_tMysqlOutput_3.trim().length() == 0) { url_tMysqlOutput_3 = "jdbc:mysql://" + "localhost" + ":" + "3306" + "/" + "fw_zuora" + "?" + "rewriteBatchedStatements=true"; } else { String properties_tMysqlOutput_3 = "noDatetimeStringSync=true"; if (!properties_tMysqlOutput_3.contains("rewriteBatchedStatements")) { properties_tMysqlOutput_3 += "&rewriteBatchedStatements=true"; } url_tMysqlOutput_3 = "jdbc:mysql://" + "localhost" + ":" + "3306" + "/" + "fw_zuora" + "?" + properties_tMysqlOutput_3; } String driverClass_tMysqlOutput_3 = "org.gjt.mm.mysql.Driver"; String dbUser_tMysqlOutput_3 = "root"; final String decryptedPassword_tMysqlOutput_3 = routines.system.PasswordEncryptUtil .decryptPassword("7a440551249af37a"); String dbPwd_tMysqlOutput_3 = decryptedPassword_tMysqlOutput_3; java.lang.Class.forName(driverClass_tMysqlOutput_3); conn_tMysqlOutput_3 = java.sql.DriverManager.getConnection(url_tMysqlOutput_3, dbUser_tMysqlOutput_3, dbPwd_tMysqlOutput_3); resourceMap.put("conn_tMysqlOutput_3", conn_tMysqlOutput_3); conn_tMysqlOutput_3.setAutoCommit(false); int commitEvery_tMysqlOutput_3 = 10000; int commitCounter_tMysqlOutput_3 = 0; int count_tMysqlOutput_3 = 0; String insert_tMysqlOutput_3 = "INSERT INTO `" + "ots_job_state" + "` (`id`,`stage`,`result`,`error`,`server_url`,`session`,`timestamp`) VALUES (?,?,?,?,?,?,?)"; int batchSize_tMysqlOutput_3 = 100; int batchSizeCounter_tMysqlOutput_3 = 0; java.sql.PreparedStatement pstmt_tMysqlOutput_3 = conn_tMysqlOutput_3 .prepareStatement(insert_tMysqlOutput_3); /** * [tMysqlOutput_3 begin ] stop */ /** * [tMap_1 begin ] start */ ok_Hash.put("tMap_1", false); start_Hash.put("tMap_1", System.currentTimeMillis()); currentComponent = "tMap_1"; int tos_count_tMap_1 = 0; // ############################### // # Lookup's keys initialization // ############################### // ############################### // # Vars initialization class Var__tMap_1__Struct { } Var__tMap_1__Struct Var__tMap_1 = new Var__tMap_1__Struct(); // ############################### // ############################### // # Outputs initialization stage_OKStruct stage_OK_tmp = new stage_OKStruct(); // ############################### /** * [tMap_1 begin ] stop */ /** * [tFileInputXML_2 begin ] start */ ok_Hash.put("tFileInputXML_2", false); start_Hash.put("tFileInputXML_2", System.currentTimeMillis()); currentComponent = "tFileInputXML_2"; int tos_count_tFileInputXML_2 = 0; int nb_line_tFileInputXML_2 = 0; String os_tFileInputXML_2 = System.getProperty("os.name").toLowerCase(); boolean isWindows_tFileInputXML_2 = false; if (os_tFileInputXML_2.indexOf("windows") > -1 || os_tFileInputXML_2.indexOf("nt") > -1) { isWindows_tFileInputXML_2 = true; } class NameSpaceTool_tFileInputXML_2 { public java.util.HashMap<String, String> xmlNameSpaceMap = new java.util.HashMap<String, String>(); private java.util.List<String> defualtNSPath = new java.util.ArrayList<String>(); public void countNSMap(org.dom4j.Element el) { for (org.dom4j.Namespace ns : (java.util.List<org.dom4j.Namespace>) el .declaredNamespaces()) { if (ns.getPrefix().trim().length() == 0) { xmlNameSpaceMap.put("pre" + defualtNSPath.size(), ns.getURI()); String path = ""; org.dom4j.Element elTmp = el; while (elTmp != null) { if (elTmp.getNamespacePrefix() != null && elTmp.getNamespacePrefix().length() > 0) { path = "/" + elTmp.getNamespacePrefix() + ":" + elTmp.getName() + path; } else { path = "/" + elTmp.getName() + path; } elTmp = elTmp.getParent(); } defualtNSPath.add(path); } else { xmlNameSpaceMap.put(ns.getPrefix(), ns.getURI()); } } for (org.dom4j.Element e : (java.util.List<org.dom4j.Element>) el.elements()) { countNSMap(e); } } private final org.talend.xpath.XPathUtil util = new org.talend.xpath.XPathUtil(); { util.setDefaultNSPath(defualtNSPath); } public String addDefaultNSPrefix(String path) { return util.addDefaultNSPrefix(path); } public String addDefaultNSPrefix(String relativeXpression, String basePath) { return util.addDefaultNSPrefix(relativeXpression, basePath); } } class XML_API_tFileInputXML_2 { public boolean isDefNull(org.dom4j.Node node) throws javax.xml.transform.TransformerException { if (node != null && node instanceof org.dom4j.Element) { org.dom4j.Attribute attri = ((org.dom4j.Element) node).attribute("nil"); if (attri != null && ("true").equals(attri.getText())) { return true; } } return false; } public boolean isMissing(org.dom4j.Node node) throws javax.xml.transform.TransformerException { return node == null ? true : false; } public boolean isEmpty(org.dom4j.Node node) throws javax.xml.transform.TransformerException { if (node != null) { return node.getText().length() == 0; } return false; } } org.dom4j.io.SAXReader reader_tFileInputXML_2 = new org.dom4j.io.SAXReader(); Object filename_tFileInputXML_2 = null; try { filename_tFileInputXML_2 = "C:/ETL_FASTWEB/ZUORA/data/responses/ots/login.xml"; } catch (java.lang.Exception e) { System.err.println(e.getMessage()); } if (filename_tFileInputXML_2 != null && filename_tFileInputXML_2 instanceof String && filename_tFileInputXML_2.toString().startsWith("//")) { if (!isWindows_tFileInputXML_2) { filename_tFileInputXML_2 = filename_tFileInputXML_2.toString().replaceFirst("//", "/"); } } boolean isValidFile_tFileInputXML_2 = true; org.dom4j.Document doc_tFileInputXML_2 = null; java.io.Closeable toClose_tFileInputXML_2 = null; try { if (filename_tFileInputXML_2 instanceof java.io.InputStream) { java.io.InputStream inputStream_tFileInputXML_2 = (java.io.InputStream) filename_tFileInputXML_2; toClose_tFileInputXML_2 = inputStream_tFileInputXML_2; doc_tFileInputXML_2 = reader_tFileInputXML_2.read(inputStream_tFileInputXML_2); } else { java.io.Reader unicodeReader_tFileInputXML_2 = new UnicodeReader( new java.io.FileInputStream(String.valueOf(filename_tFileInputXML_2)), "ISO-8859-15"); toClose_tFileInputXML_2 = unicodeReader_tFileInputXML_2; org.xml.sax.InputSource in_tFileInputXML_2 = new org.xml.sax.InputSource( unicodeReader_tFileInputXML_2); doc_tFileInputXML_2 = reader_tFileInputXML_2.read(in_tFileInputXML_2); } } catch (java.lang.Exception e) { System.err.println(e.getMessage()); isValidFile_tFileInputXML_2 = false; } finally { if (toClose_tFileInputXML_2 != null) { toClose_tFileInputXML_2.close(); } } if (isValidFile_tFileInputXML_2) { NameSpaceTool_tFileInputXML_2 nsTool_tFileInputXML_2 = new NameSpaceTool_tFileInputXML_2(); nsTool_tFileInputXML_2.countNSMap(doc_tFileInputXML_2.getRootElement()); java.util.HashMap<String, String> xmlNameSpaceMap_tFileInputXML_2 = nsTool_tFileInputXML_2.xmlNameSpaceMap; org.dom4j.XPath x_tFileInputXML_2 = doc_tFileInputXML_2.createXPath(nsTool_tFileInputXML_2 .addDefaultNSPrefix("/soapenv:Envelope/soapenv:Body/ns1:loginResponse/ns1:result")); x_tFileInputXML_2.setNamespaceURIs(xmlNameSpaceMap_tFileInputXML_2); java.util.List<org.dom4j.tree.AbstractNode> nodeList_tFileInputXML_2 = (java.util.List<org.dom4j.tree.AbstractNode>) x_tFileInputXML_2 .selectNodes(doc_tFileInputXML_2); XML_API_tFileInputXML_2 xml_api_tFileInputXML_2 = new XML_API_tFileInputXML_2(); String str_tFileInputXML_2 = ""; org.dom4j.Node node_tFileInputXML_2 = null; // init all mapping xpaths for (org.dom4j.tree.AbstractNode temp_tFileInputXML_2 : nodeList_tFileInputXML_2) { nb_line_tFileInputXML_2++; row2 = null; boolean whetherReject_tFileInputXML_2 = false; row2 = new row2Struct(); try { org.dom4j.XPath xTmp0_tFileInputXML_2 = org.dom4j.DocumentHelper .createXPath(nsTool_tFileInputXML_2.addDefaultNSPrefix("ns1:Session", "/soapenv:Envelope/soapenv:Body/ns1:loginResponse/ns1:result")); xTmp0_tFileInputXML_2.setNamespaceURIs(xmlNameSpaceMap_tFileInputXML_2); Object obj0_tFileInputXML_2 = xTmp0_tFileInputXML_2.evaluate(temp_tFileInputXML_2); if (obj0_tFileInputXML_2 == null) { node_tFileInputXML_2 = null; str_tFileInputXML_2 = ""; } else if (obj0_tFileInputXML_2 instanceof org.dom4j.Node) { node_tFileInputXML_2 = (org.dom4j.Node) obj0_tFileInputXML_2; str_tFileInputXML_2 = org.jaxen.function.StringFunction.evaluate( node_tFileInputXML_2, org.jaxen.dom4j.DocumentNavigator.getInstance()); } else if (obj0_tFileInputXML_2 instanceof String || obj0_tFileInputXML_2 instanceof Number) { node_tFileInputXML_2 = temp_tFileInputXML_2; str_tFileInputXML_2 = String.valueOf(obj0_tFileInputXML_2); } else if (obj0_tFileInputXML_2 instanceof java.util.List) { java.util.List<org.dom4j.Node> nodes_tFileInputXML_2 = (java.util.List<org.dom4j.Node>) obj0_tFileInputXML_2; node_tFileInputXML_2 = nodes_tFileInputXML_2.size() > 0 ? nodes_tFileInputXML_2.get(0) : null; str_tFileInputXML_2 = node_tFileInputXML_2 == null ? "" : org.jaxen.function.StringFunction.evaluate(node_tFileInputXML_2, org.jaxen.dom4j.DocumentNavigator.getInstance()); } if (xml_api_tFileInputXML_2.isDefNull(node_tFileInputXML_2)) { row2.Session = null; } else if (xml_api_tFileInputXML_2.isEmpty(node_tFileInputXML_2)) { row2.Session = ""; } else if (xml_api_tFileInputXML_2.isMissing(node_tFileInputXML_2)) { row2.Session = null; } else { row2.Session = str_tFileInputXML_2; } org.dom4j.XPath xTmp1_tFileInputXML_2 = org.dom4j.DocumentHelper .createXPath(nsTool_tFileInputXML_2.addDefaultNSPrefix("ns1:ServerUrl", "/soapenv:Envelope/soapenv:Body/ns1:loginResponse/ns1:result")); xTmp1_tFileInputXML_2.setNamespaceURIs(xmlNameSpaceMap_tFileInputXML_2); Object obj1_tFileInputXML_2 = xTmp1_tFileInputXML_2.evaluate(temp_tFileInputXML_2); if (obj1_tFileInputXML_2 == null) { node_tFileInputXML_2 = null; str_tFileInputXML_2 = ""; } else if (obj1_tFileInputXML_2 instanceof org.dom4j.Node) { node_tFileInputXML_2 = (org.dom4j.Node) obj1_tFileInputXML_2; str_tFileInputXML_2 = org.jaxen.function.StringFunction.evaluate( node_tFileInputXML_2, org.jaxen.dom4j.DocumentNavigator.getInstance()); } else if (obj1_tFileInputXML_2 instanceof String || obj1_tFileInputXML_2 instanceof Number) { node_tFileInputXML_2 = temp_tFileInputXML_2; str_tFileInputXML_2 = String.valueOf(obj1_tFileInputXML_2); } else if (obj1_tFileInputXML_2 instanceof java.util.List) { java.util.List<org.dom4j.Node> nodes_tFileInputXML_2 = (java.util.List<org.dom4j.Node>) obj1_tFileInputXML_2; node_tFileInputXML_2 = nodes_tFileInputXML_2.size() > 0 ? nodes_tFileInputXML_2.get(0) : null; str_tFileInputXML_2 = node_tFileInputXML_2 == null ? "" : org.jaxen.function.StringFunction.evaluate(node_tFileInputXML_2, org.jaxen.dom4j.DocumentNavigator.getInstance()); } if (xml_api_tFileInputXML_2.isDefNull(node_tFileInputXML_2)) { row2.ServerUrl = null; } else if (xml_api_tFileInputXML_2.isEmpty(node_tFileInputXML_2)) { row2.ServerUrl = ""; } else if (xml_api_tFileInputXML_2.isMissing(node_tFileInputXML_2)) { row2.ServerUrl = null; } else { row2.ServerUrl = str_tFileInputXML_2; } } catch (java.lang.Exception e) { whetherReject_tFileInputXML_2 = true; System.err.println(e.getMessage()); row2 = null; } if (nb_line_tFileInputXML_2 > 50) { break; } /** * [tFileInputXML_2 begin ] stop */ /** * [tFileInputXML_2 main ] start */ currentComponent = "tFileInputXML_2"; tos_count_tFileInputXML_2++; /** * [tFileInputXML_2 main ] stop */ // Start of branch "row2" if (row2 != null) { /** * [tMap_1 main ] start */ currentComponent = "tMap_1"; boolean hasCasePrimitiveKeyWithNull_tMap_1 = false; // ############################### // # Input tables (lookups) boolean rejectedInnerJoin_tMap_1 = false; boolean mainRowRejected_tMap_1 = false; // ############################### { // start of Var scope // ############################### // # Vars tables Var__tMap_1__Struct Var = Var__tMap_1;// ############################### // ############################### // # Output tables stage_OK = null; // # Output table : 'stage_OK' stage_OK_tmp.id = 0; stage_OK_tmp.stage = (String) globalMap.get("stage"); stage_OK_tmp.result = "OK"; stage_OK_tmp.error = null; stage_OK_tmp.server_url = row2.ServerUrl; stage_OK_tmp.session = row2.Session; stage_OK_tmp.timestamp = TalendDate.getCurrentDate(); stage_OK = stage_OK_tmp; // ############################### } // end of Var scope rejectedInnerJoin_tMap_1 = false; tos_count_tMap_1++; /** * [tMap_1 main ] stop */ // Start of branch "stage_OK" if (stage_OK != null) { /** * [tMysqlOutput_3 main ] start */ currentComponent = "tMysqlOutput_3"; whetherReject_tMysqlOutput_3 = false; pstmt_tMysqlOutput_3.setLong(1, stage_OK.id); if (stage_OK.stage == null) { pstmt_tMysqlOutput_3.setNull(2, java.sql.Types.OTHER); } else { pstmt_tMysqlOutput_3.setObject(2, stage_OK.stage); } if (stage_OK.result == null) { pstmt_tMysqlOutput_3.setNull(3, java.sql.Types.OTHER); } else { pstmt_tMysqlOutput_3.setObject(3, stage_OK.result); } if (stage_OK.error == null) { pstmt_tMysqlOutput_3.setNull(4, java.sql.Types.VARCHAR); } else { pstmt_tMysqlOutput_3.setString(4, stage_OK.error); } if (stage_OK.server_url == null) { pstmt_tMysqlOutput_3.setNull(5, java.sql.Types.VARCHAR); } else { pstmt_tMysqlOutput_3.setString(5, stage_OK.server_url); } if (stage_OK.session == null) { pstmt_tMysqlOutput_3.setNull(6, java.sql.Types.VARCHAR); } else { pstmt_tMysqlOutput_3.setString(6, stage_OK.session); } if (stage_OK.timestamp != null) { date_tMysqlOutput_3 = stage_OK.timestamp.getTime(); if (date_tMysqlOutput_3 < year1_tMysqlOutput_3 || date_tMysqlOutput_3 >= year10000_tMysqlOutput_3) { pstmt_tMysqlOutput_3.setString(7, "0000-00-00 00:00:00"); } else { pstmt_tMysqlOutput_3.setTimestamp(7, new java.sql.Timestamp(date_tMysqlOutput_3)); } } else { pstmt_tMysqlOutput_3.setNull(7, java.sql.Types.DATE); } pstmt_tMysqlOutput_3.addBatch(); nb_line_tMysqlOutput_3++; batchSizeCounter_tMysqlOutput_3++; if (batchSize_tMysqlOutput_3 <= batchSizeCounter_tMysqlOutput_3) { try { int countSum_tMysqlOutput_3 = 0; for (int countEach_tMysqlOutput_3 : pstmt_tMysqlOutput_3.executeBatch()) { countSum_tMysqlOutput_3 += (countEach_tMysqlOutput_3 < 0 ? 0 : 1); } insertedCount_tMysqlOutput_3 += countSum_tMysqlOutput_3; } catch (java.sql.BatchUpdateException e) { int countSum_tMysqlOutput_3 = 0; for (int countEach_tMysqlOutput_3 : e.getUpdateCounts()) { countSum_tMysqlOutput_3 += (countEach_tMysqlOutput_3 < 0 ? 0 : countEach_tMysqlOutput_3); } insertedCount_tMysqlOutput_3 += countSum_tMysqlOutput_3; System.err.println(e.getMessage()); } batchSizeCounter_tMysqlOutput_3 = 0; } commitCounter_tMysqlOutput_3++; if (commitEvery_tMysqlOutput_3 <= commitCounter_tMysqlOutput_3) { try { int countSum_tMysqlOutput_3 = 0; for (int countEach_tMysqlOutput_3 : pstmt_tMysqlOutput_3.executeBatch()) { countSum_tMysqlOutput_3 += (countEach_tMysqlOutput_3 < 0 ? 0 : 1); } insertedCount_tMysqlOutput_3 += countSum_tMysqlOutput_3; } catch (java.sql.BatchUpdateException e) { int countSum_tMysqlOutput_3 = 0; for (int countEach_tMysqlOutput_3 : e.getUpdateCounts()) { countSum_tMysqlOutput_3 += (countEach_tMysqlOutput_3 < 0 ? 0 : countEach_tMysqlOutput_3); } insertedCount_tMysqlOutput_3 += countSum_tMysqlOutput_3; System.err.println(e.getMessage()); } conn_tMysqlOutput_3.commit(); commitCounter_tMysqlOutput_3 = 0; } tos_count_tMysqlOutput_3++; /** * [tMysqlOutput_3 main ] stop */ } // End of branch "stage_OK" } // End of branch "row2" /** * [tFileInputXML_2 end ] start */ currentComponent = "tFileInputXML_2"; } } globalMap.put("tFileInputXML_2_NB_LINE", nb_line_tFileInputXML_2); ok_Hash.put("tFileInputXML_2", true); end_Hash.put("tFileInputXML_2", System.currentTimeMillis()); /** * [tFileInputXML_2 end ] stop */ /** * [tMap_1 end ] start */ currentComponent = "tMap_1"; // ############################### // # Lookup hashes releasing // ############################### ok_Hash.put("tMap_1", true); end_Hash.put("tMap_1", System.currentTimeMillis()); /** * [tMap_1 end ] stop */ /** * [tMysqlOutput_3 end ] start */ currentComponent = "tMysqlOutput_3"; try { if (batchSizeCounter_tMysqlOutput_3 != 0) { int countSum_tMysqlOutput_3 = 0; for (int countEach_tMysqlOutput_3 : pstmt_tMysqlOutput_3.executeBatch()) { countSum_tMysqlOutput_3 += (countEach_tMysqlOutput_3 < 0 ? 0 : 1); } insertedCount_tMysqlOutput_3 += countSum_tMysqlOutput_3; } } catch (java.sql.BatchUpdateException e) { int countSum_tMysqlOutput_3 = 0; for (int countEach_tMysqlOutput_3 : e.getUpdateCounts()) { countSum_tMysqlOutput_3 += (countEach_tMysqlOutput_3 < 0 ? 0 : countEach_tMysqlOutput_3); } insertedCount_tMysqlOutput_3 += countSum_tMysqlOutput_3; System.err.println(e.getMessage()); } batchSizeCounter_tMysqlOutput_3 = 0; if (pstmt_tMysqlOutput_3 != null) { pstmt_tMysqlOutput_3.close(); } if (commitCounter_tMysqlOutput_3 > 0) { conn_tMysqlOutput_3.commit(); } conn_tMysqlOutput_3.close(); resourceMap.put("finish_tMysqlOutput_3", true); nb_line_deleted_tMysqlOutput_3 = nb_line_deleted_tMysqlOutput_3 + deletedCount_tMysqlOutput_3; nb_line_update_tMysqlOutput_3 = nb_line_update_tMysqlOutput_3 + updatedCount_tMysqlOutput_3; nb_line_inserted_tMysqlOutput_3 = nb_line_inserted_tMysqlOutput_3 + insertedCount_tMysqlOutput_3; nb_line_rejected_tMysqlOutput_3 = nb_line_rejected_tMysqlOutput_3 + rejectedCount_tMysqlOutput_3; globalMap.put("tMysqlOutput_3_NB_LINE", nb_line_tMysqlOutput_3); globalMap.put("tMysqlOutput_3_NB_LINE_UPDATED", nb_line_update_tMysqlOutput_3); globalMap.put("tMysqlOutput_3_NB_LINE_INSERTED", nb_line_inserted_tMysqlOutput_3); globalMap.put("tMysqlOutput_3_NB_LINE_DELETED", nb_line_deleted_tMysqlOutput_3); globalMap.put("tMysqlOutput_3_NB_LINE_REJECTED", nb_line_rejected_tMysqlOutput_3); ok_Hash.put("tMysqlOutput_3", true); end_Hash.put("tMysqlOutput_3", System.currentTimeMillis()); /** * [tMysqlOutput_3 end ] stop */ } // end the resume } catch (java.lang.Exception e) { TalendException te = new TalendException(e, currentComponent, globalMap); throw te; } catch (java.lang.Error error) { throw error; } finally { try { /** * [tFileInputXML_2 finally ] start */ currentComponent = "tFileInputXML_2"; /** * [tFileInputXML_2 finally ] stop */ /** * [tMap_1 finally ] start */ currentComponent = "tMap_1"; /** * [tMap_1 finally ] stop */ /** * [tMysqlOutput_3 finally ] start */ currentComponent = "tMysqlOutput_3"; if (resourceMap.get("finish_tMysqlOutput_3") == null) { if (resourceMap.get("conn_tMysqlOutput_3") != null) { try { ((java.sql.Connection) resourceMap.get("conn_tMysqlOutput_3")).close(); } catch (java.sql.SQLException sqlEx_tMysqlOutput_3) { String errorMessage_tMysqlOutput_3 = "failed to close the connection in tMysqlOutput_3 :" + sqlEx_tMysqlOutput_3.getMessage(); System.err.println(errorMessage_tMysqlOutput_3); } } } /** * [tMysqlOutput_3 finally ] stop */ } catch (java.lang.Exception e) { // ignore } catch (java.lang.Error error) { // ignore } resourceMap = null; } globalMap.put("tFileInputXML_2_SUBPROCESS_STATE", 1); }
From source file:zuora.ots_login_0_1.OTS_Login.java
License:Apache License
public void tFileInputXML_1Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tFileInputXML_1_SUBPROCESS_STATE", 0); final boolean execStat = this.execStat; String currentVirtualComponent = null; String iterateId = ""; String currentComponent = ""; java.util.Map<String, Object> resourceMap = new java.util.HashMap<String, Object>(); try {/* w ww . ja v a 2s. co m*/ String currentMethodName = new java.lang.Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; row5Struct row5 = new row5Struct(); /** * [tWriteJSONField_2_Out begin ] start */ ok_Hash.put("tWriteJSONField_2_Out", false); start_Hash.put("tWriteJSONField_2_Out", System.currentTimeMillis()); currentVirtualComponent = "tWriteJSONField_2"; currentComponent = "tWriteJSONField_2_Out"; int tos_count_tWriteJSONField_2_Out = 0; // tWriteXMLFieldOut_begin int nb_line_tWriteJSONField_2_Out = 0; boolean needRoot_tWriteJSONField_2_Out = true; String strCompCache_tWriteJSONField_2_Out = null; java.util.Queue<row3Struct> listGroupby_tWriteJSONField_2_Out = new java.util.concurrent.ConcurrentLinkedQueue<row3Struct>(); class ThreadXMLField_tWriteJSONField_2_Out extends Thread { java.util.Queue<row3Struct> queue; java.util.List<java.util.Map<String, String>> flows; java.lang.Exception lastException; String currentComponent; ThreadXMLField_tWriteJSONField_2_Out(java.util.Queue q) { this.queue = q; globalMap.put("queue_tWriteJSONField_2_In", queue); lastException = null; } ThreadXMLField_tWriteJSONField_2_Out(java.util.Queue q, java.util.List<java.util.Map<String, String>> l) { this.queue = q; this.flows = l; lastException = null; globalMap.put("queue_tWriteJSONField_2_In", queue); globalMap.put("flows_tWriteJSONField_2_In", flows); } public java.lang.Exception getLastException() { return this.lastException; } public String getCurrentComponent() { return this.currentComponent; } @Override public void run() { try { tWriteJSONField_2_InProcess(globalMap); } catch (TalendException te) { this.lastException = te.getException(); this.currentComponent = te.getCurrentComponent(); } } } ThreadXMLField_tWriteJSONField_2_Out txf_tWriteJSONField_2_Out = new ThreadXMLField_tWriteJSONField_2_Out( listGroupby_tWriteJSONField_2_Out); txf_tWriteJSONField_2_Out.start(); java.util.List<java.util.List<String>> groupbyList_tWriteJSONField_2_Out = new java.util.ArrayList<java.util.List<String>>(); java.util.Map<String, String> valueMap_tWriteJSONField_2_Out = new java.util.HashMap<String, String>(); class NestXMLTool_tWriteJSONField_2_Out { public void parseAndAdd(org.dom4j.Element nestRoot, String value) { try { org.dom4j.Document doc4Str = org.dom4j.DocumentHelper .parseText("<root>" + value + "</root>"); nestRoot.setContent(doc4Str.getRootElement().content()); } catch (java.lang.Exception e) { e.printStackTrace(); nestRoot.setText(value); } } public void setText(org.dom4j.Element element, String value) { if (value.startsWith("<![CDATA[") && value.endsWith("]]>")) { String text = value.substring(9, value.length() - 3); element.addCDATA(text); } else { element.setText(value); } } public void replaceDefaultNameSpace(org.dom4j.Element nestRoot) { if (nestRoot != null) { for (org.dom4j.Element tmp : (java.util.List<org.dom4j.Element>) nestRoot.elements()) { if (("").equals(tmp.getQName().getNamespace().getURI()) && ("").equals(tmp.getQName().getNamespace().getPrefix())) { tmp.setQName(org.dom4j.DocumentHelper.createQName(tmp.getName(), nestRoot.getQName().getNamespace())); } replaceDefaultNameSpace(tmp); } } } public void removeEmptyElement(org.dom4j.Element root) { if (root != null) { for (org.dom4j.Element tmp : (java.util.List<org.dom4j.Element>) root.elements()) { removeEmptyElement(tmp); } if (root.content().size() == 0 && root.attributes().size() == 0 && root.declaredNamespaces().size() == 0) { if (root.getParent() != null) { root.getParent().remove(root); } } } } } NestXMLTool_tWriteJSONField_2_Out nestXMLTool_tWriteJSONField_2_Out = new NestXMLTool_tWriteJSONField_2_Out(); row5Struct rowStructOutput_tWriteJSONField_2_Out = null; // sort group root element for judgement of group java.util.List<org.dom4j.Element> groupElementList_tWriteJSONField_2_Out = new java.util.ArrayList<org.dom4j.Element>(); org.dom4j.Element root4Group_tWriteJSONField_2_Out = null; org.dom4j.Document doc_tWriteJSONField_2_Out = org.dom4j.DocumentHelper.createDocument(); org.dom4j.io.OutputFormat format_tWriteJSONField_2_Out = org.dom4j.io.OutputFormat .createCompactFormat(); format_tWriteJSONField_2_Out.setNewLineAfterDeclaration(false); format_tWriteJSONField_2_Out.setTrimText(false); format_tWriteJSONField_2_Out.setEncoding("ISO-8859-15"); int[] orders_tWriteJSONField_2_Out = new int[1]; /** * [tWriteJSONField_2_Out begin ] stop */ /** * [tFileInputXML_1 begin ] start */ ok_Hash.put("tFileInputXML_1", false); start_Hash.put("tFileInputXML_1", System.currentTimeMillis()); currentComponent = "tFileInputXML_1"; int tos_count_tFileInputXML_1 = 0; int nb_line_tFileInputXML_1 = 0; String os_tFileInputXML_1 = System.getProperty("os.name").toLowerCase(); boolean isWindows_tFileInputXML_1 = false; if (os_tFileInputXML_1.indexOf("windows") > -1 || os_tFileInputXML_1.indexOf("nt") > -1) { isWindows_tFileInputXML_1 = true; } class NameSpaceTool_tFileInputXML_1 { public java.util.HashMap<String, String> xmlNameSpaceMap = new java.util.HashMap<String, String>(); private java.util.List<String> defualtNSPath = new java.util.ArrayList<String>(); public void countNSMap(org.dom4j.Element el) { for (org.dom4j.Namespace ns : (java.util.List<org.dom4j.Namespace>) el .declaredNamespaces()) { if (ns.getPrefix().trim().length() == 0) { xmlNameSpaceMap.put("pre" + defualtNSPath.size(), ns.getURI()); String path = ""; org.dom4j.Element elTmp = el; while (elTmp != null) { if (elTmp.getNamespacePrefix() != null && elTmp.getNamespacePrefix().length() > 0) { path = "/" + elTmp.getNamespacePrefix() + ":" + elTmp.getName() + path; } else { path = "/" + elTmp.getName() + path; } elTmp = elTmp.getParent(); } defualtNSPath.add(path); } else { xmlNameSpaceMap.put(ns.getPrefix(), ns.getURI()); } } for (org.dom4j.Element e : (java.util.List<org.dom4j.Element>) el.elements()) { countNSMap(e); } } private final org.talend.xpath.XPathUtil util = new org.talend.xpath.XPathUtil(); { util.setDefaultNSPath(defualtNSPath); } public String addDefaultNSPrefix(String path) { return util.addDefaultNSPrefix(path); } public String addDefaultNSPrefix(String relativeXpression, String basePath) { return util.addDefaultNSPrefix(relativeXpression, basePath); } } class XML_API_tFileInputXML_1 { public boolean isDefNull(org.dom4j.Node node) throws javax.xml.transform.TransformerException { if (node != null && node instanceof org.dom4j.Element) { org.dom4j.Attribute attri = ((org.dom4j.Element) node).attribute("nil"); if (attri != null && ("true").equals(attri.getText())) { return true; } } return false; } public boolean isMissing(org.dom4j.Node node) throws javax.xml.transform.TransformerException { return node == null ? true : false; } public boolean isEmpty(org.dom4j.Node node) throws javax.xml.transform.TransformerException { if (node != null) { return node.getText().length() == 0; } return false; } } org.dom4j.io.SAXReader reader_tFileInputXML_1 = new org.dom4j.io.SAXReader(); Object filename_tFileInputXML_1 = null; try { filename_tFileInputXML_1 = "C:/ETL_FASTWEB/ZUORA/data/responses/ots/login.xml"; } catch (java.lang.Exception e) { System.err.println(e.getMessage()); } if (filename_tFileInputXML_1 != null && filename_tFileInputXML_1 instanceof String && filename_tFileInputXML_1.toString().startsWith("//")) { if (!isWindows_tFileInputXML_1) { filename_tFileInputXML_1 = filename_tFileInputXML_1.toString().replaceFirst("//", "/"); } } boolean isValidFile_tFileInputXML_1 = true; org.dom4j.Document doc_tFileInputXML_1 = null; java.io.Closeable toClose_tFileInputXML_1 = null; try { if (filename_tFileInputXML_1 instanceof java.io.InputStream) { java.io.InputStream inputStream_tFileInputXML_1 = (java.io.InputStream) filename_tFileInputXML_1; toClose_tFileInputXML_1 = inputStream_tFileInputXML_1; doc_tFileInputXML_1 = reader_tFileInputXML_1.read(inputStream_tFileInputXML_1); } else { java.io.Reader unicodeReader_tFileInputXML_1 = new UnicodeReader( new java.io.FileInputStream(String.valueOf(filename_tFileInputXML_1)), "ISO-8859-15"); toClose_tFileInputXML_1 = unicodeReader_tFileInputXML_1; org.xml.sax.InputSource in_tFileInputXML_1 = new org.xml.sax.InputSource( unicodeReader_tFileInputXML_1); doc_tFileInputXML_1 = reader_tFileInputXML_1.read(in_tFileInputXML_1); } } catch (java.lang.Exception e) { System.err.println(e.getMessage()); isValidFile_tFileInputXML_1 = false; } finally { if (toClose_tFileInputXML_1 != null) { toClose_tFileInputXML_1.close(); } } if (isValidFile_tFileInputXML_1) { NameSpaceTool_tFileInputXML_1 nsTool_tFileInputXML_1 = new NameSpaceTool_tFileInputXML_1(); nsTool_tFileInputXML_1.countNSMap(doc_tFileInputXML_1.getRootElement()); java.util.HashMap<String, String> xmlNameSpaceMap_tFileInputXML_1 = nsTool_tFileInputXML_1.xmlNameSpaceMap; org.dom4j.XPath x_tFileInputXML_1 = doc_tFileInputXML_1.createXPath(nsTool_tFileInputXML_1 .addDefaultNSPrefix("/soapenv:Envelope/soapenv:Body/soapenv:Fault")); x_tFileInputXML_1.setNamespaceURIs(xmlNameSpaceMap_tFileInputXML_1); java.util.List<org.dom4j.tree.AbstractNode> nodeList_tFileInputXML_1 = (java.util.List<org.dom4j.tree.AbstractNode>) x_tFileInputXML_1 .selectNodes(doc_tFileInputXML_1); XML_API_tFileInputXML_1 xml_api_tFileInputXML_1 = new XML_API_tFileInputXML_1(); String str_tFileInputXML_1 = ""; org.dom4j.Node node_tFileInputXML_1 = null; // init all mapping xpaths for (org.dom4j.tree.AbstractNode temp_tFileInputXML_1 : nodeList_tFileInputXML_1) { nb_line_tFileInputXML_1++; row5 = null; boolean whetherReject_tFileInputXML_1 = false; row5 = new row5Struct(); try { org.dom4j.XPath xTmp0_tFileInputXML_1 = org.dom4j.DocumentHelper .createXPath(nsTool_tFileInputXML_1.addDefaultNSPrefix("faultcode", "/soapenv:Envelope/soapenv:Body/soapenv:Fault")); xTmp0_tFileInputXML_1.setNamespaceURIs(xmlNameSpaceMap_tFileInputXML_1); Object obj0_tFileInputXML_1 = xTmp0_tFileInputXML_1.evaluate(temp_tFileInputXML_1); if (obj0_tFileInputXML_1 == null) { node_tFileInputXML_1 = null; str_tFileInputXML_1 = ""; } else if (obj0_tFileInputXML_1 instanceof org.dom4j.Node) { node_tFileInputXML_1 = (org.dom4j.Node) obj0_tFileInputXML_1; str_tFileInputXML_1 = org.jaxen.function.StringFunction.evaluate( node_tFileInputXML_1, org.jaxen.dom4j.DocumentNavigator.getInstance()); } else if (obj0_tFileInputXML_1 instanceof String || obj0_tFileInputXML_1 instanceof Number) { node_tFileInputXML_1 = temp_tFileInputXML_1; str_tFileInputXML_1 = String.valueOf(obj0_tFileInputXML_1); } else if (obj0_tFileInputXML_1 instanceof java.util.List) { java.util.List<org.dom4j.Node> nodes_tFileInputXML_1 = (java.util.List<org.dom4j.Node>) obj0_tFileInputXML_1; node_tFileInputXML_1 = nodes_tFileInputXML_1.size() > 0 ? nodes_tFileInputXML_1.get(0) : null; str_tFileInputXML_1 = node_tFileInputXML_1 == null ? "" : org.jaxen.function.StringFunction.evaluate(node_tFileInputXML_1, org.jaxen.dom4j.DocumentNavigator.getInstance()); } if (xml_api_tFileInputXML_1.isDefNull(node_tFileInputXML_1)) { row5.faultcode = null; } else if (xml_api_tFileInputXML_1.isEmpty(node_tFileInputXML_1)) { row5.faultcode = ""; } else if (xml_api_tFileInputXML_1.isMissing(node_tFileInputXML_1)) { row5.faultcode = null; } else { row5.faultcode = str_tFileInputXML_1; } org.dom4j.XPath xTmp1_tFileInputXML_1 = org.dom4j.DocumentHelper .createXPath(nsTool_tFileInputXML_1.addDefaultNSPrefix("faultstring", "/soapenv:Envelope/soapenv:Body/soapenv:Fault")); xTmp1_tFileInputXML_1.setNamespaceURIs(xmlNameSpaceMap_tFileInputXML_1); Object obj1_tFileInputXML_1 = xTmp1_tFileInputXML_1.evaluate(temp_tFileInputXML_1); if (obj1_tFileInputXML_1 == null) { node_tFileInputXML_1 = null; str_tFileInputXML_1 = ""; } else if (obj1_tFileInputXML_1 instanceof org.dom4j.Node) { node_tFileInputXML_1 = (org.dom4j.Node) obj1_tFileInputXML_1; str_tFileInputXML_1 = org.jaxen.function.StringFunction.evaluate( node_tFileInputXML_1, org.jaxen.dom4j.DocumentNavigator.getInstance()); } else if (obj1_tFileInputXML_1 instanceof String || obj1_tFileInputXML_1 instanceof Number) { node_tFileInputXML_1 = temp_tFileInputXML_1; str_tFileInputXML_1 = String.valueOf(obj1_tFileInputXML_1); } else if (obj1_tFileInputXML_1 instanceof java.util.List) { java.util.List<org.dom4j.Node> nodes_tFileInputXML_1 = (java.util.List<org.dom4j.Node>) obj1_tFileInputXML_1; node_tFileInputXML_1 = nodes_tFileInputXML_1.size() > 0 ? nodes_tFileInputXML_1.get(0) : null; str_tFileInputXML_1 = node_tFileInputXML_1 == null ? "" : org.jaxen.function.StringFunction.evaluate(node_tFileInputXML_1, org.jaxen.dom4j.DocumentNavigator.getInstance()); } if (xml_api_tFileInputXML_1.isDefNull(node_tFileInputXML_1)) { row5.faultstring = null; } else if (xml_api_tFileInputXML_1.isEmpty(node_tFileInputXML_1)) { row5.faultstring = ""; } else if (xml_api_tFileInputXML_1.isMissing(node_tFileInputXML_1)) { row5.faultstring = null; } else { row5.faultstring = str_tFileInputXML_1; } } catch (java.lang.Exception e) { whetherReject_tFileInputXML_1 = true; System.err.println(e.getMessage()); row5 = null; } if (nb_line_tFileInputXML_1 > 50) { break; } /** * [tFileInputXML_1 begin ] stop */ /** * [tFileInputXML_1 main ] start */ currentComponent = "tFileInputXML_1"; tos_count_tFileInputXML_1++; /** * [tFileInputXML_1 main ] stop */ // Start of branch "row5" if (row5 != null) { /** * [tWriteJSONField_2_Out main ] start */ currentVirtualComponent = "tWriteJSONField_2"; currentComponent = "tWriteJSONField_2_Out"; if (txf_tWriteJSONField_2_Out.getLastException() != null) { currentComponent = txf_tWriteJSONField_2_Out.getCurrentComponent(); throw txf_tWriteJSONField_2_Out.getLastException(); } nb_line_tWriteJSONField_2_Out++; valueMap_tWriteJSONField_2_Out.clear(); valueMap_tWriteJSONField_2_Out.put("faultcode", (row5.faultcode != null ? row5.faultcode.toString() : null)); valueMap_tWriteJSONField_2_Out.put("faultstring", (row5.faultstring != null ? row5.faultstring.toString() : null)); String strTemp_tWriteJSONField_2_Out = ""; strTemp_tWriteJSONField_2_Out = strTemp_tWriteJSONField_2_Out + valueMap_tWriteJSONField_2_Out.get("faultcode") + valueMap_tWriteJSONField_2_Out.get("faultcode").length(); strTemp_tWriteJSONField_2_Out = strTemp_tWriteJSONField_2_Out + valueMap_tWriteJSONField_2_Out.get("faultstring") + valueMap_tWriteJSONField_2_Out.get("faultstring").length(); if (strCompCache_tWriteJSONField_2_Out == null) { strCompCache_tWriteJSONField_2_Out = strTemp_tWriteJSONField_2_Out; rowStructOutput_tWriteJSONField_2_Out = row5; } else { // the data read is different from the data read // last time. if (strCompCache_tWriteJSONField_2_Out .equals(strTemp_tWriteJSONField_2_Out) == false) { nestXMLTool_tWriteJSONField_2_Out .replaceDefaultNameSpace(doc_tWriteJSONField_2_Out.getRootElement()); java.io.StringWriter strWriter_tWriteJSONField_2_Out = new java.io.StringWriter(); org.dom4j.io.XMLWriter output_tWriteJSONField_2_Out = new org.dom4j.io.XMLWriter( strWriter_tWriteJSONField_2_Out, format_tWriteJSONField_2_Out); output_tWriteJSONField_2_Out.write(doc_tWriteJSONField_2_Out); output_tWriteJSONField_2_Out.close(); row3Struct row_tWriteJSONField_2_Out = new row3Struct(); row_tWriteJSONField_2_Out.result = strWriter_tWriteJSONField_2_Out.toString(); listGroupby_tWriteJSONField_2_Out.add(row_tWriteJSONField_2_Out); doc_tWriteJSONField_2_Out.clearContent(); needRoot_tWriteJSONField_2_Out = true; for (int i_tWriteJSONField_2_Out = 0; i_tWriteJSONField_2_Out < orders_tWriteJSONField_2_Out.length; i_tWriteJSONField_2_Out++) { orders_tWriteJSONField_2_Out[i_tWriteJSONField_2_Out] = 0; } if (groupbyList_tWriteJSONField_2_Out != null && groupbyList_tWriteJSONField_2_Out.size() >= 0) { groupbyList_tWriteJSONField_2_Out.clear(); } strCompCache_tWriteJSONField_2_Out = strTemp_tWriteJSONField_2_Out; rowStructOutput_tWriteJSONField_2_Out = row5; } } org.dom4j.Element subTreeRootParent_tWriteJSONField_2_Out = null; // build root xml tree if (needRoot_tWriteJSONField_2_Out) { needRoot_tWriteJSONField_2_Out = false; org.dom4j.Element root_tWriteJSONField_2_Out = doc_tWriteJSONField_2_Out .addElement("result"); subTreeRootParent_tWriteJSONField_2_Out = root_tWriteJSONField_2_Out; org.dom4j.Element root_0_tWriteJSONField_2_Out = root_tWriteJSONField_2_Out .addElement("faultstring"); if (valueMap_tWriteJSONField_2_Out.get("faultstring") != null) { nestXMLTool_tWriteJSONField_2_Out.setText(root_0_tWriteJSONField_2_Out, valueMap_tWriteJSONField_2_Out.get("faultstring")); } root4Group_tWriteJSONField_2_Out = subTreeRootParent_tWriteJSONField_2_Out; } else { subTreeRootParent_tWriteJSONField_2_Out = root4Group_tWriteJSONField_2_Out; } // build group xml tree // build loop xml tree org.dom4j.Element loop_tWriteJSONField_2_Out = org.dom4j.DocumentHelper .createElement("faultcode"); if (orders_tWriteJSONField_2_Out[0] == 0) { orders_tWriteJSONField_2_Out[0] = 0; } if (1 < orders_tWriteJSONField_2_Out.length) { orders_tWriteJSONField_2_Out[1] = 0; } subTreeRootParent_tWriteJSONField_2_Out.elements() .add(orders_tWriteJSONField_2_Out[0]++, loop_tWriteJSONField_2_Out); if (valueMap_tWriteJSONField_2_Out.get("faultcode") != null) { nestXMLTool_tWriteJSONField_2_Out.setText(loop_tWriteJSONField_2_Out, valueMap_tWriteJSONField_2_Out.get("faultcode")); } tos_count_tWriteJSONField_2_Out++; /** * [tWriteJSONField_2_Out main ] stop */ } // End of branch "row5" /** * [tFileInputXML_1 end ] start */ currentComponent = "tFileInputXML_1"; } } globalMap.put("tFileInputXML_1_NB_LINE", nb_line_tFileInputXML_1); ok_Hash.put("tFileInputXML_1", true); end_Hash.put("tFileInputXML_1", System.currentTimeMillis()); /** * [tFileInputXML_1 end ] stop */ /** * [tWriteJSONField_2_Out end ] start */ currentVirtualComponent = "tWriteJSONField_2"; currentComponent = "tWriteJSONField_2_Out"; if (nb_line_tWriteJSONField_2_Out > 0) { nestXMLTool_tWriteJSONField_2_Out .replaceDefaultNameSpace(doc_tWriteJSONField_2_Out.getRootElement()); java.io.StringWriter strWriter_tWriteJSONField_2_Out = new java.io.StringWriter(); org.dom4j.io.XMLWriter output_tWriteJSONField_2_Out = new org.dom4j.io.XMLWriter( strWriter_tWriteJSONField_2_Out, format_tWriteJSONField_2_Out); output_tWriteJSONField_2_Out.write(doc_tWriteJSONField_2_Out); output_tWriteJSONField_2_Out.close(); row3Struct row_tWriteJSONField_2_Out = new row3Struct(); row_tWriteJSONField_2_Out.result = strWriter_tWriteJSONField_2_Out.toString(); listGroupby_tWriteJSONField_2_Out.add(row_tWriteJSONField_2_Out); } globalMap.put("tWriteJSONField_2_Out_NB_LINE", nb_line_tWriteJSONField_2_Out); globalMap.put("tWriteJSONField_2_In_FINISH" + (listGroupby_tWriteJSONField_2_Out == null ? "" : listGroupby_tWriteJSONField_2_Out.hashCode()), "true"); txf_tWriteJSONField_2_Out.join(); if (txf_tWriteJSONField_2_Out.getLastException() != null) { currentComponent = txf_tWriteJSONField_2_Out.getCurrentComponent(); throw txf_tWriteJSONField_2_Out.getLastException(); } resourceMap.put("finish_tWriteJSONField_2_Out", true); ok_Hash.put("tWriteJSONField_2_Out", true); end_Hash.put("tWriteJSONField_2_Out", System.currentTimeMillis()); /** * [tWriteJSONField_2_Out end ] stop */ } // end the resume } catch (java.lang.Exception e) { TalendException te = new TalendException(e, currentComponent, globalMap); te.setVirtualComponentName(currentVirtualComponent); throw te; } catch (java.lang.Error error) { throw error; } finally { try { /** * [tFileInputXML_1 finally ] start */ currentComponent = "tFileInputXML_1"; /** * [tFileInputXML_1 finally ] stop */ /** * [tWriteJSONField_2_Out finally ] start */ currentVirtualComponent = "tWriteJSONField_2"; currentComponent = "tWriteJSONField_2_Out"; java.util.Queue listGroupby_tWriteJSONField_2_Out = (java.util.Queue) globalMap .get("queue_tWriteJSONField_2_In"); if (resourceMap.get("finish_tWriteJSONField_2_Out") == null) { globalMap.put("tWriteJSONField_2_In_FINISH_WITH_EXCEPTION" + (listGroupby_tWriteJSONField_2_Out == null ? "" : listGroupby_tWriteJSONField_2_Out.hashCode()), "true"); } if (listGroupby_tWriteJSONField_2_Out != null) { globalMap.put("tWriteJSONField_2_In_FINISH" + (listGroupby_tWriteJSONField_2_Out == null ? "" : listGroupby_tWriteJSONField_2_Out.hashCode()), "true"); } /** * [tWriteJSONField_2_Out finally ] stop */ } catch (java.lang.Exception e) { // ignore } catch (java.lang.Error error) { // ignore } resourceMap = null; } globalMap.put("tFileInputXML_1_SUBPROCESS_STATE", 1); }