Commit 5269856e authored by asonawane's avatar asonawane

changes done for returnstring parsing to make compatible with workflow return value


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@92411 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 1b6d17b7
package ibase.webitm.ejb.sys;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.fin.GlobalFinanceConfLocal;
import ibase.webitm.ejb.fin.GlobalFinanceConfRemote;
import ibase.webitm.utility.ITMException;
import java.io.ByteArrayInputStream;
import java.io.OutputStreamWriter;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.ejb.Stateless;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.rpc.ParameterMode;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@Stateless
public class CallConfirmService extends ActionHandlerEJB implements CallConfirmServiceLocal,CallConfirmServiceRemote {
......@@ -48,7 +55,8 @@ public class CallConfirmService extends ActionHandlerEJB implements CallConfirmS
try{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
GenericUtility genericUtility = GenericUtility.getInstance();
actionURI = "http://NvoServiceurl.org/" + methodName;
sql = "SELECT SERVICE_CODE,COMP_NAME FROM SYSTEM_EVENTS WHERE OBJ_NAME = ? AND EVENT_CODE = 'pre_confirm' ";
......@@ -108,7 +116,10 @@ public class CallConfirmService extends ActionHandlerEJB implements CallConfirmS
call.setReturnType(XMLType.XSD_STRING);
retString = (String)call.invoke(aobj);
System.out.println("Return string from NVO is:==>["+retString+"]");
Document dom= parseString(retString);
String errCode = getErrorCode(dom);
retString = new ibase.webitm.ejb.ITMDBAccessEJB().getErrorString("",errCode,"");
System.out.println("Return string from ITMDBAccessEJB() is:==>["+retString+"]");
}
catch(Exception e)
{
......@@ -141,4 +152,67 @@ public class CallConfirmService extends ActionHandlerEJB implements CallConfirmS
return retString;
}
public Document parseString(String xmlString)throws ITMException
{
Document dom = null;
try
{
//Changed by Monif on 2/23/2009 [For special char parsing issue].Start
ibase.utility.GenericUtility genericUtility = new ibase.utility.GenericUtility();
xmlString = genericUtility.setXmlDec( xmlString );
//Changed by Monif on 2/23/2009 [For special char parsing issue].End
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setIgnoringComments(true);
DocumentBuilder db = dbf.newDocumentBuilder();
OutputStreamWriter errorWriter = new OutputStreamWriter(System.err, CommonConstants.ENCODING);
ByteArrayInputStream baos = new ByteArrayInputStream(xmlString.getBytes());
dom = db.parse(baos);
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return dom;
}
private String getErrorCode(Document dom)
{
NodeList detailList = null;
Node currDetail = null;
NodeList currDetailList = null;
String nodeName = "";
int currDetailListLength = 0;
int detailListLength = 0;
String errCode="";
detailList = dom.getElementsByTagName("Errors");
detailListLength = detailList.getLength();
if ( detailListLength > 0 )
{
for (int ctr = 0;ctr < detailListLength;ctr++)
{
currDetail = detailList.item(ctr);
}
currDetailList = currDetail.getChildNodes();
currDetailListLength = currDetailList.getLength();
for (int i=0;i< currDetailListLength;i++)
{
Node item =currDetailList.item(i);
nodeName = item.getNodeName();
System.out.println("@@@@ nodeName :[ "+nodeName+" ]");
if (nodeName.equalsIgnoreCase("error"))
{
errCode = currDetailList.item(i).getAttributes().getNamedItem("id").getNodeValue();
System.out.println("@@@@ errCode found :[ "+errCode+" ]");
break;
}
}
}
System.out.println("@@@@ errCode :[" + errCode+" ]");
return errCode;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment