manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1449715 - in /manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine: VariableConnectionName.java VariableString.java VariableURL.java
Date Mon, 25 Feb 2013 14:15:42 GMT
Author: kwright
Date: Mon Feb 25 14:15:41 2013
New Revision: 1449715

URL: http://svn.apache.org/r1449715
Log:
Obtain URL path components via dedicated method. Part of CONNECTORS-651.

Modified:
    manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConnectionName.java
    manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableString.java
    manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableURL.java

Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConnectionName.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConnectionName.java?rev=1449715&r1=1449714&r2=1449715&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConnectionName.java
(original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableConnectionName.java
Mon Feb 25 14:15:41 2013
@@ -19,6 +19,8 @@
 
 package org.apache.manifoldcf.scriptengine;
 
+import java.io.*;
+import java.net.*;
 
 /** Variable class representing a ManifoldCF API URL connection name segment.  In conjunction
 * with the URL variable, this variable will properly character-stuff the connection name
to make
@@ -76,6 +78,29 @@ public class VariableConnectionName exte
     return sb.toString();
   }
   
+  /** Check if the variable has a URL path value */
+  @Override
+  public boolean hasURLPathValue()
+    throws ScriptException
+  {
+    return true;
+  }
+
+  /** Get the variable's value as a URL path component */
+  @Override
+  public String getURLPathValue()
+    throws ScriptException
+  {
+    try
+    {
+      return URLEncoder.encode(encodedConnectionName,"utf-8").replace("+","%20");
+    }
+    catch (UnsupportedEncodingException e)
+    {
+      throw new ScriptException(composeMessage(e.getMessage()),e);
+    }
+  }
+
   /** Check if the variable has a string value */
   @Override
   public boolean hasStringValue()

Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableString.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableString.java?rev=1449715&r1=1449714&r2=1449715&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableString.java
(original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableString.java
Mon Feb 25 14:15:41 2013
@@ -19,12 +19,15 @@
 
 package org.apache.manifoldcf.scriptengine;
 
+import java.net.*;
+import java.io.*;
+
 /** Variable class representing an integer.
 */
 public class VariableString extends VariableBase
 {
   protected String value;
-  
+
   public VariableString(String value)
   {
     this.value = value;
@@ -76,6 +79,29 @@ public class VariableString extends Vari
     return true;
   }
 
+  /** Check if the variable has a URL path value */
+  @Override
+  public boolean hasURLPathValue()
+    throws ScriptException
+  {
+    return true;
+  }
+
+  /** Get the variable's value as a URL path component */
+  @Override
+  public String getURLPathValue()
+    throws ScriptException
+  {
+    try
+    {
+      return URLEncoder.encode(value,"utf-8").replace("+","%20");
+    }
+    catch (UnsupportedEncodingException e)
+    {
+      throw new ScriptException(composeMessage(e.getMessage()),e);
+    }
+  }
+
   /** Get the variable's script value */
   @Override
   public String getScriptValue()

Modified: manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableURL.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableURL.java?rev=1449715&r1=1449714&r2=1449715&view=diff
==============================================================================
--- manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableURL.java
(original)
+++ manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableURL.java
Mon Feb 25 14:15:41 2013
@@ -99,14 +99,7 @@ public class VariableURL extends Variabl
   {
     if (v == null)
       throw new ScriptException(composeMessage("Binary '+' operand cannot be null"));
-    try
-    {
-      return new VariableURL(encodedURL + "/" + URLEncoder.encode(v.getStringValue(),"utf-8").replace("+","%20"));
-    }
-    catch (UnsupportedEncodingException e)
-    {
-      throw new ScriptException(composeMessage(e.getMessage()),e);
-    }
+    return new VariableURL(encodedURL + "/" + v.getURLPathValue());
   }
   
   @Override



Mime
View raw message