use of org.olat.core.util.vfs.LocalFolderImpl in project OpenOLAT by OpenOLAT.
the class TACourseNodeIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, null);
Document nodeDocument = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
indexWriter.addDocument(nodeDocument);
// Index Task
File fTaskfolder = new File(FolderConfig.getCanonicalRoot() + TACourseNode.getTaskFolderPathRelToFolderRoot(course.getCourseEnvironment(), courseNode));
VFSContainer taskRootContainer = new LocalFolderImpl(fTaskfolder);
courseNodeResourceContext.setDocumentType(TYPE_TASK);
doIndexVFSContainer(courseNodeResourceContext, taskRootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
// Index Dropbox
String dropboxFilePath = FolderConfig.getCanonicalRoot() + DropboxController.getDropboxPathRelToFolderRoot(course.getCourseEnvironment(), courseNode);
File fDropboxFolder = new File(dropboxFilePath);
VFSContainer dropboxRootContainer = new LocalFolderImpl(fDropboxFolder);
courseNodeResourceContext.setDocumentType(TYPE_DROPBOX);
doIndexVFSContainer(courseNodeResourceContext, dropboxRootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
// Index Returnbox
String returnboxFilePath = FolderConfig.getCanonicalRoot() + ReturnboxController.getReturnboxPathRelToFolderRoot(course.getCourseEnvironment(), courseNode);
File fResturnboxFolder = new File(returnboxFilePath);
VFSContainer returnboxRootContainer = new LocalFolderImpl(fResturnboxFolder);
courseNodeResourceContext.setDocumentType(TYPE_RETURNBOX);
doIndexVFSContainer(courseNodeResourceContext, returnboxRootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
// Index Solutionbox
String solutionFilePath = FolderConfig.getCanonicalRoot() + SolutionController.getSolutionPathRelToFolderRoot(course.getCourseEnvironment(), courseNode);
File fSolutionFolder = new File(solutionFilePath);
VFSContainer solutionRootContainer = new LocalFolderImpl(fSolutionFolder);
courseNodeResourceContext.setDocumentType(TYPE_SOLUTIONBOX);
doIndexVFSContainer(courseNodeResourceContext, solutionRootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
}
use of org.olat.core.util.vfs.LocalFolderImpl in project OpenOLAT by OpenOLAT.
the class CPCourseNodeIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, TYPE);
Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
indexWriter.addDocument(document);
RepositoryEntry re = CPEditController.getCPReference(courseNode.getModuleConfiguration(), false);
if (re != null) {
File cpRoot = FileResourceManager.getInstance().unzipFileResource(re.getOlatResource());
if (cpRoot != null) {
VFSContainer rootContainer = new LocalFolderImpl(cpRoot);
doIndexVFSContainer(courseNodeResourceContext, rootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
}
}
}
use of org.olat.core.util.vfs.LocalFolderImpl in project OpenOLAT by OpenOLAT.
the class ZipUtil method zip.
/**
* Add the set of files residing in root to the ZIP file named target.
* Files in subfolders will be compressed too.
* if target already exists, this will abort and return false.
*
* @param files Filenames to add to ZIP, relative to root
* @param root Base path.
* @param target Target ZIP file.
* @param compress to compress ot just store
* @return true if successfull, false otherwise.
*/
public static boolean zip(Set<String> files, File root, File target, boolean compress) {
// Create a buffer for reading the files
if (target.exists())
return false;
List<VFSItem> vfsFiles = new ArrayList<VFSItem>();
LocalFolderImpl vfsRoot = new LocalFolderImpl(root);
for (Iterator<String> iter = files.iterator(); iter.hasNext(); ) {
String fileName = iter.next();
VFSItem item = vfsRoot.resolve(fileName);
if (item == null)
return false;
vfsFiles.add(item);
}
return zip(vfsFiles, new LocalFileImpl(target), compress);
}
use of org.olat.core.util.vfs.LocalFolderImpl in project OpenOLAT by OpenOLAT.
the class CertificatesManagerImpl method addHtmlTemplate.
private boolean addHtmlTemplate(String name, File file, CertificateTemplateImpl template) {
String dir = templatesStorage.generateDir();
VFSContainer templateDir = templatesStorage.getContainer(dir);
try {
File targetFolder = ((LocalFolderImpl) templateDir).getBasefile();
ZipUtils.unpackZip(file, targetFolder);
template.setName(name);
template.setPath(dir + "index.html");
return true;
} catch (IOException e) {
log.error("", e);
return false;
}
}
use of org.olat.core.util.vfs.LocalFolderImpl in project OpenOLAT by OpenOLAT.
the class CPRunController method doLaunch.
private void doLaunch(UserRequest ureq) {
DeliveryOptions deliveryOptions = (DeliveryOptions) config.get(CPEditController.CONFIG_DELIVERYOPTIONS);
if (cpRoot == null) {
// it is the first time we start the contentpackaging from this instance
// of this controller.
// need to be strict when launching -> "true"
RepositoryEntry re = CPEditController.getCPReference(config, false);
if (re == null) {
showError(CPEditController.NLS_ERROR_CPREPOENTRYMISSING);
return;
}
cpRoot = FileResourceManager.getInstance().unzipFileResource(re.getOlatResource());
// nodes reference them
if (cpRoot == null) {
showError(CPEditController.NLS_ERROR_CPREPOENTRYMISSING);
return;
}
if (deliveryOptions != null && deliveryOptions.getInherit() != null && deliveryOptions.getInherit().booleanValue()) {
CPPackageConfig packageConfig = CPManager.getInstance().getCPPackageConfig(re.getOlatResource());
if (packageConfig != null && packageConfig.getDeliveryOptions() != null) {
deliveryOptions = packageConfig.getDeliveryOptions();
}
}
}
// else cpRoot is already set (save some db access if the user opens /
// closes / reopens the cp from the same CPRuncontroller instance)
boolean activateFirstPage = true;
if ((nodecmd != null) && !nodecmd.equals("")) {
activateFirstPage = false;
}
boolean showNavigation = !config.getBooleanSafe(NodeEditController.CONFIG_COMPONENT_MENU);
cpDispC = CPUIFactory.getInstance().createContentOnlyCPDisplayController(ureq, getWindowControl(), new LocalFolderImpl(cpRoot), activateFirstPage, showNavigation, deliveryOptions, nodecmd, courseResource, cpNode.getIdent(), preview);
cpDispC.setContentEncoding(deliveryOptions.getContentEncoding());
cpDispC.setJSEncoding(deliveryOptions.getJavascriptEncoding());
cpDispC.addControllerListener(this);
main.setContent(cpDispC.getInitialComponent());
if (isExternalMenuConfigured()) {
treeModel = cpDispC.getTreeModel();
treeNodeClickListener = this;
if (activateFirstPage) {
selNodeId = cpDispC.getInitialSelectedNodeId();
} else {
String uri = nodecmd;
if (uri.startsWith("/")) {
uri = uri.substring(1, uri.length());
}
selNodeId = cpDispC.getNodeByUri(uri);
}
}
}
Aggregations