Search in sources :

Example 1 with CreateUserRequest

use of de.vitero.schema.user.CreateUserRequest 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)

Example 2 with CreateUserRequest

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

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

CreateUserRequest (de.vitero.schema.user.CreateUserRequest)2 Newusertype (de.vitero.schema.user.Newusertype)2 Userid (de.vitero.schema.user.Userid)2 BigInteger (java.math.BigInteger)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