use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class PublicFolderIndexer method doIndex.
/**
* @see org.olat.repository.handlers.RepositoryHandler#supportsDownload()
*/
@Override
public void doIndex(SearchResourceContext parentResourceContext, Object parentObject, OlatFullIndexer indexWriter) {
try {
// get public folder for user
Identity identity = (Identity) parentObject;
OlatRootFolderImpl rootContainer = new OlatRootFolderImpl(FolderConfig.getUserHome(identity.getName()) + "/public", null);
if (!rootContainer.getBasefile().exists())
return;
// build new resource context
SearchResourceContext searchResourceContext = new SearchResourceContext(parentResourceContext);
searchResourceContext.setParentContextName(identity.getName());
searchResourceContext.setBusinessControlFor(BUSINESS_CONTROL_TYPE);
searchResourceContext.setDocumentType(TYPE);
// now index the folder
doIndexVFSContainer(searchResourceContext, rootContainer, indexWriter, "", FolderIndexerAccess.FULL_ACCESS);
} catch (Exception ex) {
logWarn("Exception while indexing public folder of identity::" + parentObject.toString() + ". Skipping this user, try next one.", ex);
}
if (isLogDebugEnabled())
logDebug("PublicFolder finished for user::" + parentObject.toString());
}
use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.
the class ScormRepositoryIndexer method doIndex.
/**
* @see org.olat.repository.handlers.RepositoryHandler#supportsDownload()
*/
public void doIndex(SearchResourceContext resourceContext, Object parentObject, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
if (isLogDebugEnabled())
logDebug("Index Scorm package...");
RepositoryEntry repositoryEntry = (RepositoryEntry) parentObject;
OLATResource ores = repositoryEntry.getOlatResource();
File cpRoot = FileResourceManager.getInstance().unzipFileResource(ores);
resourceContext.setDocumentType(TYPE);
SearchResourceContext scormContext = new SearchResourceContext(resourceContext);
doIndex(scormContext, indexWriter, cpRoot);
}
use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.
the class InfoCourseNodeIndexer method doIndexInfos.
private void doIndexInfos(SearchResourceContext parentResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
List<InfoMessage> messages = infoMessageManager.loadInfoMessageByResource(course, courseNode.getIdent(), null, null, null, 0, -1);
for (InfoMessage message : messages) {
SearchResourceContext searchResourceContext = new SearchResourceContext(parentResourceContext);
OLATResourceable ores = OresHelper.createOLATResourceableInstance(InfoMessage.class, message.getKey());
searchResourceContext.setBusinessControlFor(ores);
Document document = InfoMessageDocument.createDocument(searchResourceContext, message);
indexWriter.addDocument(document);
}
}
use of org.olat.search.service.SearchResourceContext in project OpenOLAT by OpenOLAT.
the class InfoCourseNodeIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) {
try {
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, TYPE);
Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
indexWriter.addDocument(document);
doIndexInfos(courseNodeResourceContext, course, courseNode, indexWriter);
} catch (Exception ex) {
log.error("Exception indexing courseNode=" + courseNode, ex);
} catch (Error err) {
log.error("Error indexing courseNode=" + courseNode, err);
}
}
Aggregations