james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject svn commit: r1720571 - in /james/project/trunk: mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/ protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/ protocols/managesieve/src/main/java/org/ap...
Date Thu, 17 Dec 2015 14:55:04 GMT
Author: btellier
Date: Thu Dec 17 14:55:03 2015
New Revision: 1720571

URL: http://svn.apache.org/viewvc?rev=1720571&view=rev
Log:
JAMES-1618 Add a NOOP command - RFC-5804 compliant

Modified:
    james/project/trunk/mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/noop.test
    james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/CoreCommands.java
    james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/Noop.java
    james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
    james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCore.java
    james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCoreToLine.java
    james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/ManageSieveProcessor.java

Modified: james/project/trunk/mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/noop.test
URL: http://svn.apache.org/viewvc/james/project/trunk/mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/noop.test?rev=1720571&r1=1720570&r2=1720571&view=diff
==============================================================================
--- james/project/trunk/mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/noop.test
(original)
+++ james/project/trunk/mpt/impl/managesieve/core/src/main/resources/org/apache/james/managesieve/scripts/noop.test
Thu Dec 17 14:55:03 2015
@@ -18,4 +18,8 @@
 ################################################################
 
 C: NOOP
-S: NO NOOP command not yet implemented
\ No newline at end of file
+S: OK "NOOP completed"
+
+C: NOOP "STARTTLS-SYNC-42"
+S: OK \(TAG \{16\}
+S: STARTTLS-SYNC-42\) "DONE"
\ No newline at end of file

Modified: james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/CoreCommands.java
URL: http://svn.apache.org/viewvc/james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/CoreCommands.java?rev=1720571&r1=1720570&r2=1720571&view=diff
==============================================================================
--- james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/CoreCommands.java
(original)
+++ james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/CoreCommands.java
Thu Dec 17 14:55:03 2015
@@ -26,6 +26,6 @@ package org.apache.james.managesieve.api
  * @see <a href=http://tools.ietf.org/html/rfc5804#section-2>RFC 5804 Commands</a>
  */
 public interface CoreCommands extends Capability, CheckScript, DeleteScript, GetScript, HaveSpace,
-        ListScripts, PutScript, RenameScript, SetActive, GetActive {
+        ListScripts, PutScript, RenameScript, SetActive, GetActive, Noop {
 
 }

Modified: james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/Noop.java
URL: http://svn.apache.org/viewvc/james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/Noop.java?rev=1720571&r1=1720570&r2=1720571&view=diff
==============================================================================
--- james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/Noop.java
(original)
+++ james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/api/commands/Noop.java
Thu Dec 17 14:55:03 2015
@@ -26,8 +26,6 @@ package org.apache.james.managesieve.api
  */
 public interface Noop {
     
-    void noop();
-    
     String noop(String tag);
 
 }

Modified: james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
URL: http://svn.apache.org/viewvc/james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java?rev=1720571&r1=1720570&r2=1720571&view=diff
==============================================================================
--- james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
(original)
+++ james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/core/CoreProcessor.java
Thu Dec 17 14:55:03 2015
@@ -20,6 +20,7 @@
 
 package org.apache.james.managesieve.core;
 
+import com.google.common.base.Strings;
 import com.google.common.base.Throwables;
 import com.google.common.collect.Maps;
 import org.apache.commons.io.IOUtils;
@@ -191,6 +192,34 @@ public class CoreProcessor implements Co
         return builder.toString().trim();
     }
 
+    @Override
+    public String noop(String tag) {
+        if(Strings.isNullOrEmpty(tag)) {
+            return "OK \"NOOP completed\"";
+        }
+        return "OK " + taggify(tag) + " \"DONE\"";
+    }
+
+    private String taggify(String tag) {
+        String sanitizedTag = unquotaIfNeeded(tag.trim());
+        return "(TAG {" + sanitizedTag.length() + "}\r\n" + sanitizedTag + ")";
+    }
+
+    private String unquotaIfNeeded(String tag) {
+        int startIndex = 0;
+        int stopIndex = tag.length();
+        if (tag.endsWith("\r\n")) {
+            stopIndex -= 2;
+        }
+        if (tag.charAt(0) == '\"') {
+            startIndex = 1;
+        }
+        if (tag.charAt(tag.length() - 1) == '\"') {
+            stopIndex--;
+        }
+        return tag.substring(startIndex, stopIndex);
+    }
+
     private Map<Capabilities, String> precomputeCapabilitiesBase(SieveParser parser)
{
         String extensions = buildExtensions(parser);
         Map<Capabilities, String> capabilitiesBase = new HashMap<Capabilities, String>();

Modified: james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCore.java
URL: http://svn.apache.org/viewvc/james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCore.java?rev=1720571&r1=1720570&r2=1720571&view=diff
==============================================================================
--- james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCore.java
(original)
+++ james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCore.java
Thu Dec 17 14:55:03 2015
@@ -57,6 +57,10 @@ public class LineToCore{
         }
         return core.capability(session);
     }
+
+    public String noop(String args) {
+        return core.noop(args);
+    }
     
     public void deleteScript(Session session, String args) throws AuthenticationRequiredException,
ScriptNotFoundException, IsActiveException, ArgumentException {
         String scriptName = ParserUtils.getScriptName(args);

Modified: james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCoreToLine.java
URL: http://svn.apache.org/viewvc/james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCoreToLine.java?rev=1720571&r1=1720570&r2=1720571&view=diff
==============================================================================
--- james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCoreToLine.java
(original)
+++ james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/LineToCoreToLine.java
Thu Dec 17 14:55:03 2015
@@ -69,6 +69,10 @@ public class LineToCoreToLine {
         }
     }
 
+    public String noop(String args) {
+        return lineToCore.noop(args);
+    }
+
     public String checkScript(Session session, String args) {
         try {
             List<String> warnings = lineToCore.checkScript(session, args);

Modified: james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/ManageSieveProcessor.java
URL: http://svn.apache.org/viewvc/james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/ManageSieveProcessor.java?rev=1720571&r1=1720570&r2=1720571&view=diff
==============================================================================
--- james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/ManageSieveProcessor.java
(original)
+++ james/project/trunk/protocols/managesieve/src/main/java/org/apache/james/managesieve/transcode/ManageSieveProcessor.java
Thu Dec 17 14:55:03 2015
@@ -75,7 +75,7 @@ public class ManageSieveProcessor {
         if (request.contains(" ")) {
             return request.substring(firstWordEndIndex);
         } else {
-            return  "";
+            return "";
         }
     }
 
@@ -99,7 +99,7 @@ public class ManageSieveProcessor {
         } else if (command.equals(LOGOUT)) {
             return "NO LOGOUT command not yet implemented";
         } else if (command.equals(NOOP)) {
-            return "NO NOOP command not yet implemented\r\n";
+            return lineToCoreToLine.noop(arguments);
         } else if (command.equals(PUTSCRIPT)) {
             return lineToCoreToLine.putScript(session, arguments);
         } else if (command.equals(RENAMESCRIPT)) {



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message