src/com/vehiclerental/presentationLayer/branch/BranchOfficeManager.java
/**
     * Handle and dispatch the received request
     *
     * @param communicationObject received and parsed
     * @return response object
     */
Handle and dispatch the received request
@param communicationObject received and parsed
@return response object
Handle and dispatch the received request @param communicationObject received and parsed @return response object
public BranchResponseMessage handleRequest(ClusterCommunicationObject<String> communicationObject){
        BranchResponseMessage response;
        try {
            switch (communicationObject.tag) {
                case OperationCodes.SEARCH_AVAIL_VEHICLES: {
                    Type jsonType = new TypeToken<BranchRequestMessage<SearchAvailableVehiclesRequestContract>>() {}.getType();
                    BranchRequestMessage<SearchAvailableVehiclesRequestContract> request = SerializationUtils.deserialize(communicationObject.object, jsonType);
                    response = GuestBranchController.handleSearchAvailableVehicles(request, true);
                    break;
                }
                case OperationCodes.CLUSTER_SEARCH_AVAIL_VEHICLES_BROADCAST: {
                    Type jsonType = new TypeToken<BranchRequestMessage<SearchAvailableVehiclesRequestContract>>() {}.getType();
                    BranchRequestMessage<SearchAvailableVehiclesRequestContract> request = SerializationUtils.deserialize(communicationObject.object, jsonType);
                    response = GuestBranchController.handleSearchAvailableVehicles(request, false);
                    break;
                }
                case OperationCodes.BOOK_VEHICLE: {
                    Type jsonType = new TypeToken<BranchRequestMessage<CreateBookingContract>>() {}.getType();
                    BranchRequestMessage<CreateBookingContract> request = SerializationUtils.deserialize(communicationObject.object, jsonType);
                    response = UserBranchController.handleCreateBooking(request);
                    break;
                }
                case OperationCodes.GET_USER_BOOKINGS: {
                    Type jsonType = new TypeToken<BranchRequestMessage<Void>>() {}.getType();
                    BranchRequestMessage<Void> request = SerializationUtils.deserialize(communicationObject.object, jsonType);
                    response = UserBranchController.handleGetUserBookings(request);
                    break;
                }
                case OperationCodes.SHUTDOWN_SYSTEM: {
                    Type jsonType = new TypeToken<BranchRequestMessage<Void>>() {}.getType();
                    BranchRequestMessage<Void> request = SerializationUtils.deserialize(communicationObject.object, jsonType);
                    response = StaffBranchController.handleBranchShutdown(request);
                    break;
                }
                case OperationCodes.GET_BRANCH_BOOKINGS: {
                    Type jsonType = new TypeToken<BranchRequestMessage<Void>>() {}.getType();
                    BranchRequestMessage<Void> request = SerializationUtils.deserialize(communicationObject.object, jsonType);
                    response = StaffBranchController.handleGetBranchBookings(request);
                    break;
                }
                case OperationCodes.UPDATE_OR_CREATE_VEHICLE: {
                    Type jsonType = new TypeToken<BranchRequestMessage<CreateUpdateVehicleContract>>() {}.getType();
                    BranchRequestMessage<CreateUpdateVehicleContract> request = SerializationUtils.deserialize(communicationObject.object, jsonType);
                    response = StaffBranchController.handleUpdateOrCreateVehicle(request);
                    break;
                }
                case OperationCodes.SEARCH_ALL_VEHICLES: {
                    Type jsonType = new TypeToken<BranchRequestMessage<SearchVehicleContract>>() {}.getType();
                    BranchRequestMessage<SearchVehicleContract> request = SerializationUtils.deserialize(communicationObject.object, jsonType);
                    response = StaffBranchController.handleSearchVehicles(request);
                    break;
                }
                case OperationCodes.CHANGE_BOOKING_STATUS: {
                    Type jsonType = new TypeToken<BranchRequestMessage<ChangeBookingStatusContract>>() {}.getType();
                    BranchRequestMessage<ChangeBookingStatusContract> request = SerializationUtils.deserialize(communicationObject.object, jsonType);
                    response = StaffBranchController.handleChangeBookingStatus(request);
                    break;
                }
                case OperationCodes.GET_VEHICLE_MOVES: {
                    Type jsonType = new TypeToken<BranchRequestMessage<GetBranchVehicleMovesContract>>() {}.getType();
                    BranchRequestMessage<GetBranchVehicleMovesContract> request = SerializationUtils.deserialize(communicationObject.object, jsonType);
                    response = StaffBranchController.handleGetVehicleMoves(request);
                    break;
                }
                default: {
                    response = BranchResponseMessage.GetInvalidRequestResponse();
                    break;
                }
            }
            return response;
        } catch (Exception e) {
            return BranchResponseMessage.GetServerErrorResponse();
        }
    }
public BranchResponseMessage handleRequest ( ClusterCommunicationObject < String > communicationObject ) { BranchResponseMessage response ; try { switch ( communicationObject . tag ) { case OperationCodes . SEARCH_AVAIL_VEHICLES : { Type jsonType = new TypeToken < BranchRequestMessage < SearchAvailableVehiclesRequestContract > > ( ) { } . getType ( ) ; BranchRequestMessage < SearchAvailableVehiclesRequestContract > request = SerializationUtils . deserialize ( communicationObject . object , jsonType ) ; response = GuestBranchController . handleSearchAvailableVehicles ( request , true ) ; break ; } case OperationCodes . CLUSTER_SEARCH_AVAIL_VEHICLES_BROADCAST : { Type jsonType = new TypeToken < BranchRequestMessage < SearchAvailableVehiclesRequestContract > > ( ) { } . getType ( ) ; BranchRequestMessage < SearchAvailableVehiclesRequestContract > request = SerializationUtils . deserialize ( communicationObject . object , jsonType ) ; response = GuestBranchController . handleSearchAvailableVehicles ( request , false ) ; break ; } case OperationCodes . BOOK_VEHICLE : { Type jsonType = new TypeToken < BranchRequestMessage < CreateBookingContract > > ( ) { } . getType ( ) ; BranchRequestMessage < CreateBookingContract > request = SerializationUtils . deserialize ( communicationObject . object , jsonType ) ; response = UserBranchController . handleCreateBooking ( request ) ; break ; } case OperationCodes . GET_USER_BOOKINGS : { Type jsonType = new TypeToken < BranchRequestMessage < Void > > ( ) { } . getType ( ) ; BranchRequestMessage < Void > request = SerializationUtils . deserialize ( communicationObject . object , jsonType ) ; response = UserBranchController . handleGetUserBookings ( request ) ; break ; } case OperationCodes . SHUTDOWN_SYSTEM : { Type jsonType = new TypeToken < BranchRequestMessage < Void > > ( ) { } . getType ( ) ; BranchRequestMessage < Void > request = SerializationUtils . deserialize ( communicationObject . object , jsonType ) ; response = StaffBranchController . handleBranchShutdown ( request ) ; break ; } case OperationCodes . GET_BRANCH_BOOKINGS : { Type jsonType = new TypeToken < BranchRequestMessage < Void > > ( ) { } . getType ( ) ; BranchRequestMessage < Void > request = SerializationUtils . deserialize ( communicationObject . object , jsonType ) ; response = StaffBranchController . handleGetBranchBookings ( request ) ; break ; } case OperationCodes . UPDATE_OR_CREATE_VEHICLE : { Type jsonType = new TypeToken < BranchRequestMessage < CreateUpdateVehicleContract > > ( ) { } . getType ( ) ; BranchRequestMessage < CreateUpdateVehicleContract > request = SerializationUtils . deserialize ( communicationObject . object , jsonType ) ; response = StaffBranchController . handleUpdateOrCreateVehicle ( request ) ; break ; } case OperationCodes . SEARCH_ALL_VEHICLES : { Type jsonType = new TypeToken < BranchRequestMessage < SearchVehicleContract > > ( ) { } . getType ( ) ; BranchRequestMessage < SearchVehicleContract > request = SerializationUtils . deserialize ( communicationObject . object , jsonType ) ; response = StaffBranchController . handleSearchVehicles ( request ) ; break ; } case OperationCodes . CHANGE_BOOKING_STATUS : { Type jsonType = new TypeToken < BranchRequestMessage < ChangeBookingStatusContract > > ( ) { } . getType ( ) ; BranchRequestMessage < ChangeBookingStatusContract > request = SerializationUtils . deserialize ( communicationObject . object , jsonType ) ; response = StaffBranchController . handleChangeBookingStatus ( request ) ; break ; } case OperationCodes . GET_VEHICLE_MOVES : { Type jsonType = new TypeToken < BranchRequestMessage < GetBranchVehicleMovesContract > > ( ) { } . getType ( ) ; BranchRequestMessage < GetBranchVehicleMovesContract > request = SerializationUtils . deserialize ( communicationObject . object , jsonType ) ; response = StaffBranchController . handleGetVehicleMoves ( request ) ; break ; } default : { response = BranchResponseMessage . GetInvalidRequestResponse ( ) ; break ; } } return response ; } catch ( Exception e ) { return BranchResponseMessage . GetServerErrorResponse ( ) ; } }
Handle and dispatch the received request
 @param communicationObject received and parsed
 @return response object
Handle and dispatch the received request @param communicationObject received and parsed @return response object
//Guest methods //User methods //Staff methods