Search in sources :

Example 21 with WebServiceException

use of javax.xml.ws.WebServiceException 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 22 with WebServiceException

use of javax.xml.ws.WebServiceException 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)

Example 23 with WebServiceException

use of javax.xml.ws.WebServiceException in project OpenOLAT by OpenOLAT.

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 24 with WebServiceException

use of javax.xml.ws.WebServiceException in project OpenOLAT by OpenOLAT.

the class ViteroManager method getGroup.

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

Example 25 with WebServiceException

use of javax.xml.ws.WebServiceException in project OpenOLAT by OpenOLAT.

the class ViteroManager method createVmsUser.

private final int createVmsUser(Identity identity) throws VmsNotAvailableException {
    String username = null;
    try {
        CreateUserRequest createRequest = new CreateUserRequest();
        Newusertype user = new Newusertype();
        // mandatory
        User olatUser = identity.getUser();
        username = "olat." + WebappHelper.getInstanceId() + "." + identity.getName();
        user.setUsername(username);
        user.setSurname(olatUser.getProperty(UserConstants.LASTNAME, null));
        user.setFirstname(olatUser.getProperty(UserConstants.FIRSTNAME, null));
        user.setEmail(olatUser.getProperty(UserConstants.EMAIL, null));
        user.setPassword("changeme");
        int customerId = viteroModule.getCustomerId();
        user.getCustomeridlist().add(new Integer(customerId));
        // optional
        String language = identity.getUser().getPreferences().getLanguage();
        if (StringHelper.containsNonWhitespace(language) && language.startsWith("de")) {
            user.setLocale("de");
        } else {
            user.setLocale("en");
        }
        user.setPcstate("NOT_TESTED");
        user.setTimezone(viteroModule.getTimeZoneId());
        String street = olatUser.getProperty(UserConstants.STREET, null);
        if (StringHelper.containsNonWhitespace(street)) {
            user.setStreet(street);
        }
        String zip = olatUser.getProperty(UserConstants.ZIPCODE, null);
        if (StringHelper.containsNonWhitespace(zip)) {
            user.setZip(zip);
        }
        String city = olatUser.getProperty(UserConstants.CITY, null);
        if (StringHelper.containsNonWhitespace(city)) {
            user.setCity(city);
        }
        String country = olatUser.getProperty(UserConstants.COUNTRY, null);
        if (StringHelper.containsNonWhitespace(country)) {
            user.setCountry(country);
        }
        String mobile = olatUser.getProperty(UserConstants.TELMOBILE, null);
        if (StringHelper.containsNonWhitespace(mobile)) {
            user.setMobile(mobile);
        }
        String phonePrivate = olatUser.getProperty(UserConstants.TELPRIVATE, null);
        if (StringHelper.containsNonWhitespace(phonePrivate)) {
            user.setPhone(phonePrivate);
        }
        String phoneOffice = olatUser.getProperty(UserConstants.TELOFFICE, null);
        if (StringHelper.containsNonWhitespace(phoneOffice)) {
            user.setPhone(phoneOffice);
        }
        String institution = olatUser.getProperty(UserConstants.INSTITUTIONALNAME, null);
        if (StringHelper.containsNonWhitespace(institution)) {
            user.setCompany(institution);
        }
        /*
			user.setTitle("");
			*/
        user.setTechnicalnote("Generated by OpenOLAT");
        createRequest.setUser(user);
        Userid userId = getUserWebService().createUser(createRequest);
        storePortrait(identity, userId.getUserid());
        return userId.getUserid();
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            default:
                logAxisError("Cannot create vms user.", f);
        }
        return -1;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot create vms user.", e);
        return -1;
    }
}
Also used : BigInteger(java.math.BigInteger) Newusertype(de.vitero.schema.user.Newusertype) User(org.olat.core.id.User) ViteroUser(org.olat.modules.vitero.model.ViteroUser) WebServiceException(javax.xml.ws.WebServiceException) Userid(de.vitero.schema.user.Userid) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) CreateUserRequest(de.vitero.schema.user.CreateUserRequest) ErrorCode(org.olat.modules.vitero.model.ErrorCode) ConnectException(java.net.ConnectException)

Aggregations

WebServiceException (javax.xml.ws.WebServiceException)378 Test (org.junit.Test)115 SOAPException (javax.xml.soap.SOAPException)59 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)59 SOAPMessage (javax.xml.soap.SOAPMessage)57 ConnectException (java.net.ConnectException)48 ErrorCode (org.olat.modules.vitero.model.ErrorCode)48 URL (java.net.URL)46 SOAPElement (javax.xml.soap.SOAPElement)46 IOException (java.io.IOException)43 SOAPBody (javax.xml.soap.SOAPBody)34 ArrayList (java.util.ArrayList)32 SOAPBodyElement (javax.xml.soap.SOAPBodyElement)32 BindingProvider (javax.xml.ws.BindingProvider)31 Retry (io.github.resilience4j.retry.Retry)29 Service (javax.xml.ws.Service)29 QName (javax.xml.namespace.QName)27 SOAPMessageContext (javax.xml.ws.handler.soap.SOAPMessageContext)21 DataHandler (javax.activation.DataHandler)17 RetryConfig (io.github.resilience4j.retry.RetryConfig)16