use of org.olat.search.service.SearchResourceContext in project openolat by klemens.
the class PortfolioMapDocument method getContent.
private static String getContent(PortfolioStructure map, SearchResourceContext resourceContext, StringBuilder sb, Filter filter) {
sb.append(' ').append(map.getTitle());
if (StringHelper.containsNonWhitespace(map.getDescription())) {
sb.append(' ').append(filter.filter(map.getDescription()));
}
for (PortfolioStructure child : ePFMgr.loadStructureChildren(map)) {
getContent(child, resourceContext, sb, filter);
}
for (AbstractArtefact artefact : ePFMgr.getArtefacts(map)) {
String reflexion = artefact.getReflexion();
if (StringHelper.containsNonWhitespace(reflexion)) {
sb.append(' ').append(filter.filter(reflexion));
}
OLATResourceable ores = OresHelper.createOLATResourceableInstance(AbstractArtefact.class.getSimpleName(), artefact.getKey());
EPArtefactHandler<?> handler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
SearchResourceContext artefactResourceContext = new SearchResourceContext(resourceContext);
artefactResourceContext.setBusinessControlFor(ores);
OlatDocument doc = handler.getIndexerDocument(artefactResourceContext, artefact, ePFMgr);
sb.append(' ').append(doc.getContent());
}
return sb.toString();
}
use of org.olat.search.service.SearchResourceContext in project openolat by klemens.
the class GroupWikiIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext parentResourceContext, Object businessObj, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
if (!(businessObj instanceof BusinessGroup))
throw new AssertException("businessObj must be BusinessGroup");
BusinessGroup businessGroup = (BusinessGroup) businessObj;
// Index Group Wiki
if (isLogDebugEnabled())
logDebug("Analyse Wiki for Group=" + businessGroup);
CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(businessGroup);
if (collabTools.isToolEnabled(CollaborationTools.TOOL_WIKI)) {
try {
Wiki wiki = WikiManager.getInstance().getOrLoadWiki(businessGroup);
// loop over all wiki pages
List<WikiPage> wikiPageList = wiki.getAllPagesWithContent();
for (WikiPage wikiPage : wikiPageList) {
SearchResourceContext wikiResourceContext = new SearchResourceContext(parentResourceContext);
wikiResourceContext.setBusinessControlFor(BusinessGroupMainRunController.ORES_TOOLWIKI);
wikiResourceContext.setDocumentType(TYPE);
wikiResourceContext.setFilePath(wikiPage.getPageName());
Document document = WikiPageDocument.createDocument(wikiResourceContext, wikiPage);
indexWriter.addDocument(document);
}
} catch (NullPointerException nex) {
logWarn("NullPointerException in GroupWikiIndexer.doIndex.", nex);
}
} else {
if (isLogDebugEnabled())
logDebug("Group=" + businessGroup + " has no Wiki.");
}
}
use of org.olat.search.service.SearchResourceContext in project openolat by klemens.
the class IdentityIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext parentResourceContext, Object parentObject, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
int counter = 0;
BaseSecurity secMgr = BaseSecurityManager.getInstance();
List<Long> identityKeys = secMgr.loadVisibleIdentityKeys();
if (isLogDebugEnabled())
logDebug("Found " + identityKeys.size() + " active identities to index");
DBFactory.getInstance().commitAndCloseSession();
for (Long identityKey : identityKeys) {
try {
// reload the identity here before indexing it to make sure it has not been deleted in the meantime
Identity identity = secMgr.loadIdentityByKey(identityKey);
if (identity == null || (identity.getStatus() >= Identity.STATUS_VISIBLE_LIMIT)) {
logInfo("doIndex: identity was deleted while we were indexing. The deleted identity was: " + identity);
continue;
}
if (isLogDebugEnabled())
logDebug("Indexing identity::" + identity.getName() + " and counter::" + counter);
// Create a search context for this identity. The search context will open the users visiting card in a new tab
SearchResourceContext searchResourceContext = new SearchResourceContext(parentResourceContext);
searchResourceContext.setBusinessControlFor(OresHelper.createOLATResourceableInstance(Identity.class, identity.getKey()));
searchResourceContext.setParentContextType(TYPE);
// delegate indexing work to all configured indexers
for (Indexer indexer : getChildIndexers()) {
indexer.doIndex(searchResourceContext, identity, indexWriter);
}
counter++;
} catch (Exception ex) {
logWarn("Exception while indexing identity::" + identityKey + ". Skipping this user, try next one.", ex);
DBFactory.getInstance().rollbackAndCloseSession();
}
DBFactory.getInstance().commitAndCloseSession();
}
if (isLogDebugEnabled())
logDebug("IdentityIndexer finished with counter::" + counter);
}
use of org.olat.search.service.SearchResourceContext in project openolat by klemens.
the class PortfolioArtefactIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext searchResourceContext, Object object, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
if (!portfolioModule.isEnabled())
return;
Identity identity = (Identity) object;
// SearchResourceContext resourceContext = new SearchResourceContext(searchResourceContext); // dont do this way, as it would then try to open an artefact over visiting card -> not possible!
SearchResourceContext resourceContext = new SearchResourceContext();
resourceContext.setDocumentType(TYPE);
resourceContext.setParentContextType(null);
int currentPosition = 0;
List<AbstractArtefact> artefacts;
do {
artefacts = frontendManager.getArtefacts(identity, currentPosition, MAX_RESULTS);
for (AbstractArtefact artefact : artefacts) {
OLATResourceable ores = OresHelper.createOLATResourceableInstance(AbstractArtefact.class.getSimpleName(), artefact.getKey());
EPArtefactHandler<?> handler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
resourceContext.setBusinessControlFor(ores);
OlatDocument doc = handler.getIndexerDocument(resourceContext, artefact, frontendManager);
Identity author = artefact.getAuthor();
if (author != null && author.getUser() != null) {
doc.setReservedTo(author.getKey().toString());
}
if (doc != null) {
indexerWriter.addDocument(doc.getLuceneDocument());
}
}
currentPosition += artefacts.size();
} while (artefacts.size() == MAX_RESULTS);
super.doIndex(searchResourceContext, object, indexerWriter);
}
use of org.olat.search.service.SearchResourceContext in project openolat by klemens.
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);
}
}
}
Aggregations