src/com/vehiclerental/presentationLayer/branch/UserBranchController.java
/**
     * Create a booking in the specified branch with the given criteria
     *
     * @param request the request parameters
     * @return the result response
     */
Create a booking in the specified branch with the given criteria
@param request the request parameters
@return the result response
Create a booking in the specified branch with the given criteria @param request the request parameters @return the result response
public static BranchResponseMessage handleCreateBooking(BranchRequestMessage<CreateBookingContract> request) {
        try {
            /* Service calls */
            BookingService bookingService = ServiceFactory.getBookingService();
            BookingContract bookingContract = bookingService.createBooking(request.userId, NodeConfiguration.Current.nodeBranch, request.object);
            /* Handle response */
            return generateSuccessfulResponse(request.operationCode, bookingContract);
        } catch (InvalidPropertyException e) {
            return generateError(request.operationCode, 400, e.getMessage());
        } catch (NotAuthorizedException e) {
            return generateError(request.operationCode, 401, "Unauthorized");
        } catch (VehicleUnavailableException e) {
            return generateError(request.operationCode, 400, "Vehicle unavailable");
        } catch (InvalidDateException e) {
            return generateError(request.operationCode, 400, "Invalid dates");
        } catch (ClusterCommunicatorException e) {
            System.out.println(e.getMessage());
            e.printStackTrace();
            return generateError(request.operationCode, 500, "Branch error");
        } catch (DatabaseAccessFailedException e) {
            System.out.println(e.getMessage());
            e.printStackTrace();
            return generateError(request.operationCode, 500, "Branch error");
        }
    }
public static BranchResponseMessage handleCreateBooking ( BranchRequestMessage < CreateBookingContract > request ) { try { /* Service calls */ BookingService bookingService = ServiceFactory . getBookingService ( ) ; BookingContract bookingContract = bookingService . createBooking ( request . userId , NodeConfiguration . Current . nodeBranch , request . object ) ; /* Handle response */ return generateSuccessfulResponse ( request . operationCode , bookingContract ) ; } catch ( InvalidPropertyException e ) { return generateError ( request . operationCode , 400 , e . getMessage ( ) ) ; } catch ( NotAuthorizedException e ) { return generateError ( request . operationCode , 401 , "Unauthorized" ) ; } catch ( VehicleUnavailableException e ) { return generateError ( request . operationCode , 400 , "Vehicle unavailable" ) ; } catch ( InvalidDateException e ) { return generateError ( request . operationCode , 400 , "Invalid dates" ) ; } catch ( ClusterCommunicatorException e ) { System . out . println ( e . getMessage ( ) ) ; e . printStackTrace ( ) ; return generateError ( request . operationCode , 500 , "Branch error" ) ; } catch ( DatabaseAccessFailedException e ) { System . out . println ( e . getMessage ( ) ) ; e . printStackTrace ( ) ; return generateError ( request . operationCode , 500 , "Branch error" ) ; } }
Create a booking in the specified branch with the given criteria
 @param request the request parameters
 @return the result response
Create a booking in the specified branch with the given criteria @param request the request parameters @return the result response