manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1615530 - /manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/
Date Mon, 04 Aug 2014 11:14:32 GMT
Author: kwright
Date: Mon Aug  4 11:14:32 2014
New Revision: 1615530

URL: http://svn.apache.org/r1615530
Log:
Second fix for CONNECTORS-958; committed on behalf of Emmanuel Keller.

Added:
    manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerScheduler.java
  (with props)
Modified:
    manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnection.java
    manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnector.java
    manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerIndex.java

Modified: manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnection.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnection.java?rev=1615530&r1=1615529&r2=1615530&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnection.java
(original)
+++ manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnection.java
Mon Aug  4 11:14:32 2014
@@ -116,6 +116,22 @@ public class OpenSearchServerConnection 
     return url;
   }
 
+  protected StringBuffer getApiUrlV2(String path) throws ManifoldCFException {
+    StringBuffer url = new StringBuffer(serverLocation);
+    if (!serverLocation.endsWith("/"))
+        url.append('/');
+    url.append(path);
+    callUrlSnippet = url.toString();
+    if (userName != null && apiKey != null && userName.length() > 0
+        && apiKey.length() > 0) {
+      url.append("&login=");
+      url.append(URLEncoder.encode(userName));
+      url.append("&key=");
+      url.append(apiKey);
+    }
+    return url;
+  }
+
   protected static class CallThread extends Thread
   {
     protected final HttpClient client;

Modified: manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnector.java?rev=1615530&r1=1615529&r2=1615530&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnector.java
(original)
+++ manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnector.java
Mon Aug  4 11:14:32 2014
@@ -544,12 +544,11 @@ public class OpenSearchServerConnector e
     OpenSearchServerConfig config = getConfigParameters(null);
     String schedulerJob = config.getSchedulerJob();
     if (schedulerJob != null && schedulerJob.trim().length() > 0) {
-      OpenSearchServerAction oo = new OpenSearchServerAction(
-        client,
-        CommandEnum.optimize, getConfigParameters(null));
-        activities.recordActivity(startTime, OPENSEARCHSERVER_SCHEDULER_ACTIVITY,
-          null, oo.getCallUrlSnippet(), oo.getResult().name(),
-          oo.getResultDescription());
+      OpenSearchServerScheduler oo = new OpenSearchServerScheduler(
+        client, getConfigParameters(null), schedulerJob.trim());
+      activities.recordActivity(startTime, OPENSEARCHSERVER_SCHEDULER_ACTIVITY,
+        null, oo.getCallUrlSnippet(), oo.getResult().name(),
+        oo.getResultDescription());
     } 
   }
 

Modified: manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerIndex.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerIndex.java?rev=1615530&r1=1615529&r2=1615530&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerIndex.java
(original)
+++ manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerIndex.java
Mon Aug  4 11:14:32 2014
@@ -86,7 +86,6 @@ public class OpenSearchServerIndex exten
     public void writeTo(OutputStream out)
       throws IOException {
       PrintWriter pw = new PrintWriter(out);
-      boolean bUri = false;
       try
       {
         pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
@@ -99,6 +98,8 @@ public class OpenSearchServerIndex exten
           while (iter.hasNext())
           {
             String fieldName = iter.next();
+            if ("uri".equals(fieldName))
+            	continue;
             Object[] fieldValues = document.getField(fieldName);
             if (fieldValues != null && fieldValues.length > 0)
             {
@@ -108,8 +109,6 @@ public class OpenSearchServerIndex exten
                     values.add(fieldValue.toString());
                 if (!values.isEmpty())
                 {
-                  if ("uri".equals(fieldName))
-                	  bUri = true;
                   pw.print("<field name=\"");
                   pw.print(StringEscapeUtils.escapeXml(fieldName));
                   pw.print("\">");
@@ -124,12 +123,9 @@ public class OpenSearchServerIndex exten
              }
            }
         }
-        if (!bUri)
-        {
-            pw.print("<document><field name=\"uri\"><value>");
-            pw.print(documentURI);        	
-            pw.println("</value>");
-        }
+        pw.print("<field name=\"uri\"><value>");
+        pw.print(documentURI);        	
+        pw.println("</value></field>");
         if (document.getBinaryLength() > 0)
         {
           Base64 base64 = new Base64();

Added: manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerScheduler.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerScheduler.java?rev=1615530&view=auto
==============================================================================
--- manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerScheduler.java
(added)
+++ manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerScheduler.java
Mon Aug  4 11:14:32 2014
@@ -0,0 +1,64 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.manifoldcf.agents.output.opensearchserver;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.HttpEntity;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.Header;
+import org.apache.http.util.EntityUtils;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+
+import org.apache.manifoldcf.agents.interfaces.RepositoryDocument;
+import org.apache.manifoldcf.core.common.Base64;
+import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
+import org.apache.manifoldcf.core.util.URLEncoder;
+
+public class OpenSearchServerScheduler extends OpenSearchServerConnection {
+
+  private final static String PATH = "services/rest/index/{index_name}/scheduler/{scheduler_name}/run";
+  
+  public OpenSearchServerScheduler(HttpClient client, OpenSearchServerConfig config, String
schedulerName)
+    throws ManifoldCFException {
+    super(client, config);
+    String path = StringUtils.replace(PATH, "{index_name}", URLEncoder.encode(config.getIndexName()));
+    path = StringUtils.replace(path, "{scheduler_name}", URLEncoder.encode(schedulerName));
+    StringBuffer url = getApiUrlV2(path);
+    HttpPut put = new HttpPut(url.toString());
+    put.setEntity(new StringEntity("{}", ContentType.APPLICATION_JSON));
+    call(put);
+  }
+
+}

Propchange: manifoldcf/trunk/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerScheduler.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message