Search in sources :

Example 41 with LocalFolderImpl

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;
}
Also used : CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer) ICourse(org.olat.course.ICourse) File(java.io.File) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 42 with LocalFolderImpl

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());
    }
}
Also used : ForumArtefact(org.olat.modules.fo.portfolio.ForumArtefact) VFSContainer(org.olat.core.util.vfs.VFSContainer) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl) Test(org.junit.Test)

Example 43 with LocalFolderImpl

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;
        }
    });
}
Also used : TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) AssessmentMode(org.olat.course.assessment.AssessmentMode) MainLayout3ColumnsController(org.olat.core.gui.control.generic.layout.MainLayout3ColumnsController) CPDisplayController(org.olat.modules.cp.CPDisplayController) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) MainLayout3ColumnsController(org.olat.core.gui.control.generic.layout.MainLayout3ColumnsController) CPContentController(org.olat.ims.cp.ui.CPContentController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) CPDisplayController(org.olat.modules.cp.CPDisplayController) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) MainLayoutController(org.olat.core.gui.control.generic.layout.MainLayoutController) CPRuntimeController(org.olat.ims.cp.ui.CPRuntimeController) CPEditMainController(org.olat.ims.cp.ui.CPEditMainController) Controller(org.olat.core.gui.control.Controller) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl) RuntimeControllerCreator(org.olat.repository.ui.RepositoryEntryRuntimeController.RuntimeControllerCreator) CPRuntimeController(org.olat.ims.cp.ui.CPRuntimeController) RepositoryEntrySecurity(org.olat.repository.model.RepositoryEntrySecurity) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) CPPackageConfig(org.olat.ims.cp.ui.CPPackageConfig) File(java.io.File) DeliveryOptions(org.olat.core.gui.control.generic.iframe.DeliveryOptions) UserRequest(org.olat.core.gui.UserRequest)

Example 44 with LocalFolderImpl

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;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) File(java.io.File) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 45 with LocalFolderImpl

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);
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) File(java.io.File) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Aggregations

LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)122 File (java.io.File)82 VFSContainer (org.olat.core.util.vfs.VFSContainer)76 VFSItem (org.olat.core.util.vfs.VFSItem)38 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)30 ArrayList (java.util.ArrayList)14 IOException (java.io.IOException)10 Document (org.dom4j.Document)10 RepositoryEntry (org.olat.repository.RepositoryEntry)10 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 DeliveryOptions (org.olat.core.gui.control.generic.iframe.DeliveryOptions)8 OLATResource (org.olat.resource.OLATResource)8 Date (java.util.Date)6 Document (org.apache.lucene.document.Document)6 Element (org.dom4j.Element)6 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)6 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)6 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)6 CPPackageConfig (org.olat.ims.cp.ui.CPPackageConfig)6 SearchResourceContext (org.olat.search.service.SearchResourceContext)6