Example usage for javax.xml.ws WebServiceException getCause

List of usage examples for javax.xml.ws WebServiceException getCause

Introduction

In this page you can find the example usage for javax.xml.ws WebServiceException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:org.olat.modules.vitero.manager.ViteroManager.java

public List<Integer> getLicenceForAvailableRooms(Date begin, Date end) throws VmsNotAvailableException {
    List<Integer> roomSizes = new ArrayList<Integer>();
    try {/*from w w  w  .  j  a  va  2  s.c  o  m*/
        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();
        }
        logError("Cannot get licence for available room by dates.", e);
    }
    return roomSizes;
}

From source file:org.olat.modules.vitero.manager.ViteroManager.java

public int createGroup(String groupName) throws VmsNotAvailableException {
    try {/*w  ww.j a  va2  s.  c o m*/
        CreateGroupRequest createRequest = new CreateGroupRequest();
        Groupnamecustomerid groupInfos = new Groupnamecustomerid();
        groupInfos.setGroupname(groupName + "_OLAT_" + UUID.randomUUID().toString().replace("-", ""));
        groupInfos.setCustomerid(viteroModule.getCustomerId());
        createRequest.setGroup(groupInfos);

        Groupid groupId = getGroupWebService().createGroup(createRequest);
        return groupId.getGroupid();
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch (code) {
        default:
            logAxisError("Cannot create a group", f);
        }
        return -1;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        logError("Cannot create a group.", e);
        return -1;
    }
}

From source file:org.olat.modules.vitero.manager.ViteroManager.java

public ViteroGroup getGroup(int id) throws VmsNotAvailableException {
    try {/*  ww w .  j  a va2  s  .  c  o  m*/
        Groupid groupId = new Groupid();
        groupId.setGroupid(id);
        Group_Type group = getGroupWebService().getGroup(groupId);
        Completegrouptype groupType = group.getGroup();
        return convert(groupType);
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch (code) {
        default:
            logAxisError("Cannot create a group", f);
        }
        return null;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        logError("Cannot create a group.", e);
        return null;
    }
}

From source file:org.olat.modules.vitero.manager.ViteroManager.java

public boolean deleteGroup(ViteroBooking vBooking) throws VmsNotAvailableException {
    try {//from w  w w .  j  a  v a  2  s . c o  m
        Groupid groupId = new Groupid();
        groupId.setGroupid(vBooking.getGroupId());
        getGroupWebService().deleteGroup(groupId);
        return true;
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch (code) {
        case groupDoesntExist:
            logError("Group doesn't exist!", f);
            break;
        case invalidAttribut:
            logError("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();
        }
        logError("Cannot delete group: " + vBooking.getGroupId(), e);
        return false;
    }
}

From source file:org.olat.modules.vitero.manager.ViteroManager.java

public boolean removeFromRoom(ViteroBooking booking, int userId) throws VmsNotAvailableException {
    try {/*from  w  w  w .j  a  va  2 s.  co  m*/
        Groupiduserid groupuserId = new Groupiduserid();
        groupuserId.setGroupid(booking.getGroupId());
        groupuserId.setUserid(userId);
        getGroupWebService().removeUserFromGroup(groupuserId);
        return true;
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch (code) {
        case userDoesntExist:
            logError("The user doesn ?t exist!", f);
            break;
        case groupDoesntExist:
            logError("The group doesn ?t exist", f);
            break;
        case invalidAttribut:
            logError("An id <= 0", f);
            break;
        default:
            logAxisError("Cannot remove an user from a group", f);
        }
        return false;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        logError("Cannot remove an user from a group", e);
        return false;
    }
}

From source file:org.olat.modules.vitero.manager.ViteroManager.java

public ViteroStatus createBooking(BusinessGroup group, OLATResourceable ores, String subIdentifier,
        ViteroBooking vBooking) throws VmsNotAvailableException {
    Bookingtype booking = getBookingById(vBooking.getBookingId());
    if (booking != null) {
        logInfo("Booking already exists: " + vBooking.getBookingId());
        return new ViteroStatus();
    }//from w w  w  .  j a v  a2  s  .com

    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());

        //optional
        /*
        newBooking.setIgnorefaults(false);
        newBooking.setCafe(false);
        newBooking.setCapture(false);
        //phone
        BookingServiceStub.Phonetype phone = new BookingServiceStub.Phonetype();
        phone.setDialout(false);
        phone.setPhoneconference(false);
        phone.setShowdialogue(false);
        newBooking.setPhone(phone);
                
        newBooking.setPcstateokrequired(false);
        newBooking.setRepetitionpattern("once");
        newBooking.setRepetitionenddate("");
        */
        newBooking.setTimezone(viteroModule.getTimeZoneId());

        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:
            logError("Invalid time zone!", f);
            break;
        case bookingCollision:
            logError("Booking collision!", f);
            break;
        case moduleCollision:
            logError("Invalid module selection!", f);
            break;
        case bookingInPast:
            logError("Booking in the past!", f);
            break;
        case licenseExpired:
            logError("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();
        }
        logError("Cannot create a booking.", e);
        return new ViteroStatus(ErrorCode.remoteException);
    }
}

