/* * 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: * <br>AEFConst.FACTORY_ERROR * <br><a href="../commonerrorcodes.html">Common Errors</a> */ 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: * <br>AEFConst.APPLICATION_NOT_RESPONDING * <br>AEFConst.APPLICATION_NOT_IN_PROPER_STATE * <br>AEFConst.OPERATION_TIMEOUT * <br>AEFConst.TRANSACTION_CANNOT_BE_VOIDED * <br>AEFConst.NO_SUCH_PROPERTY * <br>AEFConst.NO_TRANSACTION_IN_PROGRESS * <br>AEFConst.MANAGER_OVERRIDE_REQUIRED * <br>AEFConst.OPERATOR_NOT_AUTHORIZED * <br>AEFConst.FACTORY_ERROR * <br>AEFConst.WAIT_INTERRUPTED * <br>AEFConst.VOID, AEFConst.LIMIT_EXCEEDED * <br>AEFConst.VOID, AEFConst.NOT_ALLOWED * <br>AEFConst.INVALID_ID_PASSWORD * <br>AEFConst.ANOTHER_OPERATOR_SIGNED_ON * <br>AEFConst.MANAGER_OVERRIDE_REQUIRED * <br>AEFConst.NO_DEFAULT_ID_CONFIGURED * <br><a href="../commonerrorcodes.html">Common Errors</a> */ 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); }