Return-Path: X-Original-To: apmail-oodt-commits-archive@www.apache.org Delivered-To: apmail-oodt-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0A02C4A7F for ; Fri, 27 May 2011 23:59:18 +0000 (UTC) Received: (qmail 13716 invoked by uid 500); 27 May 2011 23:59:18 -0000 Delivered-To: apmail-oodt-commits-archive@oodt.apache.org Received: (qmail 13698 invoked by uid 500); 27 May 2011 23:59:18 -0000 Mailing-List: contact commits-help@oodt.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@oodt.apache.org Delivered-To: mailing list commits@oodt.apache.org Received: (qmail 13691 invoked by uid 99); 27 May 2011 23:59:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 May 2011 23:59:17 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 May 2011 23:59:14 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id ACD0D23889D5; Fri, 27 May 2011 23:58:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1128536 - in /oodt/branches/protocol/protocol-imaps: ./ src/main/java/org/apache/oodt/cas/protocol/imaps/ Date: Fri, 27 May 2011 23:58:52 -0000 To: commits@oodt.apache.org From: bfoster@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110527235852.ACD0D23889D5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bfoster Date: Fri May 27 23:58:52 2011 New Revision: 1128536 URL: http://svn.apache.org/viewvc?rev=1128536&view=rev Log: - continued updates to IMAPS Protocol ---------------- OODT-194 Added: oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocol.java (contents, props changed) - copied, changed from r1128535, oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsClient.java oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocolFactory.java (contents, props changed) - copied, changed from r1128535, oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsClientFactory.java Removed: oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsClient.java oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsClientFactory.java Modified: oodt/branches/protocol/protocol-imaps/pom.xml Modified: oodt/branches/protocol/protocol-imaps/pom.xml URL: http://svn.apache.org/viewvc/oodt/branches/protocol/protocol-imaps/pom.xml?rev=1128536&r1=1128535&r2=1128536&view=diff ============================================================================== --- oodt/branches/protocol/protocol-imaps/pom.xml (original) +++ oodt/branches/protocol/protocol-imaps/pom.xml Fri May 27 23:58:52 2011 @@ -89,6 +89,16 @@ 1.1 + org.apache.tika + tika-core + 0.8 + + + org.apache.tika + tika-parsers + 0.8 + + junit junit 3.8.2 Copied: oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocol.java (from r1128535, oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsClient.java) URL: http://svn.apache.org/viewvc/oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocol.java?p2=oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocol.java&p1=oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsClient.java&r1=1128535&r2=1128536&rev=1128536&view=diff ============================================================================== --- oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsClient.java (original) +++ oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocol.java Fri May 27 23:58:52 2011 @@ -14,8 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -package org.apache.oodt.cas.pushpull.protocol.imaps; +package org.apache.oodt.cas.protocol.imaps; //JDK imports import java.io.ByteArrayInputStream; @@ -43,6 +42,12 @@ import org.xml.sax.SAXException; //APACHE imports import org.apache.commons.codec.DecoderException; +//OODT imports +import org.apache.oodt.cas.protocol.Protocol; +import org.apache.oodt.cas.protocol.ProtocolFile; +import org.apache.oodt.cas.protocol.auth.Authentication; +import org.apache.oodt.cas.protocol.exceptions.ProtocolException; + //TIKA imports import org.apache.tika.exception.TikaException; import org.apache.tika.metadata.Metadata; @@ -50,19 +55,13 @@ import org.apache.tika.parser.html.HtmlP import org.apache.tika.sax.BodyContentHandler; import org.apache.tika.sax.TextContentHandler; -//OODT imports -import org.apache.oodt.cas.pushpull.exceptions.ProtocolException; -import org.apache.oodt.cas.pushpull.protocol.Protocol; -import org.apache.oodt.cas.pushpull.protocol.ProtocolFile; -import org.apache.oodt.cas.pushpull.protocol.ProtocolPath; - /** * * @author bfoster * @version $Revision$ * */ -public class ImapsClient extends Protocol { +public class ImapsProtocol implements Protocol { static Store store; @@ -76,22 +75,9 @@ public class ImapsClient extends Protoco static int connectCalls = 0; - // static LinkedList currentFilesForCurrentFolder; - // static boolean changedDir = true; - - public ImapsClient() { - super("imaps"); - } - - @Override - public synchronized void abortCurFileTransfer() throws ProtocolException { - // do nothing - } - - @Override - public synchronized void chDir(ProtocolPath path) throws ProtocolException { + public synchronized void cd(ProtocolFile file) throws ProtocolException { try { - String remotePath = path.getPathString(); + String remotePath = file.getPath(); // System.out.println("cd to " + remotePath); if (remotePath.startsWith("/")) remotePath = remotePath.substring(1); @@ -106,35 +92,24 @@ public class ImapsClient extends Protoco // changedDir = true; } - @Override - public synchronized void cdToRoot() throws ProtocolException { - try { - chDir(new ProtocolPath("/", true)); - } catch (Exception e) { - throw new ProtocolException("Failed to cd to root : " + e.getMessage()); - } - } - - @Override - public synchronized void connect(String host, String username, String password) + public synchronized void connect(String host, Authentication auth) throws ProtocolException { try { if (store == null) { store = (session = Session.getInstance(System.getProperties())) .getStore("imaps"); - store.connect(host, port, username, password); + store.connect(host, port, auth.getUser(), auth.getPass()); currentFolder = store.getDefaultFolder(); } this.incrementConnections(); } catch (Exception e) { e.printStackTrace(); throw new ProtocolException("Failed to connected to IMAPS server " + host - + " with username " + username + " : " + e.getMessage()); + + " with username " + auth.getUser() + " : " + e.getMessage()); } } - @Override - public synchronized void disconnectFromServer() throws ProtocolException { + public synchronized void close() throws ProtocolException { decrementConnections(); if (connectCalls <= 0) { // changedDir = true; @@ -168,23 +143,22 @@ public class ImapsClient extends Protoco connectCalls--; } - @Override - public synchronized void getFile(ProtocolFile file, File toLocalFile) + public synchronized void get(ProtocolFile fromFile, File toFile) throws ProtocolException { try { openFolder(currentFolder); Message[] messages = currentFolder.getMessages(); for (Message message : messages) { - if (this.getMessageName(message).equals(file.getName())) { - writeMessageToLocalFile(message, toLocalFile); + if (this.getMessageName(message).equals(fromFile.getName())) { + writeMessageToLocalFile(message, toFile); // message.setFlag(Flags.Flag.DELETED, true); break; } } } catch (Exception e) { e.printStackTrace(); - throw new ProtocolException("Failed to download " + file + " to " - + toLocalFile + " : " + e.getMessage()); + throw new ProtocolException("Failed to download " + fromFile + " to " + + toFile + " : " + e.getMessage()); } finally { try { closeFolder(currentFolder); @@ -193,6 +167,10 @@ public class ImapsClient extends Protoco } } + public synchronized void put(File fromFile, ProtocolFile toFile) { + //do nothing; + } + private void writeMessageToLocalFile(Message message, File toLocalFile) throws MessagingException, IOException, DecoderException, SAXException, TikaException { @@ -219,13 +197,11 @@ public class ImapsClient extends Protoco ps.close(); } - @Override - public synchronized boolean isConnected() throws ProtocolException { + public synchronized boolean connected() { return store.isConnected(); } - @Override - public List listFiles() throws ProtocolException { + public List ls() throws ProtocolException { // if (changedDir) { // System.out.println("Refreshed LS"); // currentFilesForCurrentFolder = new LinkedList(); @@ -236,10 +212,8 @@ public class ImapsClient extends Protoco store.getDefaultFolder().getFullName())) { Message[] messages = currentFolder.getMessages(); for (Message message : messages) { - currentFilesForCurrentFolder.add(new ProtocolFile(this - .getRemoteSite(), new ProtocolPath(this.pwd().getProtocolPath() - .getPathString() - + "/" + this.getMessageName(message), false))); + currentFilesForCurrentFolder.add(new ProtocolFile(this.pwd().getPath() + + "/" + this.getMessageName(message), false)); } } // changedDir = false; @@ -256,14 +230,13 @@ public class ImapsClient extends Protoco return currentFilesForCurrentFolder; } - @Override - public synchronized ProtocolFile getCurrentWorkingDir() + public synchronized ProtocolFile pwd() throws ProtocolException { try { String pwd = this.currentFolder.getFullName(); if (!pwd.equals("") && !pwd.startsWith("/")) pwd = "/" + pwd; - return new ProtocolFile(this.getRemoteSite(), new ProtocolPath(pwd, true)); + return new ProtocolFile(pwd, true); } catch (Exception e) { throw new ProtocolException("Failed to pwd : " + e.getMessage()); } @@ -353,25 +326,21 @@ public class ImapsClient extends Protoco } } - @Override - public synchronized boolean deleteFile(ProtocolFile file) { - boolean found = false; + public synchronized void delete(ProtocolFile file) throws ProtocolException { try { openFolder(currentFolder); Message[] messages = currentFolder.getMessages(); for (Message message : messages) { if (this.getMessageName(message).equals(file.getName())) { message.setFlag(Flags.Flag.DELETED, true); - found = true; break; } } } catch (Exception e) { - e.printStackTrace(); + throw new ProtocolException("Failed to delete file '" + file + "' : " + e.getMessage(), e); } finally { closeFolder(currentFolder); } - return found; } } Propchange: oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocol.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Copied: oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocolFactory.java (from r1128535, oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsClientFactory.java) URL: http://svn.apache.org/viewvc/oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocolFactory.java?p2=oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocolFactory.java&p1=oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsClientFactory.java&r1=1128535&r2=1128536&rev=1128536&view=diff ============================================================================== --- oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsClientFactory.java (original) +++ oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocolFactory.java Fri May 27 23:58:52 2011 @@ -14,31 +14,29 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - -package org.apache.oodt.cas.pushpull.protocol.imaps; +package org.apache.oodt.cas.protocol.imaps; //OODT imports -import org.apache.oodt.cas.pushpull.protocol.Protocol; -import org.apache.oodt.cas.pushpull.protocol.ProtocolFactory; +import org.apache.oodt.cas.protocol.ProtocolFactory; /** + * Factory for creating {@link ImapsProtocol}s. * * @author bfoster * @version $Revision$ - * - *

- * Describe your class here - *

. */ -public class ImapsClientFactory implements ProtocolFactory { +public class ImapsProtocolFactory implements ProtocolFactory { - private ImapsClient imapsClient; + private ImapsProtocol imapsClient; - public Protocol newInstance() { + public ImapsProtocol newInstance() { if (this.imapsClient == null) - this.imapsClient = new ImapsClient(); + this.imapsClient = new ImapsProtocol(); return this.imapsClient; } + public String getSchema() { + return "imaps"; + } + } Propchange: oodt/branches/protocol/protocol-imaps/src/main/java/org/apache/oodt/cas/protocol/imaps/ImapsProtocolFactory.java ------------------------------------------------------------------------------ svn:mime-type = text/plain