From f461fc1fbbb66b40714433c3db7282d5b6913046 Mon Sep 17 00:00:00 2001 From: syukri-radius Date: Mon, 4 Nov 2024 17:40:28 +0700 Subject: [PATCH] clean up --- classes/.data/LogProcessorMdb.cdi | Bin 2426 -> 2393 bytes .../soakemenkeu/MessageDrivenEJBBean.class | Bin 4989 -> 4909 bytes .../OsbLogProcessor_LogProcessorMdb_ejb.jar | Bin 9306 -> 9226 bytes src/org/soakemenkeu/MessageDrivenEJBBean.java | 129 ++---------------- 4 files changed, 13 insertions(+), 116 deletions(-) diff --git a/classes/.data/LogProcessorMdb.cdi b/classes/.data/LogProcessorMdb.cdi index e07c8369a90a34795179e210990c2328a22cdf18..5dd9d0794df05b7f5923387f088a798208e60ae4 100644 GIT binary patch delta 223 zcmew*bW?~!fKgF^fq@}(BS#q%FHfpodTNPpYH@L5dg|m_CO3KB)Cwda2L9yyyga?) z)Do9`&%A=tlF8SZOgBp~H#1IN$KuH-GP#jaWV1YL8WZE2$!+Y}-1}l`fo3xTvB~5= z?Dnj(Ko-wr2aa?`<;g2JlmpqIvi3k)1&D2dSRIJ9fmk1iZGhMkh(Rv217c+$HUVNm bAO@)inI{Rv20-ip#Ez3?IQ`jy3=jYSM?5Lu delta 249 zcmca9^h=0CfKgF^fq@}>BS#t2k{?_G zluzIMfu)9t@yp~~_H6DL>n@;ej6iHQ`7ygaD-Vz*J6WA0ol$9WKZkOlJ&?}^#123V zQsoH5DnM)p#Ogq-4aE9DYzxGeKn!v_NRJW_n*gyO5Gw<*3=m5KvB6|!PJjMTAS(=r Gp#T6zZZatV diff --git a/classes/org/soakemenkeu/MessageDrivenEJBBean.class b/classes/org/soakemenkeu/MessageDrivenEJBBean.class index ebb125ba44fefb293bd914d9afe6b82fc9af48d4..5550ba1445239b9d4991fb9139e0458994dec619 100644 GIT binary patch delta 1692 zcmZ`(X>e0j6#j0L=Dxl>3Itksv_Pm@D6|Bm7Kxygf?aG&X^Ug6ETKG0Ax%P)LIEK% zBhDxzGx{87oY4_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|1KMyrQg+2e@4I{TcpMWfBbQ1(h3Bp`wFaLOWtPr=3TY8fkkEI zfg7Ui+LUh5iWIvgB`xO^-zu~~MQP50$}){}2H)|$!k81N4&(-{Q0~-%2?lxO8~nhJ zc0y{;ap#?c#;EdO$O?wC3l~*b3O!`igmP=fO++(ZvW=8m03&2~ z6mg8k%iVOQs7~&|{q$j)wCDre%XCV3h{p)9nwbJnA`lkqd6=!tW`aNzpiA&d@hlMN zbe1whG?!p3uXP`7)#Zlc@7X3~qYn($2$+A?;K>35kfZ}%`gWVzYf zGfXd0dVBjs6d_QU6WOnyKgOXm%kOT^BD=_Rdvlt|^=qbP#)P@W)WY;P-C+heUIPc| zDSAituBE|#CVlYm8#wnn=VC+{zjkP5Y%5buPb+C=Y?vYSwmv9lS zbQLG>7x^1`mz`WSKqkx8b6-q1+1f1eTZFl0I",""); -// sendHttpPost(text); -// Document jmsMessage = convertStringToXml(text); -// Node root = jmsMessage.getDocumentElement(); -// int logID = getLogNextSeq(); -// if (root != null){ -// NodeList nodeList = ((Element) root).getElementsByTagName("soa:LogRequest"); -// for (int i = 0; i < nodeList.getLength(); i++) { -// Node nodeXml = nodeList.item(i); -// if (nodeXml.getNodeType() == Node.ELEMENT_NODE) { -// Element element = (Element) nodeXml; -// System.out.println("[myMessageDrivenBean] element: " + element.toString() ); -// } else { -// System.out.println("[myMessageDrivenBean] node: " + nodeXml.toString() ); -// } -// } -// } - - - - String postPayload =""; + String postPayload =""; String cleanPayload = msgPayload.replace("", ""); postPayload += cleanPayload2.replace("",""); postPayload += " "; - - System.out.println("[myMessageDrivenBean] Received message: " + msgPayload ); - System.out.println("[myMessageDrivenBean] postPayload message: " + postPayload ); + sendHttpPost(postPayload); - - + } catch(JMSException ex) { - System.out.println("Caught JMSException: " + ex ); + System.out.println("[logJmsMessageDrivenBean] Caught JMSException: " + ex.getMessage()); } } -// private static String convertXmlToString(Document doc) { -// DOMSource domSource = new DOMSource(doc); -// StringWriter writer = new StringWriter(); -// StreamResult result = new StreamResult(writer); -// TransformerFactory tf = TransformerFactory.newInstance(); -// Transformer transformer = null; -// try { -// transformer = tf.newTransformer(); -// transformer.transform(domSource, result); -// } catch (TransformerException e) { -// throw new RuntimeException(e); -// } -// return writer.toString(); -// } -// -// private static Document convertStringToXml(String xmlString) { -// -// DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); -// -// try { -// -// // optional, but recommended -// // process XML securely, avoid attacks like XML External Entities (XXE) -// dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); -// -// DocumentBuilder builder = dbf.newDocumentBuilder(); -// -// Document doc = builder.parse(new InputSource(new StringReader(xmlString))); -// -// return doc; -// -// } catch (ParserConfigurationException | IOException | SAXException e) { -// throw new RuntimeException(e); -// } -// -// } - -// private int getLogNextSeq(){ -// int logId = 0; -// String dbUrl = ConfigUtil.getProperty("db.url"); -// String dbUsername = ConfigUtil.getProperty("db.username"); -// String dbPassword = ConfigUtil.getProperty("db.password"); -// ResultSet rs = null; -// try (Connection connection = DriverManager.getConnection(dbUrl, dbUsername, dbPassword)) { -// String sql = "SELECT PKLOGIDSEQ.nextval FROM dual"; -// PreparedStatement preparedStatement = connection.prepareStatement(sql); -// rs = preparedStatement.executeQuery(); -// -// if (rs.next()) { -// logId = rs.getInt(1); -// } -// -// -// } catch (Exception e) { -// e.printStackTrace(); -// } -// -// return logId; -// } - -// private void storeMessageInDatabase(String messageContent) { -// String dbUrl = ConfigUtil.getProperty("db.url"); -// String dbUsername = ConfigUtil.getProperty("db.username"); -// String dbPassword = ConfigUtil.getProperty("db.password"); -// -// try (Connection connection = DriverManager.getConnection(dbUrl, dbUsername, dbPassword)) { -// String sql = "INSERT INTO jms_messages (message_content) VALUES (?)"; -// try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { -// preparedStatement.setString(1, messageContent); -// preparedStatement.executeUpdate(); -// System.out.println("Message stored in the database successfully."); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } + private void sendHttpPost(String messageContent) { try { String apiUrl = ConfigUtil.getProperty("api.url"); URL url = new URL(apiUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - -// URL url = new URL("http://localhost:17080/soa-infra/services/default/SoaLoggerProject/LogOsbInsertService"); -// HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "text/xml"); conn.setRequestProperty("SOAPAction","\"execute\""); @@ -197,17 +97,14 @@ public class MessageDrivenEJBBean implements MessageDrivenBean, MessageListener String body = messageContent; OutputStream out = conn.getOutputStream(); OutputStreamWriter wout = new OutputStreamWriter(out, "UTF-8"); -// System.out.println("Writing message: " + body + " to outputstream."); + wout.write(body); wout.flush(); out.close(); - -// OutputStream output = new BufferedOutputStream(conn.getOutputStream()); -// output.write(body.getBytes()); -// output.flush(); + int responseCode = conn.getResponseCode(); -// System.out.println("POST Response Code :: " + responseCode); + System.out.println("[logJmsMessageDrivenBean] POST Response Code :: " + responseCode); if (responseCode == HttpURLConnection.HTTP_OK) { // success try (BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()))) { @@ -216,14 +113,14 @@ public class MessageDrivenEJBBean implements MessageDrivenBean, MessageListener while ((inputLine = in.readLine()) != null) { response.append(inputLine); } - System.out.println("Response :: " + response.toString()); + } } else { - System.out.println("POST request failed"); + System.out.println("[logJmsMessageDrivenBean] POST request failed"); } conn.disconnect(); } catch (IOException e) { - e.printStackTrace(); + System.out.println("[logJmsMessageDrivenBean] sendHttpPost Exception : " + e.getMessage()); } }