package br.mp.mprj.portal.portlet.gestaomensagens.service.service.messaging;

import br.mp.mprj.portal.portlet.gestaomensagens.service.service.AgendamentoLocalServiceUtil;
import br.mp.mprj.portal.portlet.gestaomensagens.service.service.AnexoMensagemLocalServiceUtil;
import br.mp.mprj.portal.portlet.gestaomensagens.service.service.ClpSerializer;
import br.mp.mprj.portal.portlet.gestaomensagens.service.service.EmailDestinatarioLocalServiceUtil;
import br.mp.mprj.portal.portlet.gestaomensagens.service.service.GrupoDestinatarioLocalServiceUtil;
import br.mp.mprj.portal.portlet.gestaomensagens.service.service.GrupoDestinatarioServiceUtil;
import br.mp.mprj.portal.portlet.gestaomensagens.service.service.MensagemLocalServiceUtil;
import br.mp.mprj.portal.portlet.gestaomensagens.service.service.MensagemServiceUtil;
import br.mp.mprj.portal.portlet.gestaomensagens.service.service.MensagemWorkflowLocalServiceUtil;
import br.mp.mprj.portal.portlet.gestaomensagens.service.service.TemplateLocalServiceUtil;
import br.mp.mprj.portal.portlet.gestaomensagens.service.service.TemplateServiceUtil;

import com.liferay.portal.kernel.messaging.BaseMessageListener;
import com.liferay.portal.kernel.messaging.Message;


public class ClpMessageListener extends BaseMessageListener {
    public static String getServletContextName() {
        return ClpSerializer.getServletContextName();
    }

    @Override
    protected void doReceive(Message message) throws Exception {
        String command = message.getString("command");
        String servletContextName = message.getString("servletContextName");

        if (command.equals("undeploy") &&
                servletContextName.equals(getServletContextName())) {
            AgendamentoLocalServiceUtil.clearService();

            AnexoMensagemLocalServiceUtil.clearService();

            EmailDestinatarioLocalServiceUtil.clearService();

            GrupoDestinatarioLocalServiceUtil.clearService();

            GrupoDestinatarioServiceUtil.clearService();
            MensagemLocalServiceUtil.clearService();

            MensagemServiceUtil.clearService();
            MensagemWorkflowLocalServiceUtil.clearService();

            TemplateLocalServiceUtil.clearService();

            TemplateServiceUtil.clearService();
        }
    }
}
