package com.sample.api;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

import com.liferay.portal.kernel.portlet.bridges.mvc.BaseMVCActionCommand;
import com.liferay.portal.kernel.portlet.bridges.mvc.MVCActionCommand;

@Component(immediate = true, property = { "javax.portlet.name=com_liferay_login_web_portlet_FastLoginPortlet",
		"javax.portlet.name=com_liferay_login_web_portlet_LoginPortlet", "mvc.command.name=/login/login",
		"service.ranking:Integer=700" }, service = MVCActionCommand.class)
public class LoginActionHook extends BaseMVCActionCommand {

	@Reference(target = "(&(mvc.command.name=/login/login)(javax.portlet.name=com_liferay_login_web_portlet_FastLoginPortlet) "
			+ "(javax.portlet.name=com_liferay_login_web_portlet_LoginPortlet))")
	public void setMvcActionCommand(MVCActionCommand mvcActionCommand) {
		this.mvcActionCommand = mvcActionCommand;
	}

	public MVCActionCommand getMvcActionCommand() {
		return this.mvcActionCommand;
	}

	protected MVCActionCommand mvcActionCommand;

	@Override
	protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
		System.out.println("******************LoginMVCActionCommand.processAction()********************");
		mvcActionCommand.processAction(actionRequest, actionResponse);

	}

	@Override
	public boolean processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException {
		System.out.println("***************LoginMVCActionCommand.processAction()******************");

		return super.processAction(actionRequest, actionResponse);
	}

}