use of org.olat.core.util.vfs.LocalFolderImpl in project openolat by klemens.
the class VersionsFileManager method cleanUp.
/**
* Clean up all revisions files, xml file
* @param leaf
*/
private void cleanUp(VFSLeaf leaf) {
String relPath = getRelPath(leaf);
// cannot handle
if (relPath == null)
return;
File fVersion = new File(getRootVersionsFile(), relPath + ".xml");
File fParentVersion = fVersion.getParentFile();
// already deleted
if (!fParentVersion.exists())
return;
VFSLeaf versionLeaf = null;
if (fVersion.exists()) {
LocalFolderImpl localVersionContainer = new LocalFolderImpl(fParentVersion);
versionLeaf = (VFSLeaf) localVersionContainer.resolve(fVersion.getName());
}
// already deleted
if (versionLeaf == null)
return;
Versions versions = readVersions(leaf, versionLeaf);
for (VFSRevision versionToDelete : versions.getRevisions()) {
RevisionFileImpl versionImpl = (RevisionFileImpl) versionToDelete;
VFSLeaf fileToDelete = versionImpl.getFile();
if (fileToDelete != null) {
fileToDelete.delete();
}
}
versionLeaf.delete();
}
use of org.olat.core.util.vfs.LocalFolderImpl in project openolat by klemens.
the class VersionsFileManager method getRootVersionsFile.
public File getRootVersionsFile() {
if (rootVersionsContainer == null) {
rootVersionFolder = new File(FolderConfig.getCanonicalVersionRoot());
if (!rootVersionFolder.exists()) {
rootVersionFolder.mkdirs();
}
rootVersionsContainer = new LocalFolderImpl(rootVersionFolder);
}
return rootVersionFolder;
}
use of org.olat.core.util.vfs.LocalFolderImpl in project openolat by klemens.
the class DialogCourseNode method doArchiveElement.
/**
* Archive a single dialog element with files and forum
* @param element
* @param exportDirectory
*/
public void doArchiveElement(DialogElement element, File exportDirectory, Locale locale) {
DialogElementsManager depm = CoreSpringFactory.getImpl(DialogElementsManager.class);
VFSContainer dialogContainer = depm.getDialogContainer(element);
// there is only one file (leave) in the top forum container
VFSItem dialogFile = dialogContainer.getItems(new VFSLeafFilter()).get(0);
VFSContainer exportContainer = new LocalFolderImpl(exportDirectory);
// append export timestamp to avoid overwriting previous export
String exportDirName = Formatter.makeStringFilesystemSave(getShortTitle()) + "_" + element.getForum().getKey() + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis()));
VFSContainer diaNodeElemExportContainer = exportContainer.createChildContainer(exportDirName);
// don't check quota
diaNodeElemExportContainer.setLocalSecurityCallback(new FullAccessCallback());
diaNodeElemExportContainer.copyFrom(dialogFile);
ForumArchiveManager fam = ForumArchiveManager.getInstance();
ForumFormatter ff = new ForumRTFFormatter(diaNodeElemExportContainer, false, locale);
fam.applyFormatter(ff, element.getForum().getKey(), null);
}
use of org.olat.core.util.vfs.LocalFolderImpl in project openolat by klemens.
the class IQ12EditForm method update.
/**
* Update the module configuration from the qti file: read min/max/cut values
* @param res
*/
protected void update(OLATResource res) {
FileResourceManager frm = FileResourceManager.getInstance();
File unzippedRoot = frm.unzipFileResource(res);
// with VFS FIXME:pb:c: remove casts to LocalFileImpl and LocalFolderImpl if no longer needed.
VFSContainer vfsUnzippedRoot = new LocalFolderImpl(unzippedRoot);
VFSItem vfsQTI = vfsUnzippedRoot.resolve("qti.xml");
if (vfsQTI == null) {
throw new AssertException("qti file did not exist even it should be guaranteed by repositor check-in ");
}
// ensures that InputStream is closed in every case.
Document doc = QTIHelper.getDocument((LocalFileImpl) vfsQTI);
if (doc == null) {
// error reading qti file (existence check was made before)
throw new AssertException("qti file could not be read " + ((LocalFileImpl) vfsQTI).getBasefile().getAbsolutePath());
}
// Extract min, max and cut value
Float minValue = null, maxValue = null, cutValue = null;
Element decvar = (Element) doc.selectSingleNode("questestinterop/assessment/outcomes_processing/outcomes/decvar");
if (decvar != null) {
Attribute minval = decvar.attribute("minvalue");
if (minval != null) {
String mv = minval.getValue();
try {
minValue = new Float(Float.parseFloat(mv));
} catch (NumberFormatException e1) {
// if not correct in qti file -> ignore
}
}
Attribute maxval = decvar.attribute("maxvalue");
if (maxval != null) {
String mv = maxval.getValue();
try {
maxValue = new Float(Float.parseFloat(mv));
} catch (NumberFormatException e1) {
// if not correct in qti file -> ignore
}
}
Attribute cutval = decvar.attribute("cutvalue");
if (cutval != null) {
String cv = cutval.getValue();
try {
cutValue = new Float(Float.parseFloat(cv));
} catch (NumberFormatException e1) {
// if not correct in qti file -> ignore
}
}
}
// Put values to module configuration
minScoreEl.setValue(minValue == null ? "" : AssessmentHelper.getRoundedScore(minValue));
minScoreEl.setVisible(minValue != null);
maxScoreEl.setValue(maxValue == null ? "" : AssessmentHelper.getRoundedScore(maxValue));
maxScoreEl.setVisible(maxValue != null);
cutValueEl.setValue(cutValue == null ? "" : AssessmentHelper.getRoundedScore(cutValue));
cutValueEl.setVisible(cutValue != null);
}
use of org.olat.core.util.vfs.LocalFolderImpl in project openolat by klemens.
the class ImsRepositoryResolver method getQTIDocument.
/**
* (non-Javadoc)
*
* @see org.olat.ims.qti.process.Resolver#getQTIDocument()
*/
public Document getQTIDocument() {
// with VFS FIXME:pb:c: remove casts to LocalFileImpl and LocalFolderImpl if no longer needed.
VFSContainer vfsUnzippedRoot = new LocalFolderImpl(fUnzippedDirRoot);
VFSItem vfsQTI = vfsUnzippedRoot.resolve(QTI_FILE);
// getDocument(..) ensures that InputStream is closed in every case.
Document theDoc = QTIHelper.getDocument((LocalFileImpl) vfsQTI);
// if doc is null an error loading the document occured (IOException, qti.xml does not exist)
return theDoc;
}
Aggregations