use of org.olat.core.util.vfs.LocalImpl in project OpenOLAT by OpenOLAT.
the class GuiDemoFileChooserController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == chooserCtr) {
// catch the events from the file chooser controller here
if (event instanceof FileChoosenEvent) {
// User pressed select button, get selected item from controller
VFSItem selectedItem = FileChooserUIFactory.getSelectedItem((FileChoosenEvent) event);
// for this demo just get file path and display an info message
LocalImpl localFile = (LocalImpl) selectedItem;
String absPath = localFile.getBasefile().getAbsolutePath();
String relPath = absPath.substring(webappRootFile.getAbsolutePath().length());
getWindowControl().setInfo("user selected /static" + relPath);
} else if (event == Event.CANCELLED_EVENT) {
// user pressed cancel
getWindowControl().setInfo("user cancelled");
} else if (event == Event.FAILED_EVENT) {
// selection failed for unknown reason
getWindowControl().setError("Ups, an error occured");
}
}
}
use of org.olat.core.util.vfs.LocalImpl in project OpenOLAT by OpenOLAT.
the class WebDocumentRunController method getWebDocument.
private LocalFileImpl getWebDocument(RepositoryEntry entry) {
OLATResource resource = entry.getOlatResource();
VFSContainer fResourceFileroot = FileResourceManager.getInstance().getFileResourceRootImpl(resource);
LocalFileImpl document = null;
for (VFSItem item : fResourceFileroot.getItems()) {
if (item instanceof VFSLeaf && item instanceof LocalImpl) {
LocalFileImpl localItem = (LocalFileImpl) item;
if (localItem != null && !localItem.getBasefile().isHidden()) {
document = (LocalFileImpl) item;
}
}
}
return document;
}
use of org.olat.core.util.vfs.LocalImpl in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_10_3_0 method processExportFolder.
private void processExportFolder(RepositoryEntry courseRe) {
try {
VFSContainer courseFolder = CourseFactory.getCourseBaseContainer(courseRe.getOlatResource().getResourceableId());
VFSItem exportFolder = courseFolder.resolve(ICourse.EXPORTED_DATA_FOLDERNAME);
if (exportFolder != null && exportFolder.exists() && exportFolder instanceof LocalImpl) {
File exportDir = ((LocalImpl) exportFolder).getBasefile();
if (exportDir.exists()) {
FileUtils.deleteDirsAndFiles(exportDir.toPath());
}
}
} catch (IOException e) {
log.error("", e);
}
}
use of org.olat.core.util.vfs.LocalImpl in project OpenOLAT by OpenOLAT.
the class QTI21QPoolServiceProvider method createItem.
public QuestionItem createItem(Identity identity, QTI21QuestionType type, String title, Locale locale) {
AssessmentItemBuilder itemBuilder = null;
Translator translator = Util.createPackageTranslator(AssessmentTestComposerController.class, locale);
switch(type) {
case sc:
itemBuilder = new SingleChoiceAssessmentItemBuilder(translator.translate("new.sc"), translator.translate("new.answer"), qtiService.qtiSerializer());
break;
case mc:
itemBuilder = new MultipleChoiceAssessmentItemBuilder(translator.translate("new.mc"), translator.translate("new.answer"), qtiService.qtiSerializer());
break;
case kprim:
itemBuilder = new KPrimAssessmentItemBuilder(translator.translate("new.kprim"), translator.translate("new.answer"), qtiService.qtiSerializer());
break;
case match:
itemBuilder = new MatchAssessmentItemBuilder(translator.translate("new.match"), QTI21Constants.CSS_MATCH_MATRIX, qtiService.qtiSerializer());
break;
case matchdraganddrop:
itemBuilder = new MatchAssessmentItemBuilder(translator.translate("new.match"), QTI21Constants.CSS_MATCH_DRAG_AND_DROP, qtiService.qtiSerializer());
break;
case matchtruefalse:
itemBuilder = new MatchAssessmentItemBuilder(translator.translate("new.match"), QTI21Constants.CSS_MATCH_TRUE_FALSE, translator.translate("match.unanswered"), translator.translate("match.true"), translator.translate("match.false"), qtiService.qtiSerializer());
break;
case fib:
itemBuilder = new FIBAssessmentItemBuilder(translator.translate("new.fib"), EntryType.text, qtiService.qtiSerializer());
break;
case numerical:
itemBuilder = new FIBAssessmentItemBuilder(translator.translate("new.fib.numerical"), EntryType.numerical, qtiService.qtiSerializer());
break;
case essay:
itemBuilder = new EssayAssessmentItemBuilder(translator.translate("new.essay"), qtiService.qtiSerializer());
break;
case upload:
itemBuilder = new UploadAssessmentItemBuilder(translator.translate("new.upload"), qtiService.qtiSerializer());
break;
case drawing:
itemBuilder = new DrawingAssessmentItemBuilder(translator.translate("new.drawing"), qtiService.qtiSerializer());
break;
case hotspot:
itemBuilder = new HotspotAssessmentItemBuilder(translator.translate("new.hotspot"), qtiService.qtiSerializer());
break;
case hottext:
itemBuilder = new HottextAssessmentItemBuilder(translator.translate("new.hottext"), translator.translate("new.hottext.start"), translator.translate("new.hottext.text"), qtiService.qtiSerializer());
break;
default:
return null;
}
AssessmentItem assessmentItem = itemBuilder.getAssessmentItem();
assessmentItem.setLabel(title);
assessmentItem.setTitle(title);
AssessmentItemMetadata itemMetadata = new AssessmentItemMetadata();
itemMetadata.setQuestionType(type);
QTI21ImportProcessor processor = new QTI21ImportProcessor(identity, locale);
QuestionItemImpl qitem = processor.processItem(assessmentItem, "", null, "OpenOLAT", Settings.getVersion(), itemMetadata);
VFSContainer baseDir = qpoolFileStorage.getContainer(qitem.getDirectory());
VFSLeaf leaf = baseDir.createChildLeaf(qitem.getRootFilename());
File itemFile = ((LocalImpl) leaf).getBasefile();
qtiService.persistAssessmentObject(itemFile, assessmentItem);
// create imsmanifest
ManifestBuilder manifest = ManifestBuilder.createAssessmentItemBuilder();
manifest.appendAssessmentItem(itemFile.getName());
manifest.write(new File(itemFile.getParentFile(), "imsmanifest.xml"));
return qitem;
}
use of org.olat.core.util.vfs.LocalImpl in project OpenOLAT by OpenOLAT.
the class WorkThreadInformations method setInfoFiles.
public static void setInfoFiles(String filePath, VFSLeaf leaf) {
try {
File file = new File(WebappHelper.getUserDataRoot(), "threadInfos");
if (!file.exists()) {
file.mkdirs();
}
if (leaf instanceof LocalImpl) {
filePath = ((LocalImpl) leaf).getBasefile().getAbsolutePath();
}
File infoFile = new File(file, Thread.currentThread().getName());
FileUtils.save(infoFile, filePath, "UTF-8");
} catch (Exception e) {
log.error("Cannot write info message about FolderIndexerWorker: " + filePath, e);
}
}
Aggregations