http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/profile/src/test/java/org/apache/oodt/profile/ResourceAttributesTest.java ---------------------------------------------------------------------- diff --git a/profile/src/test/java/org/apache/oodt/profile/ResourceAttributesTest.java b/profile/src/test/java/org/apache/oodt/profile/ResourceAttributesTest.java deleted file mode 100644 index b69bd37..0000000 --- a/profile/src/test/java/org/apache/oodt/profile/ResourceAttributesTest.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * 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.profile; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import org.apache.oodt.commons.io.NullOutputStream; -import org.apache.oodt.commons.util.XML; -import junit.framework.TestCase; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * Unit test the {@link ResourceAttributes} class. - * - * @author Kelly - */ -public class ResourceAttributesTest extends TestCase { - /** Construct the test case for the {@link ResourceAttributes} class. */ - public ResourceAttributesTest(String name) { - super(name); - } - - public void testNoArgsCtor() { - ResourceAttributes blank = new ResourceAttributes(); - assertEquals("UNKNOWN", blank.getIdentifier()); - assertEquals(0, blank.getFormats().size()); - assertEquals(0, blank.getCreators().size()); - assertEquals(0, blank.getSubjects().size()); - assertEquals(0, blank.getPublishers().size()); - assertEquals(0, blank.getContributors().size()); - assertEquals(0, blank.getDates().size()); - assertEquals(0, blank.getTypes().size()); - assertEquals(0, blank.getSources().size()); - assertEquals(0, blank.getLanguages().size()); - assertEquals(0, blank.getRelations().size()); - assertEquals(0, blank.getCoverages().size()); - assertEquals(0, blank.getRights().size()); - assertEquals(0, blank.getResContexts().size()); - assertEquals(0, blank.getResLocations().size()); - } - - public void testObjectMethods() { - List contexts = new ArrayList(); - contexts.add("context"); - ResourceAttributes r1 = new ResourceAttributes(null, "1", "title", Collections.EMPTY_LIST, "desc", - Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, - Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, - Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, - contexts, "aggregation", "class", Collections.EMPTY_LIST); - ResourceAttributes r2 = new ResourceAttributes(null, "1", "title", Collections.EMPTY_LIST, "desc", - Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, - Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, - Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, - contexts, "aggregation", "class", Collections.EMPTY_LIST); - ResourceAttributes r3 = new ResourceAttributes(null, "2", "title2", Collections.EMPTY_LIST, "desc2", - Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, - Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, - Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, - contexts, "aggregation2", "class2", Collections.EMPTY_LIST); - assertEquals(r1, r1); - assertEquals(r1, r2); - assertTrue(!r1.equals(r3)); - ResourceAttributes r4 = (ResourceAttributes) r3.clone(); - assertEquals(r3, r4); - assertTrue(r3 != r4); - } - - public void testSetters() { - ResourceAttributes q = (ResourceAttributes) TEST_RESOURCE_ATTRIBUTES.clone(); - - assertEquals("identifier", q.getIdentifier()); - q.setIdentifier("newIdentifier"); - assertEquals("newIdentifier", q.getIdentifier()); - - assertEquals("aggregation", q.getResAggregation()); - q.setResAggregation("newAggergation"); - assertEquals("newAggergation", q.getResAggregation()); - - assertEquals("class", q.getResClass()); - q.setResClass("newClass"); - assertEquals("newClass", q.getResClass()); - } - - public void testXML() throws Exception { - Document doc = XML.createDocument(); - Node root = TEST_RESOURCE_ATTRIBUTES.toXML(doc); - assertEquals("resAttributes", root.getNodeName()); - NodeList children = root.getChildNodes(); - for (int i = 0; i < children.getLength(); ++i) { - Node child = children.item(i); - String name = child.getNodeName(); - if ("Identifier".equals(name)) { - assertEquals("identifier", XML.text(child)); - } else if ("Title".equals(name)) { - assertEquals("title", XML.text(child)); - } else if ("Format".equals(name)) { - // ignore - } else if ("Description".equals(name)) { - assertEquals("desc", XML.text(child)); - } else if ("Creator".equals(name)) { - // ignore - } else if ("Subject".equals(name)) { - // ignore - } else if ("Publisher".equals(name)) { - // ignore - } else if ("Contributor".equals(name)) { - // ignore - } else if ("Date".equals(name)) { - // ignore - } else if ("Type".equals(name)) { - // ignore - } else if ("Source".equals(name)) { - // ignore - } else if ("Language".equals(name)) { - // ignore - } else if ("Coverage".equals(name)) { - // ignore - } else if ("Rights".equals(name)) { - // ignore - } else if ("resContext".equals(name)) { - assertEquals("context", XML.text(child)); - } else if ("resAggregation".equals(name)) { - assertEquals("aggregation", XML.text(child)); - } else if ("resClass".equals(name)) { - assertEquals("class", XML.text(child)); - } else if ("resLocation".equals(name)) { - // ignore - } else fail("Unknown node \"" + name + "\" in XML result"); - } - ResourceAttributes q = new ResourceAttributes(null, root); - assertEquals(TEST_RESOURCE_ATTRIBUTES, q); - } - - public void testXMLSerialization() throws Exception { - Profile p = new Profile(); - ResourceAttributes ra = new ResourceAttributes(p); - Document doc = XML.createDocument(); - Node root = ra.toXML(doc); - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer t = tf.newTransformer(); - DOMSource s = new DOMSource(root); - StreamResult r = new StreamResult(new NullOutputStream()); - t.transform(s, r); - } - - static ResourceAttributes TEST_RESOURCE_ATTRIBUTES; static { - List contexts = Collections.singletonList("context"); - List locations = Collections.singletonList("location"); - TEST_RESOURCE_ATTRIBUTES = new ResourceAttributes(null, "identifier", "title", - Collections.EMPTY_LIST, "desc", Collections.EMPTY_LIST, Collections.EMPTY_LIST, - Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, - Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, - Collections.EMPTY_LIST, contexts, "aggregation", "class", locations); - } -}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/profile/src/test/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServerTest.java ---------------------------------------------------------------------- diff --git a/profile/src/test/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServerTest.java b/profile/src/test/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServerTest.java deleted file mode 100644 index d8373ee..0000000 --- a/profile/src/test/java/org/apache/oodt/profile/handlers/lightweight/LightweightProfileServerTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * 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.profile.handlers.lightweight; - -import org.apache.oodt.profile.ProfileElement; -import org.apache.oodt.profile.ProfileException; -import org.apache.oodt.xmlquery.XMLQuery; - -import java.net.URI; -import java.util.List; -import java.util.Map; - -import junit.framework.TestCase; - -/** - * Unit test the LightweightProfileServer class. - * - * @author Kelly - */ -public class LightweightProfileServerTest extends TestCase { - /** Construct the test case for the LightweightProfileServer class. */ - public LightweightProfileServerTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - URI uri = getClass().getResource("lightweightTest.xml").toURI(); - server = new LightweightProfileServer(uri, "testing"); - } - - /** - * Test the getID method. - */ - public void testGetID() { - assertEquals("testing", server.getID()); - } - - /** - * Test the searching methods. - */ - public void testSearching() { - try { - List profiles; - - // Try a positive search. - profiles = doSearch("TEST > 2 AND TEST < 30"); - assertEquals(1, profiles.size()); - SearchableProfile profile = (SearchableProfile) profiles.get(0); - assertEquals("PROFILE1", profile.getProfileAttributes().getID()); - Map elements = profile.getProfileElements(); - assertEquals(3, elements.size()); - ProfileElement element = (ProfileElement) elements.get("TEST"); - assertNotNull(element); - assertEquals("3.14159", element.getID()); - - // Now a negative one. - profiles = doSearch("NONEXISTENT = 452712917824812123125100884"); - assertEquals(0, profiles.size()); - - // Now one that has multiple elements from one profile - profiles = doSearch("TEST <= 14 AND TEST2 >= 10"); - assertEquals(1, profiles.size()); - profile = (SearchableProfile) profiles.get(0); - assertEquals("PROFILE1", profile.getProfileAttributes().getID()); - elements = profile.getProfileElements(); - assertEquals(3, elements.size()); - assertTrue(elements.containsKey("TEST")); - assertTrue(elements.containsKey("TEST2")); - - // And again, but with OR instead of AND - profiles = doSearch("TEST <= 14 OR TEST2 >= 10"); - assertEquals(1, profiles.size()); - profile = (SearchableProfile) profiles.get(0); - assertEquals("PROFILE1", profile.getProfileAttributes().getID()); - elements = profile.getProfileElements(); - assertEquals(3, elements.size()); - assertTrue(elements.containsKey("TEST")); - assertTrue(elements.containsKey("TEST2")); - - // And again, but with one of the elements being not found - profiles = doSearch("NONEXISTENT = 123456789 OR TEST2 <= 1000000"); - assertEquals(1, profiles.size()); - profile = (SearchableProfile) profiles.get(0); - assertEquals("PROFILE1", profile.getProfileAttributes().getID()); - elements = profile.getProfileElements(); - assertEquals(3, elements.size()); - assertTrue(elements.containsKey("TEST2")); - - // And again, but spanning profiles - profiles = doSearch("TEST2 = 48 OR TEST4 = 192"); - assertEquals(2, profiles.size()); - for (Object profile1 : profiles) { - profile = (SearchableProfile) profile1; - elements = profile.getProfileElements(); - assertEquals(3, elements.size()); - if (profile.getProfileAttributes().getID().equals("PROFILE1")) { - assertTrue(elements.containsKey("TEST2")); - } else if (profile.getProfileAttributes().getID().equals("PROFILE2")) { - assertTrue(elements.containsKey("TEST4")); - } else { - fail("Profile \"" + profile.getProfileAttributes().getID() + "\" matched, but shouldn't"); - } - } - - // And again, but with a query on the "from" part. - profiles = doSearch("( TEST2 = 48 OR TEST4 = 192 ) AND Creator = Alice"); - assertEquals(1, profiles.size()); - profile = (SearchableProfile) profiles.get(0); - assertEquals("PROFILE1", profile.getProfileAttributes().getID()); - - // And again, but on a nonenumerated element with no min/max values. - profiles = doSearch("TEST5 = GEEBA"); - assertEquals(1, profiles.size()); - profile = (SearchableProfile) profiles.get(0); - assertEquals("PROFILE2", profile.getProfileAttributes().getID()); - - // And again, but with "RETURN =" parts. - //fail("Not yet implemented"); - - } catch (ProfileException ex) { - fail("Profile server failed with excepton: " + ex.getMessage()); - } - } - - /** - * Execute the given search. - * - * @param expr The search experssion. - * @return List of matching profiles. - * @throws ProfileException If the profile server fails. - */ - private List doSearch(String expr) throws ProfileException { - XMLQuery query = new XMLQuery(expr, "test1", "LightweightProfileServerTest", - "This query is to test the LightweightProfileServer", /*ddId*/null, /*resultModeId*/null, - /*propType*/null, /*propLevels*/null, XMLQuery.DEFAULT_MAX_RESULTS); - return server.findProfiles(query); - } - - - /** The lightweight profile server being tested. */ - private LightweightProfileServer server; -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/profile/src/test/resources/org/apache/oodt/profile/handlers/lightweight/lightweightTest.xml ---------------------------------------------------------------------- diff --git a/profile/src/test/resources/org/apache/oodt/profile/handlers/lightweight/lightweightTest.xml b/profile/src/test/resources/org/apache/oodt/profile/handlers/lightweight/lightweightTest.xml deleted file mode 100644 index c7ffb63..0000000 --- a/profile/src/test/resources/org/apache/oodt/profile/handlers/lightweight/lightweightTest.xml +++ /dev/null @@ -1,119 +0,0 @@ -<?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. ---> -<!DOCTYPE profiles PUBLIC "-//JPL//DTD EDA Profile 1.1//EN" "http://oodt.jpl.nasa.gov/grid-profile/dtd/prof.dtd"> -<profiles> - <profile> - <profAttributes> - <profId>PROFILE1</profId> - <profType>profile</profType> - <profStatusId>active</profStatusId> - <profSecurityType>NULL</profSecurityType> - <profRevisionNote>1.0</profRevisionNote> - </profAttributes> - <resAttributes> - <Identifier>TEST_PROFILE_1</Identifier> - <Title>Test profile number 1</Title> - <Format>text/html</Format> - <Creator>Alice</Creator> - <resContext>TEST</resContext> - <resAggregation>N/A</resAggregation> - <resClass>system.profileServer</resClass> - <resLocation>iiop://oodt.jpl.nasa.gov:10000/Test.Profile</resLocation> - </resAttributes> - <profElement> - <elemId>3.14159</elemId> - <elemName>TEST</elemName> - <elemDesc>This is a test element</elemDesc> - <elemType>Testing</elemType> - <elemUnit>fortnights-per-furlong</elemUnit> - <elemEnumFlag>F</elemEnumFlag> - <elemMinValue>0</elemMinValue> - <elemMaxValue>32</elemMaxValue> - <elemComment>Testing only.</elemComment> - </profElement> - <profElement> - <elemId>3.2</elemId> - <elemName>TEST2</elemName> - <elemDesc>This is another test element</elemDesc> - <elemType>Testing</elemType> - <elemUnit>fleas-per-tick</elemUnit> - <elemEnumFlag>F</elemEnumFlag> - <elemMinValue>32</elemMinValue> - <elemMaxValue>64</elemMaxValue> - <elemComment>More testing.</elemComment> - </profElement> - <profElement> - <elemId>3.5</elemId> - <elemName>TEST3</elemName> - <elemDesc>Yet another test element</elemDesc> - <elemType>Testing</elemType> - <elemEnumFlag>T</elemEnumFlag> - <elemValue>alpha</elemValue> - <elemValue>beta</elemValue> - <elemValue>gamma</elemValue> - <elemValue>delta</elemValue> - <elemComment>A bunch of greek letters, eh?</elemComment> - </profElement> - </profile> - - <profile> - <profAttributes> - <profId>PROFILE2</profId> - <profType>profile</profType> - <profStatusId>active</profStatusId> - <profSecurityType>NULL</profSecurityType> - <profRevisionNote>1.0</profRevisionNote> - </profAttributes> - <resAttributes> - <Identifier>TEST_PROFILE_2</Identifier> - <Title>Test profile number 2</Title> - <Format>text/html</Format> - <Creator>Bill</Creator> - <resContext>TEST</resContext> - <resAggregation>N/A</resAggregation> - <resClass>system.profileServer</resClass> - <resLocation>iiop://oodt.jpl.nasa.gov:10000/Test.Profile</resLocation> - </resAttributes> - <profElement> - <elemId>3.5</elemId> - <elemName>TEST3</elemName> - <elemDesc>Yet another test element</elemDesc> - <elemType>Testing</elemType> - <elemEnumFlag>T</elemEnumFlag> - <elemValue>alpha</elemValue> - <elemValue>beta</elemValue> - <elemValue>gamma</elemValue> - <elemValue>delta</elemValue> - <elemComment>A bunch of greek letters, eh?</elemComment> - </profElement> - <profElement> - <elemId>3.6</elemId> - <elemName>TEST4</elemName> - <elemDesc>And still another test element</elemDesc> - <elemType>Testing</elemType> - <elemEnumFlag>F</elemEnumFlag> - <elemMinValue>128</elemMinValue> - <elemMaxValue>256</elemMaxValue> - </profElement> - <profElement> - <elemId>3.7</elemId> - <elemName>TEST5</elemName> - <elemDesc>This is a nonenumerated field with no min/max values, meaning it should always match.</elemDesc> - <elemType>char</elemType> - <elemEnumFlag>F</elemEnumFlag> - </profElement> - </profile> -</profiles> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/profile/src/test/resources/org/apache/oodt/profile/test.xml ---------------------------------------------------------------------- diff --git a/profile/src/test/resources/org/apache/oodt/profile/test.xml b/profile/src/test/resources/org/apache/oodt/profile/test.xml deleted file mode 100644 index 8e38c82..0000000 --- a/profile/src/test/resources/org/apache/oodt/profile/test.xml +++ /dev/null @@ -1,71 +0,0 @@ -<!-- DO NOT put the XML processing instruction or DOCTYPE decl in this --> -<!-- file! They're added by the unit test automatically. --> -<!-- $Id: test.xml,v 1.1.1.1 2004/03/02 20:53:39 kelly Exp $ --> -<!-- -Licensed to the Apache Software Foundation (ASF) under one or more contributor -license agreements. See the NOTICE.txt 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. ---> -<profile> - <profAttributes> - <profId>OODT_PDS_PROFILE_SERVER</profId> - <profType>profile</profType> - <profStatusId>active</profStatusId> - <profSecurityType>NULL</profSecurityType> - <profRevisionNote>1999-09-30</profRevisionNote> - </profAttributes> - <resAttributes> - <Identifier>PDS_PROFILE_SERVER</Identifier> - <Title>Planetary Data System (PDS) - Profile Server V1.0</Title> - <Format>text/html</Format> - <resContext>PDS</resContext> - <resAggregation>N/A</resAggregation> - <resClass>system.profileServer</resClass> - <resLocation>iiop://oodt.jpl.nasa.gov:10000/JPL.PDS.PROFILE</resLocation> - </resAttributes> - <profElement> - <elemId>3.14159</elemId> - <elemName>TEST</elemName> - <elemDesc>This is a test element</elemDesc> - <elemType>Testing</elemType> - <elemUnit>fortnights-per-furlong</elemUnit> - <elemEnumFlag>F</elemEnumFlag> - <elemMinValue>0</elemMinValue> - <elemMaxValue>32</elemMaxValue> - <elemComment>Testing only.</elemComment> - </profElement> - <profElement> - <elemId>3.2</elemId> - <elemName>TEST2</elemName> - <elemDesc>This is another test element</elemDesc> - <elemType>Testing</elemType> - <elemUnit>fleas-per-tick</elemUnit> - <elemEnumFlag>F</elemEnumFlag> - <elemMinValue>32</elemMinValue> - <elemMaxValue>64</elemMaxValue> - <elemComment>More testing.</elemComment> - </profElement> - <profElement> - <elemId>3.5</elemId> - <elemName>TEST3</elemName> - <elemDesc>Yet another test element</elemDesc> - <elemType>Testing</elemType> - <elemEnumFlag>T</elemEnumFlag> - <elemValue>alpha</elemValue> - <elemValue>beta</elemValue> - <elemValue>gamma</elemValue> - <elemValue>delta</elemValue> - <elemComment>A bunch of greek letters, eh?</elemComment> - </profElement> -</profile> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/profile/src/test/resources/test.xml ---------------------------------------------------------------------- diff --git a/profile/src/test/resources/test.xml b/profile/src/test/resources/test.xml deleted file mode 100644 index 8e38c82..0000000 --- a/profile/src/test/resources/test.xml +++ /dev/null @@ -1,71 +0,0 @@ -<!-- DO NOT put the XML processing instruction or DOCTYPE decl in this --> -<!-- file! They're added by the unit test automatically. --> -<!-- $Id: test.xml,v 1.1.1.1 2004/03/02 20:53:39 kelly Exp $ --> -<!-- -Licensed to the Apache Software Foundation (ASF) under one or more contributor -license agreements. See the NOTICE.txt 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. ---> -<profile> - <profAttributes> - <profId>OODT_PDS_PROFILE_SERVER</profId> - <profType>profile</profType> - <profStatusId>active</profStatusId> - <profSecurityType>NULL</profSecurityType> - <profRevisionNote>1999-09-30</profRevisionNote> - </profAttributes> - <resAttributes> - <Identifier>PDS_PROFILE_SERVER</Identifier> - <Title>Planetary Data System (PDS) - Profile Server V1.0</Title> - <Format>text/html</Format> - <resContext>PDS</resContext> - <resAggregation>N/A</resAggregation> - <resClass>system.profileServer</resClass> - <resLocation>iiop://oodt.jpl.nasa.gov:10000/JPL.PDS.PROFILE</resLocation> - </resAttributes> - <profElement> - <elemId>3.14159</elemId> - <elemName>TEST</elemName> - <elemDesc>This is a test element</elemDesc> - <elemType>Testing</elemType> - <elemUnit>fortnights-per-furlong</elemUnit> - <elemEnumFlag>F</elemEnumFlag> - <elemMinValue>0</elemMinValue> - <elemMaxValue>32</elemMaxValue> - <elemComment>Testing only.</elemComment> - </profElement> - <profElement> - <elemId>3.2</elemId> - <elemName>TEST2</elemName> - <elemDesc>This is another test element</elemDesc> - <elemType>Testing</elemType> - <elemUnit>fleas-per-tick</elemUnit> - <elemEnumFlag>F</elemEnumFlag> - <elemMinValue>32</elemMinValue> - <elemMaxValue>64</elemMaxValue> - <elemComment>More testing.</elemComment> - </profElement> - <profElement> - <elemId>3.5</elemId> - <elemName>TEST3</elemName> - <elemDesc>Yet another test element</elemDesc> - <elemType>Testing</elemType> - <elemEnumFlag>T</elemEnumFlag> - <elemValue>alpha</elemValue> - <elemValue>beta</elemValue> - <elemValue>gamma</elemValue> - <elemValue>delta</elemValue> - <elemComment>A bunch of greek letters, eh?</elemComment> - </profElement> -</profile> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/.gitignore ---------------------------------------------------------------------- diff --git a/protocol/api/.gitignore b/protocol/api/.gitignore deleted file mode 100644 index b54523f..0000000 --- a/protocol/api/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/maven-eclipse.xml http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/pom.xml ---------------------------------------------------------------------- diff --git a/protocol/api/pom.xml b/protocol/api/pom.xml deleted file mode 100644 index 0cbe0a4..0000000 --- a/protocol/api/pom.xml +++ /dev/null @@ -1,147 +0,0 @@ -<?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>1.1-SNAPSHOT</version> - <relativePath>../../core/pom.xml</relativePath> - </parent> - <artifactId>cas-protocol-api</artifactId> - <name>CAS Protocol</name> - <!-- All dependencies should be listed in core/pom.xml and be ordered alphabetically by package and artifact. - Once the dependency is in the core pom, it can then be used in other modules without the version tags. - For example, within core/pom.xml: - - <dependency> - <groupId>com.amazonaws</groupId> - <artifactId>aws-java-sdk</artifactId> - <version>1.7.4</version> - </dependency> - - Elsewhere in the platform: - <dependency> - <groupId>com.amazonaws</groupId> - <artifactId>aws-java-sdk</artifactId> - </dependency> - - Where possible the same dependency version should be used across the whole platform but if required the version - can be overridden in a specific pom and should have a comment explaing why the version has been overridden - --> - <dependencies> - <dependency> - <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>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.oodt</groupId> - <artifactId>cas-cli</artifactId> - </dependency> - <dependency> - <groupId>org.apache.oodt</groupId> - <artifactId>cas-metadata</artifactId> - </dependency> - <dependency> - <groupId>org.apache.oodt</groupId> - <artifactId>oodt-commons</artifactId> - </dependency> - <dependency> - <groupId>xmlrpc</groupId> - <artifactId>xmlrpc</artifactId> - </dependency> - </dependencies> - <build> - <resources> - <resource> - <targetPath>org/apache/oodt/cas/protocol</targetPath> - <directory>${basedir}/src/main/resources/policy</directory> - <includes> - <include>protocol-config.xml</include> - </includes> - </resource> - </resources> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-assembly-plugin</artifactId> - <version>2.2-beta-2</version> - <configuration> - <descriptors> - <descriptor>src/main/assembly/assembly.xml</descriptor> - </descriptors> - <archive> - <manifest> - <mainClass>org.apache.oodt.cas.protocol.system.CLProtocolManager</mainClass> - </manifest> - </archive> - </configuration> - <executions> - <execution> - <goals> - <goal>single</goal> - </goals> - <phase>package</phase> - </execution> - </executions> - </plugin> - </plugins> - </build> - <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> - <goals> - <goal>check</goal> - </goals> - <phase>verify</phase> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> -</project> http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/assembly/assembly.xml ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/assembly/assembly.xml b/protocol/api/src/main/assembly/assembly.xml deleted file mode 100644 index 9af13fd..0000000 --- a/protocol/api/src/main/assembly/assembly.xml +++ /dev/null @@ -1,94 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one or more contributor -license agreements. See the NOTICE.txt 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. ---> -<assembly> - <id>dist</id> - <formats> - <format>tar.gz</format> - <format>zip</format> - </formats> - <includeBaseDirectory>true</includeBaseDirectory> - <baseDirectory>${project.artifactId}-${project.version}</baseDirectory> - <includeSiteDirectory>false</includeSiteDirectory> - <fileSets> - <fileSet> - <directory>${basedir}</directory> - <outputDirectory>.</outputDirectory> - <includes> - <include>LICENSE.txt</include> - <include>CHANGES.txt</include> - </includes> - </fileSet> - <fileSet> - <directory>${basedir}/src/main/bin</directory> - <outputDirectory>bin</outputDirectory> - <includes/> - <fileMode>755</fileMode> - </fileSet> - <fileSet> - <directory>${basedir}/src/main/resources</directory> - <outputDirectory>etc</outputDirectory> - <includes> - <include>*.properties</include> - <include>jssecacerts</include> - </includes> - </fileSet> - <fileSet> - <directory>${basedir}/src/main/resources/examples</directory> - <outputDirectory>etc/examples</outputDirectory> - <excludes/> - </fileSet> - <fileSet> - <directory>${basedir}/src/main/resources</directory> - <outputDirectory>logs</outputDirectory> - <includes> - <include>REMOVE.log</include> - </includes> - </fileSet> - <fileSet> - <directory>${basedir}/src/main/resources/policy</directory> - <outputDirectory>policy</outputDirectory> - <includes> - <include>cmd-line-actions.xml</include> - <include>cmd-line-options.xml</include> - </includes> - </fileSet> - <fileSet> - <directory>${basedir}/src/main/java/org/apache/oodt/cas/protocol</directory> - <outputDirectory>policy</outputDirectory> - <includes> - <include>protocol-config.xml</include> - </includes> - </fileSet> - <fileSet> - <directory>target/site/apidocs</directory> - <filtered>false</filtered> - <outputDirectory>doc</outputDirectory> - <excludes/> - </fileSet> - </fileSets> - <dependencySets> - <dependencySet> - <outputDirectory>lib</outputDirectory> - <unpack>false</unpack> - <useProjectArtifact>true</useProjectArtifact> - <useTransitiveDependencies>true</useTransitiveDependencies> - <unpackOptions/> - </dependencySet> - </dependencySets> -</assembly> - http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/bin/protocol ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/bin/protocol b/protocol/api/src/main/bin/protocol deleted file mode 100644 index ff4cc20..0000000 --- a/protocol/api/src/main/bin/protocol +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/csh - -# 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. - -set args - -if ( $#args > 0 ) then - set args = "$*" -endif - -${JAVA_HOME}/bin/java \ - -Djava.ext.dirs=../lib \ - -Djava.util.logging.config.file=../etc/logging.properties \ - -Dorg.apache.oodt.cas.cli.action.spring.config=../policy/cmd-line-actions.xml \ - -Dorg.apache.oodt.cas.cli.option.spring.config=../policy/cmd-line-options.xml \ - org.apache.oodt.cas.protocol.system.ProtocolCommandLine ${args} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/Protocol.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/Protocol.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/Protocol.java deleted file mode 100644 index 54df836..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/Protocol.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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; -import org.apache.oodt.cas.protocol.util.ProtocolFileFilter; - -//JDK imports -import java.io.File; -import java.util.List; - -/** - * Interface for communication over different transfer protocols - * - * @author bfoster - * @version $Revision$ - */ -public interface Protocol { - - void connect(String host, Authentication authentication) throws ProtocolException; - - void close() throws ProtocolException; - - boolean connected(); - - void cd(ProtocolFile file) throws ProtocolException; - - void cdRoot() throws ProtocolException; - - void cdHome() throws ProtocolException; - - void get(ProtocolFile fromFile, File toFile) throws ProtocolException; - - void put(File fromFile, ProtocolFile toFile) throws ProtocolException; - - ProtocolFile pwd() throws ProtocolException; - - List<ProtocolFile> ls() throws ProtocolException; - - List<ProtocolFile> ls(ProtocolFileFilter filter) throws ProtocolException; - - void delete(ProtocolFile file) throws ProtocolException; - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFactory.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFactory.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFactory.java deleted file mode 100644 index e0ffd61..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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; - -/** - * Factory for creating {@link Protocol}s - * - * @author bfoster - * @version $Revision$ - */ -public interface ProtocolFactory { - - Protocol newInstance(); - - String getSchema(); - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFile.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFile.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFile.java deleted file mode 100644 index 835dcc7..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/ProtocolFile.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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; - -//APACHE imports -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.Validate; - -/** - * A path representing a file/directory over some {@link Protocol} - * - * @author bfoster - */ -public class ProtocolFile { - - public static final String SEPARATOR = "/"; - - private String path; - private boolean isDir; - private ProtocolFile parent; - - public ProtocolFile(String path, boolean isDir) { - this(null, path, isDir); - } - - public ProtocolFile(ProtocolFile parent, String path, boolean isDir) { - this.parent = parent; - this.isDir = isDir; - Validate.notNull(path, "ProtocolFile's path cannot be NULL"); - this.path = path.length() > 0 && !path.equals(SEPARATOR) ? StringUtils - .chomp(path, 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(SEPARATOR) + 1); - } - - /** - * True if this path is a relative path (i.e. does not start with - * {@link SEPARATOR}). - * - * @return True is this a relative path, false otherwise - */ - public boolean isRelative() { - return !path.startsWith(SEPARATOR); - } - - /** - * Gets the parent {@link ProtocolFile} for this path. - * - * @return The parent {@link ProtocolFile} - */ - public ProtocolFile getParent() { - if (parent != null) { - return parent; - } else { - int index = StringUtils.lastIndexOf(path, SEPARATOR); - return (index > 0) ? new ProtocolFile(StringUtils.substring(path, 0, index), true) : null; - } - } - - /** - * Get Absolute pathed {@link ProtocolFile} version of this {@link ProtocolFile}. - * - * @return the absolute pathed version of this {@link ProtocolFile} - */ - public ProtocolFile getAbsoluteFile() { - if (this.isRelative()) { - ProtocolFile parent = this.getParent(); - if (parent != null) { - return new ProtocolFile(StringUtils.chomp(parent.getAbsoluteFile().getPath(), SEPARATOR) - + SEPARATOR + this.getPath(), this.isDir()); - } - } - return this; - } - - /** - * {@inheritDoc} - */ - public int hashCode() { - return this.getPath().hashCode(); - } - - /** - * {@inheritDoc} - */ - public boolean equals(Object path) { - if (path instanceof ProtocolFile) { - ProtocolFile p = (ProtocolFile) path; - return (p.getAbsoluteFile().getPath() - .equals(this.getAbsoluteFile().getPath()) && p.isDir() == this - .isDir()); - } - return false; - } - - /** - * {@inheritDoc} - */ - public String toString() { - return "{parent = '" + this.parent + "', path = '" + path + "', isDir = '" + isDir + "'}"; - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/auth/Authentication.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/auth/Authentication.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/auth/Authentication.java deleted file mode 100644 index d387933..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/auth/Authentication.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 { - - String getUser(); - - String getPass(); - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/auth/BasicAuthentication.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/auth/BasicAuthentication.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/auth/BasicAuthentication.java deleted file mode 100644 index 27e4435..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/auth/BasicAuthentication.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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; - -import org.apache.commons.lang.Validate; - -/** - * Basic username and password {@link Authentication} - * - * @author bfoster - * @version $Revision$ - */ -public class BasicAuthentication implements Authentication { - - private String user; - private String pass; - - public BasicAuthentication(String user, String pass) { - Validate.notNull(user, "NULL user not allowed"); - Validate.notNull(pass, "NULL pass not allowed"); - this.user = user; - this.pass = pass; - } - - public String getUser() { - return user; - } - - public String getPass() { - return pass; - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/auth/NoAuthentication.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/auth/NoAuthentication.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/auth/NoAuthentication.java deleted file mode 100644 index 2f402d5..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/auth/NoAuthentication.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 getUser() { - return ""; - } - - public String getPass() { - return ""; - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/BasicVerifyCliAction.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/BasicVerifyCliAction.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/BasicVerifyCliAction.java deleted file mode 100644 index f76dc0e..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/BasicVerifyCliAction.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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.cli.action; - -//OODT imports -import org.apache.oodt.cas.cli.exception.CmdLineActionException; -import org.apache.oodt.cas.protocol.Protocol; -import org.apache.oodt.cas.protocol.ProtocolFactory; -import org.apache.oodt.cas.protocol.verify.ProtocolVerifier; - -/** - * Action for determining whether a given {@link Protocol} or auto-determined - * {@link Protocol} via {@link org.apache.oodt.cas.protocol.system.ProtocolManager} can connect and pass - * verification of the given {@link Verifier} for given site. - * - * @author bfoster (Brian Foster) - */ -public class BasicVerifyCliAction extends ProtocolCliAction { - - private ProtocolVerifier verifier; - private ProtocolFactory factory; - - private boolean lastVerificationResult; - - @Override - public void execute(ActionMessagePrinter printer) - throws CmdLineActionException { - try { - if (factory != null) { - Protocol protocol = factory.newInstance(); - if (lastVerificationResult = verifier.verify(protocol, getSite(), - getAuthentication())) { - printer.println("Protocol '" - + protocol.getClass().getCanonicalName() - + "' PASSED verification!"); - } else { - printer.println("Protocol '" - + protocol.getClass().getCanonicalName() - + "' FAILED verification!"); - } - } else { - Protocol protocol = getProtocolManager().getProtocolBySite( - getSite(), getAuthentication(), verifier); - if (lastVerificationResult = protocol != null) { - printer.println("Protocol '" - + protocol.getClass().getCanonicalName() - + "' PASSED verification!"); - } else { - printer.println("No Protocol determined, FAILED verification!"); - } - } - } catch (Exception e) { - throw new CmdLineActionException("Failed to verify factory '" - + factory + "' : " + e.getMessage(), e); - } - } - - public void setVerifier(ProtocolVerifier verifier) { - this.verifier = verifier; - } - - public void setProtocolFactory(ProtocolFactory factory) { - this.factory = factory; - } - - protected boolean getLastVerificationResults() { - return lastVerificationResult; - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/CrossProtocolTransferCliAction.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/CrossProtocolTransferCliAction.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/CrossProtocolTransferCliAction.java deleted file mode 100644 index 94005e7..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/CrossProtocolTransferCliAction.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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.cli.action; - -//OODT imports -import java.io.File; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.UUID; - -//OODT imports -import org.apache.oodt.cas.cli.exception.CmdLineActionException; -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.auth.BasicAuthentication; -import org.apache.oodt.cas.protocol.auth.NoAuthentication; -import org.apache.oodt.cas.protocol.system.ProtocolManager; -import org.apache.oodt.cas.protocol.verify.ProtocolVerifier; -import org.apache.oodt.cas.protocol.verify.ProtocolVerifierFactory; - -/** - * {@link ProtocolAction} for transferring a file from one host to another - * - * @author bfoster (Brian Foster) - */ -public class CrossProtocolTransferCliAction extends ProtocolCliAction { - - private URI fromUri; - private URI toUri; - private ProtocolVerifierFactory verifierFactory; - - @Override - public void execute(ActionMessagePrinter printer) - throws CmdLineActionException { - try { - ProtocolVerifier verifier = null; - if (verifierFactory != null) { - verifier = verifierFactory.newInstance(); - } - - File localFile = createTempDownloadFile(); - if (localFile == null) { - throw new Exception("Failed to create tempory local file"); - } - - ProtocolManager protocolManager = getProtocolManager(); - Protocol fromProtocol = protocolManager.getProtocolBySite(fromUri, - getAuthentication(fromUri), verifier); - if (fromProtocol == null) { - throw new Exception("Failed to get protocol for 'from' URI '" - + fromUri + "'"); - } - - Protocol toProtocol = protocolManager.getProtocolBySite(toUri, - getAuthentication(toUri), verifier); - if (toProtocol == null) { - throw new Exception("Failed to get protocol for 'to' URI '" + toUri - + "'"); - } - - fromProtocol - .get(new ProtocolFile(fromUri.getPath(), false), localFile); - toProtocol.put(localFile, new ProtocolFile(toUri.getPath(), false)); - } catch (Exception e) { - throw new CmdLineActionException( - "Failed to transfer between 2 protocols : " + e.getMessage(), e); - } - } - - public void setFromUri(String fromUri) throws URISyntaxException { - this.fromUri = new URI(fromUri); - } - - public void setToUri(String toUri) throws URISyntaxException { - this.toUri = new URI(toUri); - } - - public void setVerifierFactory(ProtocolVerifierFactory verifierFactory) { - this.verifierFactory = verifierFactory; - } - - private File createTempDownloadFile() { - File bogusFile = null; - try { - bogusFile = File.createTempFile("bogus", "bogus"); - File tmpDir = new File(bogusFile.getParentFile(), "ProtocolTransfer/" - + UUID.randomUUID().toString()); - tmpDir.mkdirs(); - return new File(tmpDir, "temp_file"); - } catch (Exception e) { - return null; - } finally { - try { - bogusFile.delete(); - } catch (Exception ignored) { - } - } - } - - private Authentication getAuthentication(URI uri) { - if (uri.getUserInfo() != null) { - String[] userInfo = uri.getUserInfo().split("\\:"); - return new BasicAuthentication(userInfo[0], userInfo[1]); - } else { - return new NoAuthentication(); - } - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/DeleteEmptyDirectoriesCliAction.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/DeleteEmptyDirectoriesCliAction.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/DeleteEmptyDirectoriesCliAction.java deleted file mode 100644 index 5464164..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/DeleteEmptyDirectoriesCliAction.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.cli.action; - -// JDK imports -import java.util.List; -import java.util.regex.Pattern; - - - -// OODT imports -import org.apache.oodt.cas.cli.exception.CmdLineActionException; -import org.apache.oodt.cas.protocol.Protocol; -import org.apache.oodt.cas.protocol.ProtocolFile; -import org.apache.oodt.cas.protocol.verify.ProtocolVerifierFactory; - -/** - * {@link ProtocolAction} for deleting empty files from site. - * - * @author bfoster (Brian Foster) - */ -public class DeleteEmptyDirectoriesCliAction extends ProtocolCliAction { - - private String directoryRegex = ".+"; - private ProtocolVerifierFactory verifierFactory; - - @Override - public void execute(ActionMessagePrinter printer) throws CmdLineActionException { - try { - Protocol protocol = getProtocolManager().getProtocolBySite( - getSite(), getAuthentication(), verifierFactory.newInstance()); - List<ProtocolFile> files = protocol.ls(); - for (ProtocolFile file : files) { - if (file.isDir() && Pattern.matches(directoryRegex, file.getName())) { - try { - protocol.delete(file); - printer.println("Success: " + file.getPath()); - } catch (Exception e) { - printer.println("Failed: " + file.getPath()); - } - } - } - } catch (Exception e) { - throw new CmdLineActionException("Failed to delete directories", e); - } - } - - public void setDirectoryRegex(String directoryRegex) { - this.directoryRegex = directoryRegex; - } - - public void setVerifierFactory(ProtocolVerifierFactory verifierFactory) { - this.verifierFactory = verifierFactory; - } -} - http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/DownloadCliAction.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/DownloadCliAction.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/DownloadCliAction.java deleted file mode 100644 index 9497d02..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/DownloadCliAction.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.cli.action; - -//JDK imports -import java.io.File; -import java.net.URI; -import java.net.URISyntaxException; - -//OODT imports -import org.apache.oodt.cas.cli.exception.CmdLineActionException; -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 url - * - * @author bfoster (Brian Foster) - */ -public class DownloadCliAction extends ProtocolCliAction { - - protected URI uri; - protected String toDir; - protected Protocol usedProtocol; - - @Override - public void execute(ActionMessagePrinter printer) - throws CmdLineActionException { - try { - usedProtocol = createProtocol(getProtocolManager()); - ProtocolFile fromFile = createProtocolFile(); - String toFilename = fromFile.equals(ProtocolFile.SEPARATOR) - || fromFile.getName().isEmpty() ? uri.getHost() : fromFile - .getName(); - File toFile = (toDir != null) ? new File(toDir, toFilename) - : new File(toFilename); - usedProtocol.get(fromFile, toFile.getAbsoluteFile()); - } catch (Exception e) { - throw new CmdLineActionException("Failed to download : " - + e.getMessage(), e); - } - } - - public void setUrl(String urlString) throws URISyntaxException { - uri = new URI(urlString); - } - - public void setToDir(String toDir) { - this.toDir = toDir; - } - - protected Protocol getUsedProtocol() { - return usedProtocol; - } - - protected ProtocolFile createProtocolFile() { - return new ProtocolFile(uri.getPath(), false); - } - - protected Protocol createProtocol(ProtocolManager protocolManager) - throws URISyntaxException { - return protocolManager.getProtocolBySite( - new URI(uri.getScheme(), uri.getHost(), null, null), - getAuthentication(), null); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/GetSupportedFactoriesCliAction.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/GetSupportedFactoriesCliAction.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/GetSupportedFactoriesCliAction.java deleted file mode 100644 index 9402949..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/GetSupportedFactoriesCliAction.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.cli.action; - -//OODT imports -import org.apache.oodt.cas.cli.exception.CmdLineActionException; -import org.apache.oodt.cas.protocol.ProtocolFactory; - -/** - * {@link ProtocolAction} for get a list of supported {@link ProtocolFactory}s. - * - * @author bfoster (Brian Foster) - */ -public class GetSupportedFactoriesCliAction extends ProtocolCliAction { - - @Override - public void execute(ActionMessagePrinter printer) - throws CmdLineActionException { - try { - printer.println("Supported Factories:"); - for (ProtocolFactory factory : getProtocolManager().getFactories()) { - System.out.println(" - " + factory.getClass().getCanonicalName()); - } - } catch (Exception e) { - throw new CmdLineActionException( - "Failed to get supported factories : " + e.getMessage(), e); - } - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/ProtocolCliAction.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/ProtocolCliAction.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/ProtocolCliAction.java deleted file mode 100644 index 39e8784..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/cli/action/ProtocolCliAction.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.cli.action; - -//JDK imports -import java.net.URI; -import java.net.URISyntaxException; - -//OODT imports -import org.apache.oodt.cas.cli.action.CmdLineAction; -import org.apache.oodt.cas.metadata.util.PathUtils; -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.config.SpringProtocolConfig; -import org.apache.oodt.cas.protocol.system.ProtocolManager; - -/** - * Action used to perform some task via a {@link ProtocolManager} - * - * @author bfoster (Brian Foster) - */ -public abstract class ProtocolCliAction extends CmdLineAction { - - private String user; - private String pass; - private String site; - private ProtocolManager protocolManager; - - 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 void setProtocolManager(ProtocolManager protocolManager) { - this.protocolManager = protocolManager; - } - - public ProtocolManager getProtocolManager() throws Exception { - if (protocolManager != null) { - return protocolManager; - } - String protocolConfig = PathUtils - .doDynamicReplacement(System - .getProperty( - "org.apache.oodt.cas.protocol.manager.config.file", - "classpath:/org/apache/oodt/cas/protocol/protocol-config.xml")); - return protocolManager = new ProtocolManager(new SpringProtocolConfig( - protocolConfig)); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/config/ProtocolConfig.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/config/ProtocolConfig.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/config/ProtocolConfig.java deleted file mode 100644 index 6c36b62..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/config/ProtocolConfig.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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; - - -//OODT imports -import org.apache.oodt.cas.protocol.ProtocolFactory; - -//JDK imports -import java.net.URI; -import java.util.List; - - -/** - * Protocol configuration for configuring {@link org.apache.oodt.cas.protocol.system.ProtocolManager}. - * - * @author bfoster - */ -public interface ProtocolConfig { - - List<ProtocolFactory> getAllFactories(); - - List<ProtocolFactory> getFactoriesBySite(URI site); - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/config/SpringProtocolConfig.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/config/SpringProtocolConfig.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/config/SpringProtocolConfig.java deleted file mode 100644 index 9f27c86..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/config/SpringProtocolConfig.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.concurrent.ConcurrentHashMap; -import java.util.List; -import java.util.Map; - -//Spring imports -import org.apache.commons.lang.Validate; -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 { - - protected Map<String, List<ProtocolFactory>> factoryMap; - - public SpringProtocolConfig(String configFile) { - Validate.notNull(configFile, "SpringProtocolConfig configFile cannnot be NULL"); - factoryMap = new ConcurrentHashMap<String, List<ProtocolFactory>>(); - loadFactories(new FileSystemXmlApplicationContext(configFile)); - } - - private void loadFactories(FileSystemXmlApplicationContext appContext) { - 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); - factoryMap.put(factory.getSchema(), factories); - } - } - - public List<ProtocolFactory> getAllFactories() { - ArrayList<ProtocolFactory> factories = new ArrayList<ProtocolFactory>(); - for (List<ProtocolFactory> groupOfFactories : factoryMap.values()) { - factories.addAll(groupOfFactories); - } - return factories; - } - - public List<ProtocolFactory> getFactoriesBySite(URI site) { - Validate.notNull(site, "URI site cannot be NULL"); - List<ProtocolFactory> factories = factoryMap.get(site.getScheme()); - if (factories == null) { - factories = new ArrayList<ProtocolFactory>(); - } - return factories; - } - -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/exceptions/ProtocolException.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/exceptions/ProtocolException.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/exceptions/ProtocolException.java deleted file mode 100644 index 8ac2e99..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/exceptions/ProtocolException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolCommandLine.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolCommandLine.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolCommandLine.java deleted file mode 100644 index 5f463d5..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolCommandLine.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.cli.CmdLineUtility; - -/** - * @author bfoster (Brian Foster) - */ -public class ProtocolCommandLine { - - public static void main(String[] args) throws Exception { - CmdLineUtility cmdLineUtility = new CmdLineUtility(); - cmdLineUtility.run(args); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolManager.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolManager.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolManager.java deleted file mode 100644 index 462e0d5..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/system/ProtocolManager.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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.commons.lang.Validate; -import org.apache.oodt.cas.protocol.auth.Authentication; -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; - -//JDK imports -import java.net.URI; -import java.util.concurrent.ConcurrentHashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -/** - * A Manager responsible for managing site to {@link ProtocolFactory} mapping - * - * @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) { - Validate.notNull(protocolConfig, "protocolConfig must not be NULL"); - this.protocolConfig = protocolConfig; - verifiedMap = new ConcurrentHashMap<URI, ProtocolFactory>(); - } - - public ProtocolConfig getConfig() { - return protocolConfig; - } - - public List<ProtocolFactory> getFactories() { - return protocolConfig.getAllFactories(); - } - - /** - * Determines/creates the appropriate {@link Protocol} for the given site and {@link Authentication}. - * {@link ProtocolVerifier} is run and the first {@link Protocol} to pass its verification, will be - * returned already connected to the given site. If a {@link Protocol} is returned once for a given - * site/Authentication combination, then it will be remember next time this method is called an - * {@link ProtocolVerifier} will not be run (assumed pass). - * - * @param site The URI for which a {@link Protocol} will be created - * @param auth The connection {@link Authentication} to be used to connect to the given site - * @param verifier The {@link ProtocolVerifier} which any {@link Protocol} must pass to be returned - * as the approved {@link Protocol} for the given site and {@link Authentication}; may be null, - * in which case as long as the {@link Protocol} can connect to the site it is considered a pass - * as will be returned - * @return A verified {@link Protocol} for the given site and {@link Authentication}, otherwise null if - * no {@link Protocol} could be determined. - */ - 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)) { - Protocol protocol; - try { - protocol = factory.newInstance(); - if (verifier == null || verifier.verify(protocol, site, auth)) { - verifiedMap.put(site, factory); - if (protocol.connected()) { - protocol.close(); - } - protocol.connect(site.getHost(), auth); - return protocol; - } - } catch (Exception e) { - LOG.warning("Failed to create/verify protocol from factory '" - + factory.getClass().getCanonicalName() - + "' : " - + e.getMessage()); - } - } - return null; - } - } - - /** - * - * @param site - * @param auth - * @param factory - * @throws IllegalArgumentException if any of the arguments are null - */ - public void setProtocol(URI site, Authentication auth, ProtocolFactory factory) { - Validate.notNull(site, "site must not be NULL"); - Validate.notNull(auth, "auth must not be NULL"); - Validate.notNull(factory, "factory must not be NULL"); - verifiedMap.put(site, factory); - } -} http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/protocol/api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolFileFilter.java ---------------------------------------------------------------------- diff --git a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolFileFilter.java b/protocol/api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolFileFilter.java deleted file mode 100644 index 5f99845..0000000 --- a/protocol/api/src/main/java/org/apache/oodt/cas/protocol/util/ProtocolFileFilter.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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; - -//OODT imports -import org.apache.oodt.cas.protocol.ProtocolFile; - -/** - * Filter for filtering {@ProtocolFile}s. - * - * @author bfoster - * @version $Revision$ - */ -public interface ProtocolFileFilter { - - boolean accept(ProtocolFile file); - -}
