incubator-oodt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattm...@apache.org
Subject svn commit: r1023552 - in /incubator/oodt/trunk: core/ pushpull/ pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ftp/
Date Sun, 17 Oct 2010 18:43:30 GMT
Author: mattmann
Date: Sun Oct 17 18:43:29 2010
New Revision: 1023552

URL: http://svn.apache.org/viewvc?rev=1023552&view=rev
Log:
- add CogJGlobus back: OODT-22 WIP. Note: i had to add a non-Maven central remote repository
to get this done. I don't think this is a blocker to starting to roll RC's for 0.1-incubating,
but it's likely something we'll want to fix before we release. Unfortunately that fix requires
getting something set up at Sonatype OSS hosting, which is more than I can get done this weekend.
So i'm pushing forward regardless, but let's not forget to deal with this later.

Added:
    incubator/oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ftp/CogJGlobusFtpClient.java
  (with props)
    incubator/oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ftp/CogJGlobusFtpClientFactory.java
  (with props)
Modified:
    incubator/oodt/trunk/core/pom.xml
    incubator/oodt/trunk/pushpull/pom.xml

Modified: incubator/oodt/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/core/pom.xml?rev=1023552&r1=1023551&r2=1023552&view=diff
==============================================================================
--- incubator/oodt/trunk/core/pom.xml (original)
+++ incubator/oodt/trunk/core/pom.xml Sun Oct 17 18:43:29 2010
@@ -47,6 +47,17 @@ the License.
             <url>http://download.java.net/maven/2</url>
             <layout>default</layout>
         </repository>
+	   <repository>
+	     <id>globus-repo</id>
+	     <name>Globus Toolkit Internal Maven2 Repository</name>
+	     <url>http://projects.iplantcollaborative.org/archiva/repository/internal</url>
+	     <releases>
+	       <enabled>true</enabled>
+	     </releases>
+	     <snapshots>
+	       <enabled>true</enabled>
+	     </snapshots>
+	  </repository> 
     </repositories>
     <inceptionYear>1999</inceptionYear>
     <mailingLists>

Modified: incubator/oodt/trunk/pushpull/pom.xml
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/pushpull/pom.xml?rev=1023552&r1=1023551&r2=1023552&view=diff
==============================================================================
--- incubator/oodt/trunk/pushpull/pom.xml (original)
+++ incubator/oodt/trunk/pushpull/pom.xml Sun Oct 17 18:43:29 2010
@@ -171,6 +171,11 @@
       <version>3.4.4</version>
     </dependency>
     <dependency>
+      <groupId>org.globus</groupId>
+      <artifactId>cog-jglobus</artifactId>
+      <version>1.8.0</version>
+    </dependency>
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>3.8.2</version>

