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;
}
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;
}
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);
}
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();
}
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();
}
Aggregations