http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/ComponentRegistryTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/ComponentRegistryTest.java b/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/ComponentRegistryTest.java deleted file mode 100644 index f5328cc..0000000 --- a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/ComponentRegistryTest.java +++ /dev/null @@ -1,181 +0,0 @@ -package io.github.taverna_extras.component.registry; -/* - * 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. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.net.URL; -import java.util.List; - -import io.github.taverna_extras.component.api.ComponentException; -import io.github.taverna_extras.component.api.Family; -import io.github.taverna_extras.component.api.profile.Profile; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -/** - * - * - * @author David Withers - */ -@Ignore -public abstract class ComponentRegistryTest extends Harness { - private Profile componentProfile; - - @Before - public void setup() throws Exception { - URL componentProfileUrl = getClass().getClassLoader().getResource( - "ValidationComponent.xml"); - assertNotNull(componentProfileUrl); - componentProfile = util.getProfile(componentProfileUrl); - } - - @After - public void tearDown() throws Exception { - for (Family componentFamily : componentRegistry.getComponentFamilies()) { - componentRegistry.removeComponentFamily(componentFamily); - } - } - - @Test - public void testGetComponentFamilies() throws Exception { - assertEquals(0, componentRegistry.getComponentFamilies().size()); - assertEquals(0, componentRegistry.getComponentFamilies().size()); - Family componentFamily = componentRegistry.createComponentFamily( - "TestComponentFamily", componentProfile, "Some description", - null, null); - assertEquals(1, componentRegistry.getComponentFamilies().size()); - assertTrue(componentRegistry.getComponentFamilies().contains( - componentFamily)); - componentRegistry.removeComponentFamily(componentFamily); - assertEquals(0, componentRegistry.getComponentFamilies().size()); - } - - @Test - public void testGetComponentFamily() throws Exception { - assertNull(componentRegistry.getComponentFamily("TestComponentFamily")); - assertNull(componentRegistry.getComponentFamily("TestComponentFamily")); - Family componentFamily = componentRegistry.createComponentFamily( - "TestComponentFamily", componentProfile, "Some description", - null, null); - assertNotNull(componentRegistry - .getComponentFamily("TestComponentFamily")); - assertNotNull(componentRegistry - .getComponentFamily("TestComponentFamily")); - assertEquals(componentFamily, - componentRegistry.getComponentFamily("TestComponentFamily")); - componentRegistry.removeComponentFamily(componentFamily); - assertNull(componentRegistry.getComponentFamily("TestComponentFamily")); - } - - @Test - public void testCreateComponentFamily() throws Exception { - assertEquals(0, componentRegistry.getComponentFamilies().size()); - assertNull(componentRegistry.getComponentFamily("TestComponentFamily")); - Family componentFamily = componentRegistry.createComponentFamily( - "TestComponentFamily", componentProfile, "Some description", - null, null); - assertEquals("TestComponentFamily", componentFamily.getName()); - assertEquals(componentRegistry, componentFamily.getComponentRegistry()); - assertEquals(0, componentFamily.getComponents().size()); - // assertEquals(componentProfile, - // componentFamily.getComponentProfile()); - assertEquals(1, componentRegistry.getComponentFamilies().size()); - assertNotNull(componentRegistry - .getComponentFamily("TestComponentFamily")); - assertEquals(componentFamily, - componentRegistry.getComponentFamily("TestComponentFamily")); - } - - @Test(expected = ComponentException.class) - public void testCreateComponentFamilyDuplicate() throws Exception { - componentRegistry.createComponentFamily("TestComponentFamily", - componentProfile, "Some description", null, null); - componentRegistry.createComponentFamily("TestComponentFamily", - componentProfile, "Some description", null, null); - } - - @Test(expected = ComponentException.class) - public void testCreateComponentFamilyNullProfile() throws Exception { - componentRegistry.createComponentFamily("TestComponentFamily", null, - "Some description", null, null); - } - - @Test(expected = ComponentException.class) - public void testCreateComponentFamilyNullName() throws Exception { - componentRegistry.createComponentFamily(null, componentProfile, - "Some description", null, null); - } - - @Test - public void testRemoveComponentFamily() throws Exception { - assertEquals(0, componentRegistry.getComponentFamilies().size()); - assertNull(componentRegistry.getComponentFamily("TestComponentFamily")); - Family componentFamily = componentRegistry.createComponentFamily( - "TestComponentFamily", componentProfile, "Some description", - null, null); - assertEquals(1, componentRegistry.getComponentFamilies().size()); - assertNotNull(componentRegistry - .getComponentFamily("TestComponentFamily")); - assertEquals(componentFamily, - componentRegistry.getComponentFamily("TestComponentFamily")); - componentRegistry.removeComponentFamily(componentFamily); - assertEquals(0, componentRegistry.getComponentFamilies().size()); - assertNull(componentRegistry.getComponentFamily("TestComponentFamily")); - } - - @Test - public void testGetResistryBase() throws Exception { - assertEquals(componentRegistryUrl, componentRegistry.getRegistryBase()); - } - - @Test - public void testGetComponentProfiles() throws Exception { - assertNotNull(componentRegistry.getComponentProfiles()); - } - - @Test - public void testAddComponentProfile() throws Exception { - List<Profile> componentProfiles = componentRegistry - .getComponentProfiles(); - boolean contained = false; - for (Profile p : componentProfiles) { - if (p.getId().equals(componentProfile.getId())) { - contained = true; - } - } - assertFalse(contained); - int componentProfileCount = componentProfiles.size(); - componentRegistry.addComponentProfile(componentProfile, null, null); - int newSize = componentRegistry.getComponentProfiles().size(); - assertEquals(componentProfileCount + 1, newSize); - } - - @Test(expected = ComponentException.class) - public void testAddComponentProfileNullProfile() throws Exception { - componentRegistry.addComponentProfile(null, null, null); - } - -}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/ComponentTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/ComponentTest.java b/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/ComponentTest.java deleted file mode 100644 index 0ced0c8..0000000 --- a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/ComponentTest.java +++ /dev/null @@ -1,111 +0,0 @@ -package io.github.taverna_extras.component.registry; -/* - * 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. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.net.URL; - -import io.github.taverna_extras.component.api.Component; -import io.github.taverna_extras.component.api.Family; -import io.github.taverna_extras.component.api.Version; -import io.github.taverna_extras.component.api.profile.Profile; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import org.apache.taverna.scufl2.api.container.WorkflowBundle; -import org.apache.taverna.scufl2.api.io.WorkflowBundleIO; - -/** - * - * - * @author David Withers - */ -@Ignore -public class ComponentTest extends Harness { - private Family componentFamily; - private Component component; - private WorkflowBundle bundle; - - @Before - public void setUp() throws Exception { - URL dataflowUrl = getClass().getClassLoader().getResource( - "beanshell_test.t2flow"); - assertNotNull(dataflowUrl); - bundle = new WorkflowBundleIO().readBundle(dataflowUrl, null); - URL componentProfileUrl = getClass().getClassLoader().getResource( - "ValidationComponent.xml"); - assertNotNull(componentProfileUrl); - Profile componentProfile = util - .getProfile(componentProfileUrl); - componentFamily = componentRegistry.createComponentFamily( - "Test Component Family", componentProfile, "Some description", - null, null); - component = componentFamily.createComponentBasedOn("Test Component", - "Some description", bundle).getComponent(); - } - - @After - public void tearDown() throws Exception { - componentRegistry.removeComponentFamily(componentFamily); - } - - @Test - public void testGetName() throws Exception { - assertEquals("Test Component", component.getName()); - assertEquals("Test Component", component.getName()); - } - - @Test - public void testGetComponentVersionMap() throws Exception { - assertNotNull(component.getComponentVersionMap()); - assertEquals(1, component.getComponentVersionMap().size()); - assertEquals(component, component.getComponentVersionMap().get(1) - .getComponent()); - } - - @Test - public void testGetComponentVersion() throws Exception { - assertNotNull(component.getComponentVersion(1)); - assertNull(component.getComponentVersion(2)); - } - - @Test - public void testAddVersionBasedOn() throws Exception { - assertNotNull(component.getComponentVersion(1)); - assertNull(component.getComponentVersion(2)); - Version componentVersion = component.addVersionBasedOn(bundle, - "Some description"); - assertNotNull(componentVersion); - assertEquals(component, componentVersion.getComponent()); - assertEquals(2, componentVersion.getVersionNumber().intValue()); - assertEquals(bundle.getIdentifier(), componentVersion.getImplementation() - .getIdentifier()); - } - - @Test - public void testGetComponentURL() throws Exception { - assertNotNull(component.getComponentURL()); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/ComponentVersionTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/ComponentVersionTest.java b/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/ComponentVersionTest.java deleted file mode 100644 index 48b320b..0000000 --- a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/ComponentVersionTest.java +++ /dev/null @@ -1,94 +0,0 @@ -package io.github.taverna_extras.component.registry; -/* - * 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. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.net.URL; - -import io.github.taverna_extras.component.api.Family; -import io.github.taverna_extras.component.api.Version; -import io.github.taverna_extras.component.api.profile.Profile; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import org.apache.taverna.scufl2.api.container.WorkflowBundle; -import org.apache.taverna.scufl2.api.io.WorkflowBundleIO; - -/** - * - * - * @author David Withers - */ -@Ignore -public class ComponentVersionTest extends Harness { - private Family componentFamily; - private WorkflowBundle bundle; - private Version componentVersion; - - @Before - public void setUp() throws Exception { - URL dataflowUrl = getClass().getClassLoader().getResource( - "beanshell_test.t2flow"); - assertNotNull(dataflowUrl); - bundle = new WorkflowBundleIO().readBundle(dataflowUrl, null); - URL componentProfileUrl = getClass().getClassLoader().getResource( - "ValidationComponent.xml"); - assertNotNull(componentProfileUrl); - Profile componentProfile = util.getProfile(componentProfileUrl); - componentFamily = componentRegistry.createComponentFamily( - "Test Component Family", componentProfile, "Some description", - null, null); - componentVersion = componentFamily.createComponentBasedOn( - "Test Component", "Some description", bundle); - } - - @After - public void tearDown() throws Exception { - componentRegistry.removeComponentFamily(componentFamily); - } - - @Test - public void testGetVersionNumber() throws Exception { - assertNotNull(componentVersion.getVersionNumber()); - assertEquals(componentVersion.getVersionNumber(), - componentVersion.getVersionNumber()); - } - - @Test - public void testGetDescription() throws Exception { - assertNotNull(componentVersion.getDescription()); - } - - @Test - public void testGetDataflow() throws Exception { - assertNotNull(componentVersion.getImplementation()); - assertEquals(bundle.getIdentifier(), componentVersion.getImplementation() - .getIdentifier()); - } - - @Test - public void testGetComponent() throws Exception { - assertNotNull(componentVersion.getComponent()); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/Harness.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/Harness.java b/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/Harness.java deleted file mode 100644 index 663704c..0000000 --- a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/Harness.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.github.taverna_extras.component.registry; -/* - * 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. - */ - -import java.net.URL; - -import io.github.taverna_extras.component.api.Registry; -import io.github.taverna_extras.component.registry.ComponentUtil; - -public class Harness { - public static URL componentRegistryUrl; - public static Registry componentRegistry; - public static ComponentUtil util; -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/LocalComponentFamilyTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/LocalComponentFamilyTest.java b/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/LocalComponentFamilyTest.java deleted file mode 100644 index b5791e8..0000000 --- a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/LocalComponentFamilyTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package io.github.taverna_extras.component.registry.local; -/* - * 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. - */ - -import io.github.taverna_extras.component.registry.ComponentFamilyTest; -import org.junit.AfterClass; -import org.junit.BeforeClass; - -/** - * - * - * @author David Withers - */ -public class LocalComponentFamilyTest extends ComponentFamilyTest { - @BeforeClass - public static void setUpBeforeClass() throws Exception { - RegistrySupport.pre(); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - RegistrySupport.post(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/LocalComponentRegistryTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/LocalComponentRegistryTest.java b/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/LocalComponentRegistryTest.java deleted file mode 100644 index 2a57e1c..0000000 --- a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/LocalComponentRegistryTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package io.github.taverna_extras.component.registry.local; -/* - * 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. - */ - -import static org.junit.Assert.assertSame; - -import io.github.taverna_extras.component.api.Registry; -import io.github.taverna_extras.component.registry.ComponentRegistryTest; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -/** - * - * - * @author David Withers - */ -public class LocalComponentRegistryTest extends ComponentRegistryTest { - @BeforeClass - public static void setUpBeforeClass() throws Exception { - RegistrySupport.pre(); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - RegistrySupport.post(); - } - - @Test - public void testGetComponentRegistry() throws Exception { - Registry getAgain = RegistrySupport.factory - .getComponentRegistry(componentRegistryUrl); - assertSame(componentRegistry, getAgain); - } - - @Test - @Ignore("broken") - @Override - public void testAddComponentProfile() throws Exception { - super.testAddComponentProfile(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/LocalComponentTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/LocalComponentTest.java b/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/LocalComponentTest.java deleted file mode 100644 index f82e591..0000000 --- a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/LocalComponentTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package io.github.taverna_extras.component.registry.local; -/* - * 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. - */ - -import io.github.taverna_extras.component.registry.ComponentTest; -import org.junit.AfterClass; -import org.junit.BeforeClass; - -/** - * - * - * @author David Withers - */ -public class LocalComponentTest extends ComponentTest { - @BeforeClass - public static void setUpBeforeClass() throws Exception { - RegistrySupport.pre(); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - RegistrySupport.post(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/LocalComponentVersionTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/LocalComponentVersionTest.java b/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/LocalComponentVersionTest.java deleted file mode 100644 index f08425e..0000000 --- a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/LocalComponentVersionTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package io.github.taverna_extras.component.registry.local; -/* - * 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. - */ - -import io.github.taverna_extras.component.registry.ComponentVersionTest; -import org.junit.AfterClass; -import org.junit.BeforeClass; - -/** - * - * - * @author David Withers - */ -public class LocalComponentVersionTest extends ComponentVersionTest { - @BeforeClass - public static void setUpBeforeClass() throws Exception { - RegistrySupport.pre(); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - RegistrySupport.post(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/RegistrySupport.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/RegistrySupport.java b/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/RegistrySupport.java deleted file mode 100644 index cac3eff..0000000 --- a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/local/RegistrySupport.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.github.taverna_extras.component.registry.local; -/* - * 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. - */ - -import static java.lang.System.getProperty; -import static org.apache.commons.io.FileUtils.deleteDirectory; -import static io.github.taverna_extras.component.registry.Harness.componentRegistry; -import static io.github.taverna_extras.component.registry.Harness.componentRegistryUrl; - -import java.io.File; - -import io.github.taverna_extras.component.registry.local.LocalComponentRegistryFactory; - -class RegistrySupport { - private static File testRegistry; - final static LocalComponentRegistryFactory factory = new LocalComponentRegistryFactory(); - - public static void pre() throws Exception { - testRegistry = new File(getProperty("java.io.tmpdir"), "TestRegistry"); - testRegistry.mkdir(); - componentRegistryUrl = testRegistry.toURI().toURL(); - componentRegistry = factory.getComponentRegistry(componentRegistryUrl); - } - - public static void post() throws Exception { - deleteDirectory(testRegistry); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/NewComponentFamilyTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/NewComponentFamilyTest.java b/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/NewComponentFamilyTest.java deleted file mode 100644 index bb06af5..0000000 --- a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/NewComponentFamilyTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package io.github.taverna_extras.component.registry.standard; -/* - * 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. - */ - -import io.github.taverna_extras.component.registry.ComponentFamilyTest; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Ignore; - -/** - * - * - * @author David Withers - */ -@Ignore -public class NewComponentFamilyTest extends ComponentFamilyTest { - @BeforeClass - public static void setUpBeforeClass() throws Exception { - RegistrySupport.pre(); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - RegistrySupport.post(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/NewComponentRegistryTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/NewComponentRegistryTest.java b/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/NewComponentRegistryTest.java deleted file mode 100644 index 86417d5..0000000 --- a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/NewComponentRegistryTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package io.github.taverna_extras.component.registry.standard; -/* - * 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. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; - -import java.net.URL; - -import io.github.taverna_extras.component.api.Version; -import io.github.taverna_extras.component.registry.ComponentRegistryTest; -import io.github.taverna_extras.component.registry.standard.NewComponent; -import io.github.taverna_extras.component.registry.standard.NewComponentRegistry; -import io.github.taverna_extras.component.registry.standard.Policy; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -import org.apache.taverna.scufl2.api.container.WorkflowBundle; -import org.apache.taverna.scufl2.api.io.WorkflowBundleIO; - -/** - * - * - * @author David Withers - */ -@Ignore("affects remote service") -public class NewComponentRegistryTest extends ComponentRegistryTest { - @BeforeClass - public static void setUpBeforeClass() throws Exception { - RegistrySupport.pre(); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - RegistrySupport.post(); - } - - @Test - public void testGetComponentRegistry() throws Exception { - assertSame(componentRegistry, - RegistrySupport.factory.getComponentRegistry(componentRegistryUrl)); - } - - @Test - public void testUploadWorkflow() throws Exception { - URL dataflowUrl = getClass().getClassLoader().getResource( - "beanshell_test.t2flow"); - WorkflowBundle bundle = new WorkflowBundleIO().readBundle(dataflowUrl, null); - - NewComponentRegistry registry = (NewComponentRegistry) RegistrySupport.factory.getComponentRegistry(componentRegistryUrl); - Version v = registry.createComponentFrom(null, "Test Workflow", - "test description", bundle, null, Policy.PRIVATE); - assertEquals("test description", v.getDescription()); - registry.deleteComponent((NewComponent) v.getComponent()); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/NewComponentTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/NewComponentTest.java b/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/NewComponentTest.java deleted file mode 100644 index 2281cb0..0000000 --- a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/NewComponentTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package io.github.taverna_extras.component.registry.standard; -/* - * 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. - */ - -import io.github.taverna_extras.component.registry.ComponentTest; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Ignore; - -/** - * - * - * @author David Withers - */ -@Ignore -public class NewComponentTest extends ComponentTest { - @BeforeClass - public static void setUpBeforeClass() throws Exception { - RegistrySupport.pre(); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - RegistrySupport.post(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/NewComponentVersionTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/NewComponentVersionTest.java b/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/NewComponentVersionTest.java deleted file mode 100644 index cad04eb..0000000 --- a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/NewComponentVersionTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package io.github.taverna_extras.component.registry.standard; -/* - * 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. - */ - -import io.github.taverna_extras.component.registry.ComponentVersionTest; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Ignore; - -/** - * - * - * @author David Withers - */ -@Ignore -public class NewComponentVersionTest extends ComponentVersionTest { - @BeforeClass - public static void setUpBeforeClass() throws Exception { - RegistrySupport.pre(); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - RegistrySupport.post(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/RegistrySupport.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/RegistrySupport.java b/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/RegistrySupport.java deleted file mode 100644 index a1d0fef..0000000 --- a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/standard/RegistrySupport.java +++ /dev/null @@ -1,55 +0,0 @@ -package io.github.taverna_extras.component.registry.standard; -/* - * 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. - */ - -import static io.github.taverna_extras.component.registry.Harness.componentRegistry; -import static io.github.taverna_extras.component.registry.Harness.componentRegistryUrl; - -import java.net.URL; - -import io.github.taverna_extras.component.api.Component; -import io.github.taverna_extras.component.api.Family; -import io.github.taverna_extras.component.api.profile.Profile; -import io.github.taverna_extras.component.registry.standard.NewComponent; -import io.github.taverna_extras.component.registry.standard.NewComponentFamily; -import io.github.taverna_extras.component.registry.standard.NewComponentRegistry; -import io.github.taverna_extras.component.registry.standard.NewComponentRegistryFactory; - -class RegistrySupport { - static final String DEPLOYMENT = "http://aeon.cs.man.ac.uk:3006"; - static final NewComponentRegistryFactory factory = new NewComponentRegistryFactory();// FIXME - - public static void pre() throws Exception { - componentRegistryUrl = new URL(DEPLOYMENT); - componentRegistry = factory.getComponentRegistry(componentRegistryUrl); - } - - public static void post() throws Exception { - NewComponentRegistry registry = (NewComponentRegistry) factory - .getComponentRegistry(componentRegistryUrl); - for (Profile p : registry.getComponentProfiles()) - registry.client.delete("/file.xml", "id=" + p.getId()); - for (Family f : registry.getComponentFamilies()) { - for (Component c : f.getComponents()) - registry.deleteComponent((NewComponent) c); - registry.client.delete("/pack.xml", "id=" - + ((NewComponentFamily) f).getId()); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/Component.java ---------------------------------------------------------------------- diff --git a/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/Component.java b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/Component.java new file mode 100644 index 0000000..e014fb9 --- /dev/null +++ b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/Component.java @@ -0,0 +1,89 @@ +package io.github.taverna_extras.component.api; +/* + * 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. + */ + +import java.net.URL; +import java.util.SortedMap; + +import org.apache.taverna.scufl2.api.container.WorkflowBundle; + +/** + * The abstract interface supported by a component. + * + * @author Donal Fellows + * @author David Withers + */ +public interface Component extends NamedItem { + /** + * @return the name of the Component. + */ + @Override + String getName(); + + /** + * Returns the URL for the Component. + * + * @return the URL for the Component. + */ + URL getComponentURL(); + + /** + * Creates a new version of this Component. + * + * @param bundle + * the workflow that the new ComponentVersion will use. + * @return a new version of this Component. + * @throws ComponentException + * if there is a problem accessing the ComponentRegistry. + */ + Version addVersionBasedOn(WorkflowBundle bundle, String revisionComment) + throws ComponentException; + + /** + * Returns the ComponentVersion that has the specified version number. + * + * @param version + * the version number of the ComponentVersion to return. + * @return the ComponentVersion that has the specified version number. + * @throws ComponentException + * if there is a problem accessing the ComponentRegistry. + */ + Version getComponentVersion(Integer version) throws ComponentException; + + /** + * @return the description of the Component. + */ + @Override + String getDescription(); + + /** + * Returns a SortedMap of version number to ComponentVersion. + * <p> + * The returned map is sorted increasing numeric order. + * + * @return a SortedMap of version number to ComponentVersion. + */ + SortedMap<Integer, Version> getComponentVersionMap(); + + Registry getRegistry(); + + Family getFamily(); + + void delete() throws ComponentException; +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/ComponentException.java ---------------------------------------------------------------------- diff --git a/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/ComponentException.java b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/ComponentException.java new file mode 100644 index 0000000..044903e --- /dev/null +++ b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/ComponentException.java @@ -0,0 +1,48 @@ +package io.github.taverna_extras.component.api; +/* + * 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. + */ + +/** + * Thrown when there is a problem interacting with a ComponentRegistry. + * + * @author David Withers + */ +public class ComponentException extends Exception { + private static final long serialVersionUID = -5222074350812438467L; + + public ComponentException() { + super(); + } + + public ComponentException(String message, Throwable cause) { + super(message, cause); + } + + public ComponentException(String message) { + super(message); + } + + public ComponentException(Throwable cause) { + super(cause); + } + + public ComponentException(String messageTemplate, Object...parameters) { + super(String.format(messageTemplate, parameters)); + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/ComponentFactory.java ---------------------------------------------------------------------- diff --git a/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/ComponentFactory.java b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/ComponentFactory.java new file mode 100644 index 0000000..5b69b61 --- /dev/null +++ b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/ComponentFactory.java @@ -0,0 +1,45 @@ +package io.github.taverna_extras.component.api; +/* + * 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. + */ + +import java.net.URL; + +import io.github.taverna_extras.component.api.profile.Profile; + +public interface ComponentFactory { + public Registry getRegistry(URL registryBase) throws ComponentException; + + public Family getFamily(URL registryBase, String familyName) + throws ComponentException; + + public Component getComponent(URL registryBase, String familyName, + String componentName) throws ComponentException; + + public Version getVersion(URL registryBase, String familyName, + String componentName, Integer componentVersion) + throws ComponentException; + + public Version getVersion(Version.ID ident) throws ComponentException; + + public Component getComponent(Version.ID ident) throws ComponentException; + + public Profile getProfile(URL url) throws ComponentException; + + public Profile getBaseProfile() throws ComponentException; +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/Family.java ---------------------------------------------------------------------- diff --git a/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/Family.java b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/Family.java new file mode 100644 index 0000000..ca4ec54 --- /dev/null +++ b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/Family.java @@ -0,0 +1,117 @@ +package io.github.taverna_extras.component.api; +/* + * 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. + */ + +import java.util.List; + +import io.github.taverna_extras.component.api.profile.Profile; +import org.apache.taverna.scufl2.api.container.WorkflowBundle; + +public interface Family extends NamedItem { + /** + * Creates a new Component and adds it to this ComponentFamily. + * + * @param componentName + * the name of the Component to create. Must not be null. + * @param bundle + * the workflow for the Component. Must not be null. + * @return the new Component. + * @throws ComponentException + * <ul> + * <li>if componentName is null, + * <li>if dataflow is null, + * <li>if a Component with this name already exists, + * <li>if there is a problem accessing the ComponentRegistry. + * </ul> + */ + Version createComponentBasedOn(String componentName, String description, + WorkflowBundle bundle) throws ComponentException; + + /** + * Returns the Component with the specified name. + * <p> + * If this ComponentFamily does not contain a Component with the specified + * name <code>null</code> is returned. + * + * @param componentName + * the name of the Component to return. Must not be null. + * @return the Component with the specified name. + * @throws ComponentException + * if there is a problem accessing the ComponentRegistry. + */ + Component getComponent(String componentName) throws ComponentException; + + /** + * Removes the specified Component from this ComponentFamily. + * <p> + * If this ComponentFamily does not contain the Component this method has no + * effect. + * + * @param component + * the Component to remove. + * @throws ComponentException + * if there is a problem accessing the ComponentRegistry. + */ + void removeComponent(Component component) throws ComponentException; + + /** + * Returns all the Components in this ComponentFamily. + * <p> + * If this ComponentFamily does not contain any Components an empty list is + * returned. + * + * @return all the Components in this ComponentFamilies. + * @throws ComponentException + * if there is a problem accessing the ComponentRegistry. + */ + List<Component> getComponents() throws ComponentException; + + /** + * Returns the ComponentProfile for this ComponentFamily. + * + * @return the ComponentProfile for this ComponentFamily. + * @throws ComponentException + */ + Profile getComponentProfile() throws ComponentException; + + /** + * Returns the ComponentRegistry that contains this ComponentFamily. + * + * @return the ComponentRegistry that contains this ComponentFamily. + */ + Registry getComponentRegistry(); + + /** + * @return the name of the component Family. + */ + @Override + String getName(); + + /** + * @return the description of the component Family. + */ + @Override + String getDescription(); + + /** + * Delete this family from its registry. + * @throws ComponentException + */ + void delete() throws ComponentException; +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/License.java ---------------------------------------------------------------------- diff --git a/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/License.java b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/License.java new file mode 100644 index 0000000..2906288 --- /dev/null +++ b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/License.java @@ -0,0 +1,23 @@ +package io.github.taverna_extras.component.api; +/* + * 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. + */ + +public interface License extends NamedItem { + public String getAbbreviation(); +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/NamedItem.java ---------------------------------------------------------------------- diff --git a/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/NamedItem.java b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/NamedItem.java new file mode 100644 index 0000000..775e515 --- /dev/null +++ b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/NamedItem.java @@ -0,0 +1,26 @@ +package io.github.taverna_extras.component.api; +/* + * 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. + */ + +public interface NamedItem { + /** Name this entity. */ + public String getName(); + /** Describe this entity. */ + public String getDescription(); +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/Registry.java ---------------------------------------------------------------------- diff --git a/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/Registry.java b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/Registry.java new file mode 100644 index 0000000..e6d1e23 --- /dev/null +++ b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/Registry.java @@ -0,0 +1,158 @@ +package io.github.taverna_extras.component.api; +/* + * 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. + */ + + +import java.net.URL; +import java.util.List; +import java.util.Set; + +import io.github.taverna_extras.component.api.profile.Profile; + +public interface Registry { + + License getPreferredLicense() throws ComponentException; + + Set<Version.ID> searchForComponents(String prefixString, String text) + throws ComponentException; + + /** + * Returns all the ComponentFamilies in this ComponetRegistry. + * <p> + * If this ComponentRegistry does not contain any ComponentFamilies an empty + * list is returned. + * + * @return all the ComponentFamilies in this ComponetRegistry. + * @throws ComponentException + * if there is a problem accessing the ComponentRegistry. + */ + List<Family> getComponentFamilies() throws ComponentException; + + List<License> getLicenses() throws ComponentException; + + List<SharingPolicy> getPermissions() throws ComponentException; + + /** + * Adds a ComponentProfile to this ComponentRegistry. + * + * @param componentProfile + * the ComponentProfile to add. Must not be null. + * @param sharingPolicy + * @param license + * @return the ComponentProfile added to this ComponentRegistry. + * @throws ComponentException + * <ul> + * <li>if componentProfile is null, + * <li>if there is a problem accessing the ComponentRegistry. + * </ul> + */ + Profile addComponentProfile(Profile componentProfile, License license, + SharingPolicy sharingPolicy) throws ComponentException; + + /** + * Returns all the ComponentProfiles in this ComponetRegistry. + * <p> + * If this ComponentRegistry does not contain any ComponentProfiles an empty + * list is returned. + * + * @return all the ComponentProfiles in this ComponetRegistry. + * @throws ComponentException + * if there is a problem accessing the ComponentRegistry. + */ + List<Profile> getComponentProfiles() throws ComponentException; + + /** + * Returns the ComponentProfile with the given ID in this ComponetRegistry. + * <p> + * If this ComponentRegistry does not contain the ComponentProfile, a + * <tt>null</tt> is returned. + * + * @return the matching ComponentProfile in this ComponetRegistry, or + * <tt>null</tt> if there is no such thing. + * @throws ComponentException + * if there is a problem accessing the ComponentRegistry. + */ + Profile getComponentProfile(String id) throws ComponentException; + + String getRegistryBaseString(); + + /** + * Returns the location of this ComponentRepository. + * + * @return the location of this ComponentRepository + */ + URL getRegistryBase(); + + /** + * Removes a the ComponentFamily with the specified name from this + * ComponentRegistry. + * <p> + * If this ComponentRegistry does not contain a ComponentFamily with the + * specified name this method has no effect. + * + * @param componentFamily + * the ComponentFamily to remove. + * @throws ComponentException + * if there is a problem accessing the ComponentRegistry. + */ + void removeComponentFamily(Family componentFamily) throws ComponentException; + + /** + * Creates a new ComponentFamily and adds it to this ComponentRegistry. + * + * @param familyName + * the name of the ComponentFamily to create. Must not be null. + * @param componentProfile + * the ComponentProfile for the new ComponentFamily. Must not be + * null. + * @param sharingPolicy + * the SharingPolicy to use for the new ComponentFamily. + * @return the new ComponentFamily + * @throws ComponentException + * <ul> + * <li>if familyName is null, + * <li>if componentProfile is null, + * <li>if a ComponentFamily with this name already exists, + * <li>if there is a problem accessing the ComponentRegistry. + * </ul> + */ + Family createComponentFamily(String familyName, Profile componentProfile, + String description, License license, SharingPolicy sharingPolicy) + throws ComponentException; + + /** + * Returns the ComponentFamily with the specified name. + * <p> + * If this ComponentRegistry does not contain a ComponentFamily with the + * specified name <code>null</code> is returned. + * + * @param familyName + * the name of the ComponentFamily to return. Must not be null. + * @return the ComponentFamily with the specified name in this + * ComponentRepository or null if none exists. + * @throws ComponentException + * if there is a problem accessing the ComponentRegistry. + */ + Family getComponentFamily(String familyName) throws ComponentException; + + /** + * @return A description of the type of registry this is. + */ + String getRegistryTypeName(); +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/SharingPolicy.java ---------------------------------------------------------------------- diff --git a/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/SharingPolicy.java b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/SharingPolicy.java new file mode 100644 index 0000000..9965339 --- /dev/null +++ b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/SharingPolicy.java @@ -0,0 +1,32 @@ +package io.github.taverna_extras.component.api; +/* + * 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. + */ + +/** + * @author alanrw + * + */ +public interface SharingPolicy { + + /** + * @return The user-relevant name of the permission + */ + public abstract String getName(); + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/Version.java ---------------------------------------------------------------------- diff --git a/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/Version.java b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/Version.java new file mode 100644 index 0000000..2929ed0 --- /dev/null +++ b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/Version.java @@ -0,0 +1,224 @@ +package io.github.taverna_extras.component.api; +/* + * 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. + */ + +import java.io.Serializable; +import java.net.URL; + +import org.apache.taverna.scufl2.api.container.WorkflowBundle; + +public interface Version { + /** @return The version number of this version */ + Integer getVersionNumber(); + + /** @return The description of this version */ + String getDescription(); + + /** @return The implementation for this version */ + WorkflowBundle getImplementation() throws ComponentException; + + /** @return The component of which this is a version */ + Component getComponent(); + + /** @return The identification token for this version */ + ID getID(); + + URL getHelpURL(); + + interface ID extends Serializable { + /** @return The name of the family of the component to which we refer to */ + String getFamilyName(); + + /** @return The base URL of the registry containing the component */ + URL getRegistryBase(); + + /** + * @return The name of the component referred to, unique within its + * family + */ + String getComponentName(); + + /** + * @return The version number of the version of the component referred + * to + */ + Integer getComponentVersion(); + + /** + * Tests whether this ID is equal to the given one, <i>excluding</i> the + * version. + * + * @param id + * The ID to compare to. + * @return A boolean + */ + boolean mostlyEqualTo(ID id); + + /** + * Tests whether this ID is equal to the given component, + * <i>excluding</i> the version. + * + * @param component + * The component to compare to. + * @return A boolean + */ + boolean mostlyEqualTo(Component component); + } + + class Identifier implements ID { + private static final long serialVersionUID = 1139928258250264997L; + + private final URL registryBase; + private final String familyName; + private final String componentName; + private final Integer componentVersion; + + public Identifier(URL registryBase, String familyName, + String componentName, Integer componentVersion) { + super(); + this.registryBase = registryBase; + this.familyName = familyName; + this.componentName = componentName; + this.componentVersion = componentVersion; + } + + /** + * @return the registryBase + */ + @Override + public URL getRegistryBase() { + return registryBase; + } + + /** + * @return the familyName + */ + @Override + public String getFamilyName() { + return familyName; + } + + /** + * @return the componentName + */ + @Override + public String getComponentName() { + return componentName; + } + + /** + * @return the componentVersion + */ + @Override + public Integer getComponentVersion() { + return componentVersion; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result *= prime; + result += (componentName == null) ? 0 : componentName.hashCode(); + result *= prime; + result += (componentVersion == null) ? 0 : componentVersion + .hashCode(); + result *= prime; + result += (familyName == null) ? 0 : familyName.hashCode(); + result *= prime; + result += (registryBase == null) ? 0 : registryBase.hashCode(); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (!ID.class.isAssignableFrom(obj.getClass())) + return false; + ID other = (ID) obj; + if (componentName == null) { + if (other.getComponentName() != null) + return false; + } else if (!componentName.equals(other.getComponentName())) + return false; + if (componentVersion == null) { + if (other.getComponentVersion() != null) + return false; + } else if (!componentVersion.equals(other.getComponentVersion())) + return false; + if (familyName == null) { + if (other.getFamilyName() != null) + return false; + } else if (!familyName.equals(other.getFamilyName())) + return false; + if (registryBase == null) { + if (other.getRegistryBase() != null) + return false; + } else if (!registryBase.toString().equals( + other.getRegistryBase().toString())) + // NB: Comparison of URLs is on their string form! + return false; + return true; + } + + @Override + public String toString() { + return getComponentName() + " V. " + getComponentVersion() + + " in family " + getFamilyName() + " on " + + getRegistryBase().toExternalForm(); + } + + @Override + public boolean mostlyEqualTo(ID id) { + if (this == id) + return true; + if (id == null) + return false; + if (getClass() != id.getClass()) + return false; + if (componentName == null) { + if (id.getFamilyName() != null) + return false; + } else if (!componentName.equals(id.getComponentName())) + return false; + if (familyName == null) { + if (id.getFamilyName() != null) + return false; + } else if (!familyName.equals(id.getFamilyName())) + return false; + if (registryBase == null) { + if (id.getRegistryBase() != null) + return false; + } else if (!registryBase.toString().equals( + id.getRegistryBase().toString())) + // NB: Comparison of URLs is on their string form! + return false; + return true; + } + + @Override + public boolean mostlyEqualTo(Component c) { + return mostlyEqualTo(new Identifier(c.getRegistry() + .getRegistryBase(), c.getFamily().getName(), c.getName(), 0)); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/config/ComponentConfig.java ---------------------------------------------------------------------- diff --git a/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/config/ComponentConfig.java b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/config/ComponentConfig.java new file mode 100644 index 0000000..7de348c --- /dev/null +++ b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/config/ComponentConfig.java @@ -0,0 +1,23 @@ +package io.github.taverna_extras.component.api.config; +/* + * 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. + */ + +public interface ComponentConfig { + String URI = "http://ns.taverna.org.uk/2010/activity/component"; +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/config/ComponentPropertyNames.java ---------------------------------------------------------------------- diff --git a/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/config/ComponentPropertyNames.java b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/config/ComponentPropertyNames.java new file mode 100644 index 0000000..457161d --- /dev/null +++ b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/config/ComponentPropertyNames.java @@ -0,0 +1,32 @@ +package io.github.taverna_extras.component.api.config; +/* + * 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. + */ + +/** + * The names of properties used in JSON configurations associated with + * components. + * + * @author Donal Fellows + */ +public interface ComponentPropertyNames { + String REGISTRY_BASE = "registryBase"; + String FAMILY_NAME = "familyName"; + String COMPONENT_NAME = "componentName"; + String COMPONENT_VERSION = "componentVersion"; +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/package-info.java ---------------------------------------------------------------------- diff --git a/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/package-info.java b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/package-info.java new file mode 100644 index 0000000..a0b3e2f --- /dev/null +++ b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/package-info.java @@ -0,0 +1,25 @@ +/* + * 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. + */ + +/** + * An abstract API for working with components in a registry. + * @author Donal Fellows + * @author David Withers + */ +package io.github.taverna_extras.component.api; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/ActivityProfile.java ---------------------------------------------------------------------- diff --git a/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/ActivityProfile.java b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/ActivityProfile.java new file mode 100644 index 0000000..8795c8a --- /dev/null +++ b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/ActivityProfile.java @@ -0,0 +1,23 @@ +package io.github.taverna_extras.component.api.profile; +/* + * 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. + */ + +public interface ActivityProfile extends AnnotatedElement { + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/AnnotatedElement.java ---------------------------------------------------------------------- diff --git a/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/AnnotatedElement.java b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/AnnotatedElement.java new file mode 100644 index 0000000..0ad0da4 --- /dev/null +++ b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/AnnotatedElement.java @@ -0,0 +1,28 @@ +package io.github.taverna_extras.component.api.profile; +/* + * 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. + */ + +import java.util.List; + +import io.github.taverna_extras.component.api.ComponentException; + +public interface AnnotatedElement { + List<SemanticAnnotationProfile> getSemanticAnnotations() + throws ComponentException; +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/ExceptionHandling.java ---------------------------------------------------------------------- diff --git a/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/ExceptionHandling.java b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/ExceptionHandling.java new file mode 100644 index 0000000..ee5810d --- /dev/null +++ b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/ExceptionHandling.java @@ -0,0 +1,47 @@ +package io.github.taverna_extras.component.api.profile; +/* + * 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. + */ + +import java.util.ArrayList; +import java.util.List; + +/** + * @author alanrw + * + */ +public class ExceptionHandling { + private final boolean failLists; + private final List<HandleException> remapped = new ArrayList<HandleException>(); + + public ExceptionHandling( + io.github.taverna_extras.component.api.profile.doc.ExceptionHandling proxied) { + for (io.github.taverna_extras.component.api.profile.doc.HandleException he : proxied + .getHandleException()) + remapped.add(new HandleException(he)); + this.failLists = proxied.getFailLists() != null; + } + + public boolean failLists() { + return failLists; + } + + public List<HandleException> getHandleExceptions() { + return remapped; + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/ExceptionReplacement.java ---------------------------------------------------------------------- diff --git a/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/ExceptionReplacement.java b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/ExceptionReplacement.java new file mode 100644 index 0000000..69163cf --- /dev/null +++ b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/ExceptionReplacement.java @@ -0,0 +1,43 @@ +package io.github.taverna_extras.component.api.profile; +/* + * 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. + */ + + +import io.github.taverna_extras.component.api.profile.doc.Replacement; + +/** + * @author alanrw + * + */ +public class ExceptionReplacement { + private final String id, message; + + public ExceptionReplacement(Replacement replacement) { + id = replacement.getReplacementId(); + message = replacement.getReplacementMessage(); + } + + public String getReplacementId() { + return id; + } + + public String getReplacementMessage() { + return message; + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/HandleException.java ---------------------------------------------------------------------- diff --git a/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/HandleException.java b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/HandleException.java new file mode 100644 index 0000000..fb29cd6 --- /dev/null +++ b/taverna-component-repository-api/src/main/java/io/github/taverna_extras/component/api/profile/HandleException.java @@ -0,0 +1,55 @@ +package io.github.taverna_extras.component.api.profile; +/* + * 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. + */ + + +import static java.util.regex.Pattern.DOTALL; +import static java.util.regex.Pattern.compile; + +import java.util.regex.Pattern; + +/** + * @author alanrw + * + */ +public class HandleException { + private final Pattern pattern; + private ExceptionReplacement replacement; + private final boolean pruneStack; + + public HandleException( + io.github.taverna_extras.component.api.profile.doc.HandleException proxied) { + pruneStack = proxied.getPruneStack() != null; + pattern = compile(proxied.getPattern(), DOTALL); + if (proxied.getReplacement() != null) + replacement = new ExceptionReplacement(proxied.getReplacement()); + } + + public boolean matches(String s) { + return pattern.matcher(s).matches(); + } + + public boolean pruneStack() { + return pruneStack; + } + + public ExceptionReplacement getReplacement() { + return replacement; + } +}
