oodt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfos...@apache.org
Subject svn commit: r1128421 - in /oodt/branches/cas-protocol-api: ./ src/main/java/org/apache/oodt/cas/protocol/ src/main/java/org/apache/oodt/cas/protocol/action/ src/main/java/org/apache/oodt/cas/protocol/auth/ src/main/java/org/apache/oodt/cas/protocol/con...
Date Fri, 27 May 2011 18:44:14 GMT
Author: bfoster
Date: Fri May 27 18:44:13 2011
New Revision: 1128421

URL: http://svn.apache.org/viewvc?rev=1128421&view=rev
Log:

- add command-line action interface, so cas-protocol could be used standalone if so desired

----------------

OODT-194

Added:
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/BasicVerifyAction.java
  (with props)
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/DownloadAction.java
  (with props)
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/ProtocolAction.java
  (with props)
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/NoAuthentication.java
  (with props)
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/config/
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/config/ProtocolConfig.java
  (contents, props changed)
      - copied, changed from r1128120, oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolConfig.java
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/config/SpringProtocolConfig.java
  (with props)
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/CLProtocolManager.java
  (with props)
    oodt/branches/cas-protocol-api/src/main/resources/
    oodt/branches/cas-protocol-api/src/main/resources/policy/
    oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-config.xml   (with props)
Removed:
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolConfig.java
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolUtils.java
Modified:
    oodt/branches/cas-protocol-api/pom.xml
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/Protocol.java
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFactory.java
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/Authentication.java
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/BasicAuthentication.java
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolManager.java
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolFileFilter.java
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifier.java
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifier.java
    oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifierFactory.java

Modified: oodt/branches/cas-protocol-api/pom.xml
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/pom.xml?rev=1128421&r1=1128420&r2=1128421&view=diff
==============================================================================
--- oodt/branches/cas-protocol-api/pom.xml (original)
+++ oodt/branches/cas-protocol-api/pom.xml Fri May 27 18:44:13 2011
@@ -64,26 +64,6 @@
       <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>
@@ -94,64 +74,16 @@
       <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>    
+      <groupId>com.thoughtworks.xstream</groupId>
+      <artifactId>xstream</artifactId>
+      <version>1.3.1</version>
+      <exclusions>
+        <exclusion>
+          <!-- xom is an optional dependency of xstream. Its also an Apache incompatible
license -->
+          <groupId>xom</groupId>
+          <artifactId>xom</artifactId>
+        </exclusion> 
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>junit</groupId>

