package com.eactive.eai.control;

import java.util.Properties;

import com.eactive.eai.adapter.ElinkAdapter;
import com.eactive.eai.adapter.ElinkAdapterFactory;
import com.eactive.eai.adapter.wca.exception.WCAException;
import com.eactive.eai.common.exception.ExceptionUtil;

public class SNASender {
	static final long serialVersionUID = 1L;

    public static byte[] callService(String adapterGroupName, Properties prop, Object message,Properties tempProp) 
    throws Exception
    {
        byte[] resBytes;        
        try {
            ElinkAdapterFactory factory = ElinkAdapterFactory.newInstance();            
            ElinkAdapter adapter = factory.getElinkAdapter(com.eactive.eai.adapter.Keys.TYPE_SNA);
            resBytes = (byte[])adapter.callService(adapterGroupName, prop, message, tempProp);
        } 
        catch(WCAException wcae) {
//            String errCode = wcae.getErrorReturnCode();
//            throw new Exception(errCode);
            throw new Exception(wcae.getErrorReturnCode() + ":" + wcae.getMessage());
            
        }
        catch(Exception e) {
            throw new Exception(ExceptionUtil.getErrorCode(e, "RECEAIOSC001"));
        }        
        
        return resBytes;
    }
}
