Search in sources :

Example 16 with ErrorCode

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

the class ViteroManager method deleteBooking.

public boolean deleteBooking(ViteroBooking vBooking) throws VmsNotAvailableException {
    try {
        DeleteBookingRequest deleteRequest = new DeleteBookingRequest();
        deleteRequest.setBookingid(vBooking.getBookingId());
        DeleteBookingResponse response = getBookingWebService().deleteBooking(deleteRequest);
        BigInteger state = response.getDeletestate();
        deleteGroup(vBooking);
        deleteProperty(vBooking);
        return state != null;
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            case bookingDoesntExist:
            case bookingDoesntExistPrime:
                {
                    deleteGroup(vBooking);
                    deleteProperty(vBooking);
                    // ok, vms deleted, group deleted...
                    return true;
                }
            default:
                {
                    logAxisError("Cannot delete a booking.", f);
                }
        }
        return false;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot delete a booking.", e);
        return false;
    }
}
Also used : DeleteBookingRequest(de.vitero.schema.booking.DeleteBookingRequest) WebServiceException(javax.xml.ws.WebServiceException) BigInteger(java.math.BigInteger) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) DeleteBookingResponse(de.vitero.schema.booking.DeleteBookingResponse) ConnectException(java.net.ConnectException)

Example 17 with ErrorCode

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

the class ViteroManager method getBookingByDate.

public List<ViteroBooking> getBookingByDate(Date start, Date end) throws VmsNotAvailableException {
    try {
        Booking bookingWs = getBookingWebService();
        GetBookingListByDateRequest dateRequest = new GetBookingListByDateRequest();
        dateRequest.setStart(format(start));
        dateRequest.setEnd(format(end));
        dateRequest.setTimezone(viteroModule.getTimeZoneId());
        dateRequest.setCustomerid(viteroModule.getCustomerId());
        Bookinglist bookingList = bookingWs.getBookingListByDate(dateRequest);
        List<Booking_Type> bookings = bookingList.getBooking();
        return convert(bookings);
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            default:
                logAxisError("Cannot get the list of bookings by date.", f);
        }
        return Collections.emptyList();
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        return Collections.emptyList();
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) GetBookingListByDateRequest(de.vitero.schema.booking.GetBookingListByDateRequest) Booking_Type(de.vitero.schema.booking.Booking_Type) Booking(de.vitero.schema.booking.Booking) ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) Bookinglist(de.vitero.schema.booking.Bookinglist) ConnectException(java.net.ConnectException)

Example 18 with ErrorCode

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

the class ViteroManager method deleteGroup.

public boolean deleteGroup(ViteroBooking vBooking) throws VmsNotAvailableException {
    try {
        Groupid groupId = new Groupid();
        groupId.setGroupid(vBooking.getGroupId());
        getGroupWebService().deleteGroup(groupId);
        return true;
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            case groupDoesntExist:
                log.error("Group doesn't exist!", f);
                break;
            case invalidAttribut:
                log.error("Group id <= 0!", f);
            default:
                logAxisError("Cannot delete group: " + vBooking.getGroupId(), f);
        }
        return false;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot delete group: " + vBooking.getGroupId(), e);
        return false;
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) Groupid(de.vitero.schema.group.Groupid) ConnectException(java.net.ConnectException)

Example 19 with ErrorCode

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

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

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

the class ViteroManager method getLicenceForAvailableRooms.

public List<Integer> getLicenceForAvailableRooms(Date begin, Date end) throws VmsNotAvailableException {
    List<Integer> roomSizes = new ArrayList<Integer>();
    try {
        Grouprequesttype groupRequest = new Grouprequesttype();
        groupRequest.setStart(format(begin));
        groupRequest.setEnd(format(end));
        GetBookableRoomsForGroupResponse response = getLicenceWebService().getBookableRoomsForGroup(groupRequest);
        Rooms rooms = response.getRooms();
        for (Integer roomSize : rooms.getRoomsize()) {
            if (!roomSizes.contains(roomSize)) {
                roomSizes.add(roomSize);
            }
        }
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            default:
                logAxisError("Cannot get licence for available room by dates.", f);
        }
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot get licence for available room by dates.", e);
    }
    return roomSizes;
}
Also used : BigInteger(java.math.BigInteger) Grouprequesttype(de.vitero.schema.licence.Grouprequesttype) WebServiceException(javax.xml.ws.WebServiceException) GetBookableRoomsForGroupResponse(de.vitero.schema.licence.GetBookableRoomsForGroupResponse) ArrayList(java.util.ArrayList) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) Rooms(de.vitero.schema.licence.GetBookableRoomsForGroupResponse.Rooms) 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