You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2013/02/08 17:04:46 UTC

svn commit: r1444089 - in /manifoldcf/branches/release-1.1-branch: ./ connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/

Author: kwright
Date: Fri Feb  8 16:04:46 2013
New Revision: 1444089

URL: http://svn.apache.org/r1444089
Log:
Pull up fixes for CONNECTORS-606, CONNECTORS-629, CONNECTORS-634, and CONNECTORS-637 from trunk.

Modified:
    manifoldcf/branches/release-1.1-branch/CHANGES.txt
    manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchAction.java
    manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnection.java
    manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnector.java
    manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchDelete.java
    manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java
    manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchSpecs.java

Modified: manifoldcf/branches/release-1.1-branch/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/branches/release-1.1-branch/CHANGES.txt?rev=1444089&r1=1444088&r2=1444089&view=diff
==============================================================================
--- manifoldcf/branches/release-1.1-branch/CHANGES.txt (original)
+++ manifoldcf/branches/release-1.1-branch/CHANGES.txt Fri Feb  8 16:04:46 2013
@@ -3,6 +3,10 @@ $Id$
 
 ======================= Release 1.1.1 =====================
 
+CONNECTORS-606, CONNECTORS-629, CONNECTORS-634, CONNECTORS-637:
+Bring ElasticSearch connector up to spec.
+(Karl Wright)
+
 CONNECTORS-639: Maven execute of jetty-runner fails.
 (Maciej Li¿ewski)
 

Modified: manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchAction.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchAction.java?rev=1444089&r1=1444088&r2=1444089&view=diff
==============================================================================
--- manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchAction.java (original)
+++ manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchAction.java Fri Feb  8 16:04:46 2013
@@ -23,6 +23,7 @@ import org.apache.http.client.methods.Ht
 import org.apache.http.client.HttpClient;
 
 import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
+import org.apache.manifoldcf.agents.interfaces.ServiceInterruption;
 
 public class ElasticSearchAction extends ElasticSearchConnection
 {
@@ -32,10 +33,15 @@ public class ElasticSearchAction extends
     _optimize, _refresh, _status;
   }
 
