Author: bfoster
Date: Thu Jun  9 21:17:54 2011
New Revision: 1134086

URL: http://svn.apache.org/viewvc?rev=1134086&view=rev
Log:
- updated to add new Protocol method: ls(ProtocolFileFilter)

----------------
OODT-194

Modified:
    
oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocol.java

Modified: 
oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocol.java
URL: 
http://svn.apache.org/viewvc/oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocol.java?rev=1134086&r1=1134085&r2=1134086&view=diff
==============================================================================
--- 
oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocol.java
 (original)
+++ 
oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocol.java
 Thu Jun  9 21:17:54 2011
@@ -47,6 +47,7 @@ import org.apache.oodt.cas.protocol.Prot
 import org.apache.oodt.cas.protocol.ProtocolFile;
 import org.apache.oodt.cas.protocol.auth.Authentication;
 import org.apache.oodt.cas.protocol.exceptions.ProtocolException;
+import org.apache.oodt.cas.protocol.util.ProtocolFileFilter;
 
 //TIKA imports
 import org.apache.tika.exception.TikaException;
@@ -241,6 +242,34 @@ public class ImapsProtocol implements Pr
     return currentFilesForCurrentFolder;
   }
 
+       public List<ProtocolFile> ls(ProtocolFileFilter filter)
+                       throws ProtocolException {
+    LinkedList<ProtocolFile> currentFilesForCurrentFolder = new 
LinkedList<ProtocolFile>();
+    try {
+      openFolder(currentFolder);
+      if (!currentFolder.getFullName().equals(
+          store.getDefaultFolder().getFullName())) {
+        Message[] messages = currentFolder.getMessages();
+        for (Message message : messages) {
+               ProtocolFile pFile = new ProtocolFile(this.pwd().getPath()
+              + "/" + this.getMessageName(message), false);
+               if (filter.accept(pFile)) {
+                       currentFilesForCurrentFolder.add(pFile);
+               }
+        }
+      }
+    } catch (Exception e) {
+      if (!currentFolder.getFullName().equals(""))
+        throw new ProtocolException("Failed to ls : " + e.getMessage(), e);
+    } finally {
+      try {
+        closeFolder(currentFolder);
+      } catch (Exception e) {
+      }
+    }
+    return currentFilesForCurrentFolder;
+       }
+
   public synchronized ProtocolFile pwd()
       throws ProtocolException {
     try {


Reply via email to