[hibernate-commits] Hibernate SVN: r20807 - in search/trunk/hibernate-search/src/main/java/org/hibernate/search: engine and 1 other directory.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Mon Oct 11 14:22:20 EDT 2010
Author: epbernard
Date: 2010-10-11 14:22:20 -0400 (Mon, 11 Oct 2010)
New Revision: 20807
Added:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/bridge/util/ContextualException2WayBridge.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/bridge/util/ContextualExceptionBridge.java
Removed:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/bridge/util/ExceptionWrapper2WayBridge.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/bridge/util/ExceptionWrapperBridge.java
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java
Log:
HSEARCH-575 Better error report on bridge failure
Rename bridge wrapper
Copied: search/trunk/hibernate-search/src/main/java/org/hibernate/search/bridge/util/ContextualException2WayBridge.java (from rev 20806, search/trunk/hibernate-search/src/main/java/org/hibernate/search/bridge/util/ExceptionWrapper2WayBridge.java)
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/bridge/util/ContextualException2WayBridge.java (rev 0)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/bridge/util/ContextualException2WayBridge.java 2010-10-11 18:22:20 UTC (rev 20807)
@@ -0,0 +1,57 @@
+package org.hibernate.search.bridge.util;
+
+import org.apache.lucene.document.Document;
+import org.hibernate.search.bridge.TwoWayFieldBridge;
+
+/**
+ * Wrap the exception with an exception provide contextual feedback
+ *
+ * @author Emmanuel Bernard
+ */
+public class ContextualException2WayBridge extends ContextualExceptionBridge implements TwoWayFieldBridge {
+ private TwoWayFieldBridge delegate;
+
+ public ContextualException2WayBridge setFieldBridge(TwoWayFieldBridge delegate) {
+ super.setFieldBridge(delegate);
+ this.delegate = delegate;
+ return this;
+ }
+
+ public ContextualException2WayBridge setClass(Class<?> clazz) {
+ super.setClass(clazz);
+ return this;
+ }
+
+ public ContextualException2WayBridge setFieldName(String fieldName) {
+ super.setFieldName(fieldName);
+ return this;
+ }
+
+ public Object get(String name, Document document) {
+ try {
+ return delegate.get(name, document);
+ }
+ catch (Exception e) {
+ throw buildBridgeException(e, "get");
+ }
+ }
+
+ public String objectToString(Object object) {
+ try {
+ return delegate.objectToString(object);
+ }
+ catch (Exception e) {
+ throw buildBridgeException(e, "objectToString");
+ }
+ }
+
+ public ContextualException2WayBridge pushMethod(String name) {
+ super.pushMethod(name);
+ return this;
+ }
+
+ public ContextualException2WayBridge popMethod() {
+ super.popMethod();
+ return this;
+ }
+}
Copied: search/trunk/hibernate-search/src/main/java/org/hibernate/search/bridge/util/ContextualExceptionBridge.java (from rev 20806, search/trunk/hibernate-search/src/main/java/org/hibernate/search/bridge/util/ExceptionWrapperBridge.java)
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/bridge/util/ContextualExceptionBridge.java (rev 0)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/bridge/util/ContextualExceptionBridge.java 2010-10-11 18:22:20 UTC (rev 20807)
@@ -0,0 +1,74 @@
+package org.hibernate.search.bridge.util;
+
+import org.apache.lucene.document.Document;
+import org.hibernate.search.bridge.BridgeException;
+import org.hibernate.search.bridge.FieldBridge;
+import org.hibernate.search.bridge.LuceneOptions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Wrap the exception with an exception provide contextual feedback
+ *
+ * @author Emmanuel Bernard
+ */
+public class ContextualExceptionBridge implements FieldBridge {
+ private FieldBridge delegate;
+ protected Class<?> clazz;
+ protected List<String> path = new ArrayList<String>(5);
+ protected String fieldName;
+
+ public ContextualExceptionBridge setFieldBridge(FieldBridge delegate) {
+ this.delegate = delegate;
+ return this;
+ }
+
+ public ContextualExceptionBridge setClass(Class<?> clazz) {
+ this.clazz = clazz;
+ return this;
+ }
+
+ public ContextualExceptionBridge setFieldName(String fieldName) {
+ this.fieldName = fieldName;
+ return this;
+ }
+
+ protected BridgeException buildBridgeException(Exception e, String method) {
+ StringBuilder error = new StringBuilder("Exception while calling bridge#");
+ error.append(method);
+ if ( clazz != null ) {
+ error.append("\n\tclass: ").append( clazz.getName() );
+ }
+ if ( path.size() > 0 ) {
+ error.append("\n\tpath: ");
+ for(String pathNode : path) {
+ error.append(pathNode).append(".");
+ }
+ error.deleteCharAt( error.length() - 1 );
+ }
+ if ( fieldName != null ) {
+ error.append("\n\tfield bridge: ").append(fieldName);
+ }
+ throw new BridgeException(error.toString(), e);
+ }
+
+ public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
+ try {
+ delegate.set(name, value, document, luceneOptions);
+ }
+ catch (Exception e) {
+ throw buildBridgeException(e, "set");
+ }
+ }
+
+ public ContextualExceptionBridge pushMethod(String name) {
+ path.add(name);
+ return this;
+ }
+
+ public ContextualExceptionBridge popMethod() {
+ path.remove( path.size() - 1 );
+ return this;
+ }
+}
Deleted: search/trunk/hibernate-search/src/main/java/org/hibernate/search/bridge/util/ExceptionWrapper2WayBridge.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/bridge/util/ExceptionWrapper2WayBridge.java 2010-10-11 18:21:28 UTC (rev 20806)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/bridge/util/ExceptionWrapper2WayBridge.java 2010-10-11 18:22:20 UTC (rev 20807)
@@ -1,57 +0,0 @@
-package org.hibernate.search.bridge.util;
-
-import org.apache.lucene.document.Document;
-import org.hibernate.search.bridge.TwoWayFieldBridge;
-
-/**
- * Wrap the exception with an exception provide contextual feedback
- *
- * @author Emmanuel Bernard
- */
-public class ExceptionWrapper2WayBridge extends ExceptionWrapperBridge implements TwoWayFieldBridge {
- private TwoWayFieldBridge delegate;
-
- public ExceptionWrapper2WayBridge setFieldBridge(TwoWayFieldBridge delegate) {
- super.setFieldBridge(delegate);
- this.delegate = delegate;
- return this;
- }
-
- public ExceptionWrapper2WayBridge setClass(Class<?> clazz) {
- super.setClass(clazz);
- return this;
- }
-
- public ExceptionWrapper2WayBridge setFieldName(String fieldName) {
- super.setFieldName(fieldName);
- return this;
- }
-
- public Object get(String name, Document document) {
- try {
- return delegate.get(name, document);
- }
- catch (Exception e) {
- throw buildBridgeException(e, "get");
- }
- }
-
- public String objectToString(Object object) {
- try {
- return delegate.objectToString(object);
- }
- catch (Exception e) {
- throw buildBridgeException(e, "objectToString");
- }
- }
-
- public ExceptionWrapper2WayBridge pushMethod(String name) {
- super.pushMethod(name);
- return this;
- }
-
- public ExceptionWrapper2WayBridge popMethod() {
- super.popMethod();
- return this;
- }
-}
Deleted: search/trunk/hibernate-search/src/main/java/org/hibernate/search/bridge/util/ExceptionWrapperBridge.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/bridge/util/ExceptionWrapperBridge.java 2010-10-11 18:21:28 UTC (rev 20806)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/bridge/util/ExceptionWrapperBridge.java 2010-10-11 18:22:20 UTC (rev 20807)
@@ -1,76 +0,0 @@
-package org.hibernate.search.bridge.util;
-
-import org.apache.lucene.document.Document;
-import org.hibernate.search.bridge.BridgeException;
-import org.hibernate.search.bridge.FieldBridge;
-import org.hibernate.search.bridge.LuceneOptions;
-import org.hibernate.search.bridge.TwoWayFieldBridge;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Stack;
-
-/**
- * Wrap the exception with an exception provide contextual feedback
- *
- * @author Emmanuel Bernard
- */
-public class ExceptionWrapperBridge implements FieldBridge {
- private FieldBridge delegate;
- protected Class<?> clazz;
- protected List<String> path = new ArrayList<String>(5);
- protected String fieldName;
-
- public ExceptionWrapperBridge setFieldBridge(FieldBridge delegate) {
- this.delegate = delegate;
- return this;
- }
-
- public ExceptionWrapperBridge setClass(Class<?> clazz) {
- this.clazz = clazz;
- return this;
- }
-
- public ExceptionWrapperBridge setFieldName(String fieldName) {
- this.fieldName = fieldName;
- return this;
- }
-
- protected BridgeException buildBridgeException(Exception e, String method) {
- StringBuilder error = new StringBuilder("Exception while calling bridge#");
- error.append(method);
- if ( clazz != null ) {
- error.append("\n\tclass: ").append( clazz.getName() );
- }
- if ( path.size() > 0 ) {
- error.append("\n\tpath: ");
- for(String pathNode : path) {
- error.append(pathNode).append(".");
- }
- error.deleteCharAt( error.length() - 1 );
- }
- if ( fieldName != null ) {
- error.append("\n\tfield bridge: ").append(fieldName);
- }
- throw new BridgeException(error.toString(), e);
- }
-
- public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
- try {
- delegate.set(name, value, document, luceneOptions);
- }
- catch (Exception e) {
- throw buildBridgeException(e, "set");
- }
- }
-
- public ExceptionWrapperBridge pushMethod(String name) {
- path.add(name);
- return this;
- }
-
- public ExceptionWrapperBridge popMethod() {
- path.remove( path.size() - 1 );
- return this;
- }
-}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java 2010-10-11 18:21:28 UTC (rev 20806)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java 2010-10-11 18:22:20 UTC (rev 20807)
@@ -40,8 +40,8 @@
import org.apache.lucene.document.Field;
import org.apache.lucene.document.Fieldable;
import org.apache.lucene.index.Term;
-import org.hibernate.search.bridge.util.ExceptionWrapper2WayBridge;
-import org.hibernate.search.bridge.util.ExceptionWrapperBridge;
+import org.hibernate.search.bridge.util.ContextualException2WayBridge;
+import org.hibernate.search.bridge.util.ContextualExceptionBridge;
import org.slf4j.Logger;
import org.hibernate.annotations.common.AssertionFailure;
@@ -413,7 +413,7 @@
Store.YES,
Field.Index.NOT_ANALYZED_NO_NORMS, Field.TermVector.NO, idBoost
);
- final ExceptionWrapperBridge contextualBridge = new ExceptionWrapperBridge()
+ final ContextualExceptionBridge contextualBridge = new ContextualExceptionBridge()
.setFieldBridge(idBridge)
.setClass(entityType)
.setFieldName(idKeywordName);
@@ -436,7 +436,7 @@
PropertiesMetadata propertiesMetadata,
Map<String, String> fieldToAnalyzerMap,
Set<String> processedFieldNames,
- ExceptionWrapperBridge contextualBridge) {
+ ContextualExceptionBridge contextualBridge) {
if ( instance == null ) {
return;
}
@@ -638,7 +638,7 @@
final TwoWayFieldBridge fieldBridge = builderIndexedEntity.getIdBridge();
final String fieldName = builderIndexedEntity.getIdKeywordName();
- ExceptionWrapper2WayBridge contextualBridge = new ExceptionWrapper2WayBridge();
+ ContextualException2WayBridge contextualBridge = new ContextualException2WayBridge();
contextualBridge
.setClass(clazz)
.setFieldName(fieldName)
@@ -666,7 +666,7 @@
}
final int fieldNbr = fields.length;
Object[] result = new Object[fieldNbr];
- ExceptionWrapper2WayBridge contextualBridge = new ExceptionWrapper2WayBridge();
+ ContextualException2WayBridge contextualBridge = new ContextualException2WayBridge();
contextualBridge.setClass(clazz);
if ( builderIndexedEntity.idKeywordName != null ) {
final XMember member = builderIndexedEntity.idGetter;
@@ -693,7 +693,7 @@
}
private static void populateResult(String fieldName, FieldBridge fieldBridge, Store store,
- String[] fields, Object[] result, Document document, ExceptionWrapper2WayBridge contextualBridge) {
+ String[] fields, Object[] result, Document document, ContextualException2WayBridge contextualBridge) {
int matchingPosition = getFieldPosition( fields, fieldName );
if ( matchingPosition != -1 ) {
//TODO make use of an isTwoWay() method
@@ -715,7 +715,7 @@
}
}
- private static void processFieldsForProjection(PropertiesMetadata metadata, String[] fields, Object[] result, Document document, ExceptionWrapper2WayBridge contextualBridge) {
+ private static void processFieldsForProjection(PropertiesMetadata metadata, String[] fields, Object[] result, Document document, ContextualException2WayBridge contextualBridge) {
//process base fields
final int nbrFoEntityFields = metadata.fieldNames.size();
for ( int index = 0; index < nbrFoEntityFields; index++ ) {
More information about the hibernate-commits
mailing list