Search in sources :

Example 1 with Group

use of de.vitero.schema.group.Group 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 2 with Group

use of de.vitero.schema.group.Group in project OpenOLAT by OpenOLAT.

the class ViteroManager method changeGroupRole.

public ViteroStatus changeGroupRole(int groupId, int vmsUserId, int roleId) throws VmsNotAvailableException {
    try {
        Group groupWs = getGroupWebService();
        ChangeGroupRoleRequest roleRequest = new ChangeGroupRoleRequest();
        roleRequest.setGroupid(groupId);
        roleRequest.setUserid(vmsUserId);
        roleRequest.setRole(roleId);
        groupWs.changeGroupRole(roleRequest);
        return new ViteroStatus();
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            case userDoesntExist:
                log.error("The user doesn ́t exist!", f);
                break;
            case groupDoesntExist:
                log.error("The group doesn ́t exist", f);
                break;
            default:
                logAxisError("Cannot add an user to a group", f);
        }
        return new ViteroStatus(code);
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot add an user to a group", e);
        return new ViteroStatus(ErrorCode.unkown);
    }
}
Also used : Group(de.vitero.schema.group.Group) ViteroGroup(org.olat.modules.vitero.model.ViteroGroup) BusinessGroup(org.olat.group.BusinessGroup) WebServiceException(javax.xml.ws.WebServiceException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) ChangeGroupRoleRequest(de.vitero.schema.group.ChangeGroupRoleRequest) ViteroStatus(org.olat.modules.vitero.model.ViteroStatus) ConnectException(java.net.ConnectException)

Example 3 with Group

use of de.vitero.schema.group.Group in project OpenOLAT by OpenOLAT.

the class ViteroManager method getGroupWebService.

private final Group getGroupWebService() {
    GroupService ss = new GroupService();
    ss.setHandlerResolver(new VmsSecurityHandlerResolver());
    Group port = ss.getGroupSoap11();
    String endPoint = getVmsEndPoint("GroupService");
    ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endPoint);
    return port;
}
Also used : Group(de.vitero.schema.group.Group) ViteroGroup(org.olat.modules.vitero.model.ViteroGroup) BusinessGroup(org.olat.group.BusinessGroup) GroupService(de.vitero.schema.group.GroupService)

Example 4 with Group

use of de.vitero.schema.group.Group in project OpenOLAT by OpenOLAT.

the class ViteroManager method addToRoom.

public ViteroStatus addToRoom(ViteroBooking booking, Identity identity, GroupRole role) throws VmsNotAvailableException {
    try {
        GetUserInfo userInfo = getVmsUserId(identity, true);
        int userId = userInfo.getUserId();
        if (userId < 0) {
            return new ViteroStatus(ErrorCode.userDoesntExist);
        }
        if (!userInfo.isCreated()) {
            // update user information
            try {
                updateVmsUser(identity, userId);
            // storePortrait(identity, userId);
            } catch (Exception e) {
                log.error("Cannot update user on vitero system:" + identity.getName(), e);
            }
        }
        Group groupWs = getGroupWebService();
        Groupiduserid groupuserId = new Groupiduserid();
        groupuserId.setGroupid(booking.getGroupId());
        groupuserId.setUserid(userId);
        groupWs.addUserToGroup(groupuserId);
        if (role != null) {
            groupWs = getGroupWebService();
            ChangeGroupRoleRequest roleRequest = new ChangeGroupRoleRequest();
            roleRequest.setGroupid(booking.getGroupId());
            roleRequest.setUserid(userId);
            roleRequest.setRole(role.getVmsValue());
            groupWs.changeGroupRole(roleRequest);
        }
        return new ViteroStatus();
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            case userDoesntExist:
                log.error("The user doesn ́t exist!", f);
                break;
            case userNotAttachedToCustomer:
                log.error("The user is not attached to the customer (to which this group belongs)", f);
                break;
            case groupDoesntExist:
                log.error("The group doesn ́t exist", f);
                break;
            case invalidAttribut:
                log.error("An id <= 0", f);
                break;
            default:
                logAxisError("Cannot add an user to a group", f);
        }
        return new ViteroStatus(code);
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot add an user to a group", e);
        return new ViteroStatus(ErrorCode.unkown);
    }
}
Also used : Group(de.vitero.schema.group.Group) ViteroGroup(org.olat.modules.vitero.model.ViteroGroup) BusinessGroup(org.olat.group.BusinessGroup) Groupiduserid(de.vitero.schema.group.Groupiduserid) GetUserInfo(org.olat.modules.vitero.model.GetUserInfo) WebServiceException(javax.xml.ws.WebServiceException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) ViteroStatus(org.olat.modules.vitero.model.ViteroStatus) ChangeGroupRoleRequest(de.vitero.schema.group.ChangeGroupRoleRequest) 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) ConnectException(java.net.ConnectException)

Example 5 with Group

use of de.vitero.schema.group.Group in project openolat by klemens.

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)

Aggregations

Group (de.vitero.schema.group.Group)8 BusinessGroup (org.olat.group.BusinessGroup)8 ViteroGroup (org.olat.modules.vitero.model.ViteroGroup)8 ConnectException (java.net.ConnectException)6 WebServiceException (javax.xml.ws.WebServiceException)6 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)6 ErrorCode (org.olat.modules.vitero.model.ErrorCode)6 ChangeGroupRoleRequest (de.vitero.schema.group.ChangeGroupRoleRequest)4 ViteroStatus (org.olat.modules.vitero.model.ViteroStatus)4 Completegrouptype (de.vitero.schema.group.Completegrouptype)2 GroupService (de.vitero.schema.group.GroupService)2 Group_Type (de.vitero.schema.group.Group_Type)2 Groupid (de.vitero.schema.group.Groupid)2 Groupiduserid (de.vitero.schema.group.Groupiduserid)2 Usertype (de.vitero.schema.user.Usertype)2 BigInteger (java.math.BigInteger)2 ParseException (java.text.ParseException)2 HashMap (java.util.HashMap)2 ConnectTimeoutException (org.apache.commons.httpclient.ConnectTimeoutException)2 GetUserInfo (org.olat.modules.vitero.model.GetUserInfo)2