From source file:org.olat.modules.vitero.manager.ViteroManager.java

public boolean deleteBooking(ViteroBooking vBooking) throws VmsNotAvailableException {
    try {//from w w w .  j a  v a 2s  .c om
        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);
            return true;//ok, vms deleted, group deleted...
        }
        default: {
            logAxisError("Cannot delete a booking.", f);
        }
        }
        return false;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        logError("Cannot delete a booking.", e);
        return false;
    }
}

From source file:org.olat.modules.vitero.manager.ViteroManager.java

protected List<Booking_Type> getBookingInFutureByUserId(int userId) throws VmsNotAvailableException {
    try {/*from  w w w.j  a  v a 2 s  .co m*/
        GetBookingListByUserInFutureRequest request = new GetBookingListByUserInFutureRequest();
        request.setUserid(userId);
        request.setTimezone(viteroModule.getTimeZoneId());

        Bookinglist bookingList = getBookingWebService().getBookingListByUserInFuture(request);

        return bookingList.getBooking();
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch (code) {
        case userDoesntExist:
            logError("The user does not exist!", f);
            break;
        case invalidAttribut:
            logError("ids <= 0!", f);
            break;
        case invalidTimezone:
            logError("Invalid time zone!", f);
            break;
        default:
            logAxisError("Cannot get booking in future for user: " + userId, f);
        }
        return null;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        logError("Cannot get booking in future for custom: " + userId, e);
        return null;
    }
}

From source file:org.olat.modules.vitero.manager.ViteroManager.java

protected Bookingtype getBookingById(int id) throws VmsNotAvailableException {
    if (id < 0)
        return null;

    try {/*from   w w  w.  j a v  a2  s.com*/
        Bookingid bookingId = new Bookingid();
        bookingId.setBookingid(id);
        Bookingtype booking = getBookingWebService().getBookingById(bookingId);
        return booking;
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch (code) {
        case invalidAttribut:
            logError("ids <= 0", f);
            break;
        case bookingDoesntExist:
            logError("The booking does not exist", f);
            break;
        default:
            logAxisError("Cannot get booking by id: " + id, f);
        }
        return null;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        logError("Cannot get booking by id: " + id, e);
        return null;
    }
}

From source file:org.olat.modules.vitero.manager.ViteroManager.java

public boolean checkConnection(final String url, final String login, final String password,
        final int customerId) throws VmsNotAvailableException {
    try {/*from   ww  w.java 2s  . co m*/
        LicenceService ss = new LicenceService();
        ss.setHandlerResolver(new HandlerResolver() {
            @SuppressWarnings("rawtypes")
            @Override
            public List<Handler> getHandlerChain(PortInfo portInfo) {
                List<Handler> handlerList = new ArrayList<Handler>();
                handlerList.add(new ViteroSecurityHandler(login, password));
                return handlerList;
            }

        });
        Licence port = ss.getLicenceSoap11();
        String endPoint = UriBuilder.fromUri(url).path("services").path("LicenseService").build().toString();
        ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endPoint);
        GetModulesForCustomerRequest request = new GetModulesForCustomerRequest();
        request.setCustomerid(customerId);
        Modulestype modulesType = port.getModulesForCustomer(request);
        return modulesType != null;
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch (code) {
        case unsufficientRights:
            logError("Unsufficient rights", f);
            break;
        default:
            logAxisError("Cannot check connection", f);
        }
        return false;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        logWarn("Error checking connection", e);
        return false;
    }
}