use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.
the class GroupPortfolioIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext parentResourceContext, Object businessObj, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
if (!portfolioModule.isEnabled())
return;
if (!(businessObj instanceof BusinessGroup))
throw new AssertException("businessObj must be BusinessGroup");
BusinessGroup businessGroup = (BusinessGroup) businessObj;
NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(businessGroup);
Property mapKeyProperty = npm.findProperty(null, null, CollaborationTools.PROP_CAT_BG_COLLABTOOLS, CollaborationTools.KEY_PORTFOLIO);
// Check if portfolio map property exist
if (mapKeyProperty != null) {
Long mapKey = mapKeyProperty.getLongValue();
String version = mapKeyProperty.getStringValue();
if (version == null || !version.equals("2")) {
PortfolioStructure map = frontendManager.loadPortfolioStructureByKey(mapKey);
if (map != null) {
SearchResourceContext resourceContext = new SearchResourceContext(parentResourceContext);
resourceContext.setBusinessControlFor(BusinessGroupMainRunController.ORES_TOOLPORTFOLIO);
resourceContext.setDocumentType(TYPE);
resourceContext.setParentContextType(GroupDocument.TYPE);
resourceContext.setParentContextName(businessGroup.getName());
Document document = PortfolioMapDocument.createDocument(resourceContext, map);
indexerWriter.addDocument(document);
}
}
}
}
use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.
the class WikiRepositoryIndexer 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 Wiki RepositoryEntry...");
String repoEntryName = "*name not available*";
try {
repoEntryName = repositoryEntry.getDisplayname();
Wiki wiki = WikiManager.getInstance().getOrLoadWiki(repositoryEntry.getOlatResource());
// loop over all wiki pages
List<WikiPage> wikiPageList = wiki.getAllPagesWithContent();
for (WikiPage wikiPage : wikiPageList) {
try {
SearchResourceContext wikiContext = new SearchResourceContext(resourceContext);
wikiContext.setDocumentType(TYPE);
wikiContext.setFilePath(wikiPage.getPageName());
Document document = WikiPageDocument.createDocument(wikiContext, wikiPage);
indexWriter.addDocument(document);
} catch (Exception e) {
logError("Error indexing wiki page:" + repoEntryName + " " + (wikiPage == null ? "null" : wikiPage.getPageName()), e);
}
}
} catch (Exception e) {
logError("Error indexing wiki:" + repoEntryName, e);
}
}
use of org.olat.search.service.SearchResourceContext 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.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.
the class PortfolioCourseNodeIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext searchResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
if (!portfolioModule.isEnabled())
return;
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(searchResourceContext, courseNode, NODE_TYPE);
Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
indexWriter.addDocument(document);
PortfolioCourseNode portfolioNode = (PortfolioCourseNode) courseNode;
RepositoryEntry repoEntry = portfolioNode.getReferencedRepositoryEntry();
if (repoEntry != null) {
OLATResource ores = repoEntry.getOlatResource();
PortfolioStructure element = structureManager.loadPortfolioStructure(ores);
if (element != null) {
Document pDocument = PortfolioMapDocument.createDocument(courseNodeResourceContext, element);
indexWriter.addDocument(pDocument);
}
}
}
use of org.olat.search.service.SearchResourceContext 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.");
}
}
Aggregations