You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rh...@apache.org on 2013/07/16 11:43:52 UTC
svn commit: r1503636 - in /stanbol/trunk/entityhub/indexing/core/src:
main/java/org/apache/stanbol/entityhub/indexing/core/
main/java/org/apache/stanbol/entityhub/indexing/core/config/
main/java/org/apache/stanbol/entityhub/indexing/core/source/ test/j...
Author: rharo
Date: Tue Jul 16 09:43:52 2013
New Revision: 1503636
URL: http://svn.apache.org/r1503636
Log:
Fixed STANBOL-1120 with the proposed patches
Modified:
stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/IndexerFactory.java
stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/config/IndexingConfig.java
stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/config/IndexingConstants.java
stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/source/ResourceLoader.java
stanbol/trunk/entityhub/indexing/core/src/test/java/org/apache/stanbol/entityhub/indexing/core/ResourceLoaderTest.java
Modified: stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/IndexerFactory.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/IndexerFactory.java?rev=1503636&r1=1503635&r2=1503636&view=diff
==============================================================================
--- stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/IndexerFactory.java (original)
+++ stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/IndexerFactory.java Tue Jul 16 09:43:52 2013
@@ -16,8 +16,6 @@
*/
package org.apache.stanbol.entityhub.indexing.core;
-import static org.apache.stanbol.entityhub.indexing.core.config.IndexingConfig.DEFAULT_INDEXED_ENTITIES_ID_FILE_NAME;
-
import java.io.File;
import java.io.IOException;
import java.util.List;
Modified: stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/config/IndexingConfig.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/config/IndexingConfig.java?rev=1503636&r1=1503635&r2=1503636&view=diff
==============================================================================
--- stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/config/IndexingConfig.java (original)
+++ stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/config/IndexingConfig.java Tue Jul 16 09:43:52 2013
@@ -80,7 +80,7 @@ public class IndexingConfig {
private static final String DESTINATION_PATH = DEFAULT_ROOT_PATH+File.separatorChar+DESTINATION_FOLDER;
private static final String DISTRIBUTION_FOLDER = "dist";
private static final String DISTRIBUTION_PATH = DEFAULT_ROOT_PATH+File.separatorChar+DISTRIBUTION_FOLDER;
- private static final String INDEXING_PROERTIES = "indexing.properties";
+ private static final String INDEXING_PROPERTIES = "indexing.properties";
private static final String CONFIG_PARAM = "config";
public static final String KEY_INDEXING_CONFIG = "indexingConfig";
@@ -135,7 +135,7 @@ public class IndexingConfig {
// private final Map<File,File> canonicalDirs = new HashMap<File,File>();
/**
- * The main indexing configuration as parsed form {@link #INDEXING_PROERTIES}
+ * The main indexing configuration as parsed form {@link #INDEXING_PROPERTIES}
* file within the {@link #configDir}.
*/
private final Map<String,Object> configuration;
@@ -318,16 +318,16 @@ public class IndexingConfig {
}
//check the main configuration
- this.configuration = loadConfig(INDEXING_PROERTIES,true);
+ this.configuration = loadConfig(INDEXING_PROPERTIES,true);
Object value = configuration.get(KEY_NAME);
if(value == null){
throw new IllegalArgumentException("Indexing Configuration '"+
- INDEXING_PROERTIES+"' is missing the required key "+KEY_NAME+"!");
+ INDEXING_PROPERTIES+"' is missing the required key "+KEY_NAME+"!");
}
this.name = value.toString();
if(name.isEmpty()){
throw new IllegalArgumentException("Invalid Indexing Configuration '"+
- INDEXING_PROERTIES+"': The value for the parameter"+KEY_NAME+" MUST NOT be empty!");
+ INDEXING_PROPERTIES+"': The value for the parameter"+KEY_NAME+" MUST NOT be empty!");
}
value = configuration.get(KEY_INDEX_FIELD_CONFIG);
if(value == null || value.toString().isEmpty()){
@@ -360,7 +360,7 @@ public class IndexingConfig {
throw new IllegalArgumentException("Invalid Indexing Configuration: " +
"IndexFieldConfiguration '"+indexFieldConfig+"' not found. " +
"Provide the missing file or use the '"+KEY_INDEX_FIELD_CONFIG+
- "' in the '"+INDEXING_PROERTIES+"' to configure a different one!");
+ "' in the '"+INDEXING_PROPERTIES+"' to configure a different one!");
}
}
@@ -594,9 +594,9 @@ public class IndexingConfig {
String contextResource;
if(classpathResourceOffset != null){
contextResource = FilenameUtils.concat(classpathResourceOffset,
- CONFIG_PATH+File.separatorChar+INDEXING_PROERTIES);
+ CONFIG_PATH+File.separatorChar+INDEXING_PROPERTIES);
} else {
- contextResource = CONFIG_PATH+File.separatorChar+INDEXING_PROERTIES;
+ contextResource = CONFIG_PATH+File.separatorChar+INDEXING_PROPERTIES;
}
URL contextUrl = loadViaClasspath(contextResource);
if(contextUrl == null){// if indexing.properties is not found via classpath
@@ -784,6 +784,20 @@ public class IndexingConfig {
return value != null?value.toString():null;
}
/**
+ * Getter for the failOnError as configured by the {@link IndexingConstants#KEY_FAIL_ON_ERROR_LOADING_RESOURCE}
+ * by the main indexing configuration.
+ * @return the boolean value of the failOnError parameter
+ */
+ public boolean isFailOnError(){
+ //by default failOnError is false to continue execution of the indexing tool
+ boolean failOnError = false;
+ Object value = configuration.get(IndexingConstants.KEY_FAIL_ON_ERROR_LOADING_RESOURCE);
+ if(value != null && !value.toString().isEmpty()){
+ failOnError = Boolean.parseBoolean(value.toString());
+ }
+ return failOnError;
+ }
+ /**
* The {@link ScoreNormaliser} as configured by the {@link IndexingConstants#KEY_SCORE_NORMALIZER}
* by the main indexing configuration.
* @return the configured {@link ScoreNormaliser} or a {@link DefaultNormaliser} if
Modified: stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/config/IndexingConstants.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/config/IndexingConstants.java?rev=1503636&r1=1503635&r2=1503636&view=diff
==============================================================================
--- stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/config/IndexingConstants.java (original)
+++ stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/config/IndexingConstants.java Tue Jul 16 09:43:52 2013
@@ -49,4 +49,6 @@ public interface IndexingConstants {
String KEY_SCORE_NORMALIZER = "scoreNormalizer";
String KEY_ENTITY_PROCESSOR = "entityProcessor";
String KEY_ENTITY_POST_PROCESSOR = "entityPostProcessor";
+ String KEY_FAIL_ON_ERROR_LOADING_RESOURCE = "failOnErrorLoadingResource";
+
}
Modified: stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/source/ResourceLoader.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/source/ResourceLoader.java?rev=1503636&r1=1503635&r2=1503636&view=diff
==============================================================================
--- stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/source/ResourceLoader.java (original)
+++ stanbol/trunk/entityhub/indexing/core/src/main/java/org/apache/stanbol/entityhub/indexing/core/source/ResourceLoader.java Tue Jul 16 09:43:52 2013
@@ -293,16 +293,20 @@ public class ResourceLoader {
} else { //this does not use an imported folder or the state is not LOADED
files.put(file, state);
}
- //if failOnError is activated we stop the loading on the first
- //error!
- if(failOnError && ResourceState.ERROR == state){
- String msg = "Error while loading Resource "+file;
- if(e != null){
- throw new IllegalStateException(msg,e);
- } else {
- throw new IllegalStateException(msg);
- }
- }
+ if(ResourceState.ERROR == state){
+ //if failOnError is activated we stop the loading on the first error!
+ if (failOnError){
+ String msg = "Error while loading Resource "+file;
+ if(e != null){
+ throw new IllegalStateException(msg,e);
+ } else {
+ throw new IllegalStateException(msg);
+ }
+ }else {
+ //if failOnError is de-activated ignore the resource loading error and continue..
+ log.info("Ignore Error for File {} and continue", file);
+ }
+ }
} else {
log.info("Ignore Error for File {} because it is no longer registered with this RdfLoader",
file);
Modified: stanbol/trunk/entityhub/indexing/core/src/test/java/org/apache/stanbol/entityhub/indexing/core/ResourceLoaderTest.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/indexing/core/src/test/java/org/apache/stanbol/entityhub/indexing/core/ResourceLoaderTest.java?rev=1503636&r1=1503635&r2=1503636&view=diff
==============================================================================
--- stanbol/trunk/entityhub/indexing/core/src/test/java/org/apache/stanbol/entityhub/indexing/core/ResourceLoaderTest.java (original)
+++ stanbol/trunk/entityhub/indexing/core/src/test/java/org/apache/stanbol/entityhub/indexing/core/ResourceLoaderTest.java Tue Jul 16 09:43:52 2013
@@ -111,6 +111,13 @@ public class ResourceLoaderTest {
importer.checkAllProcessed();
}
+
+ @Test
+ public void testFailOnError(){
+ assertTrue(isFailedOnError(true));
+ assertFalse(isFailedOnError(false));
+ }
+
@Test
public void testFolderWithoutProcessingArchives(){
String folder = rootDir+TEST_FOLDER_NAME;
@@ -190,4 +197,19 @@ public class ResourceLoaderTest {
folder+"ignoreFileInFolder.txt")),
loader.getResources(ResourceState.IGNORED));
}
+
+ private boolean isFailedOnError(boolean failOnError){
+ String folder = rootDir + TEST_FOLDER_NAME;
+ boolean failed = false;
+ DummyResourceImporter importer = new DummyResourceImporter(
+ Arrays.asList(folder + "errorFileInFolder.txt"));
+ ResourceLoader loader = new ResourceLoader(importer, false, failOnError);
+ loader.addResource(new File(folder, "errorFileInFolder.txt"));
+ try {
+ loader.loadResources();
+ } catch (IllegalStateException ex) {
+ failed = true;
+ }
+ return failed;
+ }
}