import org.vertx.java.core.json.JsonObject; //导入方法依赖的package包/类
private void notifyBookingDeleted(final HttpServerRequest request, final UserInfos user,
final JsonObject booking, final String bookingId) {
final String owner = booking.getString("owner", null);
final String startDate = booking.getString("start_date", null);
final String endDate = booking.getString("end_date", null);
final boolean isPeriodic = booking.getBoolean("is_periodic");
final String resourceName = booking.getString("resource_name", null);
final String notificationName;
if (startDate == null || endDate == null ||
owner == null || owner.trim().isEmpty() ||
resourceName == null || resourceName.trim().isEmpty()) {
log.error("Could not get start_date, end_date, owner or resource_name from response. Unable to send timeline "+
BOOKING_DELETED_EVENT_TYPE + " or " + PERIODIC_BOOKING_DELETED_EVENT_TYPE + " notification.");
return;
}
// Notify only if current user is not the booking's owner
if(!owner.equals(user.getUserId())) {
if(isPeriodic) {
notificationName = "periodic-booking-deleted";
}
else {
notificationName = "booking-deleted";
}
JsonObject params = new JsonObject();
params.putString("username", user.getUsername())
.putString("uri", "/userbook/annuaire#" + user.getUserId() + "#" + user.getType())
.putString("startdate", startDate)
.putString("enddate", endDate)
.putString("resourcename", resourceName);
List recipients = new ArrayList<>();
recipients.add(owner);
notification.notifyTimeline(request, "rbs." + notificationName, user, recipients, bookingId, params);
}
}