/*
* ACEOperatorOverrideActionImpl
*
* 08/21/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.si.Copyright;
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 java.util.*;
import java.rmi.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* ACEOperatorOverrideActionImpl is a class used to give
* an operator override in a transaction on the ACE application.
*
*/
public class ACEOperatorOverrideActionImpl extends ACEActionImpl
{
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 HashMap of arguments.
*
*/
public ACEOperatorOverrideActionImpl(ActionRequest request) throws AEFException
{
super(request);
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter ACEOperatorOverrideActionImpl.ACEOperatorOverrideActionImpl().");
log.trace(tempAEFMessage);
}
theOverrideState = State.getState("OVERRIDE");
theOverrideSubState = Substate.getSubstate("EXPECTING_OPERATOR_OVERRIDE");
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit ACEOperatorOverrideActionImpl.ACEOperatorOverrideActionImpl().");
log.trace(tempAEFMessage);
}
}
/**
* Perform the action represented by the ActionRequest and return an ActionResult.
*
*
* @param request The ActionRequest which contains the classname and arguments.
* @return Object Null object
* @exception AEFException
* AEFException error codes:
*
AEFConst.APPLICATION_NOT_IN_PROPER_STATE, AEFConst.APPLICATION_NOT_IN_PROPER_SUBSTATE
*
AEFConst.APPLICATION_NOT_IN_PROPER_STATE, AEFConst.NONE
*/
public Object performAction() throws AEFException
{
// Don't call super (to avoid being cleared out of override state) - just check for proper state and substate
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter ACEOperatorOverrideActionImpl.performAction().");
log.trace(tempAEFMessage);
}
String currentState = getCurrentState();
String currentSubState = null;
if (currentState.equals(theOverrideState))
{
// Wait for either the manager override substate, or the operator override substate.
String[] states = {Substate.getSubstate("EXPECTING_OPERATOR_OVERRIDE"),
Substate.getSubstate("EXPECTING_MANAGER_OVERRIDE")};
try
{
waitForSubStates(states);
}
catch (AEFException aefe)
{
// Ignore the timeout at this point, because we'll handle an invalid substate
// error below.
}
currentSubState = getCurrentSubstate();
if (currentSubState.equals(theOverrideSubState))
{
sendOperatorOverrideSequence();
}
else
{
String tempString = "ACEManagerOverrideActionImpl.performAction(): POS application not in proper substate to perform override.\n Expected substate " + theOverrideSubState + ", but application is in state " + currentSubState + ".";
AEFException tempException = new AEFException(AEFConst.APPLICATION_NOT_IN_PROPER_STATE,
AEFConst.APPLICATION_NOT_IN_PROPER_SUBSTATE,
tempString);
tempAEFMessage.setMessage(tempString);
log.error(tempAEFMessage, tempException);
throw tempException;
}
}
else
{
String tempString = "ACEManagerOverrideActionImpl.performAction(): POS application not in proper state to perform override.\n Expected state " + theOverrideState + ", but application is in state " + currentState + ".";
AEFException tempException = new AEFException(AEFConst.APPLICATION_NOT_IN_PROPER_STATE,
0,
tempString);
tempAEFMessage.setMessage(tempString);
log.error(tempAEFMessage, tempException);
throw tempException;
}
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("-Exit ACEOperatorOverrideActionImpl.performAction().");
log.trace(tempAEFMessage);
}
return null;
}
/**
* Sends the key sequence which will cause the operator override to be entered.
*
*
* @return int An integer value representing the result of the key sequence.
* @exception AEFException
*/
public int sendOperatorOverrideSequence() throws AEFException
{
if (log.isTraceEnabled())
{
tempAEFMessage.setMessage("+Enter ACEOperatorOverrideActionImpl.sendOperatorOverrideSequence().");
log.trace(tempAEFMessage);
}
int retVal = -1;
args.clear();
args.put("SEQUENCE_ID", "operatorOverride");
theKeySequenceAction = (AEFAction)
(actionFactory.makeAction(new ActionRequest("SimpleKeySequenceAction", args)));
Condition[] goodConditions =
{
new PropertyNotEqualsCondition(POSDeviceProperties.CATEGORY,
POSDeviceProperties.POS_SUB_STATE,
Substate.getSubstate("EXPECTING_OPERATOR_OVERRIDE")),
};
theLock = new ConditionLock();
if (perfTrace.isEnabled(AEFPerfTrace. COARSE))
{
perfTrace.reportTimer(AEFPerfTrace. COARSE,
sessionID,
"operatorOverride",
">>>Sending operator override key sequence to application.");
}
retVal = theLock.performActionAndWait("wait-for-operator-override-complete",
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout());
if (retVal < 0)
{
AEFErrorHandler errorHandler = new AEFErrorHandler("Send Operator Override Sequence Error");
retVal = errorHandler.handleError(theLock,
theKeySequenceAction,
goodConditions,
BadConditionsImpl.getInstance().getBadConditions(),
getTimeout(),
retVal);
}
if (log.isDebugEnabled())
{
log.debug( new AEFMessage( sessionID, "Condition returned was " + retVal)) ;
}
if (perfTrace.isEnabled(AEFPerfTrace. COARSE))
{
perfTrace.reportTimer(AEFPerfTrace. COARSE,
sessionID,
"operatorOverride",
"<<