public boolean cancelReservation(int reservationId) {
    	Reservation reservation = getReservation(reservationId);
    	if(reservation == null) {
    		logger.info("Error cancelling reservation, ID is invalid");
        	return false;
    	}

    	int resourceId = reservation.getResourceID();
    	
        try {
	        
	        // creates the message to be sent to the grid resource
	    	ReservationMessage message = new ReservationMessage(super.get_id(), resourceId, reservation);
	    	message.setMessageType(MessageType.CANCEL);
	    	
	        // gets the reply from the grid resource
	    	ReservationMessage reply = sendReservationMessage(message);
	    	
	        // If error code is NO_ERROR, the reservation has been successful. 
	        ErrorType error = reply.getErrorCode();
	        if(error == ErrorType.NO_ERROR) {
	        	reservations_.remove(reservation.getID());
	        	return true;
	        }
	        else {
	        	logger.info("Error cancelling reservation.");
	        }
        }
        catch (Exception ex) {
        	logger.log(Level.WARNING,"Error cancelling reservation.", ex);
        }
    	return false;
    }