You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by bf...@apache.org on 2011/05/27 01:27:03 UTC

svn commit: r1128120 - in /oodt/branches/cas-protocol-api: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/oodt/ src/main/java/org/apache/oodt/cas/ src/main/java/org/apache/oodt/cas/protocol/ src/m...

Author: bfoster
Date: Thu May 26 23:27:01 2011
New Revision: 1128120

URL: http://svn.apache.org/viewvc?rev=1128120&view=rev
Log:
initial branch commit

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

Added:
    oodt/branches/cas-protocol-api/pom.xml   (with props)
    oodt/branches/cas-protocol-api/src/
    oodt/branches/cas-protocol-api/src/main/
    oodt/branches/cas-protocol-api/src/main/java/
    oodt/branches/cas-protocol-api/src/main/java/org/
    oodt/branches/cas-protocol-api/src/main/java/org/apache/
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/Protocol.java   (with props)
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFactory.java   (with props)
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFile.java   (with props)
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/Authentication.java   (with props)
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/BasicAuthentication.java   (with props)
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/exceptions/
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/exceptions/ProtocolException.java   (with props)
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolConfig.java   (with props)
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolManager.java   (with props)
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/util/
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolFileFilter.java   (with props)
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolUtils.java   (with props)
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifier.java   (with props)
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifier.java   (with props)
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifierFactory.java   (with props)

Added: oodt/branches/cas-protocol-api/pom.xml
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/pom.xml?rev=1128120&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/pom.xml (added)
+++ oodt/branches/cas-protocol-api/pom.xml Thu May 26 23:27:01 2011
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.oodt</groupId>
+    <artifactId>oodt-core</artifactId>
+    <version>0.3-SNAPSHOT</version>
+    <relativePath>../core/pom.xml</relativePath>
+  </parent> 
+  <artifactId>cas-protocol-api</artifactId>
+  <name>CAS Protocol</name>
+  <profiles>
+    <profile>
+      <id>audit</id>
+      <activation>
+        <activeByDefault>false</activeByDefault>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>rat-maven-plugin</artifactId>
+            <configuration>
+              <excludes>
+                <exclude>**/resources/examples/**/*</exclude>
+              </excludes>
+            </configuration>
+            <executions>
+              <execution>
+                <phase>verify</phase>
+                <goals>
+                  <goal>check</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.oodt</groupId>
+      <artifactId>cas-metadata</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
+      <version>1.3</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-httpclient</groupId>
+      <artifactId>commons-httpclient</artifactId>
+      <version>3.0</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-net</groupId>
+      <artifactId>commons-net</artifactId>
+      <version>1.4.0</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.1</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <version>2.3</version>
+    </dependency>
+    <dependency>
+      <groupId>xmlrpc</groupId>
+      <artifactId>xmlrpc</artifactId>
+      <version>2.0.1</version>
+    </dependency>
+    <dependency>
+      <groupId>oro</groupId>
+      <artifactId>oro</artifactId>
+      <version>2.0.8</version>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <version>1.2.13</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.javamail</groupId>
+      <artifactId>geronimo-javamail_1.4_mail</artifactId>
+      <version>1.8.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-activation_1.1_spec</artifactId>
+      <version>1.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.pdfbox</groupId>
+      <artifactId>pdfbox</artifactId>
+      <version>1.2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.poi</groupId>
+      <artifactId>poi</artifactId>
+      <version>3.0-FINAL</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tika</groupId>
+      <artifactId>tika-core</artifactId>
+      <version>0.8</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tika</groupId>
+      <artifactId>tika-parsers</artifactId>
+      <version>0.8</version>
+    </dependency>
+    <dependency>
+      <groupId>nekohtml</groupId>
+      <artifactId>nekohtml</artifactId>
+      <version>1.9.6.2</version>
+    </dependency>
+    <dependency>
+      <groupId>com.ibm.icu</groupId>
+      <artifactId>icu4j</artifactId>
+      <version>3.4.4</version>
+    </dependency>
+    <dependency>
+      <groupId>org.globus</groupId>
+      <artifactId>cog-jglobus</artifactId>
+      <version>1.8.0</version>
+    </dependency>
+    <dependency>
+      <groupId>com.jcraft</groupId>
+      <artifactId>jsch</artifactId>
+      <version>0.1.42</version>    
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.2</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

