Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
New mapping design for named-field indexers, not for RDF indexers, in…
…tegration tests passing, no system tests yet
  • Loading branch information
ajs6f committed Dec 6, 2013
1 parent 4a41346 commit b7f2dde
Show file tree
Hide file tree
Showing 105 changed files with 875 additions and 361 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
41 changes: 27 additions & 14 deletions fcrepo-jms-indexer-core/pom.xml
Expand Up @@ -59,10 +59,6 @@
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.abdera</groupId>
<artifactId>abdera-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
Expand All @@ -71,10 +67,6 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.apache.abdera</groupId>
<artifactId>abdera-parser</artifactId>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
Expand All @@ -84,6 +76,12 @@
<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-http-commons</artifactId>
<exclusions>
<exclusion>
<artifactId>lucene-core</artifactId>
<groupId>org.apache.lucene</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.fcrepo</groupId>
Expand Down Expand Up @@ -113,18 +111,14 @@
<scope>test</scope>
</dependency>
<!-- Start of Solr Indexer libs -->
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-core</artifactId>
</dependency>
<dependency>
<!-- <dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-test-framework</artifactId>
</dependency>
</dependency> -->
<!-- HttpClient are used for create standardalone SolrIndexer Server client.
They seem to be included with Solr 3.6.2?
Ver 4.2.5 aim to fit JENA included version -->
Expand All @@ -133,6 +127,11 @@
<artifactId>httpmime</artifactId>
</dependency>
<!-- End of Solr Indexer libs -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -242,4 +241,18 @@
</plugins>
</build>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>${solr.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-facet</artifactId>
<version>${solr.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
@@ -0,0 +1,41 @@
/**
* Copyright 2013 DuraSpace, Inc.
*
* Licensed 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.
*/

package org.fcrepo.indexer;

/**
* Indicates that a resource was not designated for named-field indexing.
* Typically this would be because there has been assigned no appropriate
* transformation.
*
* @author ajs6f
* @date Dec 4, 2013
*/
public class CannotTransformToNamedFieldsException extends Exception {

/**
*
*/
private static final long serialVersionUID = 1L;

/**
* @param msg
*/
public CannotTransformToNamedFieldsException(final String msg) {
super(msg);
}

}
Expand Up @@ -16,19 +16,24 @@

package org.fcrepo.indexer;

import static org.apache.commons.io.IOUtils.write;
import static com.google.common.base.Throwables.propagate;
import static org.apache.commons.lang.StringUtils.substringAfterLast;
import static org.fcrepo.indexer.Indexer.IndexerType.NAMEDFIELDS;
import static org.slf4j.LoggerFactory.getLogger;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.Callable;

import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;

import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListenableFutureTask;

Expand Down Expand Up @@ -70,22 +75,23 @@ public String getPath() {
* @return
**/
@Override
public ListenableFuture<File> update(final String pid, final String content) throws IOException {
public ListenableFuture<File> update(final String pid, final Reader content) throws IOException {
// timestamped filename
String fn = pid + "." + fmt.format(new Date());
if (fn.indexOf('/') != -1) {
fn = substringAfterLast(fn, "/");
}
final File file = new File(path, fn);
LOGGER.debug("Updating to file: {}", file);
return run(ListenableFutureTask.create(new Callable<File>() {

@Override
public File call() {
// write content to disk
try (Writer fw = new FileWriter(file)) {
write(content, fw);
} catch (final IOException ex) {
LOGGER.error("Error writing file", ex);
try (Writer w = new FileWriter(file)) {
IOUtils.copy(content, w);
} catch (final IOException e) {
propagate(e);
}
return file;
}
Expand All @@ -100,12 +106,17 @@ public File call() {
@Override
public ListenableFuture<File> remove(final String pid) throws IOException {
// empty update
return update(pid,"");
LOGGER.debug("Received remove for identifier: {}", pid);
return update(pid, new StringReader(""));
}

private static <T> ListenableFuture<T> run(
final ListenableFutureTask<T> task) {
task.run();
return task;
}
@Override
public IndexerType getIndexerType() {
return NAMEDFIELDS;
}
}
@@ -0,0 +1,30 @@
/**
* Copyright 2013 DuraSpace, Inc.
*
* Licensed 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.
*/

package org.fcrepo.indexer;

import java.io.InputStream;
import java.util.concurrent.Callable;

/**
* Implemented by classes that retrieve indexable content for a resource.
*
* @author ajs6f
* @date Dec 6, 2013
*/
public interface IndexableContentRetriever extends Callable<InputStream> {

}
Expand Up @@ -17,6 +17,7 @@
package org.fcrepo.indexer;

import java.io.IOException;
import java.io.Reader;

import com.google.common.util.concurrent.ListenableFuture;

Expand All @@ -34,10 +35,19 @@ public interface Indexer {
/**
* Create or update an index entry for the object.
**/
public ListenableFuture<?> update(final String pid, final String doc) throws IOException;
public ListenableFuture<?> update(final String pid, final Reader doc) throws IOException;

/**
* Remove the object from the index.
**/
public ListenableFuture<?> remove(final String pid) throws IOException;

/**
* @return What kind of indexer this is.
*/
public IndexerType getIndexerType();

public static enum IndexerType {
NAMEDFIELDS, RDF, NOOP
}
}

0 comments on commit b7f2dde

Please sign in to comment.