-  public ElasticSearchAction(HttpClient client, CommandEnum cmd, ElasticSearchConfig config, boolean checkConnection)
+  public ElasticSearchAction(HttpClient client, ElasticSearchConfig config)
       throws ManifoldCFException
   {
     super(config, client);
+  }
+  
+  public void execute(CommandEnum cmd, boolean checkConnection)
+      throws ManifoldCFException, ServiceInterruption
+  {
     StringBuffer url = getApiUrl(cmd.toString(), checkConnection);
     HttpGet method = new HttpGet(url.toString());
     call(method);

Modified: manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnection.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnection.java?rev=1444089&r1=1444088&r2=1444089&view=diff
==============================================================================
--- manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnection.java (original)
+++ manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnection.java Fri Feb  8 16:04:46 2013
@@ -26,6 +26,7 @@ import java.io.StringWriter;
 import java.io.Reader;
 import java.io.InputStreamReader;
 import java.io.InputStream;
+import java.io.InterruptedIOException;
 import java.net.URLEncoder;
 
 import org.apache.http.conn.ClientConnectionManager;
@@ -55,9 +56,12 @@ import org.apache.http.HttpException;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
+import org.apache.manifoldcf.agents.interfaces.ServiceInterruption;
 
 public class ElasticSearchConnection
 {
+  protected ElasticSearchConfig config;
+  
   private HttpClient client;
   
   private String serverLocation;
@@ -82,6 +86,7 @@ public class ElasticSearchConnection
 
   protected ElasticSearchConnection(ElasticSearchConfig config, HttpClient client)
   {
+    this.config = config;
     this.client = client;
     result = Result.UNKNOWN;
     response = null;
@@ -114,29 +119,167 @@ public class ElasticSearchConnection
     return url;
   }
 
-  protected void call(HttpRequestBase method) throws ManifoldCFException
+  protected static class CallThread extends Thread
+  {
+    protected final HttpClient client;
+    protected final HttpRequestBase method;
+    protected int resultCode = -1;
+    protected String response = null;
+    protected Throwable exception = null;
+    
+    public CallThread(HttpClient client, HttpRequestBase method)
+    {
+      this.client = client;
+      this.method = method;
+      setDaemon(true);
+    }
+    
+    @Override
+    public void run()
+    {
+      try
+      {
+        try
+        {
+          HttpResponse resp = client.execute(method);
+          resultCode = resp.getStatusLine().getStatusCode();
+          response = getResponseBodyAsString(resp.getEntity());
+        }
+        finally
+        {
+          method.abort();
+        }
+      }
+      catch (java.net.SocketTimeoutException e)
+      {
+        exception = e;
+      }
+      catch (InterruptedIOException e)
+      {
+        // Just exit
+      }
+      catch (Throwable e)
+      {
+        exception = e;
+      }
+    }
+    
+    public int getResultCode()
+    {
+      return resultCode;
+    }
+    
+    public String getResponse()
+    {
+      return response;
+    }
+    
+    public Throwable getException()
+    {
+      return exception;
+    }
+  }
+  
+  /** Call ElasticSearch.
+  *@return false if there was a "rejection".
+  */
+  protected boolean call(HttpRequestBase method)
+    throws ManifoldCFException, ServiceInterruption
   {
+    CallThread ct = new CallThread(client, method);
     try
     {
-      HttpResponse resp = client.execute(method);
-      if (!checkResultCode(resp.getStatusLine().getStatusCode()))
-        throw new ManifoldCFException(getResultDescription());
-      response = getResponseBodyAsString(resp.getEntity());
-    } catch (HttpException e)
+      ct.start();
+      try
+      {
+        ct.join();
+        Throwable t = ct.getException();
+        if (t != null)
+        {
+          if (t instanceof HttpException)
+            throw (HttpException)t;
+          else if (t instanceof IOException)
+            throw (IOException)t;
+          else if (t instanceof RuntimeException)
+            throw (RuntimeException)t;
+          else if (t instanceof Error)
+            throw (Error)t;
+          else
+            throw new RuntimeException("Unexpected exception thrown: "+t.getMessage(),t);
+        }
+        
+        response = ct.getResponse();
+        return handleResultCode(ct.getResultCode(), response);
+      }
+      catch (InterruptedException e)
+      {
+        ct.interrupt();
+        throw new ManifoldCFException("Interrupted: "+e.getMessage(),e,ManifoldCFException.INTERRUPTED);
+      }
+    }
+    catch (HttpException e)
     {
-      setResult(Result.ERROR, e.getMessage());
-      throw new ManifoldCFException(e);
-    } catch (IOException e)
+      handleHttpException(e);
+      return false;
+    }
+    catch (IOException e)
     {
-      setResult(Result.ERROR, e.getMessage());
-      throw new ManifoldCFException(e);
-    } finally
+      handleIOException(e);
+      return false;
+    }
+  }
+
+  private boolean handleResultCode(int code, String response)
+    throws ManifoldCFException, ServiceInterruption
+  {
+    if (code == 200 || code == 201)
+    {
+      setResult(Result.OK, null);
+      return true;
+    }
+    else if (code == 404)
     {
-      if (method != null)
-        method.abort();
+      setResult(Result.ERROR, response);
+      throw new ManifoldCFException("Server/page not found");
     }
+    else if (code >= 400 && code < 500)
+    {
+      setResult(Result.ERROR, response);
+      return false;
+    }
+    else if (code >= 500 && code < 600)
+    {
+      setResult(Result.ERROR, "Server exception: "+response);
+      long currentTime = System.currentTimeMillis();
+      throw new ServiceInterruption("Server exception: "+response,
+        new ManifoldCFException(response),
+        currentTime + 300000L,
+        currentTime + 20L * 60000L,
+        -1,
+        false);
+    }
+    setResult(Result.UNKNOWN, response);
+    throw new ManifoldCFException("Unexpected HTTP result code: "+code+": "+response);
   }
 
