use of org.olat.core.util.vfs.LocalFolderImpl in project OpenOLAT by OpenOLAT.
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;
}
use of org.olat.core.util.vfs.LocalFolderImpl in project OpenOLAT by OpenOLAT.
the class ImsRepositoryResolver method getObjectBank.
/**
* (non-Javadoc)
*
* @see org.olat.ims.qti.process.Resolver#getObjectBank(java.lang.String)
*/
public Element getObjectBank(String ident) {
// with VFS FIXME:pb:c: remove casts to LocalFileImpl and LocalFolderImpl if no longer needed.
VFSContainer vfsUnzippedRoot = new LocalFolderImpl(fUnzippedDirRoot);
VFSItem vfsQTI = vfsUnzippedRoot.resolve(ident + ".xml");
// 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)
if (theDoc == null)
return null;
Element objectBank = (Element) theDoc.selectSingleNode("questestinterop/objectbank");
return objectBank;
}
use of org.olat.core.util.vfs.LocalFolderImpl in project OpenOLAT by OpenOLAT.
the class CourseLogsArchiveController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
*/
public void event(UserRequest ureq, Component source, Event event) {
if (source == showFileButton) {
ICourse course = CourseFactory.loadCourse(ores);
String personalFolderDir = CourseFactory.getPersonalDirectory(ureq.getIdentity()).getPath();
String targetDir = CourseFactory.getOrCreateDataExportDirectory(ureq.getIdentity(), course.getCourseTitle()).getPath();
String relPath = "";
if (targetDir.startsWith(personalFolderDir)) {
// that should always be the case
relPath = targetDir.substring(personalFolderDir.length()).replace("\\", "/");
targetDir = targetDir.substring(0, personalFolderDir.length());
}
VFSContainer targetFolder = new LocalFolderImpl(new File(targetDir));
FolderRunController bcrun = new FolderRunController(targetFolder, true, ureq, getWindowControl());
Component folderComponent = bcrun.getInitialComponent();
if (relPath.length() != 0) {
if (!relPath.endsWith("/")) {
relPath = relPath + "/";
}
bcrun.activatePath(ureq, relPath);
}
String personalFolder = Util.createPackageTranslator(HomeMainController.class, ureq.getLocale(), null).translate("menu.bc");
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), folderComponent, true, personalFolder);
listenTo(cmc);
cmc.activate();
}
}
use of org.olat.core.util.vfs.LocalFolderImpl in project openolat by klemens.
the class RepositoryEditDescriptionController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (licenseModule.isEnabled(licenseHandler)) {
if (licenseEl != null && licenseEl.isOneSelected()) {
String licenseTypeKey = licenseEl.getSelectedKey();
LicenseType licneseType = licenseService.loadLicenseTypeByKey(licenseTypeKey);
license.setLicenseType(licneseType);
}
String licensor = null;
String freetext = null;
if (licensorEl != null && licensorEl.isVisible()) {
licensor = StringHelper.containsNonWhitespace(licensorEl.getValue()) ? licensorEl.getValue() : null;
}
if (licenseFreetextEl != null && licenseFreetextEl.isVisible()) {
freetext = StringHelper.containsNonWhitespace(licenseFreetextEl.getValue()) ? licenseFreetextEl.getValue() : null;
}
license.setLicensor(licensor);
license.setFreetext(freetext);
license = licenseService.update(license);
licensorEl.setValue(license.getLicensor());
licenseFreetextEl.setValue(license.getFreetext());
}
File uploadedImage = fileUpload.getUploadFile();
if (uploadedImage != null && uploadedImage.exists()) {
VFSContainer tmpHome = new LocalFolderImpl(new File(WebappHelper.getTmpDir()));
VFSContainer container = tmpHome.createChildContainer(UUID.randomUUID().toString());
// give it it's real name and extension
VFSLeaf newFile = fileUpload.moveUploadFileTo(container);
boolean ok = repositoryManager.setImage(newFile, repositoryEntry);
if (!ok) {
showWarning("cif.error.image");
} else {
VFSLeaf image = repositoryManager.getImage(repositoryEntry);
if (image instanceof LocalFileImpl) {
fileUpload.setInitialFile(((LocalFileImpl) image).getBasefile());
}
}
container.delete();
}
File uploadedMovie = movieUpload.getUploadFile();
if (uploadedMovie != null && uploadedMovie.exists()) {
VFSContainer m = (VFSContainer) mediaContainer.resolve("media");
VFSLeaf newFile = movieUpload.moveUploadFileTo(m);
if (newFile == null) {
showWarning("cif.error.movie");
} else {
String filename = movieUpload.getUploadFileName();
String extension = FileUtils.getFileSuffix(filename);
newFile.rename(repositoryEntry.getKey() + "." + extension);
}
}
String displayname = displayName.getValue().trim();
repositoryEntry.setDisplayname(displayname);
String mainLanguage = language.getValue();
if (StringHelper.containsNonWhitespace(mainLanguage)) {
repositoryEntry.setMainLanguage(mainLanguage);
} else {
repositoryEntry.setMainLanguage(null);
}
if (dateTypesEl != null) {
String type = "none";
if (dateTypesEl.isOneSelected()) {
type = dateTypesEl.getSelectedKey();
}
if ("none".equals(type)) {
repositoryEntry.setLifecycle(null);
} else if ("public".equals(type)) {
String key = publicDatesEl.getSelectedKey();
if (StringHelper.isLong(key)) {
Long cycleKey = Long.parseLong(key);
RepositoryEntryLifecycle cycle = lifecycleDao.loadById(cycleKey);
repositoryEntry.setLifecycle(cycle);
}
} else if ("private".equals(type)) {
Date start = startDateEl.getDate();
Date end = endDateEl.getDate();
RepositoryEntryLifecycle cycle = repositoryEntry.getLifecycle();
if (cycle == null || !cycle.isPrivateCycle()) {
String softKey = "lf_" + repositoryEntry.getSoftkey();
cycle = lifecycleDao.create(displayname, softKey, true, start, end);
} else {
cycle.setValidFrom(start);
cycle.setValidTo(end);
cycle = lifecycleDao.updateLifecycle(cycle);
}
repositoryEntry.setLifecycle(cycle);
}
}
if (externalRef != null && externalRef.isEnabled()) {
String ref = externalRef.getValue().trim();
repositoryEntry.setExternalRef(ref);
}
String desc = description.getValue().trim();
repositoryEntry.setDescription(desc);
if (authors != null) {
String auth = authors.getValue().trim();
repositoryEntry.setAuthors(auth);
}
if (objectives != null) {
String obj = objectives.getValue().trim();
repositoryEntry.setObjectives(obj);
}
if (requirements != null) {
String req = requirements.getValue().trim();
repositoryEntry.setRequirements(req);
}
if (credits != null) {
String cred = credits.getValue().trim();
repositoryEntry.setCredits(cred);
}
if (expenditureOfWork != null) {
String exp = expenditureOfWork.getValue().trim();
repositoryEntry.setExpenditureOfWork(exp);
}
if (location != null) {
String loc = location.getValue().trim();
repositoryEntry.setLocation(loc);
}
repositoryEntry = repositoryManager.setDescriptionAndName(repositoryEntry, repositoryEntry.getDisplayname(), repositoryEntry.getExternalRef(), repositoryEntry.getAuthors(), repositoryEntry.getDescription(), repositoryEntry.getObjectives(), repositoryEntry.getRequirements(), repositoryEntry.getCredits(), repositoryEntry.getMainLanguage(), repositoryEntry.getLocation(), repositoryEntry.getExpenditureOfWork(), repositoryEntry.getLifecycle());
if (repositoryEntry == null) {
showWarning("repositoryentry.not.existing");
fireEvent(ureq, Event.CLOSE_EVENT);
} else {
fireEvent(ureq, Event.CHANGED_EVENT);
MultiUserEvent modifiedEvent = new EntryChangedEvent(repositoryEntry, getIdentity(), Change.modifiedDescription, "authoring");
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, RepositoryService.REPOSITORY_EVENT_ORES);
}
}
use of org.olat.core.util.vfs.LocalFolderImpl in project openolat by klemens.
the class VideoManagerImpl method importFromExportArchive.
@Override
public boolean importFromExportArchive(RepositoryEntry repoEntry, VFSLeaf exportArchive) {
OLATResource videoResource = repoEntry.getOlatResource();
// 1) unzip archive
VFSContainer baseContainer = FileResourceManager.getInstance().getFileResourceRootImpl(videoResource);
ZipUtil.unzip(exportArchive, baseContainer);
exportArchive.delete();
// 2) update metadata from the repo entry export
LocalFolderImpl repoentryContainer = (LocalFolderImpl) baseContainer.resolve(DIRNAME_REPOENTRY);
if (repoentryContainer != null) {
RepositoryEntryImportExport importExport = new RepositoryEntryImportExport(repoentryContainer.getBasefile());
importExport.setRepoEntryPropertiesFromImport(repoEntry);
// now delete the import folder, not used anymore
repoentryContainer.delete();
}
// 3) Set poster image for repo entry
VFSContainer masterContainer = getMasterContainer(videoResource);
VFSLeaf posterImage = (VFSLeaf) masterContainer.resolve(FILENAME_POSTER_JPG);
if (posterImage != null) {
repositoryManager.setImage(posterImage, repoEntry);
}
return true;
}
Aggregations