Search in sources :

Example 81 with LocalFolderImpl

use of org.olat.core.util.vfs.LocalFolderImpl in project OpenOLAT by OpenOLAT.

the class CourseLayoutHelper method getThemeBaseFolder.

/**
 * get path according to type of theme
 * @param courseEnvironment
 * @param cssSet
 * @return
 */
public static VFSContainer getThemeBaseFolder(CourseEnvironment courseEnvironment, String cssSet) {
    VFSContainer courseBase = courseEnvironment.getCourseBaseContainer();
    // the hidden-dir CSS in "/coursecss/xy.css"
    if (StringHelper.containsNonWhitespace(cssSet) && cssSet.contains(COURSEFOLDER_CSS_BASE) && cssSet.startsWith("/") && cssSet.lastIndexOf("/") > 0) {
        if (courseEnvironment.getCourseFolderContainer().resolve(COURSEFOLDER_CSS_BASE) != null) {
            return courseEnvironment.getCourseFolderContainer();
        } else
            return null;
    } else if (!StringHelper.containsNonWhitespace(cssSet) || cssSet.startsWith("/")) {
        // the old legacy format "/blibla.css"
        return (VFSContainer) courseBase.resolve("coursefolder");
    } else if (cssSet.equals(CONFIG_KEY_CUSTOM)) {
        return (VFSContainer) courseBase.resolve(LAYOUT_COURSE_SUBFOLDER + "/custom");
    } else if (CONFIG_KEY_PREDEFINED.equals(cssSet)) {
        return (VFSContainer) courseBase.resolve(LAYOUT_COURSE_SUBFOLDER + "/predefined");
    } else if (cssSet.startsWith(CONFIG_KEY_TEMPLATE)) {
        String selTheme = cssSet.substring(CONFIG_KEY_TEMPLATE.length());
        // 1. check if it's a layout from the OLAT-theme
        VFSContainer themeContainer = getOLATThemeCourseLayoutFolder();
        if (themeContainer != null) {
            themeContainer = (VFSContainer) themeContainer.resolve("/" + selTheme);
            return themeContainer;
        }
        // 2. check if it's system-default
        String staticAbsPath = WebappHelper.getContextRealPath("/static/coursethemes/");
        File themesFile = new File(staticAbsPath + selTheme);
        if (themesFile.exists() && themesFile.isDirectory())
            return new LocalFolderImpl(themesFile);
    }
    // default was set
    return null;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) File(java.io.File) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 82 with LocalFolderImpl

use of org.olat.core.util.vfs.LocalFolderImpl in project OpenOLAT by OpenOLAT.

the class CourseLayoutHelper method getOLATThemeCourseLayoutFolder.

/**
 * returns the Folder with the additional courselayouts from the current
 * OLAT-Theme this is e.g. : /static/themes/frentix/courselayouts/<br />
 * If no courselayouts exist in the current OLAT-Theme, null is returned!
 *
 * @return the courselayouts-folder or null
 */
public static VFSContainer getOLATThemeCourseLayoutFolder() {
    VFSContainer courseLayoutFolder = null;
    File themeDir = null;
    // first attempt is to use custom theme path
    if (Settings.getGuiCustomThemePath() != null) {
        themeDir = new File(Settings.getGuiCustomThemePath(), CoreSpringFactory.getImpl(GUISettings.class).getGuiThemeIdentifyer());
        if (themeDir.exists() && themeDir.isDirectory()) {
            VFSContainer themeContainer = new LocalFolderImpl(themeDir);
            courseLayoutFolder = (VFSContainer) themeContainer.resolve("/courselayouts");
        }
    }
    // fallback is to use the standards themes directory in the web app
    if (themeDir == null || !themeDir.exists() || !themeDir.isDirectory()) {
        File themesDir = new File(WebappHelper.getContextRealPath("/static/themes/"));
        themeDir = new File(themesDir, CoreSpringFactory.getImpl(GUISettings.class).getGuiThemeIdentifyer());
    }
    // resolve now
    if (themeDir != null && themeDir.exists() && themeDir.isDirectory()) {
        VFSContainer themeContainer = new LocalFolderImpl(themeDir);
        courseLayoutFolder = (VFSContainer) themeContainer.resolve("/courselayouts");
    }
    return courseLayoutFolder;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) File(java.io.File) GUISettings(org.olat.core.helpers.GUISettings) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 83 with LocalFolderImpl

