Search in sources :

Example 1 with MeetingDate

use of de.bps.course.nodes.vc.MeetingDate in project OpenOLAT by OpenOLAT.

the class AdobeConnectCleanupJob method cleanupMeetings.

/**
 * @param adobe
 */
protected void cleanupMeetings(AdobeConnectProvider adobe, int daysToKeep) {
    boolean success = false;
    Date lowerLimit = new Date((new Date()).getTime() - (daysToKeep * 24 * 60 * 60 * 1000));
    // search all virtual classrooms with the used prefix
    List<String> roomIds = adobe.findClassrooms(AdobeConnectProvider.PREFIX);
    for (String roomId : roomIds) {
        // format is olat-courseId-nodeId, e.g. olat-82823405537032-82823405537043
        // load course and node
        String courseId = roomId.split("-")[1];
        String nodeId = roomId.split("-")[2];
        ICourse course = CourseFactory.loadCourse(Long.parseLong(courseId));
        CourseNode vcNode = course.getRunStructure().getNode(nodeId);
        if (!(vcNode instanceof VCCourseNode)) {
            logger.warn("Tried to cleanup Adobe Connect meeting for a non Adobe Connect course node: " + roomId);
            continue;
        }
        AdobeConnectConfiguration config = (AdobeConnectConfiguration) vcNode.getModuleConfiguration().get(VCCourseNode.CONF_VC_CONFIGURATION);
        if (config == null) {
            // invalid configuration, do nothing and continue
            continue;
        }
        boolean keep = false;
        for (MeetingDate date : config.getMeetingDates()) {
            if (keep)
                continue;
            Date end = date.getEnd();
            keep = lowerLimit.before(end);
        }
        // no planned date in the future, we can delete
        // build the correct roomId
        String toDelete = courseId + "-" + nodeId;
        if (!keep)
            success = adobe.removeClassroom(toDelete, config);
        if (!success) {
            logger.warn("Error when cleaning up Adobe Connect meeting \"" + roomId + "\"");
            continue;
        }
    }
}
Also used : MeetingDate(de.bps.course.nodes.vc.MeetingDate) VCCourseNode(de.bps.course.nodes.VCCourseNode) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) VCCourseNode(de.bps.course.nodes.VCCourseNode) Date(java.util.Date) MeetingDate(de.bps.course.nodes.vc.MeetingDate)

Example 2 with MeetingDate

use of de.bps.course.nodes.vc.MeetingDate in project openolat by klemens.

the class AdobeConnectCleanupJob method cleanupMeetings.

/**
 * @param adobe
 */
protected void cleanupMeetings(AdobeConnectProvider adobe, int daysToKeep) {
    boolean success = false;
    Date lowerLimit = new Date((new Date()).getTime() - (daysToKeep * 24 * 60 * 60 * 1000));
    // search all virtual classrooms with the used prefix
    List<String> roomIds = adobe.findClassrooms(AdobeConnectProvider.PREFIX);
    for (String roomId : roomIds) {
        // format is olat-courseId-nodeId, e.g. olat-82823405537032-82823405537043
        // load course and node
        String courseId = roomId.split("-")[1];
        String nodeId = roomId.split("-")[2];
        ICourse course = CourseFactory.loadCourse(Long.parseLong(courseId));
        CourseNode vcNode = course.getRunStructure().getNode(nodeId);
        if (!(vcNode instanceof VCCourseNode)) {
            logger.warn("Tried to cleanup Adobe Connect meeting for a non Adobe Connect course node: " + roomId);
            continue;
        }
        AdobeConnectConfiguration config = (AdobeConnectConfiguration) vcNode.getModuleConfiguration().get(VCCourseNode.CONF_VC_CONFIGURATION);
        if (config == null) {
            // invalid configuration, do nothing and continue
            continue;
        }
        boolean keep = false;
        for (MeetingDate date : config.getMeetingDates()) {
            if (keep)
                continue;
            Date end = date.getEnd();
            keep = lowerLimit.before(end);
        }
        // no planned date in the future, we can delete
        // build the correct roomId
        String toDelete = courseId + "-" + nodeId;
        if (!keep)
            success = adobe.removeClassroom(toDelete, config);
        if (!success) {
            logger.warn("Error when cleaning up Adobe Connect meeting \"" + roomId + "\"");
            continue;
        }
    }
}
Also used : MeetingDate(de.bps.course.nodes.vc.MeetingDate) VCCourseNode(de.bps.course.nodes.VCCourseNode) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) VCCourseNode(de.bps.course.nodes.VCCourseNode) Date(java.util.Date) MeetingDate(de.bps.course.nodes.vc.MeetingDate)

Aggregations

VCCourseNode (de.bps.course.nodes.VCCourseNode)2 MeetingDate (de.bps.course.nodes.vc.MeetingDate)2 Date (java.util.Date)2 ICourse (org.olat.course.ICourse)2 CourseNode (org.olat.course.nodes.CourseNode)2