Added: incubator/oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ftp/CogJGlobusFtpClient.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ftp/CogJGlobusFtpClient.java?rev=1023552&view=auto
==============================================================================
--- incubator/oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ftp/CogJGlobusFtpClient.java
(added)
+++ incubator/oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ftp/CogJGlobusFtpClient.java
Sun Oct 17 18:43:29 2010
@@ -0,0 +1,150 @@
+package org.apache.oodt.cas.pushpull.protocol.ftp;
+
+//JDK imports
+import java.io.File;
+import java.util.List;
+import java.util.Vector;
+
+//Globus imports
+import org.globus.ftp.FTPClient;
+import org.globus.ftp.FileInfo;
+
+//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 CogJGlobusFtpClient extends Protocol {
+
+  private FTPClient ftp;
+
+  private boolean isConnected;
+
+  public CogJGlobusFtpClient() {
+      super("ftp");
+  }
+
+  protected void chDir(ProtocolPath path) throws ProtocolException {
+      try {
+          ftp.changeDir(path.getPathString());
+      } catch (Exception e) {
+          throw new ProtocolException("Failed to cd to " + path + " : "
+                  + e.getMessage());
+      }
+  }
+
+  @Override
+  public void cdToRoot() throws ProtocolException {
+      try {
+          chDir(new ProtocolPath("/", true));
+      } catch (Exception e) {
+          throw new ProtocolException("Failed to cd to root : "
+                  + e.getMessage());
+      }
+  }
+
+  public void connect(String host, String username, String password)
+          throws ProtocolException {
+      try {
+          ftp = new FTPClient(host, 21);
+      } catch (Exception e) {
+          throw new ProtocolException("Failed to connect to: " + host + " : "
+                  + e.getMessage());
+      }
+      isConnected = true;
+
+      try {
+          ftp.authorize(username, password);
+          ftp.setActive(ftp.setLocalPassive());
+      } catch (Exception e) {
+          throw new ProtocolException("Failed to login to: " + host + " : "
+                  + e.getMessage());
+      }
+  }
+
+  public void disconnectFromServer() throws ProtocolException {
+      try {
+          ftp.close();
+          isConnected = false;
+      } catch (Exception e) {
+          throw new ProtocolException("Error disconnecting from "
+                  + this.getRemoteSite().getURL() + " : " + e.getMessage());
+      }
+  }
+
+  public void getFile(ProtocolFile file, File toLocalFile)
+          throws ProtocolException {
+      try {
+          ftp.setActive(ftp.setLocalPassive());
+          ftp.get(file.getProtocolPath().getPathString(), toLocalFile);
+      } catch (Exception e) {
+          throw new ProtocolException("Failed to download: " + file.getName()
+                  + " : " + e.getMessage());
+      }
+  }
+
+  public void abortCurFileTransfer() throws ProtocolException {
+      try {
+          ftp.abort();
+      } catch (Exception e) {
+          throw new ProtocolException("Failed to abort file transfer : "
+                  + e.getMessage());
+      }
+  }
+
+  public List<ProtocolFile> listFiles() throws ProtocolException {
+      try {
+          ftp.setActive(ftp.setLocalPassive());
+          Vector<FileInfo> fileList = (Vector<FileInfo>) ftp.list("*", null);
+          Vector<ProtocolFile> returnList = new Vector<ProtocolFile>();
+          String path = this.pwd().getProtocolPath().getPathString();
+          for (FileInfo file : fileList) {
+              returnList.add(new ProtocolFile(this.getRemoteSite(),
+                      new ProtocolPath(path + "/" + file.getName(), file
+                              .isDirectory())));
+          }
+          return returnList;
+      } catch (Exception e) {
+          throw new ProtocolException("Failed to get list of files : "
+                  + e.getMessage());
+      }
+  }
+
+  public ProtocolFile getCurrentWorkingDir() throws ProtocolException {
+      try {
+          return new ProtocolFile(this.getRemoteSite(), new ProtocolPath(ftp
+                  .getCurrentDir(), true));
+      } catch (Exception e) {
+          throw new ProtocolException("Failed to pwd : " + e.getMessage());
+      }
+  }
+
+  public boolean isConnected() {
+      return isConnected;
+  }
+
+  public void sendNoOP() {
+      try {
+          // ftp.getCurrentDir();
+      } catch (Exception e) {
+      }
+  }
+
+  @Override
+  protected boolean deleteFile(ProtocolFile file) {
+      try {
+          ftp.deleteFile(file.getProtocolPath().getPathString());
+          return true;
+      } catch (Exception e) {
+          return false;
+      }
+  }
+
+}

Propchange: incubator/oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ftp/CogJGlobusFtpClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ftp/CogJGlobusFtpClientFactory.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ftp/CogJGlobusFtpClientFactory.java?rev=1023552&view=auto
==============================================================================
--- incubator/oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ftp/CogJGlobusFtpClientFactory.java
(added)
+++ incubator/oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ftp/CogJGlobusFtpClientFactory.java
Sun Oct 17 18:43:29 2010
@@ -0,0 +1,36 @@
+/**
+ * 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.
+ */
+
+package org.apache.oodt.cas.pushpull.protocol.ftp;
+
+//OODT imports
+import org.apache.oodt.cas.pushpull.protocol.Protocol;
+import org.apache.oodt.cas.pushpull.protocol.ProtocolFactory;
+
+/**
+ * 
+ * @author bfoster
+ * @version $Revision$
+ * 
+ */
+public class CogJGlobusFtpClientFactory implements ProtocolFactory {
+
+  public Protocol newInstance() {
+    return new CogJGlobusFtpClient();
+  }
+
+}

Propchange: incubator/oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ftp/CogJGlobusFtpClientFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message