Search in sources :

Example 11 with ErrorCode

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

the class ViteroManager method createGroup.

public int createGroup(String groupName) throws VmsNotAvailableException {
    try {
        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();
        }
        log.error("Cannot create a group.", e);
        return -1;
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) CreateGroupRequest(de.vitero.schema.group.CreateGroupRequest) Groupnamecustomerid(de.vitero.schema.group.Groupnamecustomerid) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) Groupid(de.vitero.schema.group.Groupid) ConnectException(java.net.ConnectException)

Example 12 with ErrorCode

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

the class ViteroManager method getBookingInFutureByUserId.

protected List<Booking_Type> getBookingInFutureByUserId(int userId) throws VmsNotAvailableException {
    try {
        GetBookingListByUserAndCustomerInFutureRequest request = new GetBookingListByUserAndCustomerInFutureRequest();
        request.setUserid(userId);
        request.setCustomerid(viteroModule.getCustomerId());
        request.setTimezone(viteroModule.getTimeZoneId());
        Bookinglist bookingList = getBookingWebService().getBookingListByUserAndCustomerInFuture(request);
        return bookingList.getBooking();
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            case userDoesntExist:
                log.error("The user does not exist!", f);
                break;
            case invalidAttribut:
                log.error("ids <= 0!", f);
                break;
            case invalidTimezone:
                log.error("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();
        }
        log.error("Cannot get booking in future for custom: " + userId, e);
        return null;
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) GetBookingListByUserAndCustomerInFutureRequest(de.vitero.schema.booking.GetBookingListByUserAndCustomerInFutureRequest) Bookinglist(de.vitero.schema.booking.Bookinglist) ConnectException(java.net.ConnectException)

Example 13 with ErrorCode

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

the class ViteroManager method getLicencedRoomSizes.

public List<Integer> getLicencedRoomSizes() throws VmsNotAvailableException {
    List<Integer> roomSizes = new ArrayList<Integer>();
    try {
        GetModulesForCustomerRequest licenceRequest = new GetModulesForCustomerRequest();
        licenceRequest.setCustomerid(viteroModule.getCustomerId());
        Modulestype modules = getLicenceWebService().getModulesForCustomer(licenceRequest);
        Modules modulesType = modules.getModules();
        for (Module module : modulesType.getModule()) {
            if ("ROOM".equals(module.getType())) {
                Integer roomSize = module.getRoomsize();
                if (!roomSizes.contains(roomSize)) {
                    roomSizes.add(roomSize);
                }
            }
        }
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            case invalidAttribut:
                log.error("ids <=0 or invalid attributs", f);
                break;
            default:
                logAxisError("Cannot get licence for customer: " + viteroModule.getCustomerId(), f);
        }
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot get licence for customer: " + viteroModule.getCustomerId(), e);
    }
    return roomSizes;
}
Also used : BigInteger(java.math.BigInteger) WebServiceException(javax.xml.ws.WebServiceException) GetModulesForCustomerRequest(de.vitero.schema.licence.GetModulesForCustomerRequest) Modules(de.vitero.schema.licence.Modulestype.Modules) ArrayList(java.util.ArrayList) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) ViteroModule(org.olat.modules.vitero.ViteroModule) Module(de.vitero.schema.licence.Modulestype.Modules.Module) Modulestype(de.vitero.schema.licence.Modulestype) ConnectException(java.net.ConnectException)

Example 14 with ErrorCode

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

the class ViteroManager method checkConnection.

public boolean checkConnection(final String url, final String login, final String password, final int customerId) throws VmsNotAvailableException {
    try {
        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:
                log.error("Unsufficient rights", f);
                break;
            default:
                logAxisError("Cannot check connection", f);
        }
        return false;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.warn("Error checking connection", e);
        return false;
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) Handler(javax.xml.ws.handler.Handler) ViteroSecurityHandler(de.vitero.ViteroSecurityHandler) DataHandler(javax.activation.DataHandler) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Modulestype(de.vitero.schema.licence.Modulestype) PortInfo(javax.xml.ws.handler.PortInfo) HandlerResolver(javax.xml.ws.handler.HandlerResolver) GetModulesForCustomerRequest(de.vitero.schema.licence.GetModulesForCustomerRequest) Licence(de.vitero.schema.licence.Licence) ArrayList(java.util.ArrayList) List(java.util.List) ErrorCode(org.olat.modules.vitero.model.ErrorCode) ViteroSecurityHandler(de.vitero.ViteroSecurityHandler) LicenceService(de.vitero.schema.licence.LicenceService) ConnectException(java.net.ConnectException)

Example 15 with ErrorCode

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

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)

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