use of org.olat.core.util.vfs.LocalFolderImpl in project OpenOLAT by OpenOLAT.
the class ForumRTFFormatter method makeTempVFSContainer.
/**
* Generates a new temporary VFSContainer.
* @return the temp container.
*/
private VFSContainer makeTempVFSContainer() {
Long forumKey = getForumKey();
String dateStamp = String.valueOf(System.currentTimeMillis());
// TODO: (LD) could this filename regarded as unique or use System.nanoTime() instead?
String fileName = "forum" + forumKey.toString() + "_" + dateStamp;
LocalFolderImpl tempFolder = new OlatRootFolderImpl("/tmp/" + fileName, null);
return tempFolder;
}
use of org.olat.core.util.vfs.LocalFolderImpl in project OpenOLAT by OpenOLAT.
the class VideoPosterUploadForm method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
remainingSpace = Quota.UNLIMITED;
videoResourceFileroot = new LocalFolderImpl(FileResourceManager.getInstance().getFileResourceRootImpl(videoResource).getBasefile());
metaDataFolder = VFSManager.getOrCreateContainer(videoResourceFileroot, "media");
posterField = uifactory.addFileElement(getWindowControl(), "poster", "video.config.poster", formLayout);
posterField.limitToMimeType(imageMimeTypes, "poster.error.filetype", null);
posterField.setMaxUploadSizeKB(picUploadlimitKB, null, null);
posterField.setPreview(ureq.getUserSession(), true);
posterField.addActionListener(FormEvent.ONCHANGE);
posterField.setHelpTextKey("poster.help", null);
FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
formLayout.add(buttonGroupLayout);
buttonGroupLayout.setElementCssClass("o_sel_upload_buttons");
uifactory.addFormCancelButton("cancel", buttonGroupLayout, ureq, getWindowControl());
uifactory.addFormSubmitButton("track.upload", buttonGroupLayout);
}
use of org.olat.core.util.vfs.LocalFolderImpl in project OpenOLAT by OpenOLAT.
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;
}
use of org.olat.core.util.vfs.LocalFolderImpl in project OpenOLAT by OpenOLAT.
the class ImsRepositoryResolver method hasAutocompleteFiles.
/**
* @see org.olat.ims.qti.process.Resolver#hasAutocompleteFiles()
*/
public boolean hasAutocompleteFiles() {
VFSContainer vfsUnzippedRoot = new LocalFolderImpl(fUnzippedDirRoot);
VFSItem vfsAutocompleteJsItem = vfsUnzippedRoot.resolve(QTI_FIB_AUTOCOMPLETE_JS_FILE);
if (vfsAutocompleteJsItem != null) {
VFSItem vfsAutocompleteCssItem = vfsUnzippedRoot.resolve(QTI_FIB_AUTOCOMPLETE_CSS_FILE);
if (vfsAutocompleteCssItem != null) {
return true;
}
}
return false;
}
use of org.olat.core.util.vfs.LocalFolderImpl in project OpenOLAT by OpenOLAT.
the class TestFileResource method validate.
/**
* @param unzippedDir
* @return True if is of type.
*/
public static boolean validate(File unzippedDir) {
// no longer needed.
VFSContainer vfsUnzippedRoot = new LocalFolderImpl(unzippedDir);
VFSItem vfsQTI = vfsUnzippedRoot.resolve("qti.xml");
// getDocument(..) ensures that InputStream is closed in every case.
Document doc = QTIHelper.getDocument((LocalFileImpl) vfsQTI);
return validateQti(doc, new ResourceEvaluation(false)).isValid();
}
Aggregations