Skip to content
Snippets Groups Projects
Commit ace9b610 authored by srosse's avatar srosse
Browse files

OO-2626: change behavior of cache, add a lot of course node indexers, fix...

OO-2626: change behavior of cache, add a lot of course node indexers, fix issue with Open document indexer, remove cache in search controller, add the filename (without suffix) if not title in meta information found, add a batch of XSD in blacklist...
parent bf7a2e8e
No related branches found
No related tags found
No related merge requests found
Showing
with 480 additions and 92 deletions
......@@ -89,6 +89,15 @@
<list>
<!-- list of files which will not be indexed -->
<value>imsmanifest.xml</value>
<value>ims_xml.xsd</value>
<value>imscp_v1p1.xsd</value>
<value>imscp_rootv1p1p2.xsd</value>
<value>imsmd_v1p2p2.xsd</value>
<value>imsmd_rootv1p2p1.xsd</value>
<value>XMLSchema.dtd</value>
<value>adlcp_rootv1p2.xsd</value>
<value>datatypes.dtd</value>
<value>SCORM_API_wrapper.js</value>
</list>
</constructor-arg>
</bean>
......@@ -176,10 +185,48 @@
<ref bean="scormCourseNodeIndexer" />
<ref bean="portfolioCourseNodeIndexer" />
<ref bean="infoCourseNodeIndexer" />
<ref bean="calCourseNodeIndexer" />
<ref bean="ltiCourseNodeIndexer" />
<ref bean="checkListCourseNodeIndexer" />
<ref bean="denCourseNodeIndexer" />
<ref bean="enCourseNodeIndexer" />
<ref bean="goToMeetingCourseNodeIndexer" />
<ref bean="gtaCourseNodeIndexer" />
<ref bean="iqsurvCourseNodeIndexer" />
<ref bean="iqselfCourseNodeIndexer" />
<ref bean="iqtestCourseNodeIndexer" />
<ref bean="llCourseNodeIndexer" />
<ref bean="membersCourseNodeIndexer" />
<ref bean="msCourseNodeIndexer" />
<ref bean="pfCourseNodeIndexer" />
<ref bean="openMeetingsCourseNodeIndexer" />
<ref bean="tuCourseNodeIndexer" />
<ref bean="vcCourseNodeIndexer" />
<ref bean="videoCourseNodeIndexer" />
<ref bean="viteroCourseNodeIndexer" />
</list>
</property>
</bean>
<bean id="tuCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.TUCourseNodeIndexer" />
<bean id="vcCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.VCCourseNodeIndexer" />
<bean id="videoCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.VideoCourseNodeIndexer" />
<bean id="viteroCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.ViteroCourseNodeIndexer" />
<bean id="ltiCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.BasicLTICourseNodeIndexer" />
<bean id="calCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.CalCourseNodeIndexer" />
<bean id="checkListCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.CheckListCourseNodeIndexer" />
<bean id="denCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.DENCourseNodeIndexer" />
<bean id="enCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.ENCourseNodeIndexer" />
<bean id="goToMeetingCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.GoToMeetingCourseNodeIndexer" />
<bean id="gtaCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.GTACourseNodeIndexer" />
<bean id="iqsurvCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.IQSURVCourseNodeIndexer" />
<bean id="iqselfCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.IQSELFCourseNodeIndexer" />
<bean id="iqtestCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.IQTESTCourseNodeIndexer" />
<bean id="llCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.LLCourseNodeIndexer" />
<bean id="membersCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.MembersCourseNodeIndexer" />
<bean id="msCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.MSCourseNodeIndexer" />
<bean id="pfCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.PFCourseNodeIndexer" />
<bean id="openMeetingsCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.OpenMeetingsCourseNodeIndexer" />
<bean id="spCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.SPCourseNodeIndexer" />
<bean id="foCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.FOCourseNodeIndexer" />
<bean id="stCourseNodeIndexer" class="org.olat.search.service.indexer.repository.course.STCourseNodeIndexer" />
......
......@@ -92,7 +92,7 @@ public class OlatDocument extends AbstractOlatDocument {
document.add(new StringField(RESOURCEURL_MD5_FIELD_NAME, Encoder.md5hash(getResourceUrl()), Field.Store.YES));
document.add(new StringField(DOCUMENTTYPE_FIELD_NAME, getDocumentType(), Field.Store.YES));
if(getCssIcon() != null) {
document.add(new StringField(CSS_ICON,getCssIcon(), Field.Store.YES));
document.add(new StringField(CSS_ICON, getCssIcon(), Field.Store.YES));
}
document.add(new StringField(FILETYPE_FIELD_NAME, getFileType(), Field.Store.YES));
document.add(createTextField(AUTHOR_FIELD_NAME, getAuthor(), 2));
......
......@@ -54,16 +54,16 @@ public class SearchResourceContext {
// Parameter to pass from parent to child
private Date lastModified;
private Date createdDate;
private String documentType = null;
private String title = null;
private String description = null;
private String parentContextType = null;
private String parentContextName = null;
private String documentType;
private String title;
private String description;
private String parentContextType;
private String parentContextName;
private BusinessControl myBusinessControl;
private BusinessControl parentBusinessControl;
private String filePath = null;
private String filePath;
/**
......@@ -106,10 +106,8 @@ public class SearchResourceContext {
String resourceUrl = BusinessControlFactory.getInstance().getAsString(bControl);
if (filePath != null) {
// It is a file resource => Append file path
StringBuilder buf = new StringBuilder(resourceUrl);
buf.append(FILEPATH_PREFIX);
buf.append(filePath);
buf.append(ENDTAG);
StringBuilder buf = new StringBuilder(resourceUrl);
buf.append(FILEPATH_PREFIX).append(filePath).append(ENDTAG);
resourceUrl = buf.toString();
}
return resourceUrl;
......
......@@ -26,9 +26,11 @@
package org.olat.search.service.document;
import org.apache.lucene.document.Document;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.core.util.StringHelper;
import org.olat.core.util.filter.FilterFactory;
import org.olat.course.nodes.CourseNode;
import org.olat.course.nodes.CourseNodeConfiguration;
import org.olat.course.nodes.CourseNodeFactory;
import org.olat.search.model.OlatDocument;
import org.olat.search.service.SearchResourceContext;
......@@ -39,7 +41,6 @@ import org.olat.search.service.SearchResourceContext;
public class CourseNodeDocument extends OlatDocument {
private static final long serialVersionUID = -2035945166792451137L;
private static final OLog log = Tracing.createLoggerFor(CourseNodeDocument.class);
// Must correspond with LocalString_xx.properties
// Do not use '_' because we want to seach for certain documenttype and lucene haev problems with '_'
......@@ -54,25 +55,39 @@ public class CourseNodeDocument extends OlatDocument {
// Set all know attributes
courseNodeDocument.setResourceUrl(searchResourceContext.getResourceUrl());
if (searchResourceContext.getDocumentType() != null && !searchResourceContext.getDocumentType().equals("") ) {
if (StringHelper.containsNonWhitespace(searchResourceContext.getDocumentType())) {
courseNodeDocument.setDocumentType(searchResourceContext.getDocumentType());
} else {
courseNodeDocument.setDocumentType(TYPE);
courseNodeDocument.setDocumentType(TYPE);
}
courseNodeDocument.setCssIcon("o_course_icon");
courseNodeDocument.setTitle(courseNode.getShortTitle());
courseNodeDocument.setDescription(courseNode.getLongTitle());
// Get dates from paraent object via context because course node has no dates
CourseNodeConfiguration nodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(courseNode.getType());
if(nodeConfig != null && StringHelper.containsNonWhitespace(nodeConfig.getIconCSSClass())) {
courseNodeDocument.setCssIcon(nodeConfig.getIconCSSClass());
} else {
courseNodeDocument.setCssIcon("o_course_icon");
}
if(StringHelper.containsNonWhitespace(courseNode.getShortTitle())) {
courseNodeDocument.setTitle(courseNode.getShortTitle());
} else if(StringHelper.containsNonWhitespace(courseNode.getLongTitle())) {
courseNodeDocument.setTitle(courseNode.getLongTitle());
courseNodeDocument.setDescription(courseNode.getLongTitle());
}
if(StringHelper.containsNonWhitespace(courseNode.getLongTitle())) {
courseNodeDocument.setDescription(courseNode.getLongTitle());
}
if(StringHelper.containsNonWhitespace(courseNode.getLearningObjectives())) {
String objectives = courseNode.getLearningObjectives();
objectives = FilterFactory.getHtmlTagsFilter().filter(objectives);
courseNodeDocument.setContent(objectives);
}
// Get dates from parent object via context because course node has no dates
courseNodeDocument.setCreatedDate(searchResourceContext.getCreatedDate());
courseNodeDocument.setLastChange(searchResourceContext.getLastModified());
courseNodeDocument.setParentContextType(searchResourceContext.getParentContextType());
courseNodeDocument.setParentContextName(searchResourceContext.getParentContextName());
// unused course-node attributtes
// courseNode.getShortName();
// courseNode.getType();
if (log.isDebug()) log.debug(courseNodeDocument.toString());
return courseNodeDocument.getLuceneDocument();
}
}
}
\ No newline at end of file
......@@ -60,7 +60,7 @@ public abstract class FileDocument extends OlatDocument {
setResourceUrl(leafResourceContext.getResourceUrl());
setLastChange(new Date(leaf.getLastModified()));
// Check if there are documents attributes set in resource context
if (leafResourceContext.getDocumentType() != null && !leafResourceContext.getDocumentType().equals("")) {
if (StringHelper.containsNonWhitespace(leafResourceContext.getDocumentType())) {
// document-type in context is set => get from there
setDocumentType(leafResourceContext.getDocumentType());
} else {
......@@ -74,8 +74,13 @@ public abstract class FileDocument extends OlatDocument {
} else if(content != null && StringHelper.containsNonWhitespace(content.getTitle())) {
metaTitle = content.getTitle();
} else {
metaTitle = null;
}
String beautfiedName = leaf.getName();
int dotpos = beautfiedName.lastIndexOf('.');
if (dotpos > 0) {
beautfiedName = beautfiedName.substring(0, dotpos);
}
metaTitle = beautfiedName.replace('_', ' ');
}
StringBuilder title = new StringBuilder();
if (StringHelper.containsNonWhitespace(leafResourceContext.getTitle())) {
......@@ -92,7 +97,7 @@ public abstract class FileDocument extends OlatDocument {
setTitle(title.toString());
String metaDesc = (meta == null ? null : meta.getComment());
if (leafResourceContext.getDescription() != null && !leafResourceContext.getDescription().equals("")) {
if (StringHelper.containsNonWhitespace(leafResourceContext.getDescription())) {
// Title in context is set => get from there
setDescription(leafResourceContext.getDescription() + (metaDesc == null ? "" : " " + metaDesc));
} else if (metaDesc != null) {
......
......@@ -43,6 +43,7 @@ import org.olat.search.SearchModule;
import org.olat.search.SearchService;
import org.olat.search.ServiceNotAvailableException;
import org.olat.search.model.AbstractOlatDocument;
import org.olat.search.model.OlatDocument;
import org.olat.search.service.SearchResourceContext;
import org.olat.search.service.SearchServiceImpl;
......@@ -100,36 +101,45 @@ public class FileDocumentFactory {
return searchModule == null ? 120000 : (int)searchModule.getMaxFileSize();
}
public Document createDocument(SearchResourceContext leafResourceContext, VFSLeaf leaf)
throws IOException, DocumentAccessException {
private Document getDocumentFromCurrentIndex(SearchResourceContext leafResourceContext, VFSLeaf leaf) {
try {
Document doc = null;
try {
String resourceUrl = leafResourceContext.getResourceUrl();
SearchService searchService = CoreSpringFactory.getImpl(SearchServiceImpl.class);
Document indexedDoc = searchService.doSearch(resourceUrl);
if(indexedDoc != null) {
String timestamp = indexedDoc.get(AbstractOlatDocument.TIME_STAMP_NAME);
if(timestamp != null) {
Date indexLastModification = DateTools.stringToDate(timestamp);
Date docLastModificationDate = new Date(leaf.getLastModified());
if(leaf instanceof MetaTagged) {
MetaInfo metaInfo = ((MetaTagged)leaf).getMetaInfo();
Date metaDate = metaInfo.getMetaLastModified();
if(metaDate != null && metaDate.after(docLastModificationDate)) {
docLastModificationDate = metaDate;
}
}
if(docLastModificationDate.compareTo(indexLastModification) < 0) {
return indexedDoc;
String resourceUrl = leafResourceContext.getResourceUrl();
SearchService searchService = CoreSpringFactory.getImpl(SearchServiceImpl.class);
Document indexedDoc = searchService.doSearch(resourceUrl);
if(indexedDoc != null) {
String timestamp = indexedDoc.get(AbstractOlatDocument.TIME_STAMP_NAME);
if(timestamp != null) {
Date indexLastModification = DateTools.stringToDate(timestamp);
Date docLastModificationDate = new Date(leaf.getLastModified());
if(leaf instanceof MetaTagged) {
MetaInfo metaInfo = ((MetaTagged)leaf).getMetaInfo();
Date metaDate = metaInfo.getMetaLastModified();
if(metaDate != null && metaDate.after(docLastModificationDate)) {
docLastModificationDate = metaDate;
}
}
if(docLastModificationDate.compareTo(indexLastModification) < 0) {
OlatDocument olatDoc = new OlatDocument(indexedDoc);
return olatDoc.getLuceneDocument();
}
}
} catch (ServiceNotAvailableException | ParseException | QueryException | java.text.ParseException e) {
log.error("", e);
}
} catch (ServiceNotAvailableException | ParseException | QueryException | java.text.ParseException e) {
log.error("", e);
}
return null;
}
public Document createDocument(SearchResourceContext leafResourceContext, VFSLeaf leaf)
throws IOException, DocumentAccessException {
Document indexedDocument = getDocumentFromCurrentIndex(leafResourceContext, leaf);
if(indexedDocument != null) {
return indexedDocument;
}
try {
Document doc = null;
String fileName = leaf.getName();
String suffix = FileTypeDetector.getSuffix(leaf);
if (log.isDebug()) log.debug("suffix=" + suffix);
......
......@@ -53,7 +53,7 @@ public class HtmlDocument extends FileDocument {
public static Document createDocument(SearchResourceContext leafResourceContext, VFSLeaf leaf) throws IOException,DocumentException,DocumentAccessException {
HtmlDocument htmlDocument = new HtmlDocument();
htmlDocument.init(leafResourceContext,leaf);
htmlDocument.init(leafResourceContext, leaf);
htmlDocument.setFileType(FILE_TYPE);
htmlDocument.setCssIcon(CSSHelper.createFiletypeIconCssClassFor(leaf.getName()));
if (log.isDebug() ) log.debug(htmlDocument.toString());
......
......@@ -104,7 +104,7 @@ public class OpenDocument extends FileDocument {
FileUtils.closeSafely(zip);
FileUtils.closeSafely(stream);
}
return new FileContent(dh.toString());
return new FileContent(dh.getContent());
}
private void parse(InputStream stream, DefaultHandler handler) throws DocumentException {
......@@ -144,5 +144,9 @@ public class OpenDocument extends FileDocument {
}
sb.write(ch, start, length);
}
public String getContent() {
return sb.toString();
}
}
}
......@@ -46,7 +46,6 @@ public abstract class AbstractHierarchicalIndexer extends DefaultIndexer {
private final List<Indexer> childIndexers = new ArrayList<Indexer>();
public List<Indexer> getChildIndexers() {
return childIndexers;
}
......@@ -56,16 +55,17 @@ public abstract class AbstractHierarchicalIndexer extends DefaultIndexer {
* @param indexerList
*/
public void setIndexerList(List<Indexer> indexerList) {
if (indexerList == null)
if (indexerList == null) {
throw new AssertException("null value for indexerList not allowed.");
}
try {
for (Indexer indexer:indexerList) {
childIndexers.add(indexer);
logDebug("Adding indexer from configuraton. TypeName=" + indexer.getSupportedTypeName());
}
} catch (ClassCastException cce) {
throw new StartupException("Configured indexer is not of type Indexer", cce);
} catch (ClassCastException cce) {
throw new StartupException("Configured indexer is not of type Indexer", cce);
}
}
......@@ -74,7 +74,7 @@ public abstract class AbstractHierarchicalIndexer extends DefaultIndexer {
childIndexers.add(indexer);
logDebug("Adding indexer from configuraton. TypeName=" + indexer.getSupportedTypeName());
} catch (ClassCastException cce) {
throw new StartupException("Configured indexer is not of type Indexer", cce);
throw new StartupException("Configured indexer is not of type Indexer", cce);
}
}
......@@ -90,7 +90,7 @@ public abstract class AbstractHierarchicalIndexer extends DefaultIndexer {
indexer.doIndex(searchResourceContext, object, indexerWriter);
} catch (InterruptedException iex) {
throw iex;
} catch (Throwable ex) {
} catch (Throwable ex) {
// FIXME:chg: Workaround to fix indexing-abort
logWarn("Exception in diIndex indexer.typeName=" + indexer.getSupportedTypeName(),ex);
}
......
......@@ -46,7 +46,8 @@ public abstract class LeafIndexer extends AbstractHierarchicalIndexer {
protected void doIndexVFSLeafByMySelf(SearchResourceContext leafResourceContext, VFSLeaf leaf, OlatFullIndexer indexWriter, String filePath) throws InterruptedException {
if (isLogDebugEnabled()) logDebug("Analyse VFSLeaf=" + leaf.getName());
try {
if (CoreSpringFactory.getImpl(FileDocumentFactory.class).isFileSupported(leaf)) {
FileDocumentFactory documentFactory = CoreSpringFactory.getImpl(FileDocumentFactory.class);
if (documentFactory.isFileSupported(leaf)) {
String myFilePath = "";
if (filePath.endsWith("/")) {
myFilePath = filePath + leaf.getName();
......@@ -55,7 +56,7 @@ public abstract class LeafIndexer extends AbstractHierarchicalIndexer {
}
leafResourceContext.setFilePath(myFilePath);
Document document = CoreSpringFactory.getImpl(FileDocumentFactory.class).createDocument(leafResourceContext, leaf);
Document document = documentFactory.createDocument(leafResourceContext, leaf);
indexWriter.addDocument(document);
} else {
if (isLogDebugEnabled()) logDebug("Documenttype not supported. file=" + leaf.getName());
......
......@@ -127,15 +127,13 @@ public class CourseIndexer extends AbstractHierarchicalIndexer {
logWarn("Can not index course node=" + childCourseNode.getIdent(), e);
}
}
} else if (isLogDebugEnabled()) {
logDebug("ChildNode is no CourseNode, " + node);
}
//loop over all child nodes
int childCount = node.getChildCount();
for (int i=0;i<childCount; i++) {
INode childNode = node.getChildAt(i);
doIndexCourse(repositoryResourceContext, course, childNode, indexWriter);
doIndexCourse(repositoryResourceContext, course, childNode, indexWriter);
}
}
......@@ -169,7 +167,7 @@ public class CourseIndexer extends AbstractHierarchicalIndexer {
Long nodeId = bcContextEntry.getOLATResourceable().getResourceableId();
if (isLogDebugEnabled()) logDebug("nodeId=" + nodeId );
ICourse course = CourseFactory.loadCourse(repositoryEntry.getOlatResource());
ICourse course = CourseFactory.loadCourse(repositoryEntry);
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(identity);
ienv.setRoles(roles);
......@@ -212,11 +210,9 @@ public class CourseIndexer extends AbstractHierarchicalIndexer {
private CourseNodeIndexer getCourseNodeIndexer(CourseNode node) {
String courseNodeName = node.getClass().getName();
List<Indexer> courseNodeIndexer = getIndexerByType(courseNodeName);
if (courseNodeIndexer != null && !courseNodeIndexer.isEmpty()) {
return (CourseNodeIndexer)courseNodeIndexer.get(0);
} else if (isLogDebugEnabled()) {
logDebug("No indexer found for node=" + node);
}
return null;
if (courseNodeIndexer != null && !courseNodeIndexer.isEmpty()) {
return (CourseNodeIndexer)courseNodeIndexer.get(0);
}
return null;
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.search.service.indexer.repository.course;
import java.io.IOException;
import org.apache.lucene.document.Document;
import org.olat.core.id.Identity;
import org.olat.core.id.Roles;
import org.olat.core.id.context.BusinessControl;
import org.olat.core.id.context.ContextEntry;
import org.olat.course.ICourse;
import org.olat.course.nodes.CourseNode;
import org.olat.search.service.SearchResourceContext;
import org.olat.search.service.document.CourseNodeDocument;
import org.olat.search.service.indexer.OlatFullIndexer;
/**
*
* Initial date: 20 mars 2017<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public abstract class AbstractCourseNodeIndexer implements CourseNodeIndexer {
private final String type;
private final String supportedType;
public AbstractCourseNodeIndexer(String type, String supportedType) {
this.type = type;
this.supportedType = supportedType;
}
public String getType() {
return type;
}
@Override
public String getSupportedTypeName() {
return supportedType;
}
@Override
public void doIndex(SearchResourceContext searchResourceContext, Object parentObject, OlatFullIndexer indexer)
throws IOException, InterruptedException {
//
}
@Override
public void doIndex(SearchResourceContext courseResourceContext, ICourse course, CourseNode node, OlatFullIndexer indexWriter)
throws IOException, InterruptedException {
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(courseResourceContext, node, getType());
Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, node);
indexWriter.addDocument(document);
}
@Override
public boolean checkAccess(ContextEntry contextEntry, BusinessControl businessControl, Identity identity, Roles roles) {
return true;
}
}
......@@ -27,11 +27,20 @@ package org.olat.search.service.indexer.repository.course;
import java.io.IOException;
import org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl;
import org.apache.lucene.document.Document;
import org.olat.core.id.Identity;
import org.olat.core.id.Roles;
import org.olat.core.id.context.BusinessControl;
import org.olat.core.id.context.ContextEntry;
import org.olat.core.util.vfs.NamedContainerImpl;
import org.olat.core.util.vfs.VFSContainer;
import org.olat.core.util.vfs.VFSItem;
import org.olat.course.ICourse;
import org.olat.course.nodes.BCCourseNode;
import org.olat.course.nodes.CourseNode;
import org.olat.course.nodes.bc.BCCourseNodeEditController;
import org.olat.search.service.SearchResourceContext;
import org.olat.search.service.document.CourseNodeDocument;
import org.olat.search.service.indexer.FolderIndexer;
import org.olat.search.service.indexer.FolderIndexerAccess;
import org.olat.search.service.indexer.OlatFullIndexer;
......@@ -43,7 +52,7 @@ import org.olat.search.service.indexer.OlatFullIndexer;
public class BCCourseNodeIndexer extends FolderIndexer implements CourseNodeIndexer {
// Must correspond with LocalString_xx.properties
// Do not use '_' because we want to seach for certain documenttype and lucene haev problems with '_'
// Do not use '_' because we want to seach for certain documenttype and lucene have problems with '_'
public static final String TYPE = "type.course.node.bc";
private final static String SUPPORTED_TYPE_NAME = "org.olat.course.nodes.BCCourseNode";
......@@ -51,19 +60,45 @@ public class BCCourseNodeIndexer extends FolderIndexer implements CourseNodeInde
@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException,InterruptedException {
if (isLogDebugEnabled()) logDebug("Index Briefcase..." );
SearchResourceContext courseNodeResourceContext = new SearchResourceContext(repositoryResourceContext);
courseNodeResourceContext.setBusinessControlFor(courseNode);
courseNodeResourceContext.setDocumentType(TYPE);
courseNodeResourceContext.setTitle(courseNode.getShortTitle());
courseNodeResourceContext.setDescription(courseNode.getLongTitle());
OlatNamedContainerImpl namedContainer = BCCourseNode.getNodeFolderContainer((BCCourseNode) courseNode, course.getCourseEnvironment());
doIndexVFSContainer(courseNodeResourceContext,namedContainer,indexWriter,"", FolderIndexerAccess.FULL_ACCESS);
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);
}
}
@Override
public String getSupportedTypeName() {
return SUPPORTED_TYPE_NAME;
}
@Override
public boolean checkAccess(BusinessControl businessControl, Identity identity, Roles roles) {
return super.checkAccess(businessControl, identity, roles);
}
@Override
public boolean checkAccess(ContextEntry contextEntry, BusinessControl businessControl, Identity identity, Roles roles) {
return super.checkAccess(contextEntry, businessControl, identity, roles);
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.search.service.indexer.repository.course;
/**
*
* Initial date: 20 mars 2017<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class BasicLTICourseNodeIndexer extends AbstractCourseNodeIndexer {
public static final String TYPE = "type.course.node.lti";
private final static String SUPPORTED_TYPE_NAME = "org.olat.course.nodes.BasicLTICourseNode";
public BasicLTICourseNodeIndexer() {
super(TYPE, SUPPORTED_TYPE_NAME);
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.search.service.indexer.repository.course;
/**
*
* Initial date: 20 mars 2017<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class COCourseNodeIndexer extends AbstractCourseNodeIndexer {
public static final String TYPE = "type.course.node.co";
private final static String SUPPORTED_TYPE_NAME = "org.olat.course.nodes.COCourseNode";
public COCourseNodeIndexer() {
super(TYPE, SUPPORTED_TYPE_NAME);
}
}
......@@ -28,6 +28,7 @@ package org.olat.search.service.indexer.repository.course;
import java.io.File;
import java.io.IOException;
import org.apache.lucene.document.Document;
import org.olat.core.util.vfs.LocalFolderImpl;
import org.olat.core.util.vfs.VFSContainer;
import org.olat.course.ICourse;
......@@ -36,6 +37,7 @@ import org.olat.course.nodes.cp.CPEditController;
import org.olat.fileresource.FileResourceManager;
import org.olat.repository.RepositoryEntry;
import org.olat.search.service.SearchResourceContext;
import org.olat.search.service.document.CourseNodeDocument;
import org.olat.search.service.indexer.FolderIndexer;
import org.olat.search.service.indexer.FolderIndexerAccess;
import org.olat.search.service.indexer.OlatFullIndexer;
......@@ -55,14 +57,12 @@ public class CPCourseNodeIndexer extends FolderIndexer implements CourseNodeInde
@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) {
SearchResourceContext courseNodeResourceContext = new SearchResourceContext(repositoryResourceContext);
courseNodeResourceContext.setBusinessControlFor(courseNode);
courseNodeResourceContext.setDocumentType(TYPE);
courseNodeResourceContext.setTitle(courseNode.getShortTitle());
courseNodeResourceContext.setDescription(courseNode.getLongTitle());
File cpRoot = FileResourceManager.getInstance().unzipFileResource(re.getOlatResource());
if(cpRoot != null) {
VFSContainer rootContainer = new LocalFolderImpl(cpRoot);
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.search.service.indexer.repository.course;
/**
*
* Initial date: 20 mars 2017<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class CalCourseNodeIndexer extends AbstractCourseNodeIndexer {
public static final String TYPE = "type.course.node.cal";
private final static String SUPPORTED_TYPE_NAME = "org.olat.course.nodes.CalCourseNode";
public CalCourseNodeIndexer() {
super(TYPE, SUPPORTED_TYPE_NAME);
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.search.service.indexer.repository.course;
/**
*
* Initial date: 20 mars 2017<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class CheckListCourseNodeIndexer extends AbstractCourseNodeIndexer {
public static final String TYPE = "type.course.node.checklist";
private final static String SUPPORTED_TYPE_NAME = "org.olat.course.nodes.CheckListCourseNode";
public CheckListCourseNodeIndexer() {
super(TYPE, SUPPORTED_TYPE_NAME);
}
}
......@@ -28,6 +28,7 @@ package org.olat.search.service.indexer.repository.course;
import java.io.IOException;
import org.olat.core.util.StringHelper;
import org.olat.course.ICourse;
import org.olat.course.nodes.CourseNode;
import org.olat.search.service.SearchResourceContext;
......@@ -42,4 +43,16 @@ public interface CourseNodeIndexer extends Indexer {
public void doIndex(SearchResourceContext searchResourceContext, ICourse course, CourseNode node, OlatFullIndexer indexWriter) throws IOException,InterruptedException;
public default SearchResourceContext createSearchResourceContext(SearchResourceContext courseResourceContext, CourseNode node, String type) {
SearchResourceContext courseNodeResourceContext = new SearchResourceContext(courseResourceContext);
courseNodeResourceContext.setBusinessControlFor(node);
courseNodeResourceContext.setDocumentType(type);
if(StringHelper.containsNonWhitespace(node.getShortTitle())) {
courseNodeResourceContext.setTitle(node.getShortTitle());
} else if(StringHelper.containsNonWhitespace(node.getLongTitle())) {
courseNodeResourceContext.setTitle(node.getLongTitle());
}
return courseNodeResourceContext;
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.search.service.indexer.repository.course;
/**
*
* Initial date: 20 mars 2017<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class DENCourseNodeIndexer extends AbstractCourseNodeIndexer {
public static final String TYPE = "type.course.node.den";
private final static String SUPPORTED_TYPE_NAME = "de.bps.course.nodes.DENCourseNode";
public DENCourseNodeIndexer() {
super(TYPE, SUPPORTED_TYPE_NAME);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment