/*
* InitializeActionImpl Class
*
* 01/08/2003
*
* Copyright:
* Licensed Materials - Property of IBM
* "Restricted Materials of IBM"
* 5724-AEF
* (C) Copyright IBM Corp. 2003.
*
* %W% %E%
*/
package com.ibm.retail.AEF.action;
import com.ibm.retail.AEF.automation.*;
import com.ibm.retail.AEF.util.*;
import com.ibm.retail.si.util.*;
import com.ibm.retail.AEF.factory.*;
import com.ibm.retail.AEF.thread.*;
import com.ibm.retail.AEF.data.*;
import com.ibm.retail.AEF.session.*;
import com.ibm.retail.si.Copyright;
import java.util.*;
import java.rmi.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* InitializeActionImpl is a class which the POSAutomationProvider uses to get
* the application to a specific state.
*
*/
public class InitializeActionImpl extends AEFActionImpl
{
static String copyright()
{ return com.ibm.retail.si.Copyright.IBM_COPYRIGHT_SHORT; }
private static AEFPerfTrace perfTrace = AEFPerfTrace.getInstance();
/**
* Constructor
*
* @param request The ActionRequest which contains a hashtable of arguments.
* @exception com.ibm.retail.AEF.util.AEFException
* Among the possible AEFException error codes are:
*
AEFConst.FACTORY_ERROR
*
Common Errors
*/
public InitializeActionImpl(ActionRequest request) throws AEFException
{
super(request);
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter InitializeActionImpl.InitializeActionImpl().");
log.trace(tempAEFMessage);
}
desiredState = ((Integer)(request.getArguments().get("state"))).intValue();
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit InitializeActionImpl.InitializeActionImpl().");
log.trace(tempAEFMessage);
}
}
/**
* Perform the action represented by the ActionRequest and return an ActionResult.
*
*
* @return Object Null.
* @exception com.ibm.retail.AEF.util.AEFException
* Among the possible AEFException error codes are:
*
AEFConst.APPLICATION_NOT_RESPONDING
*
AEFConst.APPLICATION_NOT_IN_PROPER_STATE
*
AEFConst.OPERATION_TIMEOUT
*
AEFConst.TRANSACTION_CANNOT_BE_VOIDED
*
AEFConst.NO_SUCH_PROPERTY
*
AEFConst.NO_TRANSACTION_IN_PROGRESS
*
AEFConst.MANAGER_OVERRIDE_REQUIRED
*
AEFConst.OPERATOR_NOT_AUTHORIZED
*
AEFConst.FACTORY_ERROR
*
AEFConst.WAIT_INTERRUPTED
*
AEFConst.VOID, AEFConst.LIMIT_EXCEEDED
*
AEFConst.VOID, AEFConst.NOT_ALLOWED
*
AEFConst.INVALID_ID_PASSWORD
*
AEFConst.ANOTHER_OPERATOR_SIGNED_ON
*
AEFConst.MANAGER_OVERRIDE_REQUIRED
*
AEFConst.NO_DEFAULT_ID_CONFIGURED
*
Common Errors
*/
public Object performAction() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter InitializeActionImpl.performAction().");
log.trace(tempAEFMessage);
}
String idState = State.getState("ID");
boolean salesTranInProgress = false;
boolean nonSalesTranInProgress = false;
try
{
if (desiredState == POSAutomationProviderImpl.SIGNON)
{
if (getCurrentState().equalsIgnoreCase(idState) == false)
{
automationProvider.forceLogoff();
}
}
else
{
if (getCurrentState().equalsIgnoreCase(idState) == false)
{
salesTranInProgress = getBooleanProviderProperty(WorkstationStatusProperties.CATEGORY, WorkstationStatusProperties.SALES_TRANSACTION_IN_PROGRESS);
nonSalesTranInProgress = getBooleanProviderProperty(WorkstationStatusProperties.CATEGORY, WorkstationStatusProperties.NONSALES_TRANSACTION_IN_PROGRESS);
if (salesTranInProgress || nonSalesTranInProgress)
{
automationProvider.voidCurrentTransaction();
}
}
else
{
automationProvider.logon();
}
}
}
catch (AEFException e)
{
tempAEFMessage.setMessage("There was an AEF exception thrown in performAction of InitializeActionImpl.");
log.error(tempAEFMessage, e);
throw e;
}
catch (RemoteException re)
{
// Not expected to get here since we are calling locally.
tempAEFMessage.setMessage("There was a remote exception thrown in performAction of InitializeActionImpl.");
log.error(tempAEFMessage, re);
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit InitializeActionImpl.performAction().");
log.trace(tempAEFMessage);
}
return null;
}
/* Instance Variables */
protected int desiredState = 0;
private static Log log = LogFactory.getLog(InitializeActionImpl.class);
}