Search in sources :

Example 26 with ErrorCode

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

the class ViteroManager method deleteGroup.

public boolean deleteGroup(ViteroBooking vBooking) throws VmsNotAvailableException {
    try {
        Groupid groupId = new Groupid();
        groupId.setGroupid(vBooking.getGroupId());
        getGroupWebService().deleteGroup(groupId);
        return true;
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            case groupDoesntExist:
                log.error("Group doesn't exist!", f);
                break;
            case invalidAttribut:
                log.error("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();
        }
        log.error("Cannot delete group: " + vBooking.getGroupId(), e);
        return false;
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) Groupid(de.vitero.schema.group.Groupid) ConnectException(java.net.ConnectException)

Example 27 with ErrorCode

use of org.olat.modules.vitero.model.ErrorCode 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 28 with ErrorCode

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

the class ViteroManager method createPersonalBookingSessionCode.

/**
 * Create a session code with a one hour expiration date
 * @param identity
 * @param booking
 * @return
 */
protected String createPersonalBookingSessionCode(Identity identity, ViteroBooking booking) throws VmsNotAvailableException {
    try {
        GetUserInfo userInfo = getVmsUserId(identity, true);
        int userId = userInfo.getUserId();
        // update user information
        if (!userInfo.isCreated()) {
            try {
                updateVmsUser(identity, userId);
                storePortrait(identity, userId);
            } catch (Exception e) {
                log.error("Cannot update user on vitero system:" + identity.getName(), e);
            }
        }
        CreatePersonalBookingSessionCodeRequest.Sessioncode code = new CreatePersonalBookingSessionCodeRequest.Sessioncode();
        code.setBookingid(booking.getBookingId());
        code.setUserid(userId);
        code.setTimezone(viteroModule.getTimeZoneId());
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        cal.add(Calendar.HOUR, 1);
        code.setExpirationdate(format(cal.getTime()));
        CreatePersonalBookingSessionCodeRequest codeRequest = new CreatePersonalBookingSessionCodeRequest();
        codeRequest.setSessioncode(code);
        Codetype myCode = getSessionCodeWebService().createPersonalBookingSessionCode(codeRequest);
        return myCode.getCode();
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            case userDoesntExist:
                log.error("User does not exist.", f);
                break;
            case userNotAssignedToGroup:
                log.error("User not assigned to group.", f);
                break;
            case invalidAttribut:
                log.error("Invalid attribute.", f);
                break;
            case invalidTimezone:
                log.error("Invalid time zone.", f);
                break;
            case bookingDoesntExist:
            case bookingDoesntExistPrime:
                log.error("Booking does not exist.", f);
                break;
            default:
                logAxisError("Cannot create session code.", f);
        }
        return null;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot create session code.", e);
        return null;
    }
}
Also used : CreatePersonalBookingSessionCodeRequest(de.vitero.schema.sessioncode.CreatePersonalBookingSessionCodeRequest) WebServiceException(javax.xml.ws.WebServiceException) Calendar(java.util.Calendar) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Codetype(de.vitero.schema.sessioncode.Codetype) ConnectException(java.net.ConnectException) WebServiceException(javax.xml.ws.WebServiceException) ConnectTimeoutException(org.apache.commons.httpclient.ConnectTimeoutException) ParseException(java.text.ParseException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Date(java.util.Date) GetUserInfo(org.olat.modules.vitero.model.GetUserInfo) ErrorCode(org.olat.modules.vitero.model.ErrorCode) ConnectException(java.net.ConnectException)

Example 29 with ErrorCode

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

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 30 with ErrorCode

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

the class ViteroManager method getCustomersUsers.

public List<Usertype> getCustomersUsers() throws VmsNotAvailableException {
    try {
        GetUserListByCustomerRequest listRequest = new GetUserListByCustomerRequest();
        listRequest.setCustomerid(viteroModule.getCustomerId());
        Userlist userList = getUserWebService().getUserListByCustomer(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 of customer: " + viteroModule.getCustomerId(), f);
        }
        return null;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot get the list of users of customer: " + viteroModule.getCustomerId(), e);
        return null;
    }
}
Also used : Usertype(de.vitero.schema.user.Usertype) WebServiceException(javax.xml.ws.WebServiceException) Userlist(de.vitero.schema.user.Userlist) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) GetUserListByCustomerRequest(de.vitero.schema.user.GetUserListByCustomerRequest) 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