Search in sources :

Example 6 with VmsNotAvailableException

use of org.olat.modules.vitero.manager.VmsNotAvailableException in project OpenOLAT by OpenOLAT.

the class ViteroBookingsController method openGroup.

protected void openGroup(UserRequest ureq, ViteroBooking booking) {
    try {
        String url = viteroManager.getURLToGroup(ureq.getIdentity(), booking);
        viteroGroupVC = createVelocityContainer("opengroup");
        viteroGroupVC.contextPut("groupUrl", url);
        removeAsListenerAndDispose(cmc);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), viteroGroupVC);
        listenTo(cmc);
        cmc.activate();
    } catch (VmsNotAvailableException e) {
        showError(VmsNotAvailableException.I18N_KEY);
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) VmsNotAvailableException(org.olat.modules.vitero.manager.VmsNotAvailableException)

Example 7 with VmsNotAvailableException

use of org.olat.modules.vitero.manager.VmsNotAvailableException in project OpenOLAT by OpenOLAT.

the class ViteroBookingWebService method addMembers.

/**
 * Update the list of members of the booking, it add and mutates the
 * members and delete the missing members.
 *
 * @response.representation.200.qname {http://www.example.com}viteroGroupMemberVO
 * @response.representation.200.mediaType application/xml, application/json
 * @response.representation.200.doc This is the list of all bookings of a resource
 * @response.representation.200.example {@link org.olat.modules.vitero.restapi.Examples#SAMPLE_ViteroGroupMemberVO}
 * @param bookingId The id of the booking
 * @param members The array of members
 * @return Nothing
 */
@POST
@Path("{bookingId}/members")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response addMembers(@PathParam("bookingId") int bookingId, ViteroGroupMemberVO[] members) {
    try {
        ViteroBooking booking = viteroManager.getBookingById(null, ores, subIdentifier, bookingId);
        if (booking == null) {
            return Response.serverError().status(Status.NOT_FOUND).build();
        }
        ViteroGroupRoles roles = viteroManager.getGroupRoles(booking.getGroupId());
        if (roles == null) {
            return Response.serverError().status(Status.NOT_FOUND).build();
        }
        List<ViteroErrorVO> errors = new ArrayList<>();
        List<String> currentEmails = new ArrayList<>(roles.getEmailsOfParticipants());
        for (ViteroGroupMemberVO member : members) {
            GroupRole role = GroupRole.valueOf(member.getGroupRole());
            Identity identity = securityManager.loadIdentityByKey(member.getIdentityKey());
            String currentEmail = identity.getUser().getProperty(UserConstants.EMAIL, null);
            GroupRole currentRole = roles.getEmailsToRole().get(currentEmail);
            if (currentRole == null) {
                ViteroStatus status = viteroManager.addToRoom(booking, identity, role);
                if (!status.isOk()) {
                    errors.add(viteroErrorVO(status));
                }
            } else if (!currentRole.equals(role)) {
                Integer vmsUserId = roles.getEmailsToVmsUserId().get(currentEmail);
                ViteroStatus status = viteroManager.changeGroupRole(booking.getGroupId(), vmsUserId.intValue(), role.getVmsValue());
                if (!status.isOk()) {
                    errors.add(viteroErrorVO(status));
                }
            }
            currentEmails.remove(currentEmail);
        }
        for (String email : currentEmails) {
            SearchIdentityParams params = new SearchIdentityParams();
            params.setUserProperties(Collections.singletonMap(UserConstants.EMAIL, email));
            List<Identity> identities = securityManager.getIdentitiesByPowerSearch(params, 0, 1);
            for (Identity identity : identities) {
                ViteroStatus status = viteroManager.removeFromRoom(booking, identity);
                if (!status.isOk()) {
                    errors.add(viteroErrorVO(status));
                }
            }
        }
        return Response.ok().build();
    } catch (VmsNotAvailableException e) {
        log.error("", e);
        return handleNotAvailableException();
    }
}
Also used : ViteroGroupRoles(org.olat.modules.vitero.model.ViteroGroupRoles) VmsNotAvailableException(org.olat.modules.vitero.manager.VmsNotAvailableException) ArrayList(java.util.ArrayList) ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) GroupRole(org.olat.modules.vitero.model.GroupRole) Identity(org.olat.core.id.Identity) ViteroStatus(org.olat.modules.vitero.model.ViteroStatus) SearchIdentityParams(org.olat.basesecurity.SearchIdentityParams) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 8 with VmsNotAvailableException

use of org.olat.modules.vitero.manager.VmsNotAvailableException in project OpenOLAT by OpenOLAT.

the class ViteroBookingWebService method saveRoom.

private Response saveRoom(ViteroBookingVO booking) {
    try {
        ViteroBooking vBooking = new ViteroBooking();
        vBooking.setBookingId(booking.getBookingId());
        vBooking.setExternalId(booking.getExternalId());
        vBooking.setGroupId(booking.getGroupId());
        vBooking.setGroupName(booking.getGroupName());
        vBooking.setEventName(booking.getEventName());
        vBooking.setStart(booking.getStart());
        vBooking.setStartBuffer(booking.getStartBuffer());
        vBooking.setEnd(booking.getEnd());
        vBooking.setEndBuffer(booking.getEndBuffer());
        vBooking.setRoomSize(booking.getRoomSize());
        vBooking.setAutoSignIn(booking.isAutoSignIn());
        vBooking.setTimeZoneId(viteroModule.getTimeZoneId());
        ViteroStatus status;
        if (booking.getBookingId() > 0) {
            status = viteroManager.updateVmsBooking(vBooking);
        } else {
            status = viteroManager.createBooking(null, ores, subIdentifier, vBooking);
        }
        Response response;
        if (status.isOk()) {
            response = Response.ok(new ViteroBookingVO(vBooking)).build();
        } else {
            response = handleViteroError(status);
        }
        return response;
    } catch (VmsNotAvailableException e) {
        log.error("", e);
        return handleNotAvailableException();
    }
}
Also used : Response(javax.ws.rs.core.Response) ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) VmsNotAvailableException(org.olat.modules.vitero.manager.VmsNotAvailableException) ViteroStatus(org.olat.modules.vitero.model.ViteroStatus)

