use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.
the class BCCourseNodeIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
if (isLogDebugEnabled())
logDebug("Index Briefcase...");
BCCourseNode bcNode = (BCCourseNode) courseNode;
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, bcNode, TYPE);
Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, bcNode);
indexWriter.addDocument(document);
VFSContainer bcContainer = null;
if (bcNode.getModuleConfiguration().getBooleanSafe(BCCourseNodeEditController.CONFIG_AUTO_FOLDER)) {
bcContainer = BCCourseNode.getNodeFolderContainer(bcNode, course.getCourseEnvironment());
} else {
String subpath = courseNode.getModuleConfiguration().getStringValue(BCCourseNodeEditController.CONFIG_SUBPATH);
if (subpath != null) {
VFSItem item = course.getCourseEnvironment().getCourseFolderContainer().resolve(subpath);
if (item instanceof VFSContainer) {
bcContainer = new NamedContainerImpl(courseNode.getShortTitle(), (VFSContainer) item);
}
}
}
if (bcContainer != null) {
doIndexVFSContainer(courseNodeResourceContext, bcContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
}
}
use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.
the class SPCourseNodeIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext courseResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
if (log.isDebug())
log.debug("Index SinglePage...");
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(courseResourceContext, courseNode, TYPE);
Document nodeDocument = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
indexWriter.addDocument(nodeDocument);
// The root of the configured single page. Depends on the configuration
// whether to follow relative links or not. When relative links are
// followed, the root is the course folder root, if not, it is folder
// where the configured file is in
VFSContainer rootContainer;
// The filename of the configured file relative to the rootContainer
String chosenFile;
// Read the course node configuration
VFSContainer courseFolderContainer = course.getCourseEnvironment().getCourseFolderContainer();
boolean allowRelativeLinks = courseNode.getModuleConfiguration().getBooleanSafe(SPEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS);
String fileName = (String) courseNode.getModuleConfiguration().get(SPEditController.CONFIG_KEY_FILE);
// *** IF YOU CHANGE THIS LOGIC, do also change it in SinglePageController! ***
if (allowRelativeLinks) {
// Case 1: relative links are allowed. The root is the root of the
// course, the file name is relative to the root
rootContainer = courseFolderContainer;
chosenFile = fileName;
} else {
// Case 2: relative links are NOT allowed. We have to calculate the
// new root and remove the relative path to the course folder form
// the file.
String startURI = ((fileName.charAt(0) == '/') ? fileName.substring(1) : fileName);
int sla = startURI.lastIndexOf('/');
if (sla != -1) {
// Some subfolder path is detected, create basecontainer from it
String root = startURI.substring(0, sla);
startURI = startURI.substring(sla + 1);
// Create new root folder from the relative folder path
VFSContainer newroot = (VFSContainer) courseFolderContainer.resolve(root);
newroot.setParentContainer(null);
rootContainer = newroot;
} else {
// No subpath detected, just use course base container
rootContainer = courseFolderContainer;
}
chosenFile = startURI;
}
VFSLeaf leaf = (VFSLeaf) rootContainer.resolve(chosenFile);
if (leaf != null) {
String filePath = getPathFor(leaf);
// Use inherited method from LeafIndexer for the actual indexing of the content
SearchResourceContext fileContext = new SearchResourceContext(courseNodeResourceContext);
doIndexVFSLeafByMySelf(fileContext, leaf, indexWriter, filePath);
if (!indexOnlyChosenFile) {
if (log.isDebug())
log.debug("Index sub pages in SP.");
Set<String> alreadyIndexFileNames = new HashSet<String>();
alreadyIndexFileNames.add(chosenFile);
// Check if page has links to subpages and index those as well
indexSubPages(courseNodeResourceContext, rootContainer, indexWriter, leaf, alreadyIndexFileNames, 0, filePath);
} else if (log.isDebug()) {
log.debug("Index only chosen file in SP.");
}
} else if (log.isDebug()) {
log.debug("Can not found choosen file in SP => Nothing indexed.");
}
}
use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.
the class DialogCourseNodeIndexer method doIndexFile.
/**
* Index a file of dialog-module.
* @param filename
* @param forumKey
* @param leafResourceContext
* @param indexWriter
* @throws IOException
* @throws InterruptedException
*/
private void doIndexFile(DialogElement element, SearchResourceContext leafResourceContext, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
DialogElementsManager dialogElmsMgr = CoreSpringFactory.getImpl(DialogElementsManager.class);
VFSContainer dialogContainer = dialogElmsMgr.getDialogContainer(element);
VFSLeaf leaf = (VFSLeaf) dialogContainer.getItems(new VFSLeafFilter()).get(0);
if (isLogDebugEnabled())
logDebug("Analyse VFSLeaf=" + leaf.getName());
try {
if (CoreSpringFactory.getImpl(FileDocumentFactory.class).isFileSupported(leaf)) {
leafResourceContext.setFilePath(element.getFilename());
leafResourceContext.setDocumentType(TYPE_FILE);
Document document = CoreSpringFactory.getImpl(FileDocumentFactory.class).createDocument(leafResourceContext, leaf);
indexWriter.addDocument(document);
} else {
if (isLogDebugEnabled())
logDebug("Documenttype not supported. file=" + leaf.getName());
}
} catch (DocumentAccessException e) {
if (isLogDebugEnabled())
logDebug("Can not access document." + e.getMessage());
} catch (IOException ioEx) {
logWarn("IOException: Can not index leaf=" + leaf.getName(), ioEx);
} catch (InterruptedException iex) {
throw new InterruptedException(iex.getMessage());
} catch (Exception ex) {
logWarn("Exception: Can not index leaf=" + leaf.getName(), ex);
}
}
use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.
the class ImsCPRepositoryIndexer method doIndex.
/**
* @see org.olat.repository.handlers.RepositoryHandler#supportsDownload()
*/
@Override
public void doIndex(SearchResourceContext resourceContext, Object parentObject, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
RepositoryEntry repositoryEntry = (RepositoryEntry) parentObject;
if (isLogDebugEnabled())
logDebug("Analyse IMS CP RepositoryEntry...");
resourceContext.setDocumentType(TYPE);
if (repositoryEntry != null) {
File cpRoot = FileResourceManager.getInstance().unzipFileResource(repositoryEntry.getOlatResource());
if (cpRoot != null) {
SearchResourceContext cpContext = new SearchResourceContext(resourceContext);
VFSContainer rootContainer = new LocalFolderImpl(cpRoot);
doIndexVFSContainer(cpContext, rootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
}
}
}
use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.
the class SharedFolderRepositoryIndexer method doIndex.
/**
* @see org.olat.repository.handlers.RepositoryHandler#supportsDownload()
*/
@Override
public void doIndex(SearchResourceContext resourceContext, Object parentObject, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
RepositoryEntry repositoryEntry = (RepositoryEntry) parentObject;
if (isLogDebugEnabled())
logDebug("Analyse Shared Folder RepositoryEntry...");
resourceContext.setDocumentType(TYPE);
VFSContainer sfContainer = SharedFolderManager.getInstance().getSharedFolder(repositoryEntry.getOlatResource());
// only index if no lockfile found. see OLAT-5724
if (sfContainer != null && sfContainer.resolve(NO_FOLDER_INDEXING_LOCKFILE) == null) {
SearchResourceContext folderContext = new SearchResourceContext(resourceContext);
doIndexVFSContainer(folderContext, sfContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
}
}
Aggregations