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;
}
Aggregations