incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1162824 - in /incubator/lcf/trunk: framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ framework/script-example/ site/src/documentation/content/xdocs/
Date Mon, 29 Aug 2011 14:14:00 GMT
Author: kwright
Date: Mon Aug 29 14:14:00 2011
New Revision: 1162824

URL: http://svn.apache.org/viewvc?rev=1162824&view=rev
Log:
Fix a bunch of script bugs and parsing conflicts

Added:
    incubator/lcf/trunk/framework/script-example/
    incubator/lcf/trunk/framework/script-example/file-crawl-example.mcf   (with props)
Modified:
    incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/BasicTokenStream.java
    incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/IfCommand.java
    incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
    incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java
    incubator/lcf/trunk/site/src/documentation/content/xdocs/script.xml

Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/BasicTokenStream.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/BasicTokenStream.java?rev=1162824&r1=1162823&r2=1162824&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/BasicTokenStream.java
(original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/BasicTokenStream.java
Mon Aug 29 14:14:00 2011
@@ -190,7 +190,9 @@ public class BasicTokenStream implements
             y == '>' && q == '=' ||
             y == '<' && q == '=' ||
             y == '&' && q == '&' ||
-            y == '|' && q == '|')
+            y == '|' && q == '|' ||
+            y == '>' && q == '>' ||
+            y == '<' && q == '<')
           {
             characterStream.skip();
             return new Token(Token.TOKEN_PUNCTUATION,new StringBuilder().append(y).append(q).toString(),

Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/IfCommand.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/IfCommand.java?rev=1162824&r1=1162823&r2=1162824&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/IfCommand.java
(original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/IfCommand.java
Mon Aug 29 14:14:00 2011
@@ -52,7 +52,7 @@ public class IfCommand implements Comman
     {
       sp.skipStatements(currentStream);
       t = currentStream.peek();
-      if (t != null && t.getToken().equals("else"))
+      if (t != null && t.getToken() != null && t.getToken().equals("else"))
       {
         currentStream.skip();
         // Parse statements
@@ -77,7 +77,7 @@ public class IfCommand implements Comman
     currentStream.skip();
     sp.skipStatements(currentStream);
     t = currentStream.peek();
-    if (t != null &&t.getToken().equals("else"))
+    if (t != null && t.getToken() != null && t.getToken().equals("else"))
     {
       currentStream.skip();
       // Skip statements

Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java?rev=1162824&r1=1162823&r2=1162824&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
(original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
Mon Aug 29 14:14:00 2011
@@ -757,7 +757,7 @@ public class ScriptParser
       currentStream.skip();
       return va;
     }
-    else if (t != null && t.getPunctuation() != null && t.getPunctuation().equals("<"))
+    else if (t != null && t.getPunctuation() != null && t.getPunctuation().equals("<<"))
     {
       currentStream.skip();
       // Parse the node type
@@ -814,7 +814,7 @@ public class ScriptParser
 
       // Parse the children
       t = currentStream.peek();
-      if (t == null || t.getPunctuation() == null || !t.getPunctuation().equals(">"))
+      if (t == null || t.getPunctuation() == null || !t.getPunctuation().equals(">>"))
       {
         while (true)
         {
@@ -823,7 +823,7 @@ public class ScriptParser
             syntaxError(currentStream,"Missing expression in configurationnode object initializer");
           va.insert(vr.resolve());
           t = currentStream.peek();
-          if (t != null && t.getPunctuation() != null && t.getPunctuation().equals(">"))
+          if (t != null && t.getPunctuation() != null && t.getPunctuation().equals(">>"))
             break;
           if (t == null || t.getPunctuation() == null || !t.getPunctuation().equals(","))
             syntaxError(currentStream,"Missing ','");
@@ -986,7 +986,7 @@ public class ScriptParser
       currentStream.skip();
       return true;
     }
-    else if (t != null && t.getPunctuation() != null && t.getPunctuation().equals("<"))
+    else if (t != null && t.getPunctuation() != null && t.getPunctuation().equals("<<"))
     {
       currentStream.skip();
       // Parse the node type
@@ -1031,14 +1031,14 @@ public class ScriptParser
 
       // Parse the children
       t = currentStream.peek();
-      if (t == null || t.getPunctuation() == null || !t.getPunctuation().equals(">"))
+      if (t == null || t.getPunctuation() == null || !t.getPunctuation().equals(">>"))
       {
         while (true)
         {
           if (skipExpression(currentStream) == false)
             syntaxError(currentStream,"Missing expression in configurationnode object initializer");
           t = currentStream.peek();
-          if (t != null && t.getPunctuation() != null && t.getPunctuation().equals(">"))
+          if (t != null && t.getPunctuation() != null && t.getPunctuation().equals(">>"))
             break;
           if (t == null || t.getPunctuation() == null || !t.getPunctuation().equals(","))
             syntaxError(currentStream,"Missing ','");

Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java?rev=1162824&r1=1162823&r2=1162824&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java
(original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConfigurationNode.java
Mon Aug 29 14:14:00 2011
@@ -42,7 +42,7 @@ public class VariableConfigurationNode e
   public String toString()
   {
     StringBuilder sb = new StringBuilder();
-    sb.append("< ");
+    sb.append("<< ");
     sb.append(new VariableString(configurationNode.getType()).toString());
     sb.append(" : ");
     String valueField = configurationNode.getValue();
@@ -68,12 +68,13 @@ public class VariableConfigurationNode e
     int i = 0;
     while (i < configurationNode.getChildCount())
     {
-      ConfigurationNode child = configurationNode.findChild(i++);
+      ConfigurationNode child = configurationNode.findChild(i);
       if (i > 0)
         sb.append(", ");
       sb.append(new VariableConfigurationNode(child).toString());
+      i++;
     }
-    sb.append(" >");
+    sb.append(" >>");
     return sb.toString();
   }
 

Added: incubator/lcf/trunk/framework/script-example/file-crawl-example.mcf
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-example/file-crawl-example.mcf?rev=1162824&view=auto
==============================================================================
--- incubator/lcf/trunk/framework/script-example/file-crawl-example.mcf (added)
+++ incubator/lcf/trunk/framework/script-example/file-crawl-example.mcf Mon Aug 29 14:14:00
2011
@@ -0,0 +1,58 @@
+# 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.
+
+# Script to create a file system job and run it, sending the files to the null output connector
+# Argument: the base path of the API service, e.g. "http://localhost:8345/mcf-api-service".
+
+# Decode the argument, if any
+if __args__.__size__ > 1 then
+  error "Usage: file-crawl-example <url_path>";
+;
+if __args__.__size__ == 0 then
+  set basepath = "http://localhost:8345/mcf-api-service";
+else
+  set basepath = __argv__[0];
+;
+set baseurl = (new url basepath) + "json";
+
+# Define all the connection names, job names, etc.
+set outputConnectionName = "Null Output";
+set outputConnectionDescription = "Null Output Connection";
+set repositoryConnectionName = "File System";
+set repositoryConnectionDescription = "File System Connection";
+set fileCrawlJobName = "File system crawl";
+set fileCrawlJobDescription = "Crawl local file system";
+set fileCrawlPath = "../../.."; # Crawl the main folder
+
+# Now, create the null output connection, unless it's already there.
+PUT result = {
+  << "outputconnection" : "" :  :
+    << "description" : outputConnectionDescription :  :  >>,
+    << "configuration" : "" :  :  >>,
+    << "class_name" : "org.apache.manifoldcf.agents.output.nullconnector.NullConnector"
:  :  >>,
+    << "name" : outputConnectionName :  :  >>,
+    << "max_connections" : "100" :  :  >> >>
+  }
+  to baseurl + "outputconnections" + new connectionname outputConnectionName;
+if result.__CREATED__ then
+  print "Created output connection";
+else
+  if result.__OK__ then
+    print "Output connection already exists";
+  else
+    error "Unexpected result: "+result.__script__;
+  ;
+;
+

Propchange: incubator/lcf/trunk/framework/script-example/file-crawl-example.mcf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/trunk/framework/script-example/file-crawl-example.mcf
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/lcf/trunk/site/src/documentation/content/xdocs/script.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/site/src/documentation/content/xdocs/script.xml?rev=1162824&r1=1162823&r2=1162824&view=diff
==============================================================================
--- incubator/lcf/trunk/site/src/documentation/content/xdocs/script.xml (original)
+++ incubator/lcf/trunk/site/src/documentation/content/xdocs/script.xml Mon Aug 29 14:14:00
2011
@@ -138,7 +138,7 @@ expression:
 --&gt; '-' expression
 --&gt; '[' [expression [',' expression ...]] ']'
 --&gt; '{' [expression [',' expression ...]] '}'
---&gt; '&lt;' expression ':' expression ':' [expression '=' expression [',' expression
'=' expression ...]] ':' [expression [',' expression ...]] '&gt;'
+--&gt; '&lt;&lt;' expression ':' expression ':' [expression '=' expression [','
expression '=' expression ...]] ':' [expression [',' expression ...]] '&gt;&gt;'
 --&gt; expression '[' expression ']'
 --&gt; expression '.' token
 --&gt; token
@@ -315,7 +315,7 @@ print "3".__int__+7;
           <li>Attributes, described as a set of name/value pairs</li>
           <li>Children, which must be configuration node variable types</li>
         </ul>
-        <p>Configuration node variable types can be created using an initializer of
the form <strong>&lt;</strong> <em>expression</em> <strong>:</strong>
<em>expression</em> <strong>:</strong> [<em>expression</em>
<strong>=</strong> <em>expression</em> [<strong>,</strong>
<em>expression</em> <strong>=</strong> <em>expression</em>
...]] <strong>:</strong> [<em>expression</em> [<strong>,</strong>
<em>expression</em> ... ]] '&gt;'.
+        <p>Configuration node variable types can be created using an initializer of
the form <strong>&lt;&lt;</strong> <em>expression</em> <strong>:</strong>
<em>expression</em> <strong>:</strong> [<em>expression</em>
<strong>=</strong> <em>expression</em> [<strong>,</strong>
<em>expression</em> <strong>=</strong> <em>expression</em>
...]] <strong>:</strong> [<em>expression</em> [<strong>,</strong>
<em>expression</em> ... ]] '&gt;&gt;'.
           The first expression represents the type of the node.  The second is the node's
value.  The series of '=' expressions represents attribute names and values.  The last series
represents
           the children of the node.  For example, the script code '&lt; "description"
: "Solr" :  :  &gt;' represents a node of type 'description' with a value of 'Solr', with
no attributes or children.</p>
         <p>The operations supported for this variable type, and their meanings are
listed in the table below:</p>
@@ -323,7 +323,7 @@ print "3".__int__+7;
           <caption>Configuration node operations</caption>
           <tr><th>Operation</th><th>Meaning</th><th>Example</th></tr>
           <tr><td>subscript []</td><td>Find the specified child configuration
node variable, yielding the variable</td><td>myconfig [0]</td></tr>
-          <tr><td>binary +</td><td>Append a configuration child node
variable to the list</td><td>myconfig + &lt; "something" : "somethingvalue"
: : &gt;</td></tr>
+          <tr><td>binary +</td><td>Append a configuration child node
variable to the list</td><td>myconfig + &lt;&lt; "something" : "somethingvalue"
: : &gt;&gt;</td></tr>
         </table>
         <p>In addition, the standard attributes <em>__script__</em>, <em>__string__</em>,
<em>__size__</em>, <em>__type__</em>, and <em>__value__</em>
are supported 
           by configuration node variable types, as well as the <em>insert</em>
and <em>remove</em> statements.</p>



Mime
View raw message