Search in sources :

Example 1 with ErrorCode

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

the class ViteroManager method removeFromRoom.

public ViteroStatus removeFromRoom(ViteroBooking booking, int userId) throws VmsNotAvailableException {
    try {
        Groupiduserid groupuserId = new Groupiduserid();
        groupuserId.setGroupid(booking.getGroupId());
        groupuserId.setUserid(userId);
        getGroupWebService().removeUserFromGroup(groupuserId);
        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;
            case invalidAttribut:
                log.error("An id <= 0", f);
                break;
            default:
                logAxisError("Cannot remove an user from a group", f);
        }
        return new ViteroStatus(code);
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot remove an user from a group", e);
        return new ViteroStatus(ErrorCode.unkown);
    }
}
Also used : Groupiduserid(de.vitero.schema.group.Groupiduserid) 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 2 with ErrorCode

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

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 3 with ErrorCode

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

the class ViteroManager method getVmsUsersByGroup.

protected List<Usertype> getVmsUsersByGroup(int groupId) throws VmsNotAvailableException {
    try {
        GetUserListByGroupRequest listRequest = new GetUserListByGroupRequest();
        listRequest.setGroupid(groupId);
        Userlist userList = getUserWebService().getUserListByGroup(listRequest);
        List<Usertype> userTypes = userList.getUser();
        return userTypes;
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            default:
                logAxisError("Cannot get the list of users in group: " + groupId, f);
        }
        return null;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot get the list of users in group: " + groupId, e);
        return null;
    }
}
Also used : Usertype(de.vitero.schema.user.Usertype) GetUserListByGroupRequest(de.vitero.schema.user.GetUserListByGroupRequest) WebServiceException(javax.xml.ws.WebServiceException) Userlist(de.vitero.schema.user.Userlist) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) ConnectException(java.net.ConnectException)

Example 4 with ErrorCode

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

the class ViteroManager method storePortrait.

protected boolean storePortrait(Identity identity, int userId) throws VmsNotAvailableException {
    try {
        File portrait = DisplayPortraitManager.getInstance().getBigPortrait(identity.getName());
        if (portrait != null && portrait.exists()) {
            Mtom mtomWs = getMtomWebService();
            CompleteAvatarWrapper avatar = new CompleteAvatarWrapper();
            avatar.setType(BigInteger.ZERO);
            avatar.setUserid(BigInteger.valueOf(userId));
            avatar.setFilename(portrait.getName());
            DataHandler portraitHandler = new DataHandler(new FileDataSource(portrait));
            avatar.setFile(portraitHandler);
            mtomWs.storeAvatar(avatar);
            return true;
        }
        return false;
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            default:
                logAxisError("Cannot store the portrait of " + userId, f);
        }
        return false;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot store the portrait of " + userId, e);
        return false;
    }
}
Also used : CompleteAvatarWrapper(de.vitero.schema.mtom.CompleteAvatarWrapper) Mtom(de.vitero.schema.mtom.Mtom) WebServiceException(javax.xml.ws.WebServiceException) FileDataSource(javax.activation.FileDataSource) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) DataHandler(javax.activation.DataHandler) ErrorCode(org.olat.modules.vitero.model.ErrorCode) File(java.io.File) ConnectException(java.net.ConnectException)

Example 5 with ErrorCode

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

the class ViteroManager method getGroupRoles.

/**
 * @param id The group id
 * @return
 * @throws VmsNotAvailableException
 */
public ViteroGroupRoles getGroupRoles(int id) throws VmsNotAvailableException {
    try {
        Group groupWs = getGroupWebService();
        Groupid groupId = new Groupid();
        groupId.setGroupid(id);
        Group_Type group = groupWs.getGroup(groupId);
        Completegrouptype groupType = group.getGroup();
        List<Completegrouptype.Participant> participants = groupType.getParticipant();
        int numOfParticipants = participants == null ? 0 : participants.size();
        ViteroGroupRoles groupRoles = new ViteroGroupRoles();
        if (numOfParticipants > 0) {
            Map<Integer, String> idToEmails = new HashMap<Integer, String>();
            List<Usertype> vmsUsers = getVmsUsersByGroup(id);
            if (vmsUsers != null) {
                for (Usertype vmsUser : vmsUsers) {
                    Integer userId = new Integer(vmsUser.getId());
                    String email = vmsUser.getEmail();
                    groupRoles.getEmailsOfParticipants().add(email);
                    idToEmails.put(userId, email);
                }
            }
            for (int i = 0; i < numOfParticipants; i++) {
                Completegrouptype.Participant participant = participants.get(i);
                Integer userId = new Integer(participant.getUserid());
                String email = idToEmails.get(userId);
                if (email != null) {
                    GroupRole role = GroupRole.valueOf(participant.getRole());
                    groupRoles.getEmailsToRole().put(email, role);
                    groupRoles.getEmailsToVmsUserId().put(email, userId);
                }
            }
        }
        return groupRoles;
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            default:
                logAxisError("Cannot get group roles", f);
        }
        return null;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        return null;
    }
}
Also used : Group(de.vitero.schema.group.Group) ViteroGroup(org.olat.modules.vitero.model.ViteroGroup) BusinessGroup(org.olat.group.BusinessGroup) ViteroGroupRoles(org.olat.modules.vitero.model.ViteroGroupRoles) Usertype(de.vitero.schema.user.Usertype) WebServiceException(javax.xml.ws.WebServiceException) HashMap(java.util.HashMap) Completegrouptype(de.vitero.schema.group.Completegrouptype) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Group_Type(de.vitero.schema.group.Group_Type) Groupid(de.vitero.schema.group.Groupid) BigInteger(java.math.BigInteger) GroupRole(org.olat.modules.vitero.model.GroupRole) ErrorCode(org.olat.modules.vitero.model.ErrorCode) ConnectException(java.net.ConnectException)

Aggregations

ConnectException (java.net.ConnectException)48 WebServiceException (javax.xml.ws.WebServiceException)48 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)48 ErrorCode (org.olat.modules.vitero.model.ErrorCode)48 BigInteger (java.math.BigInteger)10 ViteroStatus (org.olat.modules.vitero.model.ViteroStatus)10 Groupid (de.vitero.schema.group.Groupid)8 Group (de.vitero.schema.group.Group)6 Usertype (de.vitero.schema.user.Usertype)6 ParseException (java.text.ParseException)6 ArrayList (java.util.ArrayList)6 ConnectTimeoutException (org.apache.commons.httpclient.ConnectTimeoutException)6 BusinessGroup (org.olat.group.BusinessGroup)6 GetUserInfo (org.olat.modules.vitero.model.GetUserInfo)6 ViteroGroup (org.olat.modules.vitero.model.ViteroGroup)6 Booking (de.vitero.schema.booking.Booking)4 Bookinglist (de.vitero.schema.booking.Bookinglist)4 Bookingtype (de.vitero.schema.booking.Bookingtype)4 ChangeGroupRoleRequest (de.vitero.schema.group.ChangeGroupRoleRequest)4 Completegrouptype (de.vitero.schema.group.Completegrouptype)4