package com.eactive.eai.inbound.action;

import java.util.Properties;

import com.eactive.eai.common.message.EAIMessageKeys;
import com.eactive.eai.common.messagekey.MessageKeyFldVO;
import com.eactive.eai.common.messagekey.MessageKeyManager;
import com.eactive.eai.common.messagekey.MessageKeyVO;
import com.eactive.eai.common.util.Logger;
import com.eactive.eai.common.util.MessageKeyExtractor;
import com.eactive.eai.common.util.MessageUtil;

public class RequestActionSupport implements RequestAction
{
    protected String adapterGroupName;
    protected String adapterName;
    protected Properties prop;

    protected Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);


    public void setAdapterInfo(String adapterGroupName,String adapterName, Properties prop)
    {
        this.adapterGroupName = adapterGroupName;
        this.adapterName = adapterName;
        this.prop = prop;
    }

    public String[] perform(Object message) throws ActionException
    {
        byte[] tmp = null;
        String[] key = null;

        if(message instanceof byte[]) {
            tmp = (byte[])message;
            if (logger.isInfo()) logger.info(adapterName+"] received data >> "+ new String(tmp));
        } else {
            if (logger.isInfo()) logger.info(adapterName+"] received data >> "+ message);
        }

        return key;
    }

	@Override
	public String getDescription() {
		return "Action Decription";
	}

    public String getEaiBizCodeFromAdapterName(String adapterGroupName) {
    	String eaiBizCode = null;

    	if(adapterGroupName != null && adapterGroupName.length() > 4) {
    		eaiBizCode = adapterGroupName.substring(1, 4);
    	}
    	return eaiBizCode;
    }

//    public static void main(String[] argv) {
//    	RequestActionSupport s = new RequestActionSupport();
//    	String adapterGroupName = "_ERF_IN_NET_AsS{KFTC}";
//    	String eaiBizCode = s.getEaiBizCodeFromAdapterName(adapterGroupName);
//    	System.out.println(adapterGroupName + "=>" + eaiBizCode);
//    }
}
