Search in sources :

Example 16 with ViteroStatus

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

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 17 with ViteroStatus

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

the class ViteroManager method removeFromRoom.

public ViteroStatus removeFromRoom(ViteroBooking booking, Identity identity) throws VmsNotAvailableException {
    GetUserInfo userInfo = getVmsUserId(identity, true);
    int userId = userInfo.getUserId();
    if (userId < 0) {
        // nothing to remove
        return new ViteroStatus();
    }
    return removeFromRoom(booking, userId);
}
Also used : GetUserInfo(org.olat.modules.vitero.model.GetUserInfo) ViteroStatus(org.olat.modules.vitero.model.ViteroStatus)

Example 18 with ViteroStatus

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

the class ViteroManager method createBooking.

public ViteroStatus createBooking(BusinessGroup group, OLATResourceable ores, String subIdentifier, ViteroBooking vBooking) throws VmsNotAvailableException {
    Bookingtype booking = getVmsBookingById(vBooking.getBookingId());
    if (booking != null) {
        log.info("Booking already exists: " + vBooking.getBookingId());
        return new ViteroStatus();
    }
    try {
        // a group per meeting
        String groupName = vBooking.getGroupName();
        int groupId = createGroup(groupName);
        if (groupId < 0) {
            return new ViteroStatus(ErrorCode.unkown);
        }
        vBooking.setGroupId(groupId);
        // create the meeting with the new group
        Booking bookingWs = getBookingWebService();
        CreateBookingRequest createRequest = new CreateBookingRequest();
        Newbookingtype newBooking = new Newbookingtype();
        // mandatory
        newBooking.setStart(format(vBooking.getStart()));
        newBooking.setEnd(format(vBooking.getEnd()));
        newBooking.setStartbuffer(vBooking.getStartBuffer());
        newBooking.setEndbuffer(vBooking.getEndBuffer());
        newBooking.setGroupid(groupId);
        newBooking.setRoomsize(vBooking.getRoomSize());
        newBooking.setTimezone(viteroModule.getTimeZoneId());
        if (StringHelper.containsNonWhitespace(vBooking.getEventName())) {
            newBooking.setEventname(vBooking.getEventName());
        }
        createRequest.setBooking(newBooking);
        CreateBookingResponse response = bookingWs.createBooking(createRequest);
        Boolean bookingCollision = response.isBookingcollision();
        Boolean moduleCollision = response.isModulecollision();
        int bookingId = response.getBookingid();
        if (bookingCollision != null && bookingCollision.booleanValue()) {
            return new ViteroStatus(ErrorCode.bookingCollision);
        } else if (moduleCollision != null && moduleCollision.booleanValue()) {
            return new ViteroStatus(ErrorCode.moduleCollision);
        }
        vBooking.setBookingId(bookingId);
        getOrCreateProperty(group, ores, subIdentifier, vBooking);
        return new ViteroStatus();
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            case invalidTimezone:
                log.error("Invalid time zone!", f);
                break;
            case bookingCollision:
                log.error("Booking collision!", f);
                break;
            case moduleCollision:
                log.error("Invalid module selection!", f);
                break;
            case bookingInPast:
                log.error("Booking in the past!", f);
                break;
            case licenseExpired:
                log.error("License/customer expired!", f);
                break;
            default:
                logAxisError("Cannot create a booking.", f);
        }
        return new ViteroStatus(code);
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot create a booking.", e);
        return new ViteroStatus(ErrorCode.remoteException);
    }
}
Also used : CreateBookingRequest(de.vitero.schema.booking.CreateBookingRequest) CreateBookingResponse(de.vitero.schema.booking.CreateBookingResponse) WebServiceException(javax.xml.ws.WebServiceException) Booking(de.vitero.schema.booking.Booking) ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Bookingtype(de.vitero.schema.booking.Bookingtype) ErrorCode(org.olat.modules.vitero.model.ErrorCode) ViteroStatus(org.olat.modules.vitero.model.ViteroStatus) Newbookingtype(de.vitero.schema.booking.Newbookingtype) ConnectException(java.net.ConnectException)

