listenTo(mediaTableCtr);
List filelist = getWiki().getMediaFileListWithMetadata();
Map files = new HashMap();
for (Iterator iter = filelist.iterator(); iter.hasNext();) {
VFSLeaf elem = (VFSLeaf) iter.next();
if(elem.getName().endsWith(METADATA_SUFFIX)) { //*.metadata files go here
Properties p = new Properties();
try {
p.load(elem.getInputStream());
MediaFileElement mediaFileElement = new MediaFileElement(elem.getName(), p.getProperty(MEDIA_FILE_CREATED_BY), p.getProperty(MEDIA_FILE_CREATIONDATE));
mediaFileElement.setDeletedBy(p.getProperty(MEDIA_FILE_DELETED_BY));
mediaFileElement.setDeletionDate(p.getProperty(MEDIA_FILE_DELETIONDATE));
files.put(p.getProperty(MEDIA_FILE_FILENAME), mediaFileElement);
} catch (IOException e) {
throw new OLATRuntimeException("Could'n read properties from media file: "+elem.getName(), e);
}
}
}
for (Iterator iter = filelist.iterator(); iter.hasNext();) {
VFSLeaf elem = (VFSLeaf) iter.next();
if(!elem.getName().endsWith(METADATA_SUFFIX)){
if(!files.containsKey(elem.getName())) {
//legacy file without metadata
files.put(elem.getName(), new MediaFileElement(elem.getName(), 0, elem.getLastModified()));
} else {
//file with metadata, update name
MediaFileElement element = (MediaFileElement)files.get(elem.getName());
element.setFileName(elem.getName());
}
}
}
mediaFilesTableModel = new MediaFilesTableModel(new ArrayList(files.values()), getTranslator());