You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2007/11/29 12:35:52 UTC

svn commit: r599391 - /lenya/trunk/src/modules/lucene/java/src/org/apache/cocoon/transformation/LuceneIndexTransformer2.java

Author: andreas
Date: Thu Nov 29 03:35:51 2007
New Revision: 599391

URL: http://svn.apache.org/viewvc?rev=599391&view=rev
Log:
Improved error notification of lucene index transformer.

Modified:
    lenya/trunk/src/modules/lucene/java/src/org/apache/cocoon/transformation/LuceneIndexTransformer2.java

Modified: lenya/trunk/src/modules/lucene/java/src/org/apache/cocoon/transformation/LuceneIndexTransformer2.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/lucene/java/src/org/apache/cocoon/transformation/LuceneIndexTransformer2.java?rev=599391&r1=599390&r2=599391&view=diff
==============================================================================
--- lenya/trunk/src/modules/lucene/java/src/org/apache/cocoon/transformation/LuceneIndexTransformer2.java (original)
+++ lenya/trunk/src/modules/lucene/java/src/org/apache/cocoon/transformation/LuceneIndexTransformer2.java Thu Nov 29 03:35:51 2007
@@ -40,7 +40,6 @@
 import org.apache.lenya.ac.Identifiable;
 import org.apache.lenya.ac.User;
 import org.apache.lenya.ac.UserManager;
-import org.apache.lenya.cms.repository.RepositoryException;
 import org.apache.lenya.cms.repository.RepositoryUtil;
 import org.apache.lenya.cms.repository.Session;
 import org.apache.lenya.notification.Message;
@@ -317,7 +316,7 @@
                     processing = DELETE_PROCESS;
                     super.startElement(namespaceURI, localName, qName, attrs);
                 } else {
-                    handleError("element " + localName + " unknown ");
+                    handleError("element " + localName + " unknown");
                 }
                 break;
 
@@ -336,7 +335,7 @@
                     processing = IN_DOCUMENT_PROCESS;
                 } else {
                     handleError("element " + localName + " is not allowed in  <" + LUCENE_PREXIF
-                            + ":" + LUCENE_DOCUMENT_ELEMENT + "> element ");
+                            + ":" + LUCENE_DOCUMENT_ELEMENT + "> element");
                 }
                 break;
 
@@ -351,7 +350,7 @@
                     }
                     processing = DELETING_PROCESS;
                 } else {
-                    handleError("element " + localName + " is not a <lucene:document> element ");
+                    handleError("element " + localName + " is not a <lucene:document> element");
                 }
                 break;
 
@@ -480,7 +479,7 @@
                 break;
 
             default:
-                handleError("unknow element " + LUCENE_FIELD_ELEMENT + " !");
+                handleError("unknow element '" + LUCENE_FIELD_ELEMENT + "'!");
             }
         } else {
             super.endElement(namespaceURI, localName, qName);
@@ -522,15 +521,15 @@
             IndexManager indexM = (IndexManager) manager.lookup(IndexManager.ROLE);
             index = indexM.getIndex(id);
             if (index == null) {
-                handleError("index id: " + id + " no found in the index definition");
+                handleError("index [" + id + "] no found in the index definition");
             }
             indexer = index.getIndexer();
             manager.release(indexM);
         } catch (ServiceException ex1) {
-            handleError("service Exception", ex1);
+            handleError(ex1);
 
         } catch (IndexException ex3) {
-            handleError(" get Indexer error for index " + id, ex3);
+            handleError("get Indexer error for index [" + id + "]", ex3);
         }
 
         // set a custum analyzer (default: the analyzer of the index)
@@ -542,9 +541,9 @@
                 indexer.setAnalyzer(analyzer);
                 manager.release(analyzerM);
             } catch (ServiceException ex1) {
-                handleError("service Exception", ex1);
+                handleError(ex1);
             } catch (ConfigurationException ex2) {
-                this.handleError("set analyzer error for index" + id, ex2);
+                handleError("error setting analyzer for index [" + id + "]", ex2);
             }
         } else {
 
@@ -560,7 +559,7 @@
                 try {
                     indexer.clearIndex();
                 } catch (IndexException ex3) {
-                    handleError(" clear index error ", ex3);
+                    handleError("error clearing index", ex3);
                 }
             }
 
@@ -577,13 +576,19 @@
             }
         }
     }
-
-    void handleError(String msg) throws SAXException {
-        this.handleError(msg, new Exception());
+    
+    void handleError(String message, Exception ex) throws SAXException {
+        handleError(message + ": " + getExceptionMessage(ex));
     }
 
     void handleError(Exception ex) throws SAXException {
-        this.handleError("", ex);
+        handleError(getExceptionMessage(ex));
+    }
+
+    protected String getExceptionMessage(Exception ex) throws SAXException {
+        String exMsg = ex.getMessage();
+        String msg = exMsg == null ? "" : " (" + exMsg + ")";
+        return ex.getClass().getName() + msg;
     }
 
     /**
@@ -593,7 +598,7 @@
      * @param ex
      * @throws SAXException
      */
-    void handleError(String msg, Exception ex) throws SAXException {
+    void handleError(String msg) throws SAXException {
         closeIndexer();
 
         try {
@@ -606,8 +611,7 @@
             String subject = "indexing-failed-subject";
             String[] subjectParams = new String[0];
             String body = "indexing-failed-body";
-            String[] bodyParams = { this.pubId, this.area, this.uuid, this.language,
-                    ex.getMessage() };
+            String[] bodyParams = { this.pubId, this.area, this.uuid, this.language, msg };
 
             Message message = new Message(subject, subjectParams, body, bodyParams, sender,
                     recipients);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org