Example 19 with ViteroStatus

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

the class ViteroManager method changeGroupRole.

public ViteroStatus changeGroupRole(int groupId, int vmsUserId, int roleId) throws VmsNotAvailableException {
    try {
        Group groupWs = getGroupWebService();
        ChangeGroupRoleRequest roleRequest = new ChangeGroupRoleRequest();
        roleRequest.setGroupid(groupId);
        roleRequest.setUserid(vmsUserId);
        roleRequest.setRole(roleId);
        groupWs.changeGroupRole(roleRequest);
        return new ViteroStatus();
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            case userDoesntExist:
                log.error("The user doesn ́t exist!", f);
                break;
            case groupDoesntExist:
                log.error("The group doesn ́t exist", f);
                break;
            default:
                logAxisError("Cannot add an user to a group", f);
        }
        return new ViteroStatus(code);
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot add an user to a group", e);
        return new ViteroStatus(ErrorCode.unkown);
    }
}
Also used : Group(de.vitero.schema.group.Group) ViteroGroup(org.olat.modules.vitero.model.ViteroGroup) BusinessGroup(org.olat.group.BusinessGroup) WebServiceException(javax.xml.ws.WebServiceException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) ChangeGroupRoleRequest(de.vitero.schema.group.ChangeGroupRoleRequest) ViteroStatus(org.olat.modules.vitero.model.ViteroStatus) ConnectException(java.net.ConnectException)

Example 20 with ViteroStatus

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

the class ViteroManager method addToRoom.

public ViteroStatus addToRoom(ViteroBooking booking, Identity identity, GroupRole role) throws VmsNotAvailableException {
    try {
        GetUserInfo userInfo = getVmsUserId(identity, true);
        int userId = userInfo.getUserId();
        if (userId < 0) {
            return new ViteroStatus(ErrorCode.userDoesntExist);
        }
        if (!userInfo.isCreated()) {
            // update user information
            try {
                updateVmsUser(identity, userId);
            // storePortrait(identity, userId);
            } catch (Exception e) {
                log.error("Cannot update user on vitero system:" + identity.getName(), e);
            }
        }
        Group groupWs = getGroupWebService();
        Groupiduserid groupuserId = new Groupiduserid();
        groupuserId.setGroupid(booking.getGroupId());
        groupuserId.setUserid(userId);
        groupWs.addUserToGroup(groupuserId);
        if (role != null) {
            groupWs = getGroupWebService();
            ChangeGroupRoleRequest roleRequest = new ChangeGroupRoleRequest();
            roleRequest.setGroupid(booking.getGroupId());
            roleRequest.setUserid(userId);
            roleRequest.setRole(role.getVmsValue());
            groupWs.changeGroupRole(roleRequest);
        }
        return new ViteroStatus();
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            case userDoesntExist:
                log.error("The user doesn ́t exist!", f);
                break;
            case userNotAttachedToCustomer:
                log.error("The user is not attached to the customer (to which this group belongs)", f);
                break;
            case groupDoesntExist:
                log.error("The group doesn ́t exist", f);
                break;
            case invalidAttribut:
                log.error("An id <= 0", f);
                break;
            default:
                logAxisError("Cannot add an user to a group", f);
        }
        return new ViteroStatus(code);
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot add an user to a group", e);
        return new ViteroStatus(ErrorCode.unkown);
    }
}
Also used : Group(de.vitero.schema.group.Group) ViteroGroup(org.olat.modules.vitero.model.ViteroGroup) BusinessGroup(org.olat.group.BusinessGroup) Groupiduserid(de.vitero.schema.group.Groupiduserid) GetUserInfo(org.olat.modules.vitero.model.GetUserInfo) 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) ChangeGroupRoleRequest(de.vitero.schema.group.ChangeGroupRoleRequest) ConnectException(java.net.ConnectException) WebServiceException(javax.xml.ws.WebServiceException) ConnectTimeoutException(org.apache.commons.httpclient.ConnectTimeoutException) ParseException(java.text.ParseException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ConnectException(java.net.ConnectException)

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