Propchange: oodt/branches/cas-protocol-api/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/Protocol.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/Protocol.java?rev=1128120&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/Protocol.java (added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/Protocol.java Thu May 26 23:27:01 2011
@@ -0,0 +1,55 @@
+/*
+ * 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.protocol;
+
+//OODT imports
+import org.apache.oodt.cas.protocol.auth.Authentication;
+import org.apache.oodt.cas.protocol.exceptions.ProtocolException;
+
+//JDK imports
+import java.io.File;
+import java.util.List;
+
+/**
+ * Interface for communication over different transfer protocols
+ * 
+ * @author bfoster
+ * @version $Revision$
+ */
+public interface Protocol {
+
+    public void connect(String host, Authentication authentication) throws ProtocolException;
+    
+    public void close() throws ProtocolException;
+
+    public boolean isConnected();
+    
+    public void cd(ProtocolFile file) throws ProtocolException;
+
+    public void getFile(ProtocolFile fromFile, File toFile) throws ProtocolException;
+
+    public void putFile(File fromFile, ProtocolFile toFile) throws ProtocolException;
+    
+    public void abortTransfer() throws ProtocolException;
+
+    public ProtocolFile pwd() throws ProtocolException;
+
+    public List<ProtocolFile> ls() throws ProtocolException;
+
+    public void deleteFile(ProtocolFile file) throws ProtocolException;
+
+}

Propchange: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/Protocol.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFactory.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFactory.java?rev=1128120&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFactory.java (added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFactory.java Thu May 26 23:27:01 2011
@@ -0,0 +1,34 @@
+/*
+ * 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.protocol;
+
+/**
+ * 
+ * @author bfoster
+ * @version $Revision$
+ * 
+ * <p>
+ * Describe your class here
+ * </p>.
+ */
+public interface ProtocolFactory {
+
+    public Protocol newInstance();
+
+}

Propchange: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFile.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFile.java?rev=1128120&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFile.java (added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFile.java Thu May 26 23:27:01 2011
@@ -0,0 +1,112 @@
+/*
+ * 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.protocol;
+
+//JDK imports
+import java.io.File;
+
+//APACHE imports
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * A path representing a file/directory over some {@link Protocol} 
+ * 
+ * @author bfoster
+ */
+public class ProtocolFile {
+
+    public static final ProtocolFile ROOT = new ProtocolFile(File.separator, true);
+    public static final ProtocolFile HOME = new ProtocolFile("~", true);
+
+    private String path;
+    private boolean isDir;
+
+    public ProtocolFile(String path, boolean isDir) {
+        this.isDir = isDir;
+    	this.path = path.length() > 0 ? StringUtils.chomp(path, File.separator) : path;
+    }
+
+    /**
+     * True is this path is a directory.
+     * 
+     * @return True if directory, false otherwise
+     */
+    public boolean isDir() {
+        return isDir;
+    }
+    
+    /**
+     * Gets the {@link String} representation of this path.
+     * 
+     * @return The {@link String} representation of this path
+     */
+    public String getPath() {
+        return path;
+    }
+
+    /**
+     * Gets the name of this file this path represents (i.e. '/path/to/file' will return 'file')
+     * 
+     * @return The name of the file this path represents
+     */
+    public String getName() {
+        return path.substring(path.lastIndexOf(File.separator) + 1);
+    }
+
+    /**
+     * True if this path is a relative path (i.e. does not start with {@link File.separator}).
+     * 
+     * @return True is this a relative path, false otherwise
+     */
+    public boolean isRelative() {
+        return !path.startsWith(File.separator);
+    }
+    
+    /**
+     * Gets the parent {@link ProtocolFile} for this path.
+     * 
+     * @return The parent {@link ProtocolFile}
+     */
+    public ProtocolFile getParent() {
+        return new ProtocolFile(path.substring(0, path.lastIndexOf(File.separator)), true);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int hashCode() {
+    	return this.getPath().hashCode();
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean equals(Object path) {
+        if (path instanceof ProtocolFile) {
+        	ProtocolFile p = (ProtocolFile) path;
+            return (p.getPath().equals(this.getPath()) && p.isDir() == this.isDir());
+        }
+        return false;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString() {
+    	return path;
+    }
+}

Propchange: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFile.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/Authentication.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/Authentication.java?rev=1128120&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/Authentication.java (added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/Authentication.java Thu May 26 23:27:01 2011
@@ -0,0 +1,9 @@
+package org.apache.oodt.cas.protocol.auth;
+
+public interface Authentication {
+
+	public String user();
+	
+	public String pass();
+	
+}

Propchange: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/Authentication.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/BasicAuthentication.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/BasicAuthentication.java?rev=1128120&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/BasicAuthentication.java (added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/BasicAuthentication.java Thu May 26 23:27:01 2011
@@ -0,0 +1,26 @@
+package org.apache.oodt.cas.protocol.auth;
+
+/**
+ * 
+ * @author bfoster
+ * @version $Revision$
+ */
+public class BasicAuthentication implements Authentication {
+
+	private String user;
+	private String pass;
+	
+	public BasicAuthentication(String user, String pass) {
+		this.user = user;
+		this.pass = pass;
+	}
+	
+	public String user() {
+		return user;
+	}
+
+	public String pass() {
+		return pass;
+	}
+
+}

Propchange: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/BasicAuthentication.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/exceptions/ProtocolException.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/exceptions/ProtocolException.java?rev=1128120&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/exceptions/ProtocolException.java (added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/exceptions/ProtocolException.java Thu May 26 23:27:01 2011
@@ -0,0 +1,34 @@
+/*
+ * 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.protocol.exceptions;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ */
+public class ProtocolException extends Exception {
+
+	private static final long serialVersionUID = -8463387026167921360L;
+
+    public ProtocolException(String msg) {
+        super(msg);
+    }
+    
+    public ProtocolException(String msg, Throwable throwable) {
+        super(msg, throwable);
+    }
+}

Propchange: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/exceptions/ProtocolException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolConfig.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolConfig.java?rev=1128120&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolConfig.java (added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolConfig.java Thu May 26 23:27:01 2011
@@ -0,0 +1,12 @@
+package org.apache.oodt.cas.protocol.system;
+
+import java.net.URI;
+import java.util.List;
+
+import org.apache.oodt.cas.protocol.ProtocolFactory;
+
+public interface ProtocolConfig {
+
+	public List<ProtocolFactory> getFactoriesBySite(URI site);
+	
+}

Propchange: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolConfig.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolManager.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolManager.java?rev=1128120&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolManager.java (added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolManager.java Thu May 26 23:27:01 2011
@@ -0,0 +1,88 @@
+/*
+ * 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.protocol.system;
+
+//OODT imports
+import org.apache.oodt.cas.protocol.auth.Authentication;
+import org.apache.oodt.cas.protocol.exceptions.ProtocolException;
+import org.apache.oodt.cas.protocol.util.ProtocolFileFilter;
+import org.apache.oodt.cas.protocol.verify.ProtocolVerifier;
+import org.apache.oodt.cas.protocol.Protocol;
+import org.apache.oodt.cas.protocol.ProtocolFactory;
+import org.apache.oodt.cas.protocol.ProtocolFile;
+
+//JDK imports
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * @author bfoster
+ */
+public class ProtocolManager {
+
+	private static final Logger LOG = Logger.getLogger(ProtocolManager.class.getName());
+	
+	private ProtocolConfig protocolConfig;
+	private Map<URI, ProtocolFactory> verifiedMap;
+	
+    public ProtocolManager(ProtocolConfig protocolConfig) {
+    	this.protocolConfig = protocolConfig;
+    	verifiedMap = new HashMap<URI, ProtocolFactory>();
+    }
+    
+    public ProtocolConfig getConfig() {
+    	return protocolConfig;
+    }
+    
+    public Protocol getProtocolBySite(URI site, Authentication auth, ProtocolVerifier verifier) {
+    	if (verifiedMap.containsKey(site)) {
+    		return verifiedMap.get(site).newInstance();
+    	} else {
+    		for (ProtocolFactory factory : protocolConfig.getFactoriesBySite(site)) {
+    			try {
+    				Protocol protocol = factory.newInstance();
+    				if (verifier.verify(protocol, site, auth)) {
+    					verifiedMap.put(site, factory);
+    					return protocol;
+    				}
+    			} catch (Exception e) {
+					LOG.warning("Failed to create/verify protocol from factory '"
+							+ factory.getClass().getCanonicalName()
+							+ "' : "
+							+ e.getMessage());
+    			}
+    		}
+        	return null;
+    	}
+    }
+    
+    public void setProtocol(URI site, ProtocolFactory factory) {
+    	verifiedMap.put(site, factory);
+    }
+}

Propchange: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolFileFilter.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolFileFilter.java?rev=1128120&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolFileFilter.java (added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolFileFilter.java Thu May 26 23:27:01 2011
@@ -0,0 +1,31 @@
+/*
+ * 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.protocol.util;
+
+import org.apache.oodt.cas.protocol.ProtocolFile;
+
+/**
+ * Filter for filtering {@ProtocolFile}s.
+ * 
+ * @author bfoster
+ * @version $Revision$
+ */
+public interface ProtocolFileFilter {
+
+    public boolean accept(ProtocolFile file);
+
+}

Propchange: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolFileFilter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolUtils.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolUtils.java?rev=1128120&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolUtils.java (added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolUtils.java Thu May 26 23:27:01 2011
@@ -0,0 +1,6 @@
+package org.apache.oodt.cas.protocol.util;
+
+public class ProtocolUtils {
+
+	
+}

Propchange: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifier.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifier.java?rev=1128120&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifier.java (added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifier.java Thu May 26 23:27:01 2011
@@ -0,0 +1,56 @@
+package org.apache.oodt.cas.protocol.verify;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+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;
+
+public class BasicProtocolVerifier implements ProtocolVerifier {
+
+	private static final Logger LOG = Logger.getLogger(BasicProtocolVerifier.class.getName());
+	
+	private Map<URI, ProtocolFile> uriTestCdMap;
+	
+	public BasicProtocolVerifier(Map<URI, ProtocolFile> uriTestCdMap) {
+		this.uriTestCdMap = uriTestCdMap;
+	}
+
+	public boolean verify(Protocol protocol, URI site, Authentication auth) {
+        try {
+            LOG.log(Level.INFO, "Testing protocol "
+                    + protocol.getClass().getCanonicalName()
+                    + " . . . this may take a few minutes . . .");
+            
+            // Test connectivity
+            protocol.connect(site.getHost(), auth);
+            
+            // Test ls, cd, and pwd
+            protocol.cd(ProtocolFile.HOME);
+            ProtocolFile home = protocol.pwd();
+            protocol.ls();
+            if (uriTestCdMap.containsKey(site)) {
+            	protocol.cd(uriTestCdMap.get(site));
+            } else {
+            	protocol.cd(ProtocolFile.ROOT);
+            }
+            protocol.cd(ProtocolFile.HOME);
+            
+            // Verify again at home directory
+            if (home == null || !home.equals(protocol.pwd()))
+                throw new ProtocolException(
+                        "Home directory not the same after cd");
+        } catch (Exception e) {
+            LOG.log(Level.SEVERE, "Protocol "
+                    + protocol.getClass().getCanonicalName()
+                    + " failed compatibility test : " + e.getMessage(), e);
+            return false;
+        }
+        return true;
+    }
+
+}

Propchange: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifier.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifier.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifier.java?rev=1128120&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifier.java (added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifier.java Thu May 26 23:27:01 2011
@@ -0,0 +1,12 @@
+package org.apache.oodt.cas.protocol.verify;
+
+import java.net.URI;
+
+import org.apache.oodt.cas.protocol.Protocol;
+import org.apache.oodt.cas.protocol.auth.Authentication;
+
+public interface ProtocolVerifier {
+	
+    public boolean verify(Protocol protocol, URI site, Authentication auth);
+    
+}

Propchange: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifier.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifierFactory.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifierFactory.java?rev=1128120&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifierFactory.java (added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifierFactory.java Thu May 26 23:27:01 2011
@@ -0,0 +1,5 @@
+package org.apache.oodt.cas.protocol.verify;
+
+public class ProtocolVerifierFactory {
+
+}

Propchange: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifierFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain