103 lines
3.9 KiB
Java
103 lines
3.9 KiB
Java
package it.valueteam.gnp.ws.crmb;
|
|
|
|
import it.valueteam.gnp.dao.db.hb.GnpCrmbSoapHeaderIn;
|
|
import it.valueteam.gnp.dao.db.hb.GnpCrmbSoapHeaderInDAO;
|
|
import it.valueteam.gnp.log.Loggable;
|
|
import it.valueteam.gnp.log.ProcessLogger;
|
|
import it.valueteam.gnp.obj.LogProcess;
|
|
import it.valueteam.gnp.systemcontroller.formatcontroller.crm.WSSOAPHandler;
|
|
import it.valueteam.gnp.utility.UserTransactionUtility;
|
|
import org.hibernate.Hibernate;
|
|
|
|
import javax.transaction.UserTransaction;
|
|
import javax.xml.rpc.handler.MessageContext;
|
|
import javax.xml.rpc.handler.soap.SOAPMessageContext;
|
|
import javax.xml.soap.SOAPBody;
|
|
import javax.xml.soap.SOAPHeader;
|
|
import javax.xml.soap.SOAPMessage;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.sql.Clob;
|
|
import java.util.Date;
|
|
|
|
public class CRMWirelineNPMgmtSOAPHandler extends WSSOAPHandler implements Loggable {
|
|
|
|
protected ProcessLogger log;
|
|
private static final String bodyNamespaceURI = "http://dbcfx/SOA/CRMWirelineNPMgmt/2023-03-23";
|
|
|
|
public CRMWirelineNPMgmtSOAPHandler() throws Exception {
|
|
LogProcess logProcess = new LogProcess();
|
|
logProcess.setCodice(codiceProcesso);
|
|
logProcess.setProcess(this);
|
|
log = new ProcessLogger(logProcess);
|
|
}
|
|
|
|
@Override
|
|
public boolean handleFault(MessageContext msgctx) {
|
|
SOAPMessageContext soapMsgCtx = (SOAPMessageContext) msgctx;
|
|
ByteArrayOutputStream payloadStringOut = new ByteArrayOutputStream();
|
|
|
|
try {
|
|
SOAPMessage message = soapMsgCtx.getMessage();
|
|
SOAPHeader header = message.getSOAPHeader();
|
|
String bid = getBid(header);
|
|
log.write("9999",bid+" - CRMWirelineNPMgmtSOAPHandler (Fault Handler) - " + new Date());
|
|
message.writeTo(payloadStringOut);
|
|
log.write("9999",bid+" - "+payloadStringOut.toString());
|
|
} catch (Exception ex) {
|
|
ex.printStackTrace();
|
|
}
|
|
|
|
return super.handleRequest(msgctx);
|
|
}
|
|
|
|
@Override
|
|
public boolean handleRequest(MessageContext msgctx) {
|
|
SOAPMessageContext soapMsgCtx = (SOAPMessageContext) msgctx;
|
|
ByteArrayOutputStream payloadStringOut = new ByteArrayOutputStream();
|
|
|
|
try {
|
|
|
|
SOAPMessage message = soapMsgCtx.getMessage();
|
|
SOAPHeader header = message.getSOAPHeader();
|
|
SOAPBody body = message.getSOAPBody();
|
|
String bid = getBid(header);
|
|
log.write("9999",bid+" - CRMWirelineNPMgmtSOAPHandler - " + new Date());
|
|
|
|
message.writeTo(payloadStringOut);
|
|
|
|
log.write("9999",bid+" - "+payloadStringOut.toString());
|
|
|
|
UserTransaction utx = null;
|
|
try {
|
|
utx = UserTransactionUtility.beginUserTransaction();
|
|
|
|
// Saving in GNP_ESITO_CESS_SOAP_HEADER_IN
|
|
GnpCrmbSoapHeaderInDAO headerDAO = new GnpCrmbSoapHeaderInDAO();
|
|
GnpCrmbSoapHeaderIn headerToSave = new GnpCrmbSoapHeaderIn();
|
|
headerToSave.setSourceSystem(getNodeValue(header, headerNamespaceURI, "sourceSystem"));
|
|
headerToSave.setBusinessId(bid);
|
|
headerToSave.setMessageId(getNodeValue(header, headerNamespaceURI, "messageID"));
|
|
headerToSave.setTransactionId(getNodeValue(header, headerNamespaceURI, "transactionID"));
|
|
headerToSave.setOrderItemId(getNodeValue(body, bodyNamespaceURI, "ORDER_ITEM"));
|
|
headerToSave.setDataRicezione(new Date());
|
|
|
|
Clob clob = Hibernate.createClob(payloadStringOut.toString());
|
|
headerToSave.setPayload(clob);
|
|
headerDAO.save(headerToSave);
|
|
|
|
UserTransactionUtility.endUserTransaction(utx, true);
|
|
} catch (Exception ex) {
|
|
ex.printStackTrace();
|
|
|
|
if (utx != null)
|
|
UserTransactionUtility.endUserTransaction(utx, false);
|
|
}
|
|
} catch (Exception ex) {
|
|
ex.printStackTrace();
|
|
}
|
|
|
|
return super.handleRequest(msgctx);
|
|
}
|
|
|
|
}
|