Example 9 with VmsNotAvailableException

use of org.olat.modules.vitero.manager.VmsNotAvailableException in project OpenOLAT by OpenOLAT.

the class ViteroBookingWebService method getMembers.

/**
 * Returns the list of members of the booking.
 *
 * @response.representation.200.qname {http://www.example.com}viteroGroupMemberVO
 * @response.representation.200.mediaType application/xml, application/json
 * @response.representation.200.doc This is the list of all bookings of a resource
 * @response.representation.200.example {@link org.olat.modules.vitero.restapi.Examples#SAMPLE_ViteroGroupMemberVO}
 * @param bookingId The id of the booking
 * @return The list of members in the specified booking
 */
@GET
@Path("{bookingId}/members")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getMembers(@PathParam("bookingId") int bookingId) {
    try {
        ViteroBooking booking = viteroManager.getBookingById(null, ores, subIdentifier, bookingId);
        if (booking == null) {
            return Response.serverError().status(Status.NOT_FOUND).build();
        }
        ViteroGroupRoles roles = viteroManager.getGroupRoles(booking.getGroupId());
        if (roles == null) {
            return Response.serverError().status(Status.NOT_FOUND).build();
        }
        List<String> currentEmails = new ArrayList<>(roles.getEmailsOfParticipants());
        List<ViteroGroupMemberVO> memberList = new ArrayList<>(currentEmails.size());
        for (String email : currentEmails) {
            SearchIdentityParams params = new SearchIdentityParams();
            params.setUserProperties(Collections.singletonMap(UserConstants.EMAIL, email));
            List<Identity> identities = securityManager.getIdentitiesByPowerSearch(params, 0, 1);
            for (Identity identity : identities) {
                GroupRole role = roles.getEmailsToRole().get(email);
                memberList.add(new ViteroGroupMemberVO(identity.getKey(), role.name()));
            }
        }
        ViteroGroupMemberVO[] members = memberList.toArray(new ViteroGroupMemberVO[memberList.size()]);
        return Response.ok(members).build();
    } catch (VmsNotAvailableException e) {
        log.error("", e);
        return handleNotAvailableException();
    }
}
Also used : ViteroGroupRoles(org.olat.modules.vitero.model.ViteroGroupRoles) VmsNotAvailableException(org.olat.modules.vitero.manager.VmsNotAvailableException) ArrayList(java.util.ArrayList) ViteroBooking(org.olat.modules.vitero.model.ViteroBooking) GroupRole(org.olat.modules.vitero.model.GroupRole) Identity(org.olat.core.id.Identity) SearchIdentityParams(org.olat.basesecurity.SearchIdentityParams) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 10 with VmsNotAvailableException

use of org.olat.modules.vitero.manager.VmsNotAvailableException in project openolat by klemens.

the class ViteroBookingsAdminController method openInfoBox.

protected void openInfoBox(UserRequest ureq, ViteroBooking booking) {
    removeAsListenerAndDispose(infoController);
    removeAsListenerAndDispose(cmc);
    try {
        ViteroGroup group = viteroManager.getGroup(booking.getGroupId());
        infoController = new ViteroAdminBookingInfosController(ureq, getWindowControl(), booking, group);
        listenTo(infoController);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), infoController.getInitialComponent(), true, translate("booking.raw.title"));
        listenTo(cmc);
        cmc.activate();
    } catch (VmsNotAvailableException e) {
        showError(VmsNotAvailableException.I18N_KEY);
    }
}
Also used : ViteroGroup(org.olat.modules.vitero.model.ViteroGroup) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) VmsNotAvailableException(org.olat.modules.vitero.manager.VmsNotAvailableException)

Aggregations

VmsNotAvailableException (org.olat.modules.vitero.manager.VmsNotAvailableException)36 ViteroBooking (org.olat.modules.vitero.model.ViteroBooking)16 ViteroStatus (org.olat.modules.vitero.model.ViteroStatus)12 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 Produces (javax.ws.rs.Produces)6 Identity (org.olat.core.id.Identity)6 GroupRole (org.olat.modules.vitero.model.GroupRole)6 ViteroGroupRoles (org.olat.modules.vitero.model.ViteroGroupRoles)6 ArrayList (java.util.ArrayList)4 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 SearchIdentityParams (org.olat.basesecurity.SearchIdentityParams)4 Date (java.util.Date)2 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 Response (javax.ws.rs.core.Response)2 TableDataModel (org.olat.core.gui.components.table.TableDataModel)2 RedirectMediaResource (org.olat.core.gui.media.RedirectMediaResource)2 CheckUserInfo (org.olat.modules.vitero.model.CheckUserInfo)2 StartBookingComparator (org.olat.modules.vitero.model.StartBookingComparator)2