Search in sources :

Example 21 with ViteroStatus

use of org.olat.modules.vitero.model.ViteroStatus in project openolat by klemens.

the class ViteroManager method updateVmsBooking.

public ViteroStatus updateVmsBooking(ViteroBooking vBooking) throws VmsNotAvailableException {
    try {
        UpdateBookingRequest updateRequest = new UpdateBookingRequest();
        updateRequest.setBookingid(vBooking.getBookingId());
        if (StringHelper.containsNonWhitespace(vBooking.getEventName())) {
            updateRequest.setEventname(vBooking.getEventName());
        }
        updateRequest.setEnd(format(vBooking.getEnd()));
        updateRequest.setEndbuffer(vBooking.getEndBuffer());
        updateRequest.setStart(format(vBooking.getStart()));
        updateRequest.setStartbuffer(vBooking.getStartBuffer());
        updateRequest.setTimezone(viteroModule.getTimeZoneId());
        getBookingWebService().updateBooking(updateRequest);
        return new ViteroStatus();
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            case unsufficientRights:
            case bookingCollision:
            case bookingInPast:
            case noRoomsAvailable:
                return new ViteroStatus(code);
            case bookingDoesntExist:
            case bookingDoesntExistPrime:
                {
                    deleteGroup(vBooking);
                    deleteProperty(vBooking);
                    // ok, vms deleted, group deleted...
                    return new ViteroStatus(code);
                }
            default:
                {
                    logAxisError("Cannot update a booking.", f);
                }
        }
        return new ViteroStatus(ErrorCode.unkown);
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot update a booking.", e);
        return new ViteroStatus(ErrorCode.unkown);
    }
}
Also used : UpdateBookingRequest(de.vitero.schema.booking.UpdateBookingRequest) WebServiceException(javax.xml.ws.WebServiceException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) ViteroStatus(org.olat.modules.vitero.model.ViteroStatus) ConnectException(java.net.ConnectException)

Example 22 with ViteroStatus

use of org.olat.modules.vitero.model.ViteroStatus in project openolat by klemens.

the class ViteroBookingEditController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    String name = groupName.getValue();
    booking.setGroupName(name);
    Date begin = beginChooser.getDate();
    booking.setStart(begin);
    int beginBuffer = 0;
    if (beginBufferEl.isOneSelected()) {
        beginBuffer = Integer.parseInt(beginBufferEl.getSelectedKey());
    }
    booking.setStartBuffer(beginBuffer);
    Date end = endChooser.getDate();
    booking.setEnd(end);
    int endBuffer = 0;
    if (endBufferEl.isOneSelected()) {
        endBuffer = Integer.parseInt(endBufferEl.getSelectedKey());
    }
    booking.setEndBuffer(endBuffer);
    int roomSize = -1;
    if (roomSizeEl.isOneSelected()) {
        roomSize = Integer.parseInt(roomSizeEl.getSelectedKey());
    }
    booking.setRoomSize(roomSize);
    boolean auto = autoSignIn.isMultiselect() && autoSignIn.isSelected(0);
    booking.setAutoSignIn(auto);
    try {
        if (booking.getBookingId() >= 0) {
            ViteroBooking updatedBooking = viteroManager.updateBooking(group, ores, subIdentifier, booking);
            if (updatedBooking != null) {
                showInfo("booking.ok");
                fireEvent(ureq, Event.DONE_EVENT);
            } else {
                showError("error.unkown");
            }
        } else {
            ViteroStatus status = viteroManager.createBooking(group, ores, subIdentifier, booking);
            if (status.isOk()) {
                showInfo("booking.ok");
                fireEvent(ureq, Event.DONE_EVENT);
            } else {
                showError(status.getError().i18nKey());
            }
        }
    } catch (VmsNotAvailableException e) {
        showError(VmsNotAvailableException.I18N_KEY);
    }
}
Also used : ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) VmsNotAvailableException(org.olat.modules.vitero.manager.VmsNotAvailableException) ViteroStatus(org.olat.modules.vitero.model.ViteroStatus) Date(java.util.Date)

Example 23 with ViteroStatus

use of org.olat.modules.vitero.model.ViteroStatus in project openolat by klemens.

the class ViteroBookingsController method signInVitero.