+  private void handleHttpException(HttpException e)
+    throws ManifoldCFException, ServiceInterruption {
+    setResult(Result.ERROR, e.getMessage());
+    throw new ManifoldCFException(e);
+  }
+  
+  private void handleIOException(IOException e)
+    throws ManifoldCFException, ServiceInterruption {
+    setResult(Result.ERROR, e.getMessage());
+    long currentTime = System.currentTimeMillis();
+    // All IO exceptions are treated as service interruptions, retried for an hour
+    throw new ServiceInterruption("IO exception: "+e.getMessage(),e,
+        currentTime + 60000L,
+        currentTime + 1L * 60L * 60000L,
+        -1,
+        true);
+  }
+    
   private static String getResponseBodyAsString(HttpEntity entity)
     throws IOException, HttpException {
     InputStream is = entity.getContent();
@@ -207,24 +350,6 @@ public class ElasticSearchConnection
     return response;
   }
 
-  private boolean checkResultCode(int code)
-  {
-    switch (code)
-    {
-    case 0:
-      setResult(Result.UNKNOWN, null);
-      return false;
-    case 200:
-      setResult(Result.OK, null);
-      return true;
-    case 404:
-      setResult(Result.ERROR, "Server/page not found");
-      return false;
-    default:
-      setResult(Result.ERROR, null);
-      return false;
-    }
-  }
 
   public Result getResult()
   {

Modified: manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnector.java?rev=1444089&r1=1444088&r2=1444089&view=diff
==============================================================================
--- manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnector.java (original)
+++ manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnector.java Fri Feb  8 16:04:46 2013
@@ -25,6 +25,7 @@ import java.io.InputStream;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.http.conn.ClientConnectionManager;
 import org.apache.http.impl.conn.PoolingClientConnectionManager;
@@ -90,10 +91,13 @@ public class ElasticSearchConnector exte
   /** Forward to the template to view the specification parameters for the job */
   private static final String VIEW_SPEC_FORWARD = "viewSpecification.html";
 
+  /** Connection expiration interval */
+  private static final long EXPIRATION_INTERVAL = 60000L;
 
   private ClientConnectionManager connectionManager = null;
   private HttpClient client = null;
-
+  private long expirationTime = -1L;
+  
   public ElasticSearchConnector()
   {
   }
@@ -102,23 +106,44 @@ public class ElasticSearchConnector exte
   public void connect(ConfigParams configParams)
   {
     super.connect(configParams);
-    PoolingClientConnectionManager localConnectionManager = new PoolingClientConnectionManager();
-    localConnectionManager.setMaxTotal(1);
-    connectionManager = localConnectionManager;
-    DefaultHttpClient localClient = new DefaultHttpClient(connectionManager);
-    // No retries
-    localClient.setHttpRequestRetryHandler(new HttpRequestRetryHandler()
-      {
-	public boolean retryRequest(
-	  IOException exception,
-	  int executionCount,
-          HttpContext context)
-	{
-	  return false;
-	}
-     
-      });
-    client = localClient;
+  }
+  
+  protected HttpClient getSession()
+    throws ManifoldCFException
+  {
+    if (client == null)
+    {
+      PoolingClientConnectionManager localConnectionManager = new PoolingClientConnectionManager();
+      localConnectionManager.setMaxTotal(1);
+      connectionManager = localConnectionManager;
+      DefaultHttpClient localClient = new DefaultHttpClient(connectionManager);
+      // No retries
+      localClient.setHttpRequestRetryHandler(new HttpRequestRetryHandler()
+        {
+          public boolean retryRequest(
+            IOException exception,
+            int executionCount,
+            HttpContext context)
+          {
+            return false;
+          }
+       
+        });
+      client = localClient;
+    }
+    expirationTime = System.currentTimeMillis() + EXPIRATION_INTERVAL;
+    return client;
+  }
+
+  protected void closeSession()
+  {
+    if (connectionManager != null)
+    {
+      connectionManager.shutdown();
+      connectionManager = null;
+    }
+    client = null;
+    expirationTime = -1L;
   }
   
   @Override
@@ -126,18 +151,22 @@ public class ElasticSearchConnector exte
     throws ManifoldCFException
   {
     super.disconnect();
-    connectionManager.shutdown();
-    connectionManager = null;
-    client = null;
+    closeSession();
   }
   
+  
   @Override
   public void poll()
     throws ManifoldCFException
   {
     super.poll();
-    // Free idle connections in the pool.
-    // MHL
+    if (connectionManager != null)
+    {
+      if (System.currentTimeMillis() > expirationTime)
+      {
+        closeSession();
+      }
+    }
   }
   
   @Override
@@ -335,17 +364,23 @@ public class ElasticSearchConnector exte
       IOutputAddActivity activities) throws ManifoldCFException,
       ServiceInterruption
   {
+    HttpClient client = getSession();
     ElasticSearchConfig config = getConfigParameters(null);
     InputStream inputStream = document.getBinaryStream();
     long startTime = System.currentTimeMillis();
-    ElasticSearchIndex oi = new ElasticSearchIndex(client, documentURI, 
-        document, inputStream, config);
-    activities.recordActivity(startTime, ELASTICSEARCH_INDEXATION_ACTIVITY,
-      document.getBinaryLength(), documentURI, oi.getResult().name(),
-      oi.getResultDescription());
-    if (oi.getResult() != Result.OK)
-      return DOCUMENTSTATUS_REJECTED;
-    return DOCUMENTSTATUS_ACCEPTED;
+    ElasticSearchIndex oi = new ElasticSearchIndex(client, config);
+    try
+    {
+      oi.execute(documentURI, document, inputStream);
+      if (oi.getResult() != Result.OK)
+        return DOCUMENTSTATUS_REJECTED;
+      return DOCUMENTSTATUS_ACCEPTED;
+    }
+    finally
+    {
+      activities.recordActivity(startTime, ELASTICSEARCH_INDEXATION_ACTIVITY,
+        document.getBinaryLength(), documentURI, oi.getResult().name(), oi.getResultDescription());
+    }
   }
 
   @Override
