Search in sources :

Example 1 with RecordingMetadata

use of org.bigbluebutton.api.domain.RecordingMetadata in project bigbluebutton by bigbluebutton.

the class RecordingService method getRecordingMetadata.

private static RecordingMetadata getRecordingMetadata(File dir) {
    File file = new File(dir.getPath() + File.separatorChar + "metadata.xml");
    RecordingMetadata rec = RecordingMetadataReaderHelper.getRecordingMetadata(file);
    return rec;
}
Also used : RecordingMetadata(org.bigbluebutton.api.domain.RecordingMetadata) File(java.io.File)

Example 2 with RecordingMetadata

use of org.bigbluebutton.api.domain.RecordingMetadata in project bigbluebutton by bigbluebutton.

the class RecordingMetadataReaderHelper method getRecordingMetadata.

public static RecordingMetadata getRecordingMetadata(File metadataXml) {
    XMLInputFactory factory = XMLInputFactory.newInstance();
    JacksonXmlModule module = new JacksonXmlModule();
    // and then configure, for example:
    module.setDefaultUseWrapper(false);
    XmlMapper mapper = new XmlMapper(module);
    //Reading from xml file and creating XMLStreamReader
    XMLStreamReader reader = null;
    RecordingMetadata recMeta = null;
    try {
        reader = factory.createXMLStreamReader(new FileInputStream(metadataXml));
        recMeta = mapper.readValue(reader, RecordingMetadata.class);
    } catch (XMLStreamException e) {
        log.error("Failed to read metadata xml for recording: " + metadataXml.getAbsolutePath(), e);
    } catch (FileNotFoundException e) {
        log.error("File not found: " + metadataXml.getAbsolutePath(), e);
    } catch (IOException e) {
        log.error("IOException on " + metadataXml.getAbsolutePath(), e);
    }
    return recMeta;
}
Also used : JacksonXmlModule(com.fasterxml.jackson.dataformat.xml.JacksonXmlModule) RecordingMetadata(org.bigbluebutton.api.domain.RecordingMetadata) XmlMapper(com.fasterxml.jackson.dataformat.xml.XmlMapper)

Example 3 with RecordingMetadata

use of org.bigbluebutton.api.domain.RecordingMetadata in project bigbluebutton by bigbluebutton.

the class RecordingService method publishRecording.

public static void publishRecording(File destDir, String recordingId, File recordingDir) {
    File metadataXml = RecordingMetadataReaderHelper.getMetadataXmlLocation(recordingDir.getPath());
    RecordingMetadata r = RecordingMetadataReaderHelper.getRecordingMetadata(metadataXml);
    if (r != null) {
        if (!destDir.exists())
            destDir.mkdirs();
        try {
            FileUtils.moveDirectory(recordingDir, new File(destDir.getPath() + File.separatorChar + recordingId));
            r.setState(Recording.STATE_PUBLISHED);
            r.setPublished(true);
            File medataXmlFile = RecordingMetadataReaderHelper.getMetadataXmlLocation(destDir.getAbsolutePath() + File.separatorChar + recordingId);
            // Process the changes by saving the recording into metadata.xml
            RecordingMetadataReaderHelper.saveRecordingMetadata(medataXmlFile, r);
        } catch (IOException e) {
            log.error("Failed to publish recording : " + recordingId, e);
        }
    }
}
Also used : RecordingMetadata(org.bigbluebutton.api.domain.RecordingMetadata) IOException(java.io.IOException) File(java.io.File)

Example 4 with RecordingMetadata

use of org.bigbluebutton.api.domain.RecordingMetadata in project bigbluebutton by bigbluebutton.

the class RecordingService method unpublishRecording.

public static void unpublishRecording(File destDir, String recordingId, File recordingDir) {
    File metadataXml = RecordingMetadataReaderHelper.getMetadataXmlLocation(recordingDir.getPath());
    RecordingMetadata r = RecordingMetadataReaderHelper.getRecordingMetadata(metadataXml);
    if (r != null) {
        if (!destDir.exists())
            destDir.mkdirs();
        try {
            FileUtils.moveDirectory(recordingDir, new File(destDir.getPath() + File.separatorChar + recordingId));
            r.setState(Recording.STATE_UNPUBLISHED);
            r.setPublished(false);
            File medataXmlFile = RecordingMetadataReaderHelper.getMetadataXmlLocation(destDir.getAbsolutePath() + File.separatorChar + recordingId);
            // Process the changes by saving the recording into metadata.xml
            RecordingMetadataReaderHelper.saveRecordingMetadata(medataXmlFile, r);
        } catch (IOException e) {
            log.error("Failed to unpublish recording : " + recordingId, e);
        }
    }
}
Also used : RecordingMetadata(org.bigbluebutton.api.domain.RecordingMetadata) IOException(java.io.IOException) File(java.io.File)

Example 5 with RecordingMetadata

use of org.bigbluebutton.api.domain.RecordingMetadata in project bigbluebutton by bigbluebutton.

the class RecordingService method getRecordingsMetadata.

public List<RecordingMetadata> getRecordingsMetadata(List<String> recordIDs, List<String> states) {
    List<RecordingMetadata> recs = new ArrayList<RecordingMetadata>();
    Map<String, List<File>> allDirectories = getAllDirectories(states);
    if (recordIDs.isEmpty()) {
        for (Map.Entry<String, List<File>> entry : allDirectories.entrySet()) {
            recordIDs.addAll(getAllRecordingIds(entry.getValue()));
        }
    }
    for (String recordID : recordIDs) {
        for (Map.Entry<String, List<File>> entry : allDirectories.entrySet()) {
            List<File> _recs = getRecordingsForPath(recordID, entry.getValue());
            Iterator<File> iterator = _recs.iterator();
            while (iterator.hasNext()) {
                RecordingMetadata r = getRecordingMetadata(iterator.next());
                if (r != null) {
                    recs.add(r);
                }
            }
        }
    }
    return recs;
}
Also used : RecordingMetadata(org.bigbluebutton.api.domain.RecordingMetadata) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File)

Aggregations

RecordingMetadata (org.bigbluebutton.api.domain.RecordingMetadata)6 File (java.io.File)5 IOException (java.io.IOException)3 JacksonXmlModule (com.fasterxml.jackson.dataformat.xml.JacksonXmlModule)1 XmlMapper (com.fasterxml.jackson.dataformat.xml.XmlMapper)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1