Modified: 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=1128421&r1=1128420&r2=1128421&view=diff
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/Protocol.java
(original)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/Protocol.java
Fri May 27 18:44:13 2011
@@ -36,20 +36,18 @@ public interface Protocol {
     
     public void close() throws ProtocolException;
 
-    public boolean isConnected();
+    public boolean connected();
     
     public void cd(ProtocolFile file) throws ProtocolException;
 
-    public void getFile(ProtocolFile fromFile, File toFile) throws ProtocolException;
+    public void get(ProtocolFile fromFile, File toFile) throws ProtocolException;
 
-    public void putFile(File fromFile, ProtocolFile toFile) throws ProtocolException;
+    public void put(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;
+    public void delete(ProtocolFile file) throws ProtocolException;
 
 }

Modified: 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=1128421&r1=1128420&r2=1128421&view=diff
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFactory.java
(original)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFactory.java
Fri May 27 18:44:13 2011
@@ -14,21 +14,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-
 package org.apache.oodt.cas.protocol;
 
 /**
+ * Factory for creating {@link Protocol}s
  * 
  * @author bfoster
  * @version $Revision$
- * 
- * <p>
- * Describe your class here
- * </p>.
  */
 public interface ProtocolFactory {
 
     public Protocol newInstance();
 
+    public String getSchema();
+    
 }

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/BasicVerifyAction.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/BasicVerifyAction.java?rev=1128421&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/BasicVerifyAction.java
(added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/BasicVerifyAction.java
Fri May 27 18:44:13 2011
@@ -0,0 +1,64 @@
+/*
+ * 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.action;
+
+//OODT imports
+import org.apache.oodt.cas.protocol.Protocol;
+import org.apache.oodt.cas.protocol.ProtocolFactory;
+import org.apache.oodt.cas.protocol.system.ProtocolManager;
+import org.apache.oodt.cas.protocol.verify.ProtocolVerifier;
+
+/**
+ * Action for determining whether a given {@link Protocol} or auto-determined {@link Protocol}

+ * via {@link ProtocolManager} can connect and pass verification of the given {@link Verifier}
+ * for given site.
+ *
+ * @author bfoster
+ */
+public class BasicVerifyAction extends ProtocolAction {
+	
+	private ProtocolVerifier verifier;
+	private ProtocolFactory factory;
+	
+	@Override
+	public void performAction(ProtocolManager protocolManager) throws Exception {
+		if (factory != null) {
+			Protocol protocol = factory.newInstance();
+			if (verifier.verify(protocol, getSite(), getAuthentication())) {
+				LOG.info("Protocol '" + protocol.getClass().getCanonicalName() + "' PASSED verification!");
+			} else {
+				LOG.severe("Protocol '" + protocol.getClass().getCanonicalName() + "' FAILED verification!");
+			}
+		} else {
+			Protocol protocol = protocolManager.getProtocolBySite(getSite(), getAuthentication(),
verifier);
+			if (protocol != null) {
+				LOG.info("Protocol '" + protocol.getClass().getCanonicalName() + "' PASSED verification!");
+			} else {
+				LOG.info("No Protocol determined, FAILED verification!");				
+			}
+		}
+	}
+
+	public void setVerifier(ProtocolVerifier verifier) {
+		this.verifier = verifier;
+	}
+	
+	public void setProtocolFactory(ProtocolFactory factory) {
+		this.factory = factory;
+	}
+	
+}

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

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/DownloadAction.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/DownloadAction.java?rev=1128421&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/DownloadAction.java
(added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/DownloadAction.java
Fri May 27 18:44:13 2011
@@ -0,0 +1,45 @@
+/*
+ * 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.action;
+
+//JDK imports
+import java.io.File;
+
+//OODT imports
+import org.apache.oodt.cas.protocol.Protocol;
+import org.apache.oodt.cas.protocol.ProtocolFile;
+import org.apache.oodt.cas.protocol.system.ProtocolManager;
+
+/**
+ * A {@link ProtocolAction} which will downlaod a file from a given site
+ *
+ * @author bfoster
+ */
+public class DownloadAction extends ProtocolAction {
+	
+	private String file;
+	
+	public void performAction(ProtocolManager protocolManager) throws Exception {
+		Protocol protocol = protocolManager.getProtocolBySite(getSite(), getAuthentication(), null);
+		protocol.get(new ProtocolFile(file, false), new File(""));
+	}
+	
+	public void setFile(String file) {
+		this.file = file;
+	}
+
+}

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

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/ProtocolAction.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/ProtocolAction.java?rev=1128421&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/ProtocolAction.java
(added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/action/ProtocolAction.java
Fri May 27 18:44:13 2011
@@ -0,0 +1,78 @@
+/*
+ * 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.action;
+
+//OODT imports
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.logging.Logger;
+
+import org.apache.oodt.cas.protocol.auth.Authentication;
+import org.apache.oodt.cas.protocol.auth.BasicAuthentication;
+import org.apache.oodt.cas.protocol.auth.NoAuthentication;
+import org.apache.oodt.cas.protocol.system.ProtocolManager;
+import org.apache.oodt.commons.spring.SpringSetIdInjectionType;
+
+/**
+ * Action used to perform some task via a {@link ProtocolManager}
+ *
+ * @author bfoster
+ */
+public abstract class ProtocolAction implements SpringSetIdInjectionType {
+	
+	protected static final Logger LOG = Logger.getLogger(ProtocolAction.class.getName());
+	
+	private String id;
+	private String user;
+	private String pass;
+	private String site;
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+		
+	public void setUser(String user) {
+		this.user = user;
+	}
+	
+	public void setPass(String pass) {
+		this.pass = pass;
+	}
+	
+	public void setSite(String site) {
+		this.site = site;
+	}
+
+	public URI getSite() throws URISyntaxException {
+		return site != null ? new URI(site) : null;
+	}
+	
+	public Authentication getAuthentication() {
+		if (user == null || pass == null) {
+			return new NoAuthentication();
+		} else {
+			return new BasicAuthentication(user, pass);
+		}
+	}
+	
+	public abstract void performAction(ProtocolManager protocolManager) throws Exception;
+	
+}

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

Modified: 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=1128421&r1=1128420&r2=1128421&view=diff
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/Authentication.java
(original)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/Authentication.java
Fri May 27 18:44:13 2011
@@ -1,5 +1,26 @@
+/*
+ * 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.auth;
 
+/**
+ * Authentication interface for {@link Protocol} connections
+ * 
+ * @author bfoster
+ */
 public interface Authentication {
 
 	public String user();

Modified: 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=1128421&r1=1128420&r2=1128421&view=diff
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/BasicAuthentication.java
(original)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/BasicAuthentication.java
Fri May 27 18:44:13 2011
@@ -1,6 +1,23 @@
+/*
+ * 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.auth;
 
 /**
+ * Basic username and password {@link Authentication}
  * 
  * @author bfoster
  * @version $Revision$

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/NoAuthentication.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/NoAuthentication.java?rev=1128421&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/NoAuthentication.java
(added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/auth/NoAuthentication.java
Fri May 27 18:44:13 2011
@@ -0,0 +1,33 @@
+/*
+ * 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.auth;
+
+/**
+ * Use when {@link Protocol} requires no {@link Authentication} 
+ * 
+ * @author bfoster
+ */
+public class NoAuthentication implements Authentication {
+
+	public String user() {
+		return null;
+	}
+
+	public String pass() {
+		return null;
+	}
+}

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

Copied: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/config/ProtocolConfig.java
(from r1128120, 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/config/ProtocolConfig.java?p2=oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/config/ProtocolConfig.java&p1=oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolConfig.java&r1=1128120&r2=1128421&rev=1128421&view=diff
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolConfig.java
(original)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/config/ProtocolConfig.java
Fri May 27 18:44:13 2011
@@ -1,10 +1,34 @@
-package org.apache.oodt.cas.protocol.system;
+/*
+ * 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.config;
 
+//JDK imports
 import java.net.URI;
 import java.util.List;
 
+//OODT imports
 import org.apache.oodt.cas.protocol.ProtocolFactory;
+import org.apache.oodt.cas.protocol.system.ProtocolManager;
 
+/**
+ * Protocol configuration for configuring {@link ProtocolManager}.
+ *
+ * @author bfoster
+ */
 public interface ProtocolConfig {
 
 	public List<ProtocolFactory> getFactoriesBySite(URI site);

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

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/config/SpringProtocolConfig.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/config/SpringProtocolConfig.java?rev=1128421&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/config/SpringProtocolConfig.java
(added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/config/SpringProtocolConfig.java
Fri May 27 18:44:13 2011
@@ -0,0 +1,58 @@
+/*
+ * 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.config;
+
+//JDK imports
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+//Spring imports
+import org.apache.oodt.cas.protocol.ProtocolFactory;
+import org.springframework.context.support.FileSystemXmlApplicationContext;
+
+/**
+ * Spring Framework base {@link ProtocolConfig} which loads {@link ProtocolFactory}s
+ * from a Spring xml bean file.
+ *
+ * @author bfoster
+ */
+public class SpringProtocolConfig implements ProtocolConfig {
+
+	private Map<String, List<ProtocolFactory>> factoryMap;
+	
+	public SpringProtocolConfig(String configFile) {
+		factoryMap = new HashMap<String, List<ProtocolFactory>>();
+		FileSystemXmlApplicationContext appContext = new FileSystemXmlApplicationContext(configFile);
+		Collection<ProtocolFactory> protocolFactories = appContext.getBeansOfType(ProtocolFactory.class).values();
+		for (ProtocolFactory factory : protocolFactories) {
+			List<ProtocolFactory> factories = factoryMap.get(factory.getSchema());
+			if (factories == null) {
+				factories = new ArrayList<ProtocolFactory>();
+			}
+			factories.add(factory);
+		}
+	}
+	
+	public List<ProtocolFactory> getFactoriesBySite(URI site) {
+		return factoryMap.get(site.getScheme());
+	}
+
+}

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

Added: oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/CLProtocolManager.java
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/CLProtocolManager.java?rev=1128421&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/CLProtocolManager.java
(added)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/CLProtocolManager.java
Fri May 27 18:44:13 2011
@@ -0,0 +1,73 @@
+/*
+ * 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;
+
+//JDK imports
+import java.util.List;
+
+//OODT imports
+import org.apache.oodt.cas.metadata.util.PathUtils;
+import org.apache.oodt.cas.protocol.action.ProtocolAction;
+import org.apache.oodt.cas.protocol.config.ProtocolConfig;
+import org.apache.oodt.cas.protocol.config.SpringProtocolConfig;
+import org.apache.oodt.commons.option.CmdLineOptionInstance;
+import org.apache.oodt.commons.option.util.CmdLineOptionUtils;
+
+//Spring imports
+import org.springframework.context.support.FileSystemXmlApplicationContext;
+
+/**
+ * Command-Line {@link ProtocolManager} which {@link ProtocolAction}s to be
+ * invoked
+ * 
+ * @author bfoster
+ */
+public class CLProtocolManager extends ProtocolManager {
+
+	public CLProtocolManager(ProtocolConfig protocolConfig) {
+		super(protocolConfig);
+	}
+
+	public static void main(String[] args) throws Exception {
+		String protocolConfig = PathUtils
+				.doDynamicReplacement(System
+						.getProperty(
+								"org.apache.oodt.cas.protocol.manager.config.file",
+								"classpath:/org/apache/oodt/cas/protocol/actions/protocol-manager-config.xml"));
+		String cmdLineConfig = PathUtils
+				.doDynamicReplacement(System
+						.getProperty(
+								"org.apache.oodt.cas.protocol.cmdline.config.file",
+								"classpath:/org/apache/oodt/cas/protocol/actions/protocol-cmdline-beans.xml"));
+
+		FileSystemXmlApplicationContext appContext = new FileSystemXmlApplicationContext(
+				cmdLineConfig);
+		List<CmdLineOptionInstance> optionInstances = CmdLineOptionUtils
+				.loadValidateAndHandleInstances(appContext, args);
+		CmdLineOptionInstance actionInstance = CmdLineOptionUtils
+				.getOptionInstanceByName("action", optionInstances);
+		String actionArgValue = actionInstance.getValues().get(0);
+		ProtocolAction action = ((ProtocolAction) appContext.getBean(
+				actionArgValue, ProtocolAction.class));
+		try {
+			action.performAction(new CLProtocolManager(
+					new SpringProtocolConfig(protocolConfig)));
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+}

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

Modified: 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=1128421&r1=1128420&r2=1128421&view=diff
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolManager.java
(original)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolManager.java
Fri May 27 18:44:13 2011
@@ -14,34 +14,24 @@
  * 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.config.ProtocolConfig;
 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;
 
 /**
+ * A Manager responsible for managing site to {@link ProtocolFactory} mapping
+ *
  * @author bfoster
  */
 public class ProtocolManager {

Modified: 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=1128421&r1=1128420&r2=1128421&view=diff
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolFileFilter.java
(original)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolFileFilter.java
Fri May 27 18:44:13 2011
@@ -16,6 +16,7 @@
  */
 package org.apache.oodt.cas.protocol.util;
 
+//OODT imports
 import org.apache.oodt.cas.protocol.ProtocolFile;
 
 /**

Modified: 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=1128421&r1=1128420&r2=1128421&view=diff
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifier.java
(original)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/BasicProtocolVerifier.java
Fri May 27 18:44:13 2011
@@ -1,15 +1,40 @@
+/*
+ * 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.verify;
 
+//JDK imports
 import java.net.URI;
 import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+//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;
 
+/**
+ * {@link ProtocolVerifier} which performs basic verification of a given {@link Protocol}
to
+ * a given site.  It check that {@link Protocol} can connect to the site, cd to a directory,
+ * cd back to HOME directory, and able to perform an ls and pwd.
+ * 
+ * @author bfoster
+ */
 public class BasicProtocolVerifier implements ProtocolVerifier {
 
 	private static final Logger LOG = Logger.getLogger(BasicProtocolVerifier.class.getName());

Modified: 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=1128421&r1=1128420&r2=1128421&view=diff
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifier.java
(original)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifier.java
Fri May 27 18:44:13 2011
@@ -1,10 +1,33 @@
+/*
+ * 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.verify;
 
+//JDK imports
 import java.net.URI;
 
+//OODT imports
 import org.apache.oodt.cas.protocol.Protocol;
 import org.apache.oodt.cas.protocol.auth.Authentication;
 
+/**
+ * Interface for verifying {@link Protocol}s can connect to sites.
+ * 
+ * @author bfoster
+ */
 public interface ProtocolVerifier {
 	
     public boolean verify(Protocol protocol, URI site, Authentication auth);

Modified: 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=1128421&r1=1128420&r2=1128421&view=diff
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifierFactory.java
(original)
+++ oodt/branches/cas-protocol-api/src/main/java/org/apache/oodt/cas/protocol/verify/ProtocolVerifierFactory.java
Fri May 27 18:44:13 2011
@@ -1,5 +1,28 @@
+/*
+ * 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.verify;
 
-public class ProtocolVerifierFactory {
+/**
+ * Factory for creating {@link ProtocolVerifier}s
+ * 
+ * @author bfoster
+ */
+public interface ProtocolVerifierFactory {
+
+	public ProtocolVerifier newInstance();
 
 }

Added: oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-config.xml
URL: http://svn.apache.org/viewvc/oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-config.xml?rev=1128421&view=auto
==============================================================================
--- oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-config.xml (added)
+++ oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-config.xml Fri May 27
18:44:13 2011
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+	
+	Author: bfoster
+	Description: ProtocolManager Configuration
+	
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean class="org.apache.oodt.cas.protocol.some.factory">
+		
+	</bean>
+	
+</beans>
\ No newline at end of file

Propchange: oodt/branches/cas-protocol-api/src/main/resources/policy/protocol-config.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message