src/com/vehiclerental/presentationLayer/headOffice/HeadOfficeManager.java
/**
     * Handle and dispatch the received request
     *
     * @param request received and parsed request
     * @return response object
     * @throws Exception if any error
     */
Handle and dispatch the received request
@param request received and parsed request
@return response object
@throws Exception if any error
Handle and dispatch the received request @param request received and parsed request @return response object @throws Exception if any error
private HeadOfficeResponseMessage handleRequest(HeadOfficeRequestMessage request) throws Exception {
        HeadOfficeResponseMessage response;
        if (!NodeConfiguration.Current.systemAvailable) {
            return generateSystemUnavailableError();
        }
        if (request == null) {
            return HeadOfficeResponseMessage.GetInvalidRequestResponse();
        }
        switch (request.OperationCode) {
            case OperationCodes.GET_BRANCHES: {
                response = GuestHeadOfficeController.HandleGetBranches(request);
                break;
            }
            case OperationCodes.SEARCH_AVAIL_VEHICLES: {
                response = GuestHeadOfficeController.HandleSearchAvailableVehicles(request);
                break;
            }
            case OperationCodes.CREATE_ACCOUNT: {
                response = GuestHeadOfficeController.HandleCreateAccount(request);
                break;
            }
            case OperationCodes.GET_ACCOUNT_DETAILS: {
                response = UserHeadOfficeController.HandleGetAccountDetails(request);
                break;
            }
            case OperationCodes.BOOK_VEHICLE: {
                response = UserHeadOfficeController.HandleBookVehicle(request);
                break;
            }
            case OperationCodes.GET_USER_BOOKINGS: {
                response = UserHeadOfficeController.HandleGetUserBookings(request);
                break;
            }
            case OperationCodes.SHUTDOWN_SYSTEM: {
                response = StaffHeadOfficeController.HandleShutdownSystem(request);
                break;
            }
            case OperationCodes.GET_BRANCH_BOOKINGS: {
                response = StaffHeadOfficeController.HandleGetBranchBookings(request);
                break;
            }
            case OperationCodes.CREATE_USER: {
                response = StaffHeadOfficeController.HandleCreateUser(request);
                break;
            }
            case OperationCodes.SEARCH_USER: {
                response = StaffHeadOfficeController.HandleSearchUser(request);
                break;
            }
            case OperationCodes.UPDATE_OR_CREATE_VEHICLE: {
                response = StaffHeadOfficeController.HandleUpdateOrCreateVehicle(request);
                break;
            }
            case OperationCodes.SEARCH_ALL_VEHICLES: {
                response = StaffHeadOfficeController.HandleSearchVehicles(request);
                break;
            }
            case OperationCodes.CHANGE_BOOKING_STATUS: {
                response = StaffHeadOfficeController.HandleChangeBookingStatus(request);
                break;
            }
            case OperationCodes.GET_VEHICLE_MOVES: {
                response = StaffHeadOfficeController.HandleGetVehicleMoves(request);
                break;
            }
            default: {
                response = HeadOfficeResponseMessage.GetInvalidRequestResponse();
                break;
            }
        }
        return response;
    }
private HeadOfficeResponseMessage handleRequest ( HeadOfficeRequestMessage request ) throws Exception { HeadOfficeResponseMessage response ; if ( ! NodeConfiguration . Current . systemAvailable ) { return generateSystemUnavailableError ( ) ; } if ( request == null ) { return HeadOfficeResponseMessage . GetInvalidRequestResponse ( ) ; } switch ( request . OperationCode ) { case OperationCodes . GET_BRANCHES : { response = GuestHeadOfficeController . HandleGetBranches ( request ) ; break ; } case OperationCodes . SEARCH_AVAIL_VEHICLES : { response = GuestHeadOfficeController . HandleSearchAvailableVehicles ( request ) ; break ; } case OperationCodes . CREATE_ACCOUNT : { response = GuestHeadOfficeController . HandleCreateAccount ( request ) ; break ; } case OperationCodes . GET_ACCOUNT_DETAILS : { response = UserHeadOfficeController . HandleGetAccountDetails ( request ) ; break ; } case OperationCodes . BOOK_VEHICLE : { response = UserHeadOfficeController . HandleBookVehicle ( request ) ; break ; } case OperationCodes . GET_USER_BOOKINGS : { response = UserHeadOfficeController . HandleGetUserBookings ( request ) ; break ; } case OperationCodes . SHUTDOWN_SYSTEM : { response = StaffHeadOfficeController . HandleShutdownSystem ( request ) ; break ; } case OperationCodes . GET_BRANCH_BOOKINGS : { response = StaffHeadOfficeController . HandleGetBranchBookings ( request ) ; break ; } case OperationCodes . CREATE_USER : { response = StaffHeadOfficeController . HandleCreateUser ( request ) ; break ; } case OperationCodes . SEARCH_USER : { response = StaffHeadOfficeController . HandleSearchUser ( request ) ; break ; } case OperationCodes . UPDATE_OR_CREATE_VEHICLE : { response = StaffHeadOfficeController . HandleUpdateOrCreateVehicle ( request ) ; break ; } case OperationCodes . SEARCH_ALL_VEHICLES : { response = StaffHeadOfficeController . HandleSearchVehicles ( request ) ; break ; } case OperationCodes . CHANGE_BOOKING_STATUS : { response = StaffHeadOfficeController . HandleChangeBookingStatus ( request ) ; break ; } case OperationCodes . GET_VEHICLE_MOVES : { response = StaffHeadOfficeController . HandleGetVehicleMoves ( request ) ; break ; } default : { response = HeadOfficeResponseMessage . GetInvalidRequestResponse ( ) ; break ; } } return response ; }
Handle and dispatch the received request
 @param request received and parsed request
 @return response object
 @throws Exception if any error
Handle and dispatch the received request @param request received and parsed request @return response object @throws Exception if any error
//Not implemented yet, but the system can be switched to a fake shutdown mode which could allow soft close/start if needed //System not running //Main dispatch //Guest methods //User methods //Also handles create a booking for someone else //Staff methods