@@ -353,34 +388,56 @@ public class ElasticSearchConnector exte
       IOutputRemoveActivity activities) throws ManifoldCFException,
       ServiceInterruption
   {
+    HttpClient client = getSession();
     long startTime = System.currentTimeMillis();
-    ElasticSearchDelete od = new ElasticSearchDelete(client, documentURI,
-        getConfigParameters(null));
-    activities.recordActivity(startTime, ELASTICSEARCH_DELETION_ACTIVITY, null,
-        documentURI, od.getResult().name(), od.getResultDescription());
+    ElasticSearchDelete od = new ElasticSearchDelete(client, getConfigParameters(null));
+    try
+    {
+      od.execute(documentURI);
+    }
+    finally
+    {
+      activities.recordActivity(startTime, ELASTICSEARCH_DELETION_ACTIVITY, null,
+          documentURI, od.getResult().name(), od.getResultDescription());
+    }
   }
 
   @Override
   public String check() throws ManifoldCFException
   {
-    ElasticSearchAction oss = new ElasticSearchAction(client, CommandEnum._status,
-      getConfigParameters(null), true);
-    String resultName = oss.getResult().name();
-    if (resultName.equals("OK"))
-      return super.check();
-    return resultName + " " + oss.getResultDescription();
+    HttpClient client = getSession();
+    ElasticSearchAction oss = new ElasticSearchAction(client, getConfigParameters(null));
+    try
+    {
+      oss.execute(CommandEnum._status, true);
+      String resultName = oss.getResult().name();
+      if (resultName.equals("OK"))
+        return super.check();
+      return resultName + " " + oss.getResultDescription();
+    }
+    catch (ServiceInterruption e)
+    {
+      return "Transient exception: "+e.getMessage();
+    }
   }
 
   @Override
   public void noteJobComplete(IOutputNotifyActivity activities)
       throws ManifoldCFException, ServiceInterruption
   {
+    HttpClient client = getSession();
     long startTime = System.currentTimeMillis();
-    ElasticSearchAction oo = new ElasticSearchAction(client, CommandEnum._optimize,
-        getConfigParameters(null), false);
-    activities.recordActivity(startTime, ELASTICSEARCH_OPTIMIZE_ACTIVITY, null,
-        oo.getCallUrlSnippet(), oo.getResult().name(),
-        oo.getResultDescription());
+    ElasticSearchAction oo = new ElasticSearchAction(client, getConfigParameters(null));
+    try
+    {
+      oo.execute(CommandEnum._optimize, false);
+    }
+    finally
+    {
+      activities.recordActivity(startTime, ELASTICSEARCH_OPTIMIZE_ACTIVITY, null,
+          oo.getCallUrlSnippet(), oo.getResult().name(),
+          oo.getResultDescription());
+    }
   }
 
 }

