diff --git a/src/main/java/org/olat/search/_spring/searchContext.xml b/src/main/java/org/olat/search/_spring/searchContext.xml index 14736634f9f1ee7d35985eb0bfd9e12b7f8877b5..70058a66e933d83c8d1fe9c14dd83bd9f49b07c3 100644 --- a/src/main/java/org/olat/search/_spring/searchContext.xml +++ b/src/main/java/org/olat/search/_spring/searchContext.xml @@ -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" /> diff --git a/src/main/java/org/olat/search/model/OlatDocument.java b/src/main/java/org/olat/search/model/OlatDocument.java index f43ed11a2afc989e989d8dbd1b7fc98dffdc57ce..7f27d78944dacc5182de6639f30b466fc170a210 100644 --- a/src/main/java/org/olat/search/model/OlatDocument.java +++ b/src/main/java/org/olat/search/model/OlatDocument.java @@ -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)); diff --git a/src/main/java/org/olat/search/service/SearchResourceContext.java b/src/main/java/org/olat/search/service/SearchResourceContext.java index 63e4149554658d532a7cbd7fcd47783b81037fbf..ae39ee4ce1aab54062ccdabfe67572b99a358537 100644 --- a/src/main/java/org/olat/search/service/SearchResourceContext.java +++ b/src/main/java/org/olat/search/service/SearchResourceContext.java @@ -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; diff --git a/src/main/java/org/olat/search/service/document/CourseNodeDocument.java b/src/main/java/org/olat/search/service/document/CourseNodeDocument.java index da3d65eb87d8351bf65d113cc09bd759d93f09b1..1aec69f47c855a14e638b652a5645801e48797c3 100644 --- a/src/main/java/org/olat/search/service/document/CourseNodeDocument.java +++ b/src/main/java/org/olat/search/service/document/CourseNodeDocument.java @@ -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 diff --git a/src/main/java/org/olat/search/service/document/file/FileDocument.java b/src/main/java/org/olat/search/service/document/file/FileDocument.java index 7986d098755c0731a5c6e3517a0f516bc22f2a6a..3f4f7865210f6f01bf6789d0e8d538a3854b6f79 100644 --- a/src/main/java/org/olat/search/service/document/file/FileDocument.java +++ b/src/main/java/org/olat/search/service/document/file/FileDocument.java @@ -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) { diff --git a/src/main/java/org/olat/search/service/document/file/FileDocumentFactory.java b/src/main/java/org/olat/search/service/document/file/FileDocumentFactory.java index 7583cc93ff6888402d5d75ccbe67efa61ee6ea44..3ec43c2c64de03dc4d6a1bb5968a4a723305fb60 100644 --- a/src/main/java/org/olat/search/service/document/file/FileDocumentFactory.java +++ b/src/main/java/org/olat/search/service/document/file/FileDocumentFactory.java @@ -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); diff --git a/src/main/java/org/olat/search/service/document/file/HtmlDocument.java b/src/main/java/org/olat/search/service/document/file/HtmlDocument.java index 0aa234d4be4c5515712cc9e4306c20307c9d381d..acd6481af3c69c1610102699034d54374969b47f 100644 --- a/src/main/java/org/olat/search/service/document/file/HtmlDocument.java +++ b/src/main/java/org/olat/search/service/document/file/HtmlDocument.java @@ -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()); diff --git a/src/main/java/org/olat/search/service/document/file/OpenDocument.java b/src/main/java/org/olat/search/service/document/file/OpenDocument.java index 91f59ec4a1852d5bd0e484fafaac9627d94ac150..b6c083cbeb78f90b18517082e05f2726b4a596af 100644 --- a/src/main/java/org/olat/search/service/document/file/OpenDocument.java +++ b/src/main/java/org/olat/search/service/document/file/OpenDocument.java @@ -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(); + } } } diff --git a/src/main/java/org/olat/search/service/indexer/AbstractHierarchicalIndexer.java b/src/main/java/org/olat/search/service/indexer/AbstractHierarchicalIndexer.java index 38debcfc7e25f7703b07db1bae8e9c94ec30a54c..1ba8d42bfa98f37ff7d15b57f65408a4bdf8dc89 100644 --- a/src/main/java/org/olat/search/service/indexer/AbstractHierarchicalIndexer.java +++ b/src/main/java/org/olat/search/service/indexer/AbstractHierarchicalIndexer.java @@ -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); } diff --git a/src/main/java/org/olat/search/service/indexer/LeafIndexer.java b/src/main/java/org/olat/search/service/indexer/LeafIndexer.java index 03f6211e6930c20b252314f949be02e5dee4314e..492691c7aa2fa27fa474f97bfa55448f94f9127c 100644 --- a/src/main/java/org/olat/search/service/indexer/LeafIndexer.java +++ b/src/main/java/org/olat/search/service/indexer/LeafIndexer.java @@ -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()); diff --git a/src/main/java/org/olat/search/service/indexer/repository/CourseIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/CourseIndexer.java index 57525c7f93092938d829b6a9aeb934c0fd736fa4..2003a877efe90d9d83186d68ceafa854c00dd46e 100644 --- a/src/main/java/org/olat/search/service/indexer/repository/CourseIndexer.java +++ b/src/main/java/org/olat/search/service/indexer/repository/CourseIndexer.java @@ -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; } } diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/AbstractCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/AbstractCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..bc145275e4acb4b424179b2cf139f66aa404f71a --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/AbstractCourseNodeIndexer.java @@ -0,0 +1,78 @@ +/** + * <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; + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/BCCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/BCCourseNodeIndexer.java index 179854487ce4e3dadee47f6a4155dddf8d2ad7f3..020165e9341261b15fcebcbea2878e9858938b81 100644 --- a/src/main/java/org/olat/search/service/indexer/repository/course/BCCourseNodeIndexer.java +++ b/src/main/java/org/olat/search/service/indexer/repository/course/BCCourseNodeIndexer.java @@ -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); + } + + } diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/BasicLTICourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/BasicLTICourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..a34d8f82ef7749b4c93255421a26174bcf63b432 --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/BasicLTICourseNodeIndexer.java @@ -0,0 +1,38 @@ +/** + * <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); + } + +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/COCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/COCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..3d75400c63c7a91db9bc0578f72384bc49c3f9a5 --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/COCourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/CPCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/CPCourseNodeIndexer.java index 45f2d2439a9cdbf6df1ccbe8b8b2a1a9dcbcc1dd..8e72cd2afc220afe358497093267322506141e20 100644 --- a/src/main/java/org/olat/search/service/indexer/repository/course/CPCourseNodeIndexer.java +++ b/src/main/java/org/olat/search/service/indexer/repository/course/CPCourseNodeIndexer.java @@ -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); diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/CalCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/CalCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..0e415fd0a0f1c55e4af95e0945698f754e6e0632 --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/CalCourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/CheckListCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/CheckListCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..58f3c5d595f3a093bbd4b7114c4e5e9de5e35c47 --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/CheckListCourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/CourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/CourseNodeIndexer.java index 3e5f140f430ea573d183e9b76f7b58bbe24ca1c9..5739b590aa2e4dc852689bd7a7f81e741058e290 100644 --- a/src/main/java/org/olat/search/service/indexer/repository/course/CourseNodeIndexer.java +++ b/src/main/java/org/olat/search/service/indexer/repository/course/CourseNodeIndexer.java @@ -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; + } } diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/DENCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/DENCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..0cc8b2b60d8a0218974889fdc5e1f261650b8940 --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/DENCourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/DialogCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/DialogCourseNodeIndexer.java index 5f69ec1b34b1d93a701379b76ebfce9b878a57fc..21fcae121461573aa33e384bd3f5f42667f0f055 100644 --- a/src/main/java/org/olat/search/service/indexer/repository/course/DialogCourseNodeIndexer.java +++ b/src/main/java/org/olat/search/service/indexer/repository/course/DialogCourseNodeIndexer.java @@ -55,6 +55,7 @@ import org.olat.modules.fo.Message; import org.olat.modules.fo.Status; import org.olat.modules.fo.manager.ForumManager; import org.olat.search.service.SearchResourceContext; +import org.olat.search.service.document.CourseNodeDocument; import org.olat.search.service.document.ForumMessageDocument; import org.olat.search.service.document.file.DocumentAccessException; import org.olat.search.service.document.file.FileDocumentFactory; @@ -81,11 +82,10 @@ public class DialogCourseNodeIndexer extends DefaultIndexer implements CourseNod @Override public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException,InterruptedException { - SearchResourceContext courseNodeResourceContext = new SearchResourceContext(repositoryResourceContext); - courseNodeResourceContext.setBusinessControlFor(courseNode); - courseNodeResourceContext.setTitle(courseNode.getShortTitle()); - courseNodeResourceContext.setDescription(courseNode.getLongTitle()); - + SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, null); + Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode); + indexWriter.addDocument(document); + CoursePropertyManager coursePropMgr = course.getCourseEnvironment().getCoursePropertyManager(); DialogElementsPropertyManager dialogElmsMgr = DialogElementsPropertyManager.getInstance(); DialogPropertyElements elements = dialogElmsMgr.findDialogElements(coursePropMgr, courseNode); diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/ENCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/ENCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..7735b2edd708d27d8a488f7057d3324a17ee4367 --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/ENCourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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 ENCourseNodeIndexer extends AbstractCourseNodeIndexer { + + public static final String TYPE = "type.course.node.en"; + + private final static String SUPPORTED_TYPE_NAME = "org.olat.course.nodes.ENCourseNode"; + + public ENCourseNodeIndexer() { + super(TYPE, SUPPORTED_TYPE_NAME); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/FOCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/FOCourseNodeIndexer.java index cf73e575a9d86491b92daebead037671ec784162..44b10763782f1359c4e58d596d381ec4431381d5 100644 --- a/src/main/java/org/olat/search/service/indexer/repository/course/FOCourseNodeIndexer.java +++ b/src/main/java/org/olat/search/service/indexer/repository/course/FOCourseNodeIndexer.java @@ -27,6 +27,7 @@ package org.olat.search.service.indexer.repository.course; import java.io.IOException; +import org.apache.lucene.document.Document; import org.olat.basesecurity.BaseSecurityManager; import org.olat.basesecurity.Constants; import org.olat.core.id.Identity; @@ -45,6 +46,7 @@ import org.olat.modules.fo.Status; import org.olat.modules.fo.manager.ForumManager; import org.olat.properties.Property; import org.olat.search.service.SearchResourceContext; +import org.olat.search.service.document.CourseNodeDocument; import org.olat.search.service.indexer.ForumIndexer; import org.olat.search.service.indexer.OlatFullIndexer; @@ -63,11 +65,10 @@ public class FOCourseNodeIndexer extends ForumIndexer implements CourseNodeIndex @Override public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) { try { - SearchResourceContext courseNodeResourceContext = new SearchResourceContext(repositoryResourceContext); - courseNodeResourceContext.setBusinessControlFor(courseNode); - courseNodeResourceContext.setDocumentType(TYPE); - courseNodeResourceContext.setTitle(courseNode.getShortTitle()); - courseNodeResourceContext.setDescription(courseNode.getLongTitle()); + SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, TYPE); + Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode); + indexWriter.addDocument(document); + doIndexForum(courseNodeResourceContext, course, courseNode, indexWriter); } catch(Exception ex) { log.error("Exception indexing courseNode=" + courseNode, ex); diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/GTACourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/GTACourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..a8cf9940c332d1e464dbdf26be83f4d8f07cf0ec --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/GTACourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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 GTACourseNodeIndexer extends AbstractCourseNodeIndexer { + + public static final String TYPE = "type.course.node.gta"; + + private final static String SUPPORTED_TYPE_NAME = "org.olat.course.nodes.GTACourseNode"; + + public GTACourseNodeIndexer() { + super(TYPE, SUPPORTED_TYPE_NAME); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/GoToMeetingCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/GoToMeetingCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..6cf0ed37040d78812b7732273b58fabe29364f56 --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/GoToMeetingCourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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 GoToMeetingCourseNodeIndexer extends AbstractCourseNodeIndexer { + + public static final String TYPE = "type.course.node.gotomeeting"; + + private final static String SUPPORTED_TYPE_NAME = "org.olat.course.nodes.GoToMeetingCourseNode"; + + public GoToMeetingCourseNodeIndexer() { + super(TYPE, SUPPORTED_TYPE_NAME); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/IQSELFCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/IQSELFCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..b3e0e522c3d3ab897a26973937ccc1846ea095ae --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/IQSELFCourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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 IQSELFCourseNodeIndexer extends AbstractCourseNodeIndexer { + + public static final String TYPE = "type.course.node.iqself"; + + private final static String SUPPORTED_TYPE_NAME = "org.olat.course.nodes.IQSELFCourseNode"; + + public IQSELFCourseNodeIndexer() { + super(TYPE, SUPPORTED_TYPE_NAME); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/IQSURVCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/IQSURVCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..36a1bc1002fd70637b421527f241e47527e0c832 --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/IQSURVCourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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 IQSURVCourseNodeIndexer extends AbstractCourseNodeIndexer { + + public static final String TYPE = "type.course.node.iqsurv"; + + private final static String SUPPORTED_TYPE_NAME = "org.olat.course.nodes.IQSURVCourseNode"; + + public IQSURVCourseNodeIndexer() { + super(TYPE, SUPPORTED_TYPE_NAME); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/IQTESTCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/IQTESTCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..23a3c41b0c3c732df83e94aa1f73634b5eb9759e --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/IQTESTCourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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 IQTESTCourseNodeIndexer extends AbstractCourseNodeIndexer { + + public static final String TYPE = "type.course.node.iqtest"; + + private final static String SUPPORTED_TYPE_NAME = "org.olat.course.nodes.IQTESTCourseNode"; + + public IQTESTCourseNodeIndexer() { + super(TYPE, SUPPORTED_TYPE_NAME); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/InfoCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/InfoCourseNodeIndexer.java index 57372eaf3a3c69e31c9424278154a45363b775f6..911f50bb9a1a00c6057be64ab6165e11fede5cd2 100644 --- a/src/main/java/org/olat/search/service/indexer/repository/course/InfoCourseNodeIndexer.java +++ b/src/main/java/org/olat/search/service/indexer/repository/course/InfoCourseNodeIndexer.java @@ -38,6 +38,7 @@ import org.olat.core.util.resource.OresHelper; 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.document.InfoMessageDocument; import org.olat.search.service.indexer.DefaultIndexer; import org.olat.search.service.indexer.OlatFullIndexer; @@ -74,14 +75,14 @@ public class InfoCourseNodeIndexer extends DefaultIndexer implements CourseNode // } + @Override public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) { try { - SearchResourceContext courseNodeResourceContext = new SearchResourceContext(repositoryResourceContext); - courseNodeResourceContext.setBusinessControlFor(courseNode); - courseNodeResourceContext.setDocumentType(TYPE); - courseNodeResourceContext.setTitle(courseNode.getShortTitle()); - courseNodeResourceContext.setDescription(courseNode.getLongTitle()); - doIndexInfos(courseNodeResourceContext, course, courseNode, indexWriter); + 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) { @@ -89,6 +90,7 @@ public class InfoCourseNodeIndexer extends DefaultIndexer implements CourseNode } } + @Override public String getSupportedTypeName() { return SUPPORTED_TYPE_NAME; } @@ -101,7 +103,7 @@ public class InfoCourseNodeIndexer extends DefaultIndexer implements CourseNode OLATResourceable ores = OresHelper.createOLATResourceableInstance(InfoMessage.class, message.getKey()); searchResourceContext.setBusinessControlFor(ores); Document document = InfoMessageDocument.createDocument(searchResourceContext, message); - indexWriter.addDocument(document); + indexWriter.addDocument(document); } } } diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/LLCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/LLCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..078eb78343f93cabe994bf79e54e4956ea7cdbcf --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/LLCourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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 LLCourseNodeIndexer extends AbstractCourseNodeIndexer { + + public static final String TYPE = "type.course.node.ll"; + + private final static String SUPPORTED_TYPE_NAME = "de.bps.course.nodes.LLCourseNode"; + + public LLCourseNodeIndexer() { + super(TYPE, SUPPORTED_TYPE_NAME); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/MSCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/MSCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..cfb36dab8b0345fad39bab67567492cb756e99f0 --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/MSCourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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 MSCourseNodeIndexer extends AbstractCourseNodeIndexer { + + public static final String TYPE = "type.course.node.ms"; + + private final static String SUPPORTED_TYPE_NAME = "org.olat.course.nodes.MSCourseNode"; + + public MSCourseNodeIndexer() { + super(TYPE, SUPPORTED_TYPE_NAME); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/MembersCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/MembersCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..3fe92d6833c5685ac2f8404a5a39b97519176449 --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/MembersCourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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 MembersCourseNodeIndexer extends AbstractCourseNodeIndexer { + + public static final String TYPE = "type.course.node.membersCourseNodeConf"; + + private final static String SUPPORTED_TYPE_NAME = "org.olat.course.nodes.MembersCourseNode"; + + public MembersCourseNodeIndexer() { + super(TYPE, SUPPORTED_TYPE_NAME); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/OpenMeetingsCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/OpenMeetingsCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..4a9199985335f863984142b9ae15180a40ddc69a --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/OpenMeetingsCourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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 OpenMeetingsCourseNodeIndexer extends AbstractCourseNodeIndexer { + + public static final String TYPE = "type.course.node.openmeetings"; + + private final static String SUPPORTED_TYPE_NAME = "org.olat.course.nodes.OpenMeetingsCourseNode"; + + public OpenMeetingsCourseNodeIndexer() { + super(TYPE, SUPPORTED_TYPE_NAME); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/PFCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/PFCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..6091625ed84c32e17ae03eb1d1d5d496ff6ec0aa --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/PFCourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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 PFCourseNodeIndexer extends AbstractCourseNodeIndexer { + + public static final String TYPE = "type.course.node.pf"; + + private final static String SUPPORTED_TYPE_NAME = "org.olat.course.nodes.PFCourseNode"; + + public PFCourseNodeIndexer() { + super(TYPE, SUPPORTED_TYPE_NAME); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/PortfolioCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/PortfolioCourseNodeIndexer.java index 26d259a29efbbec824004966885ac9077bf57a76..0fdc83fe704f6c4d100ee2f9cc15f5370aac95a3 100644 --- a/src/main/java/org/olat/search/service/indexer/repository/course/PortfolioCourseNodeIndexer.java +++ b/src/main/java/org/olat/search/service/indexer/repository/course/PortfolioCourseNodeIndexer.java @@ -31,6 +31,7 @@ import org.olat.portfolio.model.structel.PortfolioStructure; import org.olat.repository.RepositoryEntry; import org.olat.resource.OLATResource; import org.olat.search.service.SearchResourceContext; +import org.olat.search.service.document.CourseNodeDocument; import org.olat.search.service.document.PortfolioMapDocument; import org.olat.search.service.indexer.DefaultIndexer; import org.olat.search.service.indexer.OlatFullIndexer; @@ -84,20 +85,17 @@ public class PortfolioCourseNodeIndexer extends DefaultIndexer implements Course throws IOException, InterruptedException { if(!portfolioModule.isEnabled()) return; - PortfolioCourseNode portfolioNode = (PortfolioCourseNode)courseNode; + 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); - - SearchResourceContext courseNodeResourceContext = new SearchResourceContext(searchResourceContext); - courseNodeResourceContext.setBusinessControlFor(courseNode); - courseNodeResourceContext.setDocumentType(NODE_TYPE); - courseNodeResourceContext.setTitle(courseNode.getShortTitle()); - courseNodeResourceContext.setDescription(courseNode.getLongTitle()); - - Document document = PortfolioMapDocument.createDocument(courseNodeResourceContext, element); - indexWriter.addDocument(document); + Document pDocument = PortfolioMapDocument.createDocument(courseNodeResourceContext, element); + indexWriter.addDocument(pDocument); } } } \ No newline at end of file diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/ProjectBrokerCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/ProjectBrokerCourseNodeIndexer.java index a0e3052f7d10aaae3d16f9c14b8e4333d9236582..920ed0b45baf86b872ca60f002f77488e68c0cf7 100644 --- a/src/main/java/org/olat/search/service/indexer/repository/course/ProjectBrokerCourseNodeIndexer.java +++ b/src/main/java/org/olat/search/service/indexer/repository/course/ProjectBrokerCourseNodeIndexer.java @@ -26,7 +26,6 @@ package org.olat.search.service.indexer.repository.course; import java.io.IOException; -import java.util.Iterator; import java.util.List; import org.apache.lucene.document.Document; @@ -39,6 +38,7 @@ import org.olat.course.nodes.projectbroker.datamodel.Project; import org.olat.course.nodes.projectbroker.service.ProjectBrokerManager; import org.olat.course.properties.CoursePropertyManager; import org.olat.search.service.SearchResourceContext; +import org.olat.search.service.document.CourseNodeDocument; import org.olat.search.service.document.ProjectBrokerProjectDocument; import org.olat.search.service.indexer.AbstractHierarchicalIndexer; import org.olat.search.service.indexer.OlatFullIndexer; @@ -56,20 +56,17 @@ public class ProjectBrokerCourseNodeIndexer extends AbstractHierarchicalIndexer @Override public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException,InterruptedException { - SearchResourceContext courseNodeResourceContext = new SearchResourceContext(repositoryResourceContext); - courseNodeResourceContext.setBusinessControlFor(courseNode); - courseNodeResourceContext.setDocumentType(TYPE); - courseNodeResourceContext.setTitle(courseNode.getShortTitle()); - courseNodeResourceContext.setDescription(courseNode.getLongTitle()); - + SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, TYPE); + Document nodeDocument = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode); + indexWriter.addDocument(nodeDocument); + // go further, index my projects CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager(); ProjectBrokerManager projectBrokerManager = CoreSpringFactory.getImpl(ProjectBrokerManager.class); Long projectBrokerId = projectBrokerManager.getProjectBrokerId(cpm, courseNode); if (projectBrokerId != null) { List<Project> projects = projectBrokerManager.getProjectListBy(projectBrokerId); - for (Iterator<Project> iterator = projects.iterator(); iterator.hasNext();) { - Project project = iterator.next(); + for (Project project: projects) { Document document = ProjectBrokerProjectDocument.createDocument(courseNodeResourceContext, project); indexWriter.addDocument(document); } diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/SPCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/SPCourseNodeIndexer.java index 624ef12c1812c75f99db59f3e07f785fcbc3fd65..54037dd3e9e56ee757ec027c9e2ed30c170c25d9 100644 --- a/src/main/java/org/olat/search/service/indexer/repository/course/SPCourseNodeIndexer.java +++ b/src/main/java/org/olat/search/service/indexer/repository/course/SPCourseNodeIndexer.java @@ -34,17 +34,18 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.lucene.document.Document; import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; import org.olat.core.util.FileUtils; import org.olat.core.util.vfs.VFSContainer; import org.olat.core.util.vfs.VFSItem; import org.olat.core.util.vfs.VFSLeaf; -import org.olat.core.util.vfs.VFSManager; import org.olat.course.ICourse; import org.olat.course.nodes.CourseNode; import org.olat.course.nodes.sp.SPEditController; import org.olat.search.service.SearchResourceContext; +import org.olat.search.service.document.CourseNodeDocument; import org.olat.search.service.indexer.LeafIndexer; import org.olat.search.service.indexer.OlatFullIndexer; @@ -66,15 +67,13 @@ public class SPCourseNodeIndexer extends LeafIndexer implements CourseNodeIndexe private static final String HTML_SUFFIXES = "html htm xhtml xml"; @Override - public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException,InterruptedException { + public void doIndex(SearchResourceContext courseResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException,InterruptedException { if (log.isDebug()) log.debug("Index SinglePage..."); - SearchResourceContext courseNodeResourceContext = new SearchResourceContext(repositoryResourceContext); - courseNodeResourceContext.setBusinessControlFor(courseNode); - courseNodeResourceContext.setDocumentType(TYPE); - courseNodeResourceContext.setTitle(courseNode.getShortTitle()); - courseNodeResourceContext.setDescription(courseNode.getLongTitle()); - + 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 @@ -85,10 +84,6 @@ public class SPCourseNodeIndexer extends LeafIndexer implements CourseNodeIndexe // Read the course node configuration VFSContainer courseFolderContainer = course.getCourseEnvironment().getCourseFolderContainer(); -// String path = course.getCourseEnvironment().getCourseBaseContainer().getRelPath() + "/coursefolder"; -// VFSContainer courseFolderContainer = new OlatRootFolderImpl(path, null); - - boolean allowRelativeLinks = courseNode.getModuleConfiguration().getBooleanSafe(SPEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS); String fileName = (String) courseNode.getModuleConfiguration().get(SPEditController.CONFIG_KEY_FILE); @@ -99,7 +94,7 @@ public class SPCourseNodeIndexer extends LeafIndexer implements CourseNodeIndexe rootContainer = courseFolderContainer; chosenFile = fileName; } else { - // Csae 2: relative links are NOT allowed. We have to calculate the + // 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); @@ -118,21 +113,15 @@ public class SPCourseNodeIndexer extends LeafIndexer implements CourseNodeIndexe } chosenFile = startURI; } - - // First: Index configured HTML file - if (log.isDebug()) { - log.debug("-------------------- Indexing course node::" + courseNode.getIdent() + " " + courseNode.getShortName()); - log.debug("Config: allow relative links::" + allowRelativeLinks); - log.debug("Config: filename::" + fileName); - log.debug("Base dir::" + VFSManager.getRealPath(rootContainer)); - log.debug("chosenFile::" + chosenFile); - } + VFSLeaf leaf = (VFSLeaf)rootContainer.resolve(chosenFile); if (leaf != null) { String filePath = getPathFor(leaf); - if (log.isDebug()) log.debug("Found chosen file in SP. filePath=" + filePath ); // Use inherited method from LeafIndexer for the actual indexing of the content - doIndexVFSLeafByMySelf(courseNodeResourceContext, leaf, indexWriter, filePath); + + 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>(); @@ -147,6 +136,7 @@ public class SPCourseNodeIndexer extends LeafIndexer implements CourseNodeIndexe } } + @Override public String getSupportedTypeName() { return SUPPORTED_TYPE_NAME; } diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/STCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/STCourseNodeIndexer.java index 7a9ffc0a9e97d1afb7259ba4f9c4c8cb571ff826..0925c35f5afbe3861e84fedde6c3cb3adde48e7d 100644 --- a/src/main/java/org/olat/search/service/indexer/repository/course/STCourseNodeIndexer.java +++ b/src/main/java/org/olat/search/service/indexer/repository/course/STCourseNodeIndexer.java @@ -64,12 +64,7 @@ public class STCourseNodeIndexer extends LeafIndexer implements CourseNodeIndexe public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException,InterruptedException { if (log.isDebug()) log.debug("Index StructureNode..."); - SearchResourceContext courseNodeResourceContext = new SearchResourceContext(repositoryResourceContext); - courseNodeResourceContext.setBusinessControlFor(courseNode); - courseNodeResourceContext.setDocumentType(TYPE); - courseNodeResourceContext.setTitle(courseNode.getShortTitle()); - courseNodeResourceContext.setDescription(courseNode.getLongTitle()); - + SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, TYPE); Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode); indexWriter.addDocument(document); diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/ScormCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/ScormCourseNodeIndexer.java index a6878989c3ac391eded308487ad1285382748f1d..9a8bbffd92ffd34b7fb61b2d6fb072ebb2fece5e 100644 --- a/src/main/java/org/olat/search/service/indexer/repository/course/ScormCourseNodeIndexer.java +++ b/src/main/java/org/olat/search/service/indexer/repository/course/ScormCourseNodeIndexer.java @@ -22,12 +22,14 @@ 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.course.ICourse; import org.olat.course.nodes.CourseNode; import org.olat.fileresource.FileResourceManager; import org.olat.repository.RepositoryEntry; import org.olat.resource.OLATResource; import org.olat.search.service.SearchResourceContext; +import org.olat.search.service.document.CourseNodeDocument; import org.olat.search.service.indexer.OlatFullIndexer; import org.olat.search.service.indexer.repository.ScormRepositoryIndexer; @@ -47,18 +49,14 @@ public class ScormCourseNodeIndexer extends ScormRepositoryIndexer implements Co @Override public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException { - + SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, NODE_TYPE); + Document nodeDocument = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode); + indexWriter.addDocument(nodeDocument); + RepositoryEntry repoEntry = courseNode.getReferencedRepositoryEntry(); if(repoEntry != null) { - SearchResourceContext courseNodeResourceContext = new SearchResourceContext(repositoryResourceContext); - courseNodeResourceContext.setBusinessControlFor(courseNode); - courseNodeResourceContext.setDocumentType(NODE_TYPE); - courseNodeResourceContext.setTitle(courseNode.getShortTitle()); - courseNodeResourceContext.setDescription(courseNode.getLongTitle()); - OLATResource ores = repoEntry.getOlatResource(); File cpRoot = FileResourceManager.getInstance().unzipFileResource(ores); - doIndex(courseNodeResourceContext, indexWriter, cpRoot); } } diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/TACourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/TACourseNodeIndexer.java index ae3ba59f83d9b6907ecc65e5f6a6c8aa7ebc6c48..6fbe0c0d21fa12082282048297888bc9e27432ed 100644 --- a/src/main/java/org/olat/search/service/indexer/repository/course/TACourseNodeIndexer.java +++ b/src/main/java/org/olat/search/service/indexer/repository/course/TACourseNodeIndexer.java @@ -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.commons.modules.bc.FolderConfig; import org.olat.core.util.vfs.LocalFolderImpl; import org.olat.core.util.vfs.VFSContainer; @@ -38,6 +39,7 @@ import org.olat.course.nodes.ta.DropboxController; import org.olat.course.nodes.ta.ReturnboxController; import org.olat.course.nodes.ta.SolutionController; 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; @@ -58,11 +60,10 @@ public class TACourseNodeIndexer extends FolderIndexer implements CourseNodeInde @Override public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException,InterruptedException { - SearchResourceContext courseNodeResourceContext = new SearchResourceContext(repositoryResourceContext); - courseNodeResourceContext.setBusinessControlFor(courseNode); - courseNodeResourceContext.setTitle(courseNode.getShortTitle()); - courseNodeResourceContext.setDescription(courseNode.getLongTitle()); - + SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, null); + Document nodeDocument = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode); + indexWriter.addDocument(nodeDocument); + // Index Task File fTaskfolder = new File(FolderConfig.getCanonicalRoot() + TACourseNode.getTaskFolderPathRelToFolderRoot(course.getCourseEnvironment(), courseNode)); VFSContainer taskRootContainer = new LocalFolderImpl(fTaskfolder); diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/TUCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/TUCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..ae73d3ccde21376de7bd3b90dd117cabdd3a4d59 --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/TUCourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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 TUCourseNodeIndexer extends AbstractCourseNodeIndexer { + + public static final String TYPE = "type.course.node.tu"; + + private final static String SUPPORTED_TYPE_NAME = "org.olat.course.nodes.TUCourseNode"; + + public TUCourseNodeIndexer() { + super(TYPE, SUPPORTED_TYPE_NAME); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/VCCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/VCCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..4e0be7dd921f116fc5ef57ae70b8f911a240b895 --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/VCCourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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 VCCourseNodeIndexer extends AbstractCourseNodeIndexer { + + public static final String TYPE = "type.course.node.vc"; + + private final static String SUPPORTED_TYPE_NAME = "de.bps.course.nodes.VCCourseNode"; + + public VCCourseNodeIndexer() { + super(TYPE, SUPPORTED_TYPE_NAME); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/VideoCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/VideoCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..a84ca5963d0cbcef6f1f46bc7402863bb7f57d85 --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/VideoCourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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 VideoCourseNodeIndexer extends AbstractCourseNodeIndexer { + + public static final String TYPE = "type.course.node.video"; + + private final static String SUPPORTED_TYPE_NAME = "org.olat.course.nodes.VideoCourseNode"; + + public VideoCourseNodeIndexer() { + super(TYPE, SUPPORTED_TYPE_NAME); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/ViteroCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/ViteroCourseNodeIndexer.java new file mode 100644 index 0000000000000000000000000000000000000000..433644d3cc6ac572d77b221174c5c77b117c25c7 --- /dev/null +++ b/src/main/java/org/olat/search/service/indexer/repository/course/ViteroCourseNodeIndexer.java @@ -0,0 +1,37 @@ +/** + * <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 ViteroCourseNodeIndexer extends AbstractCourseNodeIndexer { + + public static final String TYPE = "type.course.node.vitero"; + + private final static String SUPPORTED_TYPE_NAME = "org.olat.course.nodes.ViteroCourseNode"; + + public ViteroCourseNodeIndexer() { + super(TYPE, SUPPORTED_TYPE_NAME); + } +} diff --git a/src/main/java/org/olat/search/service/indexer/repository/course/WikiCourseNodeIndexer.java b/src/main/java/org/olat/search/service/indexer/repository/course/WikiCourseNodeIndexer.java index aa1678b1ffd329a58dd69de1c184295c3ece9ded..56e5f4c3a6e2aa1f6b79c064fb6d128927428c73 100644 --- a/src/main/java/org/olat/search/service/indexer/repository/course/WikiCourseNodeIndexer.java +++ b/src/main/java/org/olat/search/service/indexer/repository/course/WikiCourseNodeIndexer.java @@ -37,6 +37,7 @@ import org.olat.modules.wiki.WikiManager; import org.olat.modules.wiki.WikiPage; import org.olat.repository.RepositoryEntry; import org.olat.search.service.SearchResourceContext; +import org.olat.search.service.document.CourseNodeDocument; import org.olat.search.service.document.WikiPageDocument; import org.olat.search.service.indexer.AbstractHierarchicalIndexer; import org.olat.search.service.indexer.OlatFullIndexer; @@ -56,23 +57,20 @@ public class WikiCourseNodeIndexer extends AbstractHierarchicalIndexer implement @Override public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) { - if (log.isDebug()) log.debug("Index wiki..."); String repoEntryName = "*name not available*"; try { - RepositoryEntry repositoryEntry = courseNode.getReferencedRepositoryEntry(); - if(repositoryEntry == null) return; + SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, TYPE); + Document nodeDocument = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode); + indexWriter.addDocument(nodeDocument); + RepositoryEntry repositoryEntry = courseNode.getReferencedRepositoryEntry(); + if(repositoryEntry == null) return; 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 courseNodeResourceContext = new SearchResourceContext(repositoryResourceContext); - courseNodeResourceContext.setBusinessControlFor(courseNode); - courseNodeResourceContext.setDocumentType(TYPE); - courseNodeResourceContext.setTitle(courseNode.getShortTitle()); - courseNodeResourceContext.setDescription(courseNode.getLongTitle()); courseNodeResourceContext.setFilePath(wikiPage.getPageName()); Document document = WikiPageDocument.createDocument(courseNodeResourceContext, wikiPage); diff --git a/src/main/java/org/olat/search/ui/SearchInputController.java b/src/main/java/org/olat/search/ui/SearchInputController.java index ededb34a509a48c7796c3e4c915e835e2eda86ee..d4fc064f9c399790d41556ddbe6b2d401f1eaaae 100644 --- a/src/main/java/org/olat/search/ui/SearchInputController.java +++ b/src/main/java/org/olat/search/ui/SearchInputController.java @@ -86,7 +86,6 @@ public class SearchInputController extends FormBasicController implements Generi private static final String FUZZY_SEARCH = "~0.7"; private static final String CMD_DID_YOU_MEAN_LINK = "didYouMeanLink-"; private static final String SEARCH_STORE_KEY = "search-store-key"; - private static final String SEARCH_CACHE_KEY = "search-cache-key"; private String parentContext; private String documentType; @@ -103,7 +102,6 @@ public class SearchInputController extends FormBasicController implements Generi protected List<FormLink> didYouMeanLinks; private Map<String,Properties> prefs; - private SearchLRUCache searchCache; private SearchClient searchClient; public SearchInputController(UserRequest ureq, WindowControl wControl, String resourceUrl, DisplayOption displayOption) { @@ -256,12 +254,6 @@ public class SearchInputController extends FormBasicController implements Generi prefs = new HashMap<String,Properties>(); ureq.getUserSession().putEntry(SEARCH_STORE_KEY, prefs); } - - searchCache = (SearchLRUCache)ureq.getUserSession().getEntry(SEARCH_CACHE_KEY); - if(searchCache == null) { - searchCache = new SearchLRUCache(); - ureq.getUserSession().putEntry(SEARCH_CACHE_KEY, searchCache); - } } @Override @@ -271,7 +263,7 @@ public class SearchInputController extends FormBasicController implements Generi @Override public void formOK(UserRequest ureq) { - fireEvent(ureq, QuickSearchEvent.QUICKSEARCH_EVENT); + fireEvent(ureq, QuickSearchEvent.QUICKSEARCH_EVENT); doSearch(ureq); } @@ -477,11 +469,8 @@ public class SearchInputController extends FormBasicController implements Generi query = getQueryString(searchString, false); condQueries = getCondQueryStrings(condSearchStrings, parentCtxt, docType, rsrcUrl); - SearchResults searchResults = searchCache.get(getQueryCacheKey(firstResult, query, condQueries)); - if(searchResults == null || true) { - searchResults = searchClient.doSearch(query, condQueries, ureq.getIdentity(), ureq.getUserSession().getRoles(), firstResult, maxReturns, true); - searchCache.put(getQueryCacheKey(firstResult, query, condQueries), searchResults); - } + SearchResults searchResults = searchClient.doSearch(query, condQueries, ureq.getIdentity(), ureq.getUserSession().getRoles(), firstResult, maxReturns, true); + if (firstResult == 0 && searchResults.size() == 0 && !query.endsWith(FUZZY_SEARCH)) { // result-list was empty => first try to find word via spell-checker if (doSpellCheck) { @@ -519,21 +508,7 @@ public class SearchInputController extends FormBasicController implements Generi hideDidYouMeanWords(); String query = getQueryString(searchString, true); List<String> condQueries = getCondQueryStrings(condSearchStrings, parentCtxt, docType, rsrcUrl); - SearchResults searchResults = searchCache.get(getQueryCacheKey(firstResult, query, condQueries)); - if(searchResults == null) { - searchResults = searchClient.doSearch(query, condQueries, ureq.getIdentity(), ureq.getUserSession().getRoles(), firstResult, maxReturns, true); - searchCache.put(getQueryCacheKey(firstResult, query, condQueries), searchResults); - } - return searchResults; - } - - private Object getQueryCacheKey(int firstResult, String query, List<String> condQueries) { - StringBuilder sb = new StringBuilder(); - sb.append('[').append(firstResult).append(']').append(query).append(' '); - for(String condQuery:condQueries) { - sb.append(condQuery).append(' '); - } - return sb.toString(); + return searchClient.doSearch(query, condQueries, ureq.getIdentity(), ureq.getUserSession().getRoles(), firstResult, maxReturns, true); } public Set<String> getDidYouMeanWords() { diff --git a/src/main/java/org/olat/search/ui/StandardResultController.java b/src/main/java/org/olat/search/ui/StandardResultController.java index 46a538f41379e81185e34514f380478052d8633b..76c442a5295b87f500409ee33d6aff56338173f1 100644 --- a/src/main/java/org/olat/search/ui/StandardResultController.java +++ b/src/main/java/org/olat/search/ui/StandardResultController.java @@ -133,8 +133,4 @@ public class StandardResultController extends FormBasicController implements Res } } } - - public FormItem getInitialFormItem() { - return flc; - } } diff --git a/src/main/java/org/olat/search/ui/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/search/ui/_i18n/LocalStrings_de.properties index 11aae66266e2cee0bfe31e12a94f63cee7d4297b..f7f7f93d15c606ed806342acb5d7394c5d15f0b0 100644 --- a/src/main/java/org/olat/search/ui/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/search/ui/_i18n/LocalStrings_de.properties @@ -60,17 +60,37 @@ toolfolder=Ordner toolforum=Foren type.course.node=Kursbaustein type.course.node.bc=Kursbaustein, Ordner +type.course.node.cal=Kursbaustein, Kalender type.course.node.cp=Kursbaustein, CP-Lerninhalt +type.course.node.checklist=Kurbautein, Checkliste +type.course.node.co=Kursbaustein, E-Mail +type.course.node.den=Kursbaustein, Terminvergabe type.course.node.dialog.file=Kursbaustein, Dateidiskussion (Datei) type.course.node.dialog.forum.message=Kursbaustein Dateidiskussion (Diskussion) +type.course.node.en=Kursbaustein, Einschreibung type.course.node.ep=Kursbaustein, Portfolioaufgabe +type.course.node.iqself=Kursbaustein, Selbsttest +type.course.node.iqsurv=Kursbaustein, Fragebogen +type.course.node.iqtest=Kursbaustein, Test type.course.node.forum.message=Kursbaustein, Forum +type.course.node.gotomeeting=Kursbaustein, GoToMeeting +type.course.node.gta=Kursbaustein, Aufgabe +type.course.node.ll=Kursbaustein, Linkliste +type.course.node.lti=Kursbaustein, LTI-Seite +type.course.node.membersCourseNodeConf=Kursbaustein, Teilnehmerliste +type.course.node.ms=Kursbaustein, Bewertung +type.course.node.openmeetings=Kursbaustein, OpenMeetings +type.course.node.pf=Kursbaustein, Teilnehmer Ordner type.course.node.sp=Kursbaustein, Einzelne Seite type.course.node.st=Kursbaustein, Struktur type.course.node.ta.dropbox=Kursbaustein, Aufgabe (Abgabeordner) type.course.node.ta.returnbox=Kursbaustein, Aufgabe (R\u00FCckgabeordner) type.course.node.ta.solutionbox=Kursbaustein, Aufgabe (Musterl\u00F6sung) type.course.node.ta.task=Kursbaustein, Aufgabe (Aufgabenordner) +type.course.node.tu=Kursbaustein, Externe Seite +type.course.node.vc=Kursbaustein, Virtuelles Klassenzimmer +type.course.node.video=Kursbaustein, Video +type.course.node.vitero=Kursbaustein, vitero type.course.node.wiki=Kursbaustein, Wiki type.course.node.projectbroker=Kursbaustein, Themenb\u00F6rse type.course.node.blog=Kursbaustein, Blog diff --git a/src/main/java/org/olat/search/ui/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/search/ui/_i18n/LocalStrings_en.properties index eb277da3f6d46a3c2e96326e8694d2e7593c1bd1..28a25d0024e5d5ee943f8d258aa77fa2b4aaa8c0 100644 --- a/src/main/java/org/olat/search/ui/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/search/ui/_i18n/LocalStrings_en.properties @@ -66,10 +66,25 @@ type.course.node=Course element type.course.node.bc=Course element, folder type.course.node.blog=Course element, blog type.course.node.cp=Course element, CP learning content +type.course.node.checklist=Course element, checklist +type.course.node.co=Course element, E-mail +type.course.node.den=Course element, assignment of dates type.course.node.dialog.file=Course element, file dialog (file) type.course.node.dialog.forum.message=Course element, file dialog (discussion) +type.course.node.en=Course element, enrolment type.course.node.ep=Course element, portfolio task +type.course.node.iqself=Course element, self-test +type.course.node.iqsurv=Course element, survey +type.course.node.iqtest=Course element, test type.course.node.forum.message=Course element, forum +type.course.node.gotomeeting=Course element, GoToMeeting +type.course.node.gta=Course element, task +type.course.node.ll=Course element, link list +type.course.node.lti=Course element, LTI page +type.course.node.membersCourseNodeConf=Course element, participant list +type.course.node.ms=Course element, assessment +type.course.node.openmeetings=Course element, OpenMeetings +type.course.node.pf=Course element, participant folder type.course.node.podcast=Course element, Podcast type.course.node.projectbroker=Course element, topic assignment type.course.node.scorm=Course element, SCORM @@ -79,6 +94,10 @@ type.course.node.ta.dropbox=Course element, task (drop box) type.course.node.ta.returnbox=Course element, task (return box) type.course.node.ta.solutionbox=Course element, task (sample solution) type.course.node.ta.task=Course element, task (task folder) +type.course.node.tu=Course element, external page +type.course.node.vc=Course element, virtual classroom +type.course.node.video=Course element, video +type.course.node.vitero=Course element, vitero type.course.node.wiki=Course element, Wiki type.db.EPDefaultMap=Portfolio folder type.db.EPStructuredMap=Portfolio task