src/com/vehiclerental/presentationLayer/branch/GuestBranchController.java
/**
     * Search for the available vehicles in the current branch and optionally across the system and returns the results
     *
     * @param request request criteria
     * @param requireBroadcast true if should search in other branches
     * @return the result response
     */
Search for the available vehicles in the current branch and optionally across the system and returns the results
@param request request criteria
@param requireBroadcast true if should search in other branches
@return the result response
Search for the available vehicles in the current branch and optionally across the system and returns the results @param request request criteria @param requireBroadcast true if should search in other branches @return the result response
public static BranchResponseMessage handleSearchAvailableVehicles(BranchRequestMessage<SearchAvailableVehiclesRequestContract> request, boolean requireBroadcast) {
        try {
            /* Service calls */
            VehicleService vehicleService = ServiceFactory.getVehicleService();
            List<BookingSearchResultContract> vehicleContracts;
            vehicleContracts = vehicleService.searchAvailableVehicles(request.object, NodeConfiguration.Current.nodeBranch, !requireBroadcast);
            if (requireBroadcast) {
                vehicleContracts.addAll(vehicleService.broadcastSearchAvailableVehicles(request.object, request.userId));
            }
            /* Handle response */
            return generateSuccessfulResponse(request.operationCode, vehicleContracts);
        } catch (InvalidDateException e) {
            return generateError(request.operationCode, 400, e.getMessage());
        } catch (DatabaseAccessFailedException e) {
            System.out.println(e.getMessage());
            e.printStackTrace();
            return generateError(request.operationCode, 500, "Branch error");
        } catch (ClusterCommunicatorException e) {
            System.out.println(e.getMessage());
            e.printStackTrace();
            return generateError(request.operationCode, 500, "Branch error");
        }
    }
public static BranchResponseMessage handleSearchAvailableVehicles ( BranchRequestMessage < SearchAvailableVehiclesRequestContract > request , boolean requireBroadcast ) { try { /* Service calls */ VehicleService vehicleService = ServiceFactory . getVehicleService ( ) ; List < BookingSearchResultContract > vehicleContracts ; vehicleContracts = vehicleService . searchAvailableVehicles ( request . object , NodeConfiguration . Current . nodeBranch , ! requireBroadcast ) ; if ( requireBroadcast ) { vehicleContracts . addAll ( vehicleService . broadcastSearchAvailableVehicles ( request . object , request . userId ) ) ; } /* Handle response */ return generateSuccessfulResponse ( request . operationCode , vehicleContracts ) ; } catch ( InvalidDateException e ) { return generateError ( request . operationCode , 400 , e . getMessage ( ) ) ; } catch ( DatabaseAccessFailedException e ) { System . out . println ( e . getMessage ( ) ) ; e . printStackTrace ( ) ; return generateError ( request . operationCode , 500 , "Branch error" ) ; } catch ( ClusterCommunicatorException e ) { System . out . println ( e . getMessage ( ) ) ; e . printStackTrace ( ) ; return generateError ( request . operationCode , 500 , "Branch error" ) ; } }
Search for the available vehicles in the current branch and optionally across the system and returns the results
 @param request request criteria
 @param requireBroadcast true if should search in other branches
 @return the result response
Search for the available vehicles in the current branch and optionally across the system and returns the results @param request request criteria @param requireBroadcast true if should search in other branches @return the result response
//Search database for current branch (the vehicle found in the first branch (not broacasted) will not require a move) //Search other branches