on 10-07-2008 5:23 PM
Iam trying to do a java mapping
Exception recevied is Application mapping program com/al/credtosap/GenCredential throws a stream transformation exception: GenCredential:execute:Praser failedFor input string: ""
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
import java.util.Properties;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import com.al.credtosap.exception.CredToSAPException;
import com.al.credtosap.helper.Debug;
import com.sap.aii.mapping.api.MappingTrace;
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.StreamTransformationConstants;
import com.sap.aii.mapping.api.StreamTransformationException;
public class GenCredential implements StreamTransformation {
private Map map;
private MappingTrace trace = null;
public void setParameter(Map param){
map=param;
if (map.get(StreamTransformationConstants.MAPPING_TRACE) != null)
trace=(MappingTrace)map.get(StreamTransformationConstants.MAPPING_TRACE);
trace.addInfo("Got Param");
}
public void execute (InputStream in, OutputStream out) throws com.sap.aii.mapping.api.StreamTransformationException{
trace.addInfo("GenCredential:execute In");
// Use an instance of ourselves as the SAX event handler
ByteArrayInputStream rb;
ByteArrayInputStream rb1;
InputStream input=null;;
InputStream input1=null;
try{
byte[] buffer = new byte[in.available()];
int a = in.read(buffer);
in.close();
rb = new ByteArrayInputStream(buffer);
rb1 = new ByteArrayInputStream(buffer);
input= (InputStream)rb;
input1=(InputStream)rb1;
}
catch(IOException ioe){
throw new StreamTransformationException("GenCredential:execute:Failed to buffer inputstream"+ioe.getMessage());
}
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = null;
factory.setNamespaceAware(false);
factory.setValidating(false);
Document indoc;
int firmCount=0;
int individualCount=0;
int matchIndividualCount=0;
int matchFirmCount=0;
try {
InputSource source = new InputSource(input);
System.out.println("Input Received " + source);
Debug.writeTrace(trace,"Input Received");
builder = factory.newDocumentBuilder();
indoc = builder.parse(input);
System.out.println("Indoc Received " + indoc);
Debug.writeTrace(trace,"Indoc Received::");
Element tree_root = indoc.getDocumentElement ();
NamedNodeMap n = tree_root.getAttributes();
firmCount=Integer.parseInt(n.getNamedItem("FirmCount").getNodeValue());
individualCount=Integer.parseInt(n.getNamedItem("IndividualCount").getNodeValue());
NodeList individualList = indoc.getElementsByTagName("Individual");
matchIndividualCount = individualList.getLength();
NodeList firmList = indoc.getElementsByTagName("Firm");
matchFirmCount = firmList.getLength();
trace.addInfo("GenCredential:execute firmCount:"+ firmCount + "individualCount:" + individualCount + " matchIndividualCount"+ matchIndividualCount);
if ((firmCount != matchFirmCount) || (individualCount != matchIndividualCount)){
throw new StreamTransformationException("GenCredential:execute:Count Mismatch:: firmCount: "+ firmCount + "-- individualCount:" + individualCount + "matchIndividualCount:"+ matchIndividualCount + " firmCount:" + firmCount + "--matchFirmCount:"+ matchFirmCount);
}
} catch (Exception e) {
Debug.writeTrace(trace,"CredToSAP: "+e.getMessage());
e.printStackTrace();
throw new StreamTransformationException("GenCredential:execute:Praser failed"+e.getMessage());
}
// Set the ContentHandler...
try{
CredToSAP credToSAPObj = new CredToSAP(map);
credToSAPObj.execute(input1, out);
}catch ( CredToSAPException e ) {
Debug.writeTrace(trace,"CredToSAP: "+e.getMessage());
throw new StreamTransformationException("GenCredential:execute:FailedCredToSAP"+e.getMessage());
}
}
can some body give inputs please
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.