use of org.olat.core.util.vfs.LocalFolderImpl in project openolat by klemens.
the class CheckboxEditController method getFileContainer.
private VFSContainer getFileContainer() {
VFSContainer container;
if (courseNode == null) {
File tmp = new File(FolderConfig.getCanonicalTmpDir(), checkbox.getCheckboxId());
container = new LocalFolderImpl(tmp);
} else {
ICourse course = CourseFactory.loadCourse(courseOres);
CourseEnvironment courseEnv = course.getCourseEnvironment();
container = checkboxManager.getFileContainer(courseEnv, courseNode);
}
return container;
}
use of org.olat.core.util.vfs.LocalFolderImpl in project openolat by klemens.
the class EPArtefactManagerTest method testCreateForumArtefact.
@Test
public void testCreateForumArtefact() {
EPArtefactHandler<?> handler = portfolioModule.getArtefactHandler("Forum");
AbstractArtefact artefact = handler.createArtefact();
artefact.setAuthor(ident1);
assertNotNull(artefact);
assertTrue(artefact instanceof ForumArtefact);
// update the artefact
AbstractArtefact persistedArtefact = epFrontendManager.updateArtefact(artefact);
assertNotNull(persistedArtefact);
assertTrue(persistedArtefact instanceof ForumArtefact);
dbInstance.commitAndCloseSession();
// reload the artefact
AbstractArtefact loadedArtefact = epFrontendManager.loadArtefactByKey(artefact.getKey());
assertNotNull(loadedArtefact);
assertTrue(loadedArtefact instanceof ForumArtefact);
// get the VFS container of the artefact
VFSContainer container = epFrontendManager.getArtefactContainer(loadedArtefact);
assertNotNull(container);
if (container instanceof LocalFolderImpl) {
LocalFolderImpl folder = (LocalFolderImpl) container;
assertNotNull(folder.getBasefile());
assertTrue(folder.getBasefile().exists());
assertTrue(folder.getBasefile().isDirectory());
}
}
use of org.olat.core.util.vfs.LocalFolderImpl in project openolat by klemens.
the class ImsCPHandler method createLaunchController.
@Override
public MainLayoutController createLaunchController(RepositoryEntry re, RepositoryEntrySecurity reSecurity, UserRequest ureq, WindowControl wControl) {
OLATResource res = re.getOlatResource();
File cpRoot = FileResourceManager.getInstance().unzipFileResource(res);
final LocalFolderImpl vfsWrapper = new LocalFolderImpl(cpRoot);
CPPackageConfig packageConfig = CPManager.getInstance().getCPPackageConfig(res);
final DeliveryOptions deliveryOptions = (packageConfig == null ? null : packageConfig.getDeliveryOptions());
return new CPRuntimeController(ureq, wControl, re, reSecurity, new RuntimeControllerCreator() {
@Override
public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry entry, RepositoryEntrySecurity security, AssessmentMode assessmentMode) {
boolean activateFirstPage = true;
String initialUri = null;
CoreSpringFactory.getImpl(UserCourseInformationsManager.class).updateUserCourseInformations(entry.getOlatResource(), uureq.getIdentity());
CPDisplayController cpCtr = new CPDisplayController(uureq, wwControl, vfsWrapper, true, true, activateFirstPage, true, deliveryOptions, initialUri, entry.getOlatResource(), "", false);
MainLayout3ColumnsController ctr = new LayoutMain3ColsController(uureq, wwControl, cpCtr.getMenuComponent(), cpCtr.getInitialComponent(), vfsWrapper.getName());
ctr.addDisposableChildController(cpCtr);
return ctr;
}
});
}
use of org.olat.core.util.vfs.LocalFolderImpl in project openolat by klemens.
the class RepositoryManager method getImage.
public VFSLeaf getImage(OLATResourceable re) {
VFSContainer repositoryHome = new LocalFolderImpl(new File(FolderConfig.getCanonicalRepositoryHome()));
String imageName = re.getResourceableId() + ".jpg";
VFSItem image = repositoryHome.resolve(imageName);
if (image instanceof VFSLeaf) {
return (VFSLeaf) image;
}
imageName = re.getResourceableId() + ".png";
image = repositoryHome.resolve(imageName);
if (image instanceof VFSLeaf) {
return (VFSLeaf) image;
}
return null;
}
use of org.olat.core.util.vfs.LocalFolderImpl in project openolat by klemens.
the class CatalogEntryEditController method formOK.
@Override
protected void formOK(UserRequest ureq) {
catalogEntry.setName(nameEl.getValue());
if (styleEl.isOneSelected()) {
catalogEntry.setStyle(Style.valueOf(styleEl.getSelectedKey()));
} else {
catalogEntry.setStyle(null);
}
catalogEntry.setDescription(descriptionEl.getValue());
if (catalogEntry.getKey() == null) {
// a new one
catalogEntry.setOwnerGroup(BaseSecurityManager.getInstance().createAndPersistSecurityGroup());
catalogEntry.setRepositoryEntry(null);
catalogEntry.setParent(parentEntry);
catalogEntry = catalogManager.saveCatalogEntry(catalogEntry);
} else {
catalogEntry = catalogManager.updateCatalogEntry(catalogEntry);
}
File uploadedFile = fileUpload.getUploadFile();
if (uploadedFile != null) {
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, true);
if (newFile != null) {
boolean ok = catalogManager.setImage(newFile, catalogEntry);
if (!ok) {
showError("error.download.image");
}
} else {
logError("Cannot move and or crop: " + fileUpload.getUploadFileName() + " ( " + fileUpload.getUploadMimeType() + " )", null);
showError("error.download.image");
}
}
fireEvent(ureq, Event.DONE_EVENT);
}
Aggregations