protected void signInVitero(UserRequest ureq, ViteroBooking booking) {
    try {
        ViteroStatus status = viteroManager.addToRoom(booking, ureq.getIdentity(), null);
        if (status.isOk()) {
            showInfo("signin.ok");
        } else {
            showError("signin.nok");
        }
        loadModel();
    } catch (VmsNotAvailableException e) {
        showError(VmsNotAvailableException.I18N_KEY);
    }
}
Also used : VmsNotAvailableException(org.olat.modules.vitero.manager.VmsNotAvailableException) ViteroStatus(org.olat.modules.vitero.model.ViteroStatus)

Example 24 with ViteroStatus

use of org.olat.modules.vitero.model.ViteroStatus in project openolat by klemens.

the class ViteroBookingsController method signOutVitero.

protected void signOutVitero(UserRequest ureq, ViteroBooking booking) {
    try {
        ViteroStatus status = viteroManager.removeFromRoom(booking, ureq.getIdentity());
        if (status.isOk()) {
            showInfo("signout.ok");
        } else {
            showError("signout.nok");
        }
        loadModel();
    } catch (VmsNotAvailableException e) {
        showError(VmsNotAvailableException.I18N_KEY);
    }
}
Also used : VmsNotAvailableException(org.olat.modules.vitero.manager.VmsNotAvailableException) ViteroStatus(org.olat.modules.vitero.model.ViteroStatus)

Example 25 with ViteroStatus

use of org.olat.modules.vitero.model.ViteroStatus in project openolat by klemens.

the class ViteroBookingWebService method saveRoom.

private Response saveRoom(ViteroBookingVO booking) {
    try {
        ViteroBooking vBooking = new ViteroBooking();
        vBooking.setBookingId(booking.getBookingId());
        vBooking.setExternalId(booking.getExternalId());
        vBooking.setGroupId(booking.getGroupId());
        vBooking.setGroupName(booking.getGroupName());
        vBooking.setEventName(booking.getEventName());
        vBooking.setStart(booking.getStart());
        vBooking.setStartBuffer(booking.getStartBuffer());
        vBooking.setEnd(booking.getEnd());
        vBooking.setEndBuffer(booking.getEndBuffer());
        vBooking.setRoomSize(booking.getRoomSize());
        vBooking.setAutoSignIn(booking.isAutoSignIn());
        vBooking.setTimeZoneId(viteroModule.getTimeZoneId());
        ViteroStatus status;
        if (booking.getBookingId() > 0) {
            status = viteroManager.updateVmsBooking(vBooking);
        } else {
            status = viteroManager.createBooking(null, ores, subIdentifier, vBooking);
        }
        Response response;
        if (status.isOk()) {
            response = Response.ok(new ViteroBookingVO(vBooking)).build();
        } else {
            response = handleViteroError(status);
        }
        return response;
    } catch (VmsNotAvailableException e) {
        log.error("", e);
        return handleNotAvailableException();
    }
}
Also used : Response(javax.ws.rs.core.Response) ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) VmsNotAvailableException(org.olat.modules.vitero.manager.VmsNotAvailableException) ViteroStatus(org.olat.modules.vitero.model.ViteroStatus)

Aggregations

ViteroStatus (org.olat.modules.vitero.model.ViteroStatus)26 VmsNotAvailableException (org.olat.modules.vitero.manager.VmsNotAvailableException)12 ConnectException (java.net.ConnectException)10 WebServiceException (javax.xml.ws.WebServiceException)10 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)10 ErrorCode (org.olat.modules.vitero.model.ErrorCode)10 ViteroBooking (org.olat.modules.vitero.model.ViteroBooking)8 ChangeGroupRoleRequest (de.vitero.schema.group.ChangeGroupRoleRequest)4 Group (de.vitero.schema.group.Group)4 Groupiduserid (de.vitero.schema.group.Groupiduserid)4 Identity (org.olat.core.id.Identity)4 BusinessGroup (org.olat.group.BusinessGroup)4 GetUserInfo (org.olat.modules.vitero.model.GetUserInfo)4 GroupRole (org.olat.modules.vitero.model.GroupRole)4 ViteroGroup (org.olat.modules.vitero.model.ViteroGroup)4 Booking (de.vitero.schema.booking.Booking)2 Bookingtype (de.vitero.schema.booking.Bookingtype)2 CreateBookingRequest (de.vitero.schema.booking.CreateBookingRequest)2 CreateBookingResponse (de.vitero.schema.booking.CreateBookingResponse)2 Newbookingtype (de.vitero.schema.booking.Newbookingtype)2