lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From no...@apache.org
Subject svn commit: r882838 - in /lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport: ContextImpl.java ScriptTransformer.java
Date Sat, 21 Nov 2009 07:38:53 GMT
Author: noble
Date: Sat Nov 21 07:38:51 2009
New Revision: 882838

URL: http://svn.apache.org/viewvc?rev=882838&view=rev
Log:
SOLR-1522

Modified:
    lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/ContextImpl.java
    lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/ScriptTransformer.java

Modified: lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/ContextImpl.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/ContextImpl.java?rev=882838&r1=882837&r2=882838&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/ContextImpl.java
(original)
+++ lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/ContextImpl.java
Sat Nov 21 07:38:51 2009
@@ -89,6 +89,7 @@
 
   public DataSource getDataSource() {
     if (ds != null) return ds;
+    if(entity == null) return  null;
     if (entity.dataSrc == null) {
       entity.dataSrc = dataImporter.getDataSourceInstance(entity, entity.dataSource, this);
     }

Modified: lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/ScriptTransformer.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/ScriptTransformer.java?rev=882838&r1=882837&r2=882838&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/ScriptTransformer.java
(original)
+++ lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/ScriptTransformer.java
Sat Nov 21 07:38:51 2009
@@ -16,6 +16,9 @@
  */
 package org.apache.solr.handler.dataimport;
 
+import static org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow;
+import static org.apache.solr.handler.dataimport.DataImportHandlerException.SEVERE;
+
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.Map;
@@ -55,24 +58,27 @@
     } catch (DataImportHandlerException e) {
       throw e;
     } catch (InvocationTargetException e) {
-      throw new DataImportHandlerException(DataImportHandlerException.SEVERE,
+      wrapAndThrow(SEVERE,e,
               "Could not invoke method :"
                       + functionName
                       + "\n <script>\n"
-                      + context.getVariableResolver().resolve(
-                      DataConfig.IMPORTER_NS + "." + DataConfig.SCRIPT)
-                      + "</script>", e);
+                      + context.getScript()
+                      + "</script>");
     } catch (Exception e) {
-      throw new DataImportHandlerException(DataImportHandlerException.SEVERE,
-              "Error invoking script for entity "
-                      + context.getEntityAttribute("name"), e);
+      wrapAndThrow(SEVERE,e, "Error invoking script for entity " + context.getEntityAttribute("name"));
     }
+    //will not reach here
+    return null;
   }
 
   private void initEngine(Context context) {
     try {
       String scriptText = context.getScript();
       String scriptLang = context.getScriptLanguage();
+      if(scriptText == null ){
+        throw new DataImportHandlerException(SEVERE,
+              "<script> tag is not present under <dataConfig>");
+      }
       Object scriptEngineMgr = Class
               .forName("javax.script.ScriptEngineManager").newInstance();
       // create a Script engine
@@ -84,8 +90,7 @@
               String.class, Object[].class);
       evalMethod.invoke(engine, scriptText);
     } catch (Exception e) {
-      throw new DataImportHandlerException(DataImportHandlerException.SEVERE,
-              "<script> can be used only in java 6 or above", e);
+      wrapAndThrow(SEVERE,e, "<script> can be used only in java 6 or above");
     }
   }
 



Mime
View raw message