package com.ejie.ad74a.ws.server.beneficiario.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.ejie.ad74a.ws.server.televida.model.Comunicacion;
import com.ejie.ad74a.ws.server.televida.model.Respuesta;

@Service(value = "BeneficiarioService")
public class BeneficiarioServiceImpl implements BeneficiarioService {

	/**
	 * Final static logger.
	 */
	private static final Logger logger = LoggerFactory.getLogger(BeneficiarioServiceImpl.class);

	private static final int TRANSACTION_TIMEOUT = 60;

	@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class, timeout = BeneficiarioServiceImpl.TRANSACTION_TIMEOUT)
	@Override
	public Respuesta proccesComunication(Comunicacion comunicacion) throws Throwable {
		BeneficiarioServiceImpl.logger.info("TelevidaServiceImpl.proccesMessage - Inicio");
		Respuesta result = null;

		String accion = comunicacion.getCabecera().getTipoComunicacion().value();

		BeneficiarioServiceImpl.logger.info("TelevidaServiceImpl.proccesMessage - Fin");
		return result;
	}

	private String getErrorMessage(String error) {
		if (null != error && error.length() > 800) {
			error = error.substring(0, 799);
		}
		return error;
	}
}