Search in sources :

Example 6 with QTIChangeLogMessage

use of org.olat.ims.qti.QTIChangeLogMessage in project openolat by klemens.

the class ImsRepositoryResolver method getDocumentChangeLog.

/**
 * reads the files in the ../changelog directory, and generates a
 * <code>QTIChangeLogMessage</code> per file.
 *
 * @return qti changelog messages or an empty array if no changelog exists.
 * @see QTIChangeLogMessage
 */
public QTIChangeLogMessage[] getDocumentChangeLog() {
    VFSContainer dirRoot = new LocalFolderImpl(fUnzippedDirRoot);
    VFSContainer dirChangelog = (VFSContainer) dirRoot.resolve("changelog");
    if (dirChangelog == null) {
        // no change log
        return new QTIChangeLogMessage[0];
    }
    List<VFSItem> items = dirChangelog.getItems();
    // PRECONDITION: only changelog files in the changelog directory
    QTIChangeLogMessage[] logArr = new QTIChangeLogMessage[items.size()];
    String filName;
    String msg;
    int i = 0;
    java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH_mm_ss");
    for (Iterator<VFSItem> iter = items.iterator(); iter.hasNext(); ) {
        VFSLeaf file = (VFSLeaf) iter.next();
        filName = file.getName();
        String[] parts = filName.split("\\.");
        msg = FileUtils.load(file.getInputStream(), "utf-8");
        try {
            logArr[i] = new QTIChangeLogMessage(msg, parts[1].equals("all"), formatter.parse(parts[0]).getTime());
            i++;
        } catch (ParseException e) {
            log.error("", e);
        }
    }
    return logArr;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl) QTIChangeLogMessage(org.olat.ims.qti.QTIChangeLogMessage) ParseException(java.text.ParseException)

Aggregations

QTIChangeLogMessage (org.olat.ims.qti.QTIChangeLogMessage)6 ParseException (java.text.ParseException)2 Date (java.util.Date)2 TreePosition (org.olat.core.gui.components.tree.TreePosition)2 Event (org.olat.core.gui.control.Event)2 Roles (org.olat.core.id.Roles)2 Formatter (org.olat.core.util.Formatter)2 Memento (org.olat.core.util.memento.Memento)2 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 VFSItem (org.olat.core.util.vfs.VFSItem)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 GenericQtiNode (org.olat.ims.qti.editor.tree.GenericQtiNode)2 ImsRepositoryResolver (org.olat.ims.qti.process.ImsRepositoryResolver)2 ItemsPackage (org.olat.ims.qti.questionimport.ItemsPackage)2 ContactFormController (org.olat.modules.co.ContactFormController)2 QuestionItemView (org.olat.modules.qpool.QuestionItemView)2 QItemViewEvent (org.olat.modules.qpool.ui.events.QItemViewEvent)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2