Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,23 @@ limitations under the License.
<version>${lucene.version}</version>
</dependency>

<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>9.1.1</version>
<!-- exclude vulnerable dependencies -->
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- slf4j implementing the apache commons-logging interfaces -->
<!-- note: commons-logging needs to be excluded in all dependencies transitive depending on it.
See 2006 RFE https://issues.apache.org/jira/browse/MNG-1977 for maven's missing feature of global exclusions -->
Expand Down Expand Up @@ -365,7 +382,7 @@ limitations under the License.
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.9</version>
<version>1.10.0</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -571,6 +588,20 @@ limitations under the License.
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.2.4</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.instancio</groupId>
<artifactId>instancio-junit</artifactId>
<version>2.9.0</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import org.apache.roller.weblogger.business.plugins.PluginManagerImpl;
import org.apache.roller.weblogger.business.runnable.ThreadManager;
import org.apache.roller.weblogger.business.search.IndexManager;
import org.apache.roller.weblogger.business.search.IndexManagerImpl;
import org.apache.roller.weblogger.business.search.lucene.LuceneIndexManager;
import org.apache.roller.weblogger.business.themes.ThemeManager;
import org.apache.roller.weblogger.business.themes.ThemeManagerImpl;
import org.apache.roller.weblogger.planet.business.WebloggerRomeFeedFetcher;
Expand Down Expand Up @@ -81,7 +81,7 @@ public void configure(Binder binder) {

binder.bind(MediaFileManager.class).to( JPAMediaFileManagerImpl.class);
binder.bind(FileContentManager.class).to( FileContentManagerImpl.class);
binder.bind(IndexManager.class).to( IndexManagerImpl.class);
binder.bind(IndexManager.class).to( LuceneIndexManager.class);
binder.bind(PluginManager.class).to( PluginManagerImpl.class);
binder.bind(ThemeManager.class).to( ThemeManagerImpl.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,58 @@

import org.apache.roller.weblogger.WebloggerException;
import org.apache.roller.weblogger.business.InitializationException;
import org.apache.roller.weblogger.business.search.operations.IndexOperation;
import org.apache.roller.weblogger.pojos.WeblogEntry;
import org.apache.roller.weblogger.business.URLStrategy;
import org.apache.roller.weblogger.pojos.Weblog;
import org.apache.roller.weblogger.pojos.WeblogEntry;

/**
* Interface to Roller's Lucene-based search facility.
* Interface to Roller's full-text search facility.
* @author Dave Johnson
*/
public interface IndexManager
{
/** Does index need to be rebuild */
boolean isInconsistentAtStartup();

/** Remove user from index, returns immediately and operates in background */
void removeWebsiteIndex(Weblog website) throws WebloggerException;

/** Remove entry from index, returns immediately and operates in background */
void removeEntryIndexOperation(WeblogEntry entry) throws WebloggerException;

/** Add entry to index, returns immediately and operates in background */
void addEntryIndexOperation(WeblogEntry entry) throws WebloggerException;

/** R-index entry, returns immediately and operates in background */
void addEntryReIndexOperation(WeblogEntry entry) throws WebloggerException;

/** Execute operation immediately */
void executeIndexOperationNow(final IndexOperation op);
public interface IndexManager {

/**
* Release all resources associated with Roller session.
*/
void release();


/**
* Initialize the search system.
*
* @throws InitializationException If there is a problem during initialization.
*/
void initialize() throws InitializationException;



/** Shutdown to be called on application shutdown */
void shutdown();

void rebuildWebsiteIndex(Weblog website) throws WebloggerException;
/**
* Release all resources associated with Roller session.
*/
void release();

/** Does index need to be rebuilt */
boolean isInconsistentAtStartup();

/** Add entry to index, returns immediately and operates in background */
void addEntryIndexOperation(WeblogEntry entry) throws WebloggerException;

/** Re-index entry, returns immediately and operates in background */
void addEntryReIndexOperation(WeblogEntry entry) throws WebloggerException;

void rebuildWeblogIndex(Weblog weblog) throws WebloggerException;

void rebuildWeblogIndex() throws WebloggerException;

void rebuildWebsiteIndex() throws WebloggerException;
/** Remove weblog from index, returns immediately and operates in background */
void removeWeblogIndex(Weblog weblog) throws WebloggerException;

/** Remove entry from index, returns immediately and operates in background */
void removeEntryIndexOperation(WeblogEntry entry) throws WebloggerException;

SearchResultList search(
String term,
String weblogHandle,
String category,
String locale,
int pageNum,
int entryCount,
URLStrategy urlStrategy
) throws WebloggerException;
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. The ASF licenses this file to You
* under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. For additional information regarding
* copyright in this work, please see the NOTICE file in the top level
* directory of this distribution.
*/

/* Created on March 8, 2023 */

package org.apache.roller.weblogger.business.search;

import java.util.List;
import java.util.Set;
import org.apache.roller.weblogger.pojos.wrapper.WeblogEntryWrapper;

public class SearchResultList {
int limit;
int offset;
Set<String> categories;
List<WeblogEntryWrapper> results;
public SearchResultList(
List<WeblogEntryWrapper> results, Set<String> categories, int limit, int offset) {
this.results = results;
this.categories = categories;
this.limit = limit;
this.offset = offset;
}
public int getLimit() {
return limit;
}
public int getOffset() {
return offset;
}
public List<WeblogEntryWrapper> getResults() {
return results;
}
public Set<String> getCategories() {
return categories;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. The ASF licenses this file to You
* under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. For additional information regarding
* copyright in this work, please see the NOTICE file in the top level
* directory of this distribution.
*/

/* Created on March 8, 2023 */

package org.apache.roller.weblogger.business.search;

import java.util.Date;
import java.util.Map;
import java.util.Set;
import org.apache.roller.weblogger.pojos.wrapper.WeblogEntryWrapper;

public class SearchResultMap {
int limit;
int offset;
Set<String> categories;
Map<Date, Set<WeblogEntryWrapper>> results;
public SearchResultMap(Map<Date, Set<WeblogEntryWrapper>> results, Set<String> categories, int limit, int offset) {
this.results = results;
this.categories = categories;
this.limit = limit;
this.offset = offset;
}
public int getLimit() {
return limit;
}
public int getOffset() {
return offset;
}
public Map<Date, Set<WeblogEntryWrapper>> getResults() {
return results;
}
public Set<String> getCategories() {
return categories;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
* directory of this distribution.
*/
/* Created on Jul 16, 2003 */
package org.apache.roller.weblogger.business.search.operations;
package org.apache.roller.weblogger.business.search.lucene;

import java.io.IOException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lucene.index.IndexWriter;
import org.apache.roller.weblogger.WebloggerException;
import org.apache.roller.weblogger.business.search.IndexManagerImpl;
import org.apache.roller.weblogger.business.Weblogger;
import org.apache.roller.weblogger.business.WeblogEntryManager;
import org.apache.roller.weblogger.pojos.WeblogEntry;
Expand All @@ -37,7 +36,7 @@ public class AddEntryOperation extends WriteToIndexOperation {

//~ Static fields/initializers =============================================

private static Log mLogger =
private static Log logger =
LogFactory.getFactory().getInstance(AddEntryOperation.class);

//~ Instance fields ========================================================
Expand All @@ -50,7 +49,7 @@ public class AddEntryOperation extends WriteToIndexOperation {
/**
* Adds a web log entry into the index.
*/
public AddEntryOperation(Weblogger roller, IndexManagerImpl mgr,WeblogEntry data) {
public AddEntryOperation(Weblogger roller, LuceneIndexManager mgr, WeblogEntry data) {
super(mgr);
this.roller = roller;
this.data = data;
Expand All @@ -69,7 +68,7 @@ public void doRun() {
WeblogEntryManager wMgr = roller.getWeblogEntryManager();
this.data = wMgr.getWeblogEntry(this.data.getId());
} catch (WebloggerException ex) {
mLogger.error("Error getting weblogentry object", ex);
logger.error("Error getting weblogentry object", ex);
return;
}

Expand All @@ -78,7 +77,7 @@ public void doRun() {
writer.addDocument(getDocument(data));
}
} catch (IOException e) {
mLogger.error("Problems adding doc to index", e);
logger.error("Problems adding doc to index", e);
} finally {
if (roller != null) {
roller.release();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* directory of this distribution.
*/
/* Created on Jul 19, 2003 */
package org.apache.roller.weblogger.business.search;
package org.apache.roller.weblogger.business.search.lucene;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
* copyright in this work, please see the NOTICE file in the top level
* directory of this distribution.
*/

/* Created on Jul 16, 2003 */
package org.apache.roller.weblogger.business.search.operations;

package org.apache.roller.weblogger.business.search.lucene;

import java.io.IOException;
import java.util.List;
Expand All @@ -32,8 +34,6 @@
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.util.BytesRef;
import org.apache.roller.weblogger.business.search.FieldConstants;
import org.apache.roller.weblogger.business.search.IndexManagerImpl;
import org.apache.roller.weblogger.config.WebloggerConfig;
import org.apache.roller.weblogger.pojos.WeblogCategory;
import org.apache.roller.weblogger.pojos.WeblogEntry;
Expand All @@ -50,17 +50,17 @@
*/
public abstract class IndexOperation implements Runnable {

private static Log mLogger = LogFactory.getFactory().getInstance(
private static Log logger = LogFactory.getFactory().getInstance(
IndexOperation.class);

// ~ Instance fields
// ========================================================
protected IndexManagerImpl manager;
protected LuceneIndexManager manager;
private IndexWriter writer;

// ~ Constructors
// ===========================================================
public IndexOperation(IndexManagerImpl manager) {
public IndexOperation(LuceneIndexManager manager) {
this.manager = manager;
}

Expand Down Expand Up @@ -172,15 +172,15 @@ protected IndexWriter beginWriting() {
try {

LimitTokenCountAnalyzer analyzer = new LimitTokenCountAnalyzer(
IndexManagerImpl.getAnalyzer(),
LuceneIndexManager.getAnalyzer(),
WebloggerConfig.getIntProperty("lucene.analyzer.maxTokenCount"));

IndexWriterConfig config = new IndexWriterConfig(analyzer);

writer = new IndexWriter(manager.getIndexDirectory(), config);

} catch (IOException e) {
mLogger.error("ERROR creating writer", e);
logger.error("ERROR creating writer", e);
}

return writer;
Expand All @@ -194,7 +194,7 @@ protected void endWriting() {
try {
writer.close();
} catch (IOException e) {
mLogger.error("ERROR closing writer", e);
logger.error("ERROR closing writer", e);
}
}
}
Expand Down
Loading