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 2015/04/01 01:52:59 UTC

svn commit: r1670520 - in /manifoldcf/branches/CONNECTORS-1177/framework: script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ script-example/

Author: kwright
Date: Tue Mar 31 23:52:59 2015
New Revision: 1670520

URL: http://svn.apache.org/r1670520
Log:
Enhance example etc.

Modified:
    manifoldcf/branches/CONNECTORS-1177/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/Variable.java
    manifoldcf/branches/CONNECTORS-1177/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java
    manifoldcf/branches/CONNECTORS-1177/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableResult.java
    manifoldcf/branches/CONNECTORS-1177/framework/script-example/file-crawl-example.mcf

Modified: manifoldcf/branches/CONNECTORS-1177/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/Variable.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1177/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/Variable.java?rev=1670520&r1=1670519&r2=1670520&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1177/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/Variable.java (original)
+++ manifoldcf/branches/CONNECTORS-1177/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/Variable.java Tue Mar 31 23:52:59 2015
@@ -52,6 +52,8 @@ public interface Variable
   public static String ATTRIBUTE_NOTFOUNDSTATUS = "__NOTFOUND__";
   /** CREATED status attribute */
   public static String ATTRIBUTE_CREATEDSTATUS = "__CREATED__";
+  /** UNAUTHORIZED status attribute */
+  public static String ATTRIBUTE_UNAUTHORIZEDSTATUS = "__UNAUTHORIZED__";
   
   /** Check if the variable has a string value */
   public boolean hasStringValue()

Modified: manifoldcf/branches/CONNECTORS-1177/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1177/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java?rev=1670520&r1=1670519&r2=1670520&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1177/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java (original)
+++ manifoldcf/branches/CONNECTORS-1177/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfiguration.java Tue Mar 31 23:52:59 2015
@@ -41,13 +41,17 @@ public class VariableConfiguration exten
     throws ScriptException
   {
     configuration = new Configuration();
-    try
+    if (json != null && json.length() > 0)
     {
-      configuration.fromJSON(json);
-    }
-    catch (ManifoldCFException e)
-    {
-      throw new ScriptException(e.getMessage(),e);
+      try
+      {
+        configuration.fromJSON(json);
+      }
+      catch (ManifoldCFException e)
+      {
+        System.out.println("'"+json+"'");
+        throw new ScriptException(e.getMessage(),e);
+      }
     }
   }
   

Modified: manifoldcf/branches/CONNECTORS-1177/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableResult.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1177/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableResult.java?rev=1670520&r1=1670519&r2=1670520&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1177/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableResult.java (original)
+++ manifoldcf/branches/CONNECTORS-1177/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableResult.java Tue Mar 31 23:52:59 2015
@@ -77,6 +77,8 @@ public class VariableResult extends Vari
       return new VariableBoolean(resultCode == 201);
     else if (attributeName.equals(ATTRIBUTE_NOTFOUNDSTATUS))
       return new VariableBoolean(resultCode == 404);
+    else if (attributeName.equals(ATTRIBUTE_UNAUTHORIZEDSTATUS))
+      return new VariableBoolean(resultCode == 401);
     else if (attributeName.equals(ATTRIBUTE_VALUE))
       return result;
     else

Modified: manifoldcf/branches/CONNECTORS-1177/framework/script-example/file-crawl-example.mcf
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1177/framework/script-example/file-crawl-example.mcf?rev=1670520&r1=1670519&r2=1670520&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1177/framework/script-example/file-crawl-example.mcf (original)
+++ manifoldcf/branches/CONNECTORS-1177/framework/script-example/file-crawl-example.mcf Tue Mar 31 23:52:59 2015
@@ -17,14 +17,22 @@
 # Argument: the base path of the API service, e.g. "http://localhost:8345/mcf-api-service".
 
 # Decode the argument, if any
-if __args__.__size__ > 2 || __args__.__size__ < 1 then
-  error "Usage: file-crawl-example <file_path> [<url_path>]";
+if __args__.__size__ > 4 || __args__.__size__ < 1 || __args__.__size__ == 3 then
+  error "Usage: file-crawl-example <file_path> [ <url_path> [ <user_name> <password> ] ]";
 ;
 if __args__.__size__ == 1 then
   set basepath = "http://localhost:8345/mcf-api-service";
 else
   set basepath = __args__[1];
 ;
+if __args__.__size__ == 4 then
+  set username = __args__[2];
+  set password = __args__[3];
+else
+  set username = "";
+  set password = "";
+;
+
 set baseurl = (new url basepath) + "json";
 
 # Define all the connection names, job names, etc.
@@ -35,6 +43,17 @@ set repositoryConnectionDescription = "F
 set fileCrawlPath = __args__[0];
 set fileCrawlJobName = "File system crawl of "+fileCrawlPath;
 
+# First, login
+POST result = {
+  << "userID" : username :  :  >>,
+  << "password" : password : : >> }
+  to baseurl + "LOGIN";
+if result.__OK__ then
+  print "Login successful";
+else
+  error "Login failed";
+;
+
 # Now, create the null output connection, unless it's already there.
 PUT result = {
   << "outputconnection" : "" :  :