use of org.olat.core.util.vfs.LocalFolderImpl in project OpenOLAT by OpenOLAT.

the class ExportManager method archiveCourseLogFiles.

/**
 * Archives the course log files
 * @param oresID
 * @param exportDir
 * @param begin
 * @param end
 * @param adminLog
 * @param userLog
 * @param statisticLog
 * @param charset
 * @param locale
 * @param email
 */
public void archiveCourseLogFiles(Long oresID, String exportDir, Date begin, Date end, boolean adminLog, boolean userLog, boolean statisticLog, String charset, Locale locale, String email) {
    String zipName = ExportUtil.createFileNameWithTimeStamp(ExportManager.COURSE_LOG_FILES, "zip");
    Date date = new Date();
    String tmpDirName = oresID + "-" + date.getTime();
    final VFSContainer tmpDirVFSContainer = new LocalFolderImpl(new File(WebappHelper.getTmpDir(), tmpDirName));
    final File tmpDir = new File(WebappHelper.getTmpDir(), tmpDirName);
    List<VFSItem> logFiles = new ArrayList<VFSItem>();
    if (adminLog) {
        logFiles.add(createLogFile(oresID, begin, end, charset, tmpDirVFSContainer, tmpDir, FILENAME_ADMIN_LOG, true, false));
    }
    if (userLog) {
        logFiles.add(createLogFile(oresID, begin, end, charset, tmpDirVFSContainer, tmpDir, FILENAME_USER_LOG, false, false));
    }
    if (statisticLog) {
        logFiles.add(createLogFile(oresID, begin, end, charset, tmpDirVFSContainer, tmpDir, FILENAME_STATISTIC_LOG, false, true));
    }
    saveFile(exportDir, zipName, tmpDirVFSContainer, logFiles, email, "email.archive", locale);
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) ArrayList(java.util.ArrayList) VFSItem(org.olat.core.util.vfs.VFSItem) File(java.io.File) Date(java.util.Date) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 84 with LocalFolderImpl

use of org.olat.core.util.vfs.LocalFolderImpl in project OpenOLAT by OpenOLAT.

the class VersionsFileManager method cleanUp.

/**
 * Clean up all revisions files, xml file
 * @param leaf
 */
private void cleanUp(VFSLeaf leaf) {
    String relPath = getRelPath(leaf);
    // cannot handle
    if (relPath == null)
        return;
    File fVersion = new File(getRootVersionsFile(), relPath + ".xml");
    File fParentVersion = fVersion.getParentFile();
    // already deleted
    if (!fParentVersion.exists())
        return;
    VFSLeaf versionLeaf = null;
    if (fVersion.exists()) {
        LocalFolderImpl localVersionContainer = new LocalFolderImpl(fParentVersion);
        versionLeaf = (VFSLeaf) localVersionContainer.resolve(fVersion.getName());
    }
    // already deleted
    if (versionLeaf == null)
        return;
    Versions versions = readVersions(leaf, versionLeaf);
    for (VFSRevision versionToDelete : versions.getRevisions()) {
        RevisionFileImpl versionImpl = (RevisionFileImpl) versionToDelete;
        VFSLeaf fileToDelete = versionImpl.getFile();
        if (fileToDelete != null) {
            fileToDelete.delete();
        }
    }
    versionLeaf.delete();
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) File(java.io.File) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 85 with LocalFolderImpl

use of org.olat.core.util.vfs.LocalFolderImpl in project OpenOLAT by OpenOLAT.

the class SurveyFileResource method validate.

/**
 * @param unzippedDir
 * @return True if is of type.
 */
public static boolean validate(File unzippedDir) {
    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();
}
Also used : ResourceEvaluation(org.olat.fileresource.types.ResourceEvaluation) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) Document(org.dom4j.Document) 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