Search in sources :

Example 1 with UpdateUserRequest

use of de.vitero.schema.user.UpdateUserRequest in project OpenOLAT by OpenOLAT.

the class ViteroManager method updateVmsUser.

protected boolean updateVmsUser(Identity identity, int vmsUserId) throws VmsNotAvailableException {
    try {
        UpdateUserRequest updateRequest = new UpdateUserRequest();
        Completeusertype user = new Completeusertype();
        user.setId(vmsUserId);
        // mandatory
        User olatUser = identity.getUser();
        user.setUsername("olat." + WebappHelper.getInstanceId() + "." + identity.getName());
        user.setSurname(olatUser.getProperty(UserConstants.LASTNAME, null));
        user.setFirstname(olatUser.getProperty(UserConstants.FIRSTNAME, null));
        user.setEmail(olatUser.getProperty(UserConstants.EMAIL, null));
        // optional
        String language = identity.getUser().getPreferences().getLanguage();
        if (StringHelper.containsNonWhitespace(language) && language.startsWith("de")) {
            user.setLocale("de_DE");
        } else if (StringHelper.containsNonWhitespace(language) && language.startsWith("fr")) {
            user.setLocale("fr_FR");
        } else if (StringHelper.containsNonWhitespace(language) && language.startsWith("zh_CN")) {
            user.setLocale("zh_CN");
        } else {
            user.setLocale("en_GB");
        }
        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);
        }
        updateRequest.setUser(user);
        getUserWebService().updateUser(updateRequest);
        return true;
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            default:
                logAxisError("Cannot create vms user.", f);
        }
        return true;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot create vms user.", e);
        return true;
    }
}
Also used : User(org.olat.core.id.User) ViteroUser(org.olat.modules.vitero.model.ViteroUser) WebServiceException(javax.xml.ws.WebServiceException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) UpdateUserRequest(de.vitero.schema.user.UpdateUserRequest) Completeusertype(de.vitero.schema.user.Completeusertype) ConnectException(java.net.ConnectException)

Example 2 with UpdateUserRequest

use of de.vitero.schema.user.UpdateUserRequest in project openolat by klemens.

the class ViteroManager method updateVmsUser.

protected boolean updateVmsUser(Identity identity, int vmsUserId) throws VmsNotAvailableException {
    try {
        UpdateUserRequest updateRequest = new UpdateUserRequest();
        Completeusertype user = new Completeusertype();
        user.setId(vmsUserId);
        // mandatory
        User olatUser = identity.getUser();
        user.setUsername("olat." + WebappHelper.getInstanceId() + "." + identity.getName());
        user.setSurname(olatUser.getProperty(UserConstants.LASTNAME, null));
        user.setFirstname(olatUser.getProperty(UserConstants.FIRSTNAME, null));
        user.setEmail(olatUser.getProperty(UserConstants.EMAIL, null));
        // optional
        String language = identity.getUser().getPreferences().getLanguage();
        if (StringHelper.containsNonWhitespace(language) && language.startsWith("de")) {
            user.setLocale("de_DE");
        } else if (StringHelper.containsNonWhitespace(language) && language.startsWith("fr")) {
            user.setLocale("fr_FR");
        } else if (StringHelper.containsNonWhitespace(language) && language.startsWith("zh_CN")) {
            user.setLocale("zh_CN");
        } else {
            user.setLocale("en_GB");
        }
        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);
        }
        updateRequest.setUser(user);
        getUserWebService().updateUser(updateRequest);
        return true;
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            default:
                logAxisError("Cannot create vms user.", f);
        }
        return true;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot create vms user.", e);
        return true;
    }
}
Also used : User(org.olat.core.id.User) ViteroUser(org.olat.modules.vitero.model.ViteroUser) WebServiceException(javax.xml.ws.WebServiceException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) UpdateUserRequest(de.vitero.schema.user.UpdateUserRequest) Completeusertype(de.vitero.schema.user.Completeusertype) ConnectException(java.net.ConnectException)

Aggregations

Completeusertype (de.vitero.schema.user.Completeusertype)2 UpdateUserRequest (de.vitero.schema.user.UpdateUserRequest)2 ConnectException (java.net.ConnectException)2 WebServiceException (javax.xml.ws.WebServiceException)2 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)2 User (org.olat.core.id.User)2 ErrorCode (org.olat.modules.vitero.model.ErrorCode)2 ViteroUser (org.olat.modules.vitero.model.ViteroUser)2