Modified: manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchDelete.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchDelete.java?rev=1444089&r1=1444088&r2=1444089&view=diff
==============================================================================
--- manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchDelete.java (original)
+++ manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchDelete.java Fri Feb  8 16:04:46 2013
@@ -23,14 +23,19 @@ import org.apache.http.client.HttpClient
 import org.apache.http.client.methods.HttpDelete;
 
 import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
+import org.apache.manifoldcf.agents.interfaces.ServiceInterruption;
 
 public class ElasticSearchDelete extends ElasticSearchConnection
 {
 
-  public ElasticSearchDelete(HttpClient client, String documentURI, ElasticSearchConfig config)
-      throws ManifoldCFException
+  public ElasticSearchDelete(HttpClient client, ElasticSearchConfig config)
   {
     super(config, client);
+  }
+  
+  public void execute(String documentURI)
+      throws ManifoldCFException, ServiceInterruption
+  {
     try
     {
       String idField = java.net.URLEncoder.encode(documentURI,"utf-8");

Modified: manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java?rev=1444089&r1=1444088&r2=1444089&view=diff
==============================================================================
--- manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java (original)
+++ manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java Fri Feb  8 16:04:46 2013
@@ -34,6 +34,7 @@ import org.apache.http.Header;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.manifoldcf.agents.interfaces.RepositoryDocument;
+import org.apache.manifoldcf.agents.interfaces.ServiceInterruption;
 import org.apache.manifoldcf.core.common.Base64;
 import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
 import org.apache.manifoldcf.crawler.system.Logging;
@@ -151,11 +152,17 @@ public class ElasticSearchIndex extends 
 
   }
 
-  public ElasticSearchIndex(HttpClient client, String documentURI, RepositoryDocument document, 
-      InputStream inputStream, ElasticSearchConfig config) throws ManifoldCFException
+  public ElasticSearchIndex(HttpClient client, ElasticSearchConfig config)
   {
     super(config, client);
-    
+  }
+  
+  /** Do the indexing.
+  *@return false to indicate that the document was rejected.
+  */
+  public boolean execute(String documentURI, RepositoryDocument document, 
+      InputStream inputStream) throws ManifoldCFException, ServiceInterruption
+  {
     String idField;
     try
     {
@@ -169,12 +176,14 @@ public class ElasticSearchIndex extends 
     StringBuffer url = getApiUrl(config.getIndexType() + "/" + idField, false);
     HttpPut put = new HttpPut(url.toString());
     put.setEntity(new IndexRequestEntity(document, inputStream));
-    call(put);
+    if (call(put) == false)
+      return false;
     if ("true".equals(checkJson(jsonStatus)))
-      return;
+      return true;
     String error = checkJson(jsonException);
     setResult(Result.ERROR, error);
     Logging.connectors.error(getResponse());
+    return true;
   }
 
 }

Modified: manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchSpecs.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchSpecs.java?rev=1444089&r1=1444088&r2=1444089&view=diff
==============================================================================
--- manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchSpecs.java (original)
+++ manifoldcf/branches/release-1.1-branch/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchSpecs.java Fri Feb  8 16:04:46 2013
@@ -156,11 +156,15 @@ public class ElasticSearchSpecs extends 
 
   public boolean checkExtension(String extension)
   {
+    if (extension == null)
+      extension = "";
     return extensionSet.contains(extension);
   }
 
   public boolean checkMimeType(String mimeType)
   {
+    if (mimeType == null)
+      mimeType = "application/unknown";
     return mimeTypeSet.contains(mimeType);
   }
 }