ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1357570 [26/34] - in /ace/sandbox/marrs: cnf/ cnf/ext/ cnf/lib/ cnf/releaserepo/ cnf/repo/ cnf/repo/.obrcache/ cnf/repo/.obrcache/http%3A%2F%2Fbundles.bndtools.org.s3.amazonaws.com%2Fcom.jcraft.jsch/ cnf/repo/.obrcache/http%3A%2F%2Fbundles...
Date Thu, 05 Jul 2012 12:10:06 GMT
Added: ace/sandbox/marrs/org.apache.ace.deployment.api/src/org/apache/ace/deployment/packageinfo
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.api/src/org/apache/ace/deployment/packageinfo?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.api/src/org/apache/ace/deployment/packageinfo (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.api/src/org/apache/ace/deployment/packageinfo Thu Jul  5 12:09:30 2012
@@ -0,0 +1 @@
+version 1.0
\ No newline at end of file

Added: ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/.classpath
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/.classpath?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/.classpath (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/.classpath Thu Jul  5 12:09:30 2012
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" output="bin_test" path="test"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.testng.TESTNG_CONTAINER"/>
+	<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/.project
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/.project?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/.project (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/.project Thu Jul  5 12:09:30 2012
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.apache.ace.deployment.deploymentadmin</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>bndtools.core.bndbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>bndtools.core.bndnature</nature>
+	</natures>
+</projectDescription>

Added: ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/bnd.bnd?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/bnd.bnd (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/bnd.bnd Thu Jul  5 12:09:30 2012
@@ -0,0 +1,7 @@
+-buildpath: osgi.core,\
+	osgi.cmpn,\
+	org.apache.felix.dependencymanager,\
+	org.apache.ace.deployment.api;version=latest,\
+	org.apache.ace.util;version=latest
+Private-Package: org.apache.ace.deployment.deploymentadmin
+Bundle-Activator: org.apache.ace.deployment.deploymentadmin.Activator
\ No newline at end of file

Added: ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/build.xml
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/build.xml?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/build.xml (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/build.xml Thu Jul  5 12:09:30 2012
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="project" default="build"> 
+	<import file="../cnf/build.xml"/>
+</project>

Added: ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/pom.xml
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/pom.xml?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/pom.xml (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/pom.xml Thu Jul  5 12:09:30 2012
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.ace</groupId>
+        <artifactId>ace-pom</artifactId>
+        <version>0.8.1-SNAPSHOT</version>
+        <relativePath>../pom/pom.xml</relativePath>
+    </parent>
+
+    <version>0.8.1-SNAPSHOT</version>
+    <artifactId>org.apache.ace.deployment.deploymentadmin</artifactId>
+    <packaging>bundle</packaging>
+
+    <name>Apache ACE :: Deployment :: DeploymentAdmin Based</name>
+    <description />
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/ace/trunk/ace-deployment-deploymentadmin</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/ace/trunk/ace-deployment-deploymentadmin</developerConnection>
+        <url>http://svn.apache.org/repos/asf/ace/trunk/ace-deployment-deploymentadmin</url>
+    </scm>
+    
+    <properties>
+        <import.package>
+            org.apache.ace.deployment;version=${project.version},
+            *
+        </import.package>
+        <private.package>
+            org.apache.ace.deployment.deploymentadmin
+        </private.package>
+        <bundle.activator>
+            org.apache.ace.deployment.deploymentadmin.Activator
+        </bundle.activator>
+    </properties>
+
+     <dependencies>
+         <dependency>
+            <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.deployment.api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.util</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.dependencymanager</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>

Added: ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/src/org/apache/ace/deployment/deploymentadmin/Activator.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/src/org/apache/ace/deployment/deploymentadmin/Activator.java?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/src/org/apache/ace/deployment/deploymentadmin/Activator.java (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/src/org/apache/ace/deployment/deploymentadmin/Activator.java Thu Jul  5 12:09:30 2012
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ace.deployment.deploymentadmin;
+
+import org.apache.ace.deployment.Deployment;
+import org.apache.felix.dm.DependencyActivatorBase;
+import org.apache.felix.dm.DependencyManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.deploymentadmin.DeploymentAdmin;
+import org.osgi.service.log.LogService;
+
+public class Activator extends DependencyActivatorBase {
+    public void init(BundleContext context, DependencyManager manager) throws Exception {
+        manager.add(createComponent()
+            .setInterface(Deployment.class.getName(), null)
+            .setImplementation(DeploymentAdminDeployer.class)
+            .add(createServiceDependency().setService(DeploymentAdmin.class).setRequired(true))
+            .add(createServiceDependency().setService(LogService.class).setRequired(false)));
+    }
+
+    public void destroy(BundleContext context, DependencyManager manager) throws Exception {
+        // do nothing
+    }
+}
\ No newline at end of file

Added: ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/src/org/apache/ace/deployment/deploymentadmin/DeploymentAdminDeployer.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/src/org/apache/ace/deployment/deploymentadmin/DeploymentAdminDeployer.java?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/src/org/apache/ace/deployment/deploymentadmin/DeploymentAdminDeployer.java (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/src/org/apache/ace/deployment/deploymentadmin/DeploymentAdminDeployer.java Thu Jul  5 12:09:30 2012
@@ -0,0 +1,60 @@
+/*
+ * 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.ace.deployment.deploymentadmin;
+
+import java.io.InputStream;
+import org.apache.ace.deployment.Deployment;
+import org.osgi.framework.Version;
+import org.osgi.service.deploymentadmin.DeploymentAdmin;
+import org.osgi.service.deploymentadmin.DeploymentPackage;
+import org.osgi.service.log.LogService;
+
+/**
+ * Implementation of the <code>DeploymentService</code> interface that uses the <code>DeploymentAdmin</code>
+ * to deploy components.
+ */
+public class DeploymentAdminDeployer implements Deployment {
+    private volatile LogService m_log; /* will be injected by dependencymanager */
+    private volatile DeploymentAdmin m_admin; /* will be injected by dependencymanager */
+
+    public String getName(Object object) throws IllegalArgumentException {
+        if (!(object instanceof DeploymentPackage)) {
+            throw new IllegalArgumentException("Argument is not a DeploymentPackage");
+        }
+        return ((DeploymentPackage) object).getName();
+    }
+
+    public Version getVersion(Object object) throws IllegalArgumentException {
+        if (!(object instanceof DeploymentPackage)) {
+            throw new IllegalArgumentException("Argument is not a DeploymentPackage");
+        }
+        return ((DeploymentPackage) object).getVersion();
+    }
+
+    public Object install(InputStream inputStream) throws Exception {
+        DeploymentPackage deploymentPackage = m_admin.installDeploymentPackage(inputStream);
+        m_log.log(LogService.LOG_INFO, "Deployment Package installed: name=" + deploymentPackage.getName() + " version=" + deploymentPackage.getVersion());
+        return deploymentPackage;
+    }
+
+    public Object[] list() {
+        // DeploymentAdmin spec says this call should never return null
+        return m_admin.listDeploymentPackages();
+    }
+}
\ No newline at end of file

Added: ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/test/org/apache/ace/deployment/DeploymentTest.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/test/org/apache/ace/deployment/DeploymentTest.java?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/test/org/apache/ace/deployment/DeploymentTest.java (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.deploymentadmin/test/org/apache/ace/deployment/DeploymentTest.java Thu Jul  5 12:09:30 2012
@@ -0,0 +1,92 @@
+/*
+ * 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.ace.deployment;
+
+import static org.apache.ace.test.utils.TestUtils.UNIT;
+
+import java.io.InputStream;
+
+import org.apache.ace.deployment.deploymentadmin.DeploymentAdminDeployer;
+import org.apache.ace.test.utils.TestUtils;
+import org.osgi.framework.Version;
+import org.osgi.service.deploymentadmin.DeploymentAdmin;
+import org.osgi.service.deploymentadmin.DeploymentPackage;
+import org.osgi.service.log.LogService;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+public class DeploymentTest {
+
+    private DeploymentAdminDeployer m_deploymentAdminDeployer;
+    private DeploymentPackage m_mockDeploymentPackage;
+
+    private static final String MOCK_NAME = "MockName";
+    private static final Version MOCK_VERSION = new Version("0.1");
+
+    @BeforeTest(alwaysRun = true)
+    protected void setUp() throws Exception {
+        m_deploymentAdminDeployer = new DeploymentAdminDeployer();
+        TestUtils.configureObject(m_deploymentAdminDeployer, LogService.class);
+        Object mockDeploymentAdmin = TestUtils.createMockObjectAdapter(DeploymentAdmin.class, new MockDeploymentAdmin());
+        TestUtils.configureObject(m_deploymentAdminDeployer, DeploymentAdmin.class, mockDeploymentAdmin);
+        m_mockDeploymentPackage = TestUtils.createMockObjectAdapter(DeploymentPackage.class, new MockDeploymentPackage());
+    }
+
+    @Test(groups = { UNIT })
+    public void testDeployment() throws Exception {
+        Object deploymentPackage = m_deploymentAdminDeployer.install(null);
+        assert m_deploymentAdminDeployer.getName(deploymentPackage).equals(MOCK_NAME) : "Installation of mock deployment package failed";
+        assert m_deploymentAdminDeployer.getVersion(deploymentPackage).equals(MOCK_VERSION) : "Installation of mock deployment package failed";
+        assert ((DeploymentPackage) m_deploymentAdminDeployer.list()[0]).getName().equals(MOCK_NAME) : "List result does not match expected result";
+        boolean exceptionthrown = false;
+        try {
+            m_deploymentAdminDeployer.getName(new String("illegalargument"));
+        } catch (IllegalArgumentException iae) {
+            exceptionthrown = true;
+        }
+        assert exceptionthrown : "Illegal argument for getName() did not throw exception";
+        exceptionthrown = false;
+        try {
+            m_deploymentAdminDeployer.getVersion(new String("illegalargument"));
+        } catch (IllegalArgumentException iae) {
+            exceptionthrown = true;
+        }
+        assert exceptionthrown : "Illegal argument for getVersion() did not throw exception";
+    }
+
+    private class MockDeploymentAdmin {
+        public DeploymentPackage installDeploymentPackage(InputStream is) {
+            return m_mockDeploymentPackage;
+        }
+
+        public DeploymentPackage[] listDeploymentPackages() {
+            return new DeploymentPackage[] {m_mockDeploymentPackage};
+        }
+    }
+
+    private class MockDeploymentPackage {
+        public String getName() {
+            return MOCK_NAME;
+        }
+
+        public Version getVersion() {
+            return MOCK_VERSION;
+        }
+    }
+}

Added: ace/sandbox/marrs/org.apache.ace.deployment.provider.api/.classpath
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.provider.api/.classpath?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.provider.api/.classpath (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.provider.api/.classpath Thu Jul  5 12:09:30 2012
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" output="bin_test" path="test"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: ace/sandbox/marrs/org.apache.ace.deployment.provider.api/.project
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.provider.api/.project?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.provider.api/.project (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.provider.api/.project Thu Jul  5 12:09:30 2012
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.apache.ace.deployment.provider.api</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>bndtools.core.bndbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>bndtools.core.bndnature</nature>
+	</natures>
+</projectDescription>

Added: ace/sandbox/marrs/org.apache.ace.deployment.provider.api/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.provider.api/bnd.bnd?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.provider.api/bnd.bnd (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.provider.api/bnd.bnd Thu Jul  5 12:09:30 2012
@@ -0,0 +1 @@
+Export-Package: org.apache.ace.deployment.provider
\ No newline at end of file

Added: ace/sandbox/marrs/org.apache.ace.deployment.provider.api/build.xml
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.provider.api/build.xml?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.provider.api/build.xml (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.provider.api/build.xml Thu Jul  5 12:09:30 2012
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="project" default="build"> 
+	<import file="../cnf/build.xml"/>
+</project>

Added: ace/sandbox/marrs/org.apache.ace.deployment.provider.api/pom.xml
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.provider.api/pom.xml?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.provider.api/pom.xml (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.provider.api/pom.xml Thu Jul  5 12:09:30 2012
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.ace</groupId>
+        <artifactId>ace-pom</artifactId>
+        <version>0.8.1-SNAPSHOT</version>
+        <relativePath>../pom/pom.xml</relativePath>
+    </parent>
+
+    <artifactId>org.apache.ace.deployment.provider.api</artifactId>
+    <packaging>bundle</packaging>
+    <version>0.8.1-SNAPSHOT</version>
+    <name>Apache ACE :: Deployment :: Provider :: API</name>
+    <description />
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/ace/trunk/ace-deployment-provider-api</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/ace/trunk/ace-deployment-provider-api</developerConnection>
+        <url>http://svn.apache.org/repos/asf/ace/trunk/ace-deployment-provider-api</url>
+    </scm>
+    
+    <properties>
+        <export.package>
+            org.apache.ace.deployment.provider;version=${project.version}
+        </export.package>
+        <import.package>
+            !org.apache.ace.deployment.provider
+        </import.package>
+    </properties>
+
+</project>

Added: ace/sandbox/marrs/org.apache.ace.deployment.provider.api/src/org/apache/ace/deployment/provider/ArtifactData.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.provider.api/src/org/apache/ace/deployment/provider/ArtifactData.java?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.provider.api/src/org/apache/ace/deployment/provider/ArtifactData.java (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.provider.api/src/org/apache/ace/deployment/provider/ArtifactData.java Thu Jul  5 12:09:30 2012
@@ -0,0 +1,81 @@
+/*
+ * 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.ace.deployment.provider;
+
+import java.net.URL;
+import java.util.jar.Attributes;
+
+/**
+ * The ArtifactData as returned by the <code>DeploymentProvider</code> class in this package.
+ * It contains several pieces of data which describe the artifact and the place where it can be found.
+ */
+public interface ArtifactData {
+
+    /**
+     * Indicate if the bundle has changed. This is used when comparing artifacts in 2 versions. (see DeploymentProvider)
+     * If you requested one version it always returns true.
+     *
+     * @return if this artifact has changed.
+     */
+    public boolean hasChanged();
+
+    /**
+     * @return <code>true</code> if this artifact is a bundle; <code>false</code> otherwise.
+     */
+    public boolean isBundle();
+
+    /**
+     * @return <code>true</code> if this artifact is a customizer that contains a resource processor; <code>false</code> otherwise.
+     */
+    public boolean isCustomizer();
+
+    /**
+     * @return the filename of the artifact
+     */
+    public String getFilename();
+
+    /**
+     *  @return the symbolic name, if this artifact is a bundle.
+     */
+    public String getSymbolicName();
+
+    /**
+     *  @return the version, if this artifact is a bundle. If it is an artifact, this function
+     *  will always return "0.0.0".
+     */
+    public String getVersion();
+
+    /**
+     * @return the url to the artifact data.
+     */
+    public URL getUrl();
+
+    /**
+     * @return the processor Pid to be used for this resource, if any.
+     */
+    public String getProcessorPid();
+
+    /**
+     * @return a set of attributes that describes this artifact in a manifest.
+     * @param fixPackage Indicating whether this set of headers is intended to be part
+     * of a fixpackage.
+     */
+    public Attributes getManifestAttributes(boolean fixPackage);
+
+}
\ No newline at end of file

Added: ace/sandbox/marrs/org.apache.ace.deployment.provider.api/src/org/apache/ace/deployment/provider/DeploymentProvider.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.provider.api/src/org/apache/ace/deployment/provider/DeploymentProvider.java?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.provider.api/src/org/apache/ace/deployment/provider/DeploymentProvider.java (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.provider.api/src/org/apache/ace/deployment/provider/DeploymentProvider.java Thu Jul  5 12:09:30 2012
@@ -0,0 +1,70 @@
+/*
+ * 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.ace.deployment.provider;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * An interface that provides the meta information for the bundles
+ * in a certain version number.
+ */
+public interface DeploymentProvider {
+
+    /**
+     * Get the collection of bundleData for a specific version. This data can be used to generate a deployment package.
+     * The ArtifactData.hasChanged method will return true for all bundles in this collection
+     *
+     * @return a collection of bundledata. If there are no bundles in this version, return an empty list
+     * @throws IllegalArgumentException if the target or version do not exist
+     * @throws java.io.IOException If an IOException occurs.
+     */
+    public List<ArtifactData> getBundleData(String targetId, String version) throws IllegalArgumentException, IOException;
+
+    /**
+     * This data can be used to generate a fix package. It gives the differences between the versionFrom and versionTo.
+     *
+     * Changes between versions are indicated by ArtifactData.hasChanged:
+     * <ol>
+     * <li> If a bundle was present in versionFrom and not in VersionTo, it will not be in the collection</li>
+     * <li> If a bundle existed in versionFrom and exists unchanged in VersionTo, hasChanged will return false</li>
+     * <li> If a bundle existed in versionFrom and exists changed (i.e. other version) in versionTo, hasChanged will return true</li>
+     * <li> If a bundle did not exist in versionFrom and exists in VersionTo, hasChanged will return true</li>
+     * </ol>
+     *
+     * @return a list of bundles.
+     * @throws IllegalArgumentException if the target, the versionFrom or versionTo do no exist
+     * @throws java.io.IOException If an IOException occurs.
+     */
+
+    public List<ArtifactData> getBundleData(String targetId, String versionFrom, String versionTo) throws IllegalArgumentException, IOException;
+
+    /**
+     * Returns a list of versions for a specific target. The list is sorted in
+     * ascending order, so the latest version is the last one in the list.
+     *
+     * @param targetId  The id of the target for which all available deployment package
+     *                   versions are being retrieved.
+     * @return All available deployment package versions for a specific target. If none available,
+     *         return an empty List.
+     *         If the target doesn't exist, an IllegalArgumentException is thrown
+     * @throws java.io.IOException If an IOException occurs.
+     */
+    public List<String> getVersions(String targetId) throws IllegalArgumentException, IOException;
+}
\ No newline at end of file

Added: ace/sandbox/marrs/org.apache.ace.deployment.provider.api/src/org/apache/ace/deployment/provider/packageinfo
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.provider.api/src/org/apache/ace/deployment/provider/packageinfo?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.provider.api/src/org/apache/ace/deployment/provider/packageinfo (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.provider.api/src/org/apache/ace/deployment/provider/packageinfo Thu Jul  5 12:09:30 2012
@@ -0,0 +1 @@
+version 1.0
\ No newline at end of file

Added: ace/sandbox/marrs/org.apache.ace.deployment.provider.base/.classpath
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.provider.base/.classpath?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.provider.base/.classpath (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.provider.base/.classpath Thu Jul  5 12:09:30 2012
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: ace/sandbox/marrs/org.apache.ace.deployment.provider.base/.project
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.provider.base/.project?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.provider.base/.project (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.provider.base/.project Thu Jul  5 12:09:30 2012
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.apache.ace.deployment.provider.base</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>bndtools.core.bndbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>bndtools.core.bndnature</nature>
+	</natures>
+</projectDescription>

Added: ace/sandbox/marrs/org.apache.ace.deployment.provider.base/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.provider.base/bnd.bnd?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.provider.base/bnd.bnd (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.provider.base/bnd.bnd Thu Jul  5 12:09:30 2012
@@ -0,0 +1,5 @@
+-buildpath: osgi.core,\
+	osgi.cmpn,\
+	org.apache.ace.client.repository.api;version=latest,\
+	org.apache.ace.deployment.provider.api;version=latest
+Export-Package: org.apache.ace.deployment.provider.impl
\ No newline at end of file

Added: ace/sandbox/marrs/org.apache.ace.deployment.provider.base/build.xml
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.provider.base/build.xml?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.provider.base/build.xml (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.provider.base/build.xml Thu Jul  5 12:09:30 2012
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="project" default="build"> 
+	<import file="../cnf/build.xml"/>
+</project>

Added: ace/sandbox/marrs/org.apache.ace.deployment.provider.base/pom.xml
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.provider.base/pom.xml?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.provider.base/pom.xml (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.provider.base/pom.xml Thu Jul  5 12:09:30 2012
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.ace</groupId>
+        <artifactId>ace-pom</artifactId>
+        <version>0.8.1-SNAPSHOT</version>
+        <relativePath>../pom/pom.xml</relativePath>
+    </parent>
+
+    <version>0.8.1-SNAPSHOT</version>
+    <artifactId>org.apache.ace.deployment.provider.base</artifactId>
+    <packaging>jar</packaging>
+    <name>Apache ACE :: Deployment :: Provider :: Base (library)</name>
+    <description />
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/ace/trunk/ace-deployment-provider-base</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/ace/trunk/ace-deployment-provider-base</developerConnection>
+        <url>http://svn.apache.org/repos/asf/ace/trunk/ace-deployment-provider-base</url>
+    </scm>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.client.repository.api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.deployment.provider.api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>

Added: ace/sandbox/marrs/org.apache.ace.deployment.provider.base/src/org/apache/ace/deployment/provider/impl/ArtifactDataImpl.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.provider.base/src/org/apache/ace/deployment/provider/impl/ArtifactDataImpl.java?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.provider.base/src/org/apache/ace/deployment/provider/impl/ArtifactDataImpl.java (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.provider.base/src/org/apache/ace/deployment/provider/impl/ArtifactDataImpl.java Thu Jul  5 12:09:30 2012
@@ -0,0 +1,215 @@
+/*
+ * 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.ace.deployment.provider.impl;
+
+import java.net.URL;
+import java.util.Map;
+import java.util.jar.Attributes;
+import org.apache.ace.client.repository.object.DeploymentArtifact;
+import org.apache.ace.deployment.provider.ArtifactData;
+import org.osgi.framework.Constants;
+
+/**
+ * Implementation of <code>ArtifactData</code>. It overrides equals to make comparisons between versions easier.
+ */
+public class ArtifactDataImpl implements ArtifactData {
+    public final static String HEADER_NAME = "Name";
+    public static final String CUSTOMIZER = "DeploymentPackage-Customizer";
+    public static final String PROCESSORPID = "Resource-Processor";
+
+    private final String m_filename;
+    private final String m_symbolicName;
+    private final String m_version;
+    private final Map<String, String> m_directives;
+
+    private final URL m_url;
+    private volatile boolean m_hasChanged;
+
+    /**
+     * Constructs an ArtifactDataImpl object.
+     * @param url The URL to the bundle. It will also be used to create the filename.
+     * The file-part of the url (after the last /) should It must only contain characters [A-Za-z0-9._-].
+     * @param directives A map of extra directives.
+     * @param symbolicName The symbolicname of the bundle.
+     * @param version The version of the bundle. If this is <code>null</code> or empty, it will be
+     * normalized to "0.0.0".
+     * @param hasChanged Indication of whether this bundle has changed relative to the previous deployment.
+     */
+    public ArtifactDataImpl(URL url, Map<String, String> directives, String symbolicName, String version, boolean hasChanged) {
+        this(url, symbolicName, version, null, directives, hasChanged);
+    }
+
+    /**
+     * Constructs an ArtifactDataImpl object.
+     * @param url The URL to the bundle. It will also be used to create the filename.
+     * The file-part of the url (after the last /) should It must only contain characters [A-Za-z0-9._-].
+     * @param directives A map of extra directives.
+     * @param hasChanged Indication of whether this bundle has changed relative to the previous deployment.
+     */
+    public ArtifactDataImpl(URL url, Map<String, String> directives, boolean hasChanged) {
+        this(url, null, null, null, directives, hasChanged);
+    }
+
+    public ArtifactDataImpl(String filename, URL url, Map<String, String> directives, boolean hasChanged) {
+        this(url, null, null, filename, directives, hasChanged);
+    }
+
+    /**
+     * Constructs an ArtifactDataImpl object.
+     * @param filename The filename of the bundle. If passed, it must only contain characters [A-Za-z0-9._-]; can be null.
+     * @param symbolicName The symbolicname of the bundle.
+     * @param version The version of the bundle. If this is <code>null</code> or empty, it will be
+     * normalized to "0.0.0".
+     * @param url The URL to the bundle. If filename is null, this will be used to create the filename; hence, the file-part of
+     * the url (after the last /) should adhere to the same rules as filename.
+     * @param hasChanged Indication of whether this bundle has changed relative to the previous deployment.
+     */
+    public ArtifactDataImpl(String filename, String symbolicName, String version, URL url, boolean hasChanged) {
+        this(url, symbolicName, version, filename, null, hasChanged);
+    }
+
+    private ArtifactDataImpl(URL url, String symbolicName, String version, String filename, Map<String, String> directives, boolean hasChanged) {
+        m_url = url;
+
+        if (filename != null) {
+            m_filename = filename;
+        }
+        else {
+            String urlString = m_url.toString();
+            m_filename = (urlString == null) ? null : urlString.substring(urlString.lastIndexOf('/') + 1);
+        }
+
+        for (byte b : m_filename.getBytes()) {
+            if (!(((b >= 'A') && (b <= 'Z')) || ((b >= 'a') && (b <= 'z')) || ((b >= '0') && (b <= '9')) || (b == '.') || (b == '-') || (b == '_'))) {
+                throw new IllegalArgumentException("Filename " + m_filename + " " + (filename == null ? "constructed from the url" : "") + " contains an illegal character '" + new String(new byte[] {b}) + "'");
+            }
+        }
+
+        m_symbolicName = symbolicName;
+        if ((version == null) || (version.trim().length() == 0)) {
+            m_version = "0.0.0";
+        }
+        else {
+            m_version = version;
+        }
+        m_directives = directives;
+        m_hasChanged = hasChanged;
+    }
+
+    public String getFilename() {
+        return m_filename;
+    }
+
+    public String getSymbolicName() {
+        return m_symbolicName;
+    }
+
+    public String getVersion() {
+        return m_version;
+    }
+
+    public String getProcessorPid() {
+        if (m_directives != null) {
+            return m_directives.get(DeploymentArtifact.DIRECTIVE_KEY_PROCESSORID);
+        }
+        return null;
+    }
+
+    public URL getUrl() {
+        return m_url;
+    }
+
+    public boolean hasChanged() {
+        return m_hasChanged;
+    }
+
+    /**
+     * @param hasChanged Indicate the bundle has changed
+     */
+    public void setChanged(boolean hasChanged) {
+        m_hasChanged = hasChanged;
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (!(other instanceof ArtifactDataImpl)) {
+            return false;
+        }
+        ArtifactDataImpl jarFile2 = (ArtifactDataImpl) other;
+
+        if (getSymbolicName() != null) {
+            // this is a bundle
+            return getSymbolicName().equals(jarFile2.getSymbolicName()) &&
+            getVersion().equals(jarFile2.getVersion());
+        }
+        else {
+            // this is another artifact.
+            return m_url.equals(jarFile2.getUrl());
+        }
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 11;
+        if (getSymbolicName() != null) {
+            result = result ^ getSymbolicName().hashCode();
+        }
+        result = result ^ getVersion().hashCode();
+        result = result ^ getUrl().hashCode();
+        return result;
+    }
+
+    public Attributes getManifestAttributes(boolean fixPackage) {
+        Attributes a = new Attributes();
+
+        if (!isBundle()) {
+            // this is a regular artifact
+            a.putValue(PROCESSORPID, getProcessorPid());
+        }
+        else {
+            a.putValue(Constants.BUNDLE_SYMBOLICNAME, getSymbolicName());
+            a.putValue(Constants.BUNDLE_VERSION, getVersion());
+            // this is a bundle
+            if (isCustomizer()) {
+                a.putValue(CUSTOMIZER, "true");
+            }
+        }
+        
+        if (m_directives != null) {
+            String path = m_directives.get(DeploymentArtifact.REPOSITORY_PATH);
+            if (path != null) {
+            	a.putValue(DeploymentArtifact.REPOSITORY_PATH, path);
+            }
+        }
+        if (!hasChanged() && fixPackage) {
+            a.putValue("DeploymentPackage-Missing", "true");
+        }
+
+        return a;
+    }
+
+    public boolean isCustomizer() {
+        return (m_directives != null) && "true".equals(m_directives.get(DeploymentArtifact.DIRECTIVE_ISCUSTOMIZER));
+    }
+
+    public boolean isBundle() {
+        return getSymbolicName() != null;
+    }
+
+}
\ No newline at end of file

Added: ace/sandbox/marrs/org.apache.ace.deployment.provider.base/src/org/apache/ace/deployment/provider/impl/packageinfo
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.provider.base/src/org/apache/ace/deployment/provider/impl/packageinfo?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.provider.base/src/org/apache/ace/deployment/provider/impl/packageinfo (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.provider.base/src/org/apache/ace/deployment/provider/impl/packageinfo Thu Jul  5 12:09:30 2012
@@ -0,0 +1 @@
+version 1.0
\ No newline at end of file

Added: ace/sandbox/marrs/org.apache.ace.deployment.servlet/.classpath
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.servlet/.classpath?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.servlet/.classpath (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.servlet/.classpath Thu Jul  5 12:09:30 2012
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" output="bin_test" path="test"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.testng.TESTNG_CONTAINER"/>
+	<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: ace/sandbox/marrs/org.apache.ace.deployment.servlet/.project
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.servlet/.project?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.servlet/.project (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.servlet/.project Thu Jul  5 12:09:30 2012
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.apache.ace.deployment.servlet</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>bndtools.core.bndbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>bndtools.core.bndnature</nature>
+	</natures>
+</projectDescription>

Added: ace/sandbox/marrs/org.apache.ace.deployment.servlet/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.servlet/bnd.bnd?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.servlet/bnd.bnd (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.servlet/bnd.bnd Thu Jul  5 12:09:30 2012
@@ -0,0 +1,12 @@
+-buildpath: osgi.core,\
+	osgi.cmpn,\
+	org.apache.felix.dependencymanager,\
+	javax.servlet,\
+	org.apache.ace.util;version=latest,\
+	org.apache.ace.authentication.api;version=latest,\
+	org.apache.ace.deployment.api;version=latest,\
+	org.apache.ace.deployment.provider.api;version=latest,\
+	org.apache.ace.deployment.streamgenerator;version=latest
+Private-Package: org.apache.ace.deployment.servlet
+Bundle-Activator: org.apache.ace.deployment.servlet.Activator
+Export-Package: org.apache.ace.deployment.processor
\ No newline at end of file

Added: ace/sandbox/marrs/org.apache.ace.deployment.servlet/build.xml
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.servlet/build.xml?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.servlet/build.xml (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.servlet/build.xml Thu Jul  5 12:09:30 2012
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="project" default="build"> 
+	<import file="../cnf/build.xml"/>
+</project>

Added: ace/sandbox/marrs/org.apache.ace.deployment.servlet/pom.xml
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.servlet/pom.xml?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.servlet/pom.xml (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.servlet/pom.xml Thu Jul  5 12:09:30 2012
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.ace</groupId>
+        <artifactId>ace-pom</artifactId>
+        <version>0.8.1-SNAPSHOT</version>
+        <relativePath>../pom/pom.xml</relativePath>
+    </parent>
+
+    <version>0.8.1-SNAPSHOT</version>
+    <artifactId>org.apache.ace.deployment.servlet</artifactId>
+    <packaging>bundle</packaging>
+
+    <name>Apache ACE :: Deployment :: Servlet</name>
+    <description>Servlet that is used by management agents to get an overview of available versions and request 'deployment packages' of specific versions or deltas between versions.</description>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/ace/trunk/ace-deployment-servlet</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/ace/trunk/ace-deployment-servlet</developerConnection>
+        <url>http://svn.apache.org/repos/asf/ace/trunk/ace-deployment-servlet</url>
+    </scm>
+
+    <properties>
+        <export.package>
+            org.apache.ace.deployment.processor;version=${project.version}
+        </export.package>
+        <import.package>
+            org.apache.ace.authentication.api;resolution:=optional;version=${project.version},
+            org.apache.ace.deployment.processor;version=${project.version},
+            org.apache.ace.deployment.provider;version=${project.version},
+            org.apache.ace.deployment.streamgenerator;version=${project.version},
+            *
+        </import.package>
+        <private.package>
+            org.apache.ace.deployment.servlet
+        </private.package>
+        <bundle.activator>
+            org.apache.ace.deployment.servlet.Activator
+        </bundle.activator>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.authentication.api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.deployment.api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.deployment.provider.api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.deployment.streamgenerator</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ace</groupId>
+            <artifactId>org.apache.ace.util</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.dependencymanager</artifactId>
+        </dependency> 
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+        </dependency>
+    </dependencies>
+</project>

Added: ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/processor/DeploymentProcessor.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/processor/DeploymentProcessor.java?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/processor/DeploymentProcessor.java (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/processor/DeploymentProcessor.java Thu Jul  5 12:09:30 2012
@@ -0,0 +1,44 @@
+package org.apache.ace.deployment.processor;
+/*
+ * 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.IOException;
+import java.io.InputStream;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Deployment processors can post process the deployment package before it is sent to the original requester. This allows you to
+ * transform how the data is actually sent, allowing you to basically "repackage" the content on the fly. Deployment processors
+ * should be registered as services with a service property called "processor" which should match a request property of the same
+ * name and value.
+ */
+public interface DeploymentProcessor {
+    /**
+     * Post-process the stream and send it to the response. The input stream is the deployment package as it was generated. You
+     * should set the correct mime type and start writing to the response.
+     * 
+     * @param inputStream the input stream for the deployment package
+     * @param request the original request, in case you want to access certain parameters
+     * @param response the response to write to
+     */
+    public void process(InputStream inputStream, HttpServletRequest request, HttpServletResponse response) throws IOException;
+}

Added: ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/processor/packageinfo
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/processor/packageinfo?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/processor/packageinfo (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/processor/packageinfo Thu Jul  5 12:09:30 2012
@@ -0,0 +1 @@
+version 1.0
\ No newline at end of file

Added: ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/servlet/AceRestException.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/servlet/AceRestException.java?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/servlet/AceRestException.java (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/servlet/AceRestException.java Thu Jul  5 12:09:30 2012
@@ -0,0 +1,46 @@
+/*
+ * 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.ace.deployment.servlet;
+
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Handle common rest problems here.
+ * This can be thrown by services (unaware of how to handle it in the end) and handeled inside the catching servlet.
+ */
+public class AceRestException extends Exception {
+    private final int m_statusCode;
+    private final String m_description;
+
+    public AceRestException(int statusCode, String description) {
+        super(statusCode + ":" + description);
+        m_statusCode = statusCode;
+        m_description = description;
+    }
+
+    /**
+     * handling code where we turn <code>this</code> into http error.
+     *
+     * @param response
+     */
+    public void handleAsHttpError(HttpServletResponse response) throws IOException {
+        response.sendError(m_statusCode, m_description);
+    }
+}
\ No newline at end of file

Added: ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/servlet/Activator.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/servlet/Activator.java?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/servlet/Activator.java (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/servlet/Activator.java Thu Jul  5 12:09:30 2012
@@ -0,0 +1,51 @@
+/*
+ * 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.ace.deployment.servlet;
+
+import javax.servlet.Servlet;
+
+import org.apache.ace.deployment.processor.DeploymentProcessor;
+import org.apache.ace.deployment.provider.DeploymentProvider;
+import org.apache.ace.deployment.streamgenerator.StreamGenerator;
+import org.apache.felix.dm.DependencyActivatorBase;
+import org.apache.felix.dm.DependencyManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+public class Activator extends DependencyActivatorBase {
+    public static final String PID = "org.apache.ace.deployment.servlet";
+
+    @Override
+    public void init(BundleContext context, DependencyManager manager) throws Exception {
+        manager.add(createComponent()
+            .setInterface(Servlet.class.getName(), null)
+            .setImplementation(DeploymentServlet.class)
+            .add(createConfigurationDependency().setPropagate(true).setPid(PID))
+            .add(createServiceDependency().setService(StreamGenerator.class).setRequired(true))
+            .add(createServiceDependency().setService(DeploymentProvider.class).setRequired(true))
+            .add(createServiceDependency().setService(DeploymentProcessor.class).setRequired(false).setCallbacks("addProcessor", "removeProcessor"))
+            .add(createServiceDependency().setService(LogService.class).setRequired(false))
+        );
+    }
+
+    @Override
+    public void destroy(BundleContext context, DependencyManager manager) throws Exception {
+        // do nothing
+    }
+}
\ No newline at end of file

Added: ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/servlet/DeploymentServlet.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/servlet/DeploymentServlet.java?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/servlet/DeploymentServlet.java (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.servlet/src/org/apache/ace/deployment/servlet/DeploymentServlet.java Thu Jul  5 12:09:30 2012
@@ -0,0 +1,308 @@
+/*
+ * 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.ace.deployment.servlet;
+
+import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Dictionary;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.ace.authentication.api.AuthenticationService;
+import org.apache.ace.deployment.processor.DeploymentProcessor;
+import org.apache.ace.deployment.provider.DeploymentProvider;
+import org.apache.ace.deployment.streamgenerator.StreamGenerator;
+import org.apache.felix.dm.Component;
+import org.apache.felix.dm.DependencyManager;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.log.LogService;
+import org.osgi.service.useradmin.User;
+
+/**
+ * The DeploymentServlet class provides in a list of versions available for a target and a stream
+ * of data containing the DeploymentPackage (or fix package) for a specific target and version.
+ */
+public class DeploymentServlet extends HttpServlet implements ManagedService {
+    private static final long serialVersionUID = 1L;
+
+    /** A boolean denoting whether or not authentication is enabled. */
+    private static final String KEY_USE_AUTHENTICATION = "authentication.enabled";
+
+    public static final String CURRENT = "current";
+    public static final String PROCESSOR = "processor";
+    public static final String VERSIONS = "versions";
+    public static final String DP_MIMETYPE = "application/vnd.osgi.dp";
+    public static final String TEXT_MIMETYPE = "text/plain";
+    
+    private final ConcurrentMap<String, DeploymentProcessor> m_processors = new ConcurrentHashMap<String, DeploymentProcessor>();
+    
+    // injected by Dependency Manager
+    private volatile DependencyManager m_dm; 
+    private volatile LogService m_log;
+    private volatile StreamGenerator m_streamGenerator;
+    private volatile DeploymentProvider m_provider;
+    private volatile AuthenticationService m_authService;
+
+    private volatile boolean m_useAuth = false;
+
+    /**
+     * Responds to GET requests sent to this endpoint, the response depends on the requested path:
+     * <li>http://host/endpoint/targetid/versions/ returns a list of versions available for the specified target
+     * <li>http://host/endpoint/targetid/versions/x.y.z returns a deployment package stream for the specified target and version
+     *
+     * The status code of the response can be one of the following:
+     * <li><code>HttpServletResponse.SC_BAD_REQUEST</code> - If no target is specified or the request is malformed in a different way.
+     * <li><code>HttpServletResponse.SC_NOT_FOUND</code> - If the specified target or version does not exist.
+     * <li><code>HttpServletResponse.SC_INTERNAL_SERVER_ERROR</code> - If there was a problem processing the request.
+     * <li><code>HttpServletResponse.SC_OK</code> - If all went fine
+     */
+    @Override
+    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        try {
+            String[] pathElements = verifyAndGetPathElements(request.getPathInfo());
+            String targetID = pathElements[1];
+            List<String> versions = getVersions(targetID);
+            int numberOfElements = pathElements.length;
+
+            if (numberOfElements == 3) {
+                handleVersionsRequest(versions, response);
+            }
+            else {
+                String version = pathElements[3];
+                handlePackageDelivery(targetID, version, versions, request, response);
+            }
+        }
+        catch (AceRestException e) {
+            m_log.log(LogService.LOG_WARNING, e.getMessage(), e);
+            e.handleAsHttpError(response);
+        }
+    }
+
+    /**
+     * Called by Dependency Manager upon initialization of this component.
+     * 
+     * @param comp the component to initialize, cannot be <code>null</code>.
+     */
+    protected void init(Component comp) {
+        comp.add(m_dm.createServiceDependency()
+            .setService(AuthenticationService.class)
+            .setRequired(m_useAuth)
+            .setInstanceBound(true)
+            );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+        if (!authenticate(req)) {
+            // Authentication failed; don't proceed with the original request...
+            resp.sendError(SC_UNAUTHORIZED);
+        } else {
+            // Authentication successful, proceed with original request...
+            super.service(req, resp);
+        }
+    }
+
+    /**
+     * Authenticates, if needed the user with the information from the given request.
+     * 
+     * @param request the request to obtain the credentials from, cannot be <code>null</code>.
+     * @return <code>true</code> if the authentication was successful, <code>false</code> otherwise.
+     */
+    private boolean authenticate(HttpServletRequest request) {
+        if (m_useAuth) {
+            User user = m_authService.authenticate(request);
+            if (user == null) {
+                m_log.log(LogService.LOG_INFO, "Authentication failure!");
+            }
+            return (user != null);
+        }
+        return true;
+    }
+
+    /**
+     * Serve the case where requested path is like:
+     * http://host/endpoint/targetid/versions/ returns a list of versions available for the specified target
+     *
+     * @param versions versions to be put into response
+     * @param response response object.
+     */
+    private void handleVersionsRequest(List<String> versions, HttpServletResponse response) throws AceRestException {
+        ServletOutputStream output = null;
+
+        response.setContentType(TEXT_MIMETYPE);
+        try {
+            output = response.getOutputStream();
+            for (String version : versions) {
+                output.print(version);
+                output.print("\n");
+            }
+        }
+        catch (IOException e) {
+            throw new AceRestException(HttpServletResponse.SC_BAD_REQUEST, "Request URI is invalid");
+        }
+        finally {
+            tryClose(output);
+        }
+    }
+
+    private void handlePackageDelivery(final String targetID, final String version, final List<String> versions, final HttpServletRequest request, final HttpServletResponse response) throws AceRestException {
+        ServletOutputStream output = null;
+
+        try {
+            if (!versions.contains(version)) {
+                throw new AceRestException(HttpServletResponse.SC_NOT_FOUND, "Unknown version (" + version + ")");
+            }
+            String current = request.getParameter(CURRENT);
+            String processor = request.getParameter(PROCESSOR);
+
+            InputStream inputStream;
+            if (current != null) {
+                inputStream = m_streamGenerator.getDeploymentPackage(targetID, current, version);
+            }
+            else {
+                inputStream = m_streamGenerator.getDeploymentPackage(targetID, version);
+            }
+
+            if (processor != null) {
+                DeploymentProcessor deploymentProcessor = m_processors.get(processor);
+                if (deploymentProcessor != null) {
+                    deploymentProcessor.process(inputStream, request, response);
+                    return;
+                }
+                else {
+                    throw new AceRestException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Could not find a deployment processor called: " + processor);
+                }
+            }
+            response.setContentType(DP_MIMETYPE);
+            output = response.getOutputStream();
+            byte[] buffer = new byte[1024 * 32];
+            for (int bytesRead = inputStream.read(buffer); bytesRead != -1; bytesRead = inputStream.read(buffer)) {
+                output.write(buffer, 0, bytesRead);
+            }
+        }
+        catch (IOException e) {
+            throw new AceRestException(HttpServletResponse.SC_BAD_REQUEST, "Request URI is invalid");
+        }
+        finally {
+            tryClose(output);
+        }
+    }
+
+    private List<String> getVersions(String targetID) throws AceRestException {
+        try {
+            return m_provider.getVersions(targetID);
+        }
+        catch (IllegalArgumentException iae) {
+            throw new AceRestException(HttpServletResponse.SC_NOT_FOUND, "Unknown target (" + targetID + ")");
+        }
+        catch (IOException ioe) {
+            m_log.log(LogService.LOG_WARNING, "Error getting available versions.", ioe);
+            throw new AceRestException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error getting available versions.");
+        }
+    }
+
+    private void tryClose(OutputStream output) {
+        try {
+            if (output != null) {
+                output.close();
+            }
+        }
+        catch (IOException e) {
+            m_log.log(LogService.LOG_WARNING, "Exception trying to close stream after request. ", e);
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * Make sure the path is valid.
+     * Also returns the splited version of #path.
+     *
+     * @param path http request path
+     *
+     * @return splitted version of #path. Split delim is "/"
+     *
+     * @throws org.apache.ace.deployment.servlet.AceRestException if path is not valid or cannot be processed.
+     */
+    private String[] verifyAndGetPathElements(String path) throws AceRestException {
+        if (path == null) {
+            throw new AceRestException(HttpServletResponse.SC_BAD_REQUEST, "Request URI is invalid");
+        }
+        String[] elements = path.split("/");
+        int numberOfElements = elements.length;
+
+        if ((numberOfElements < 3) || (numberOfElements > 4) || !VERSIONS.equals(elements[2])) {
+            throw new AceRestException(HttpServletResponse.SC_BAD_REQUEST, "Request URI is invalid");
+        }
+        return elements;
+    }
+
+    @Override
+    public String getServletInfo() {
+        return "Ace Deployment Servlet Endpoint";
+    }
+
+    public void updated(Dictionary settings) throws ConfigurationException {
+        if (settings != null) {
+            String useAuthString = (String) settings.get(KEY_USE_AUTHENTICATION);
+            if (useAuthString == null
+                || !("true".equalsIgnoreCase(useAuthString) || "false".equalsIgnoreCase(useAuthString))) {
+                throw new ConfigurationException(KEY_USE_AUTHENTICATION, "Missing or invalid value!");
+            }
+            boolean useAuth = Boolean.parseBoolean(useAuthString);
+
+            m_useAuth = useAuth;
+        }
+        else {
+            m_useAuth = false;
+        }
+    }
+
+    public void addProcessor(ServiceReference ref, DeploymentProcessor processor) {
+        String key = (String) ref.getProperty(PROCESSOR);
+        if (key == null) {
+            m_log.log(LogService.LOG_WARNING, "Deployment processor ignored, required service property '" + PROCESSOR + "' is missing.");
+            return;
+        }
+        m_processors.putIfAbsent(key, processor);
+    }
+
+    public void removeProcessor(ServiceReference ref, DeploymentProcessor processor) {
+        String key = (String) ref.getProperty(PROCESSOR);
+        if (key == null) {
+            // we do not log this here again, we already did so in 'addProcessor'
+            return;
+        }
+        m_processors.remove(key);
+    }
+}
\ No newline at end of file

Added: ace/sandbox/marrs/org.apache.ace.deployment.servlet/test/org/apache/ace/deployment/servlet/DeploymentServletTest.java
URL: http://svn.apache.org/viewvc/ace/sandbox/marrs/org.apache.ace.deployment.servlet/test/org/apache/ace/deployment/servlet/DeploymentServletTest.java?rev=1357570&view=auto
==============================================================================
--- ace/sandbox/marrs/org.apache.ace.deployment.servlet/test/org/apache/ace/deployment/servlet/DeploymentServletTest.java (added)
+++ ace/sandbox/marrs/org.apache.ace.deployment.servlet/test/org/apache/ace/deployment/servlet/DeploymentServletTest.java Thu Jul  5 12:09:30 2012
@@ -0,0 +1,232 @@
+/*
+ * 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.ace.deployment.servlet;
+
+import static org.apache.ace.test.utils.TestUtils.UNIT;
+import static org.apache.ace.test.utils.TestUtils.configureObject;
+import static org.apache.ace.test.utils.TestUtils.createMockObjectAdapter;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.ace.deployment.provider.ArtifactData;
+import org.apache.ace.deployment.provider.DeploymentProvider;
+import org.apache.ace.deployment.streamgenerator.StreamGenerator;
+import org.osgi.service.log.LogService;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+public class DeploymentServletTest {
+
+    private DeploymentServlet m_servlet;
+
+    private HttpServletRequest m_request;
+    private String m_requestCurrentParameter;
+    private String m_requestPathInfo;
+
+    private HttpServletResponse m_response;
+    private ByteArrayOutputStream m_responseOutputStream;
+    private int m_responseStatus;
+
+    private DeploymentProvider m_provider;
+    private List<String> m_providerVersions;
+
+    private StreamGenerator m_generator;
+    private InputStream m_generatorResultStream;
+    private String m_generatorId;
+    private String m_generatorFromVersion;
+    private String m_generatorToVersion;
+
+
+    @BeforeMethod(alwaysRun = true)
+    protected void setUp() throws Exception {
+        // resets variables that store results of tests
+        m_generatorResultStream = null;
+        m_generatorId = null;
+        m_generatorFromVersion = null;
+        m_generatorToVersion = null;
+        m_providerVersions = null;
+
+        // create mock stream generator
+        m_generator = new StreamGenerator() {
+            public InputStream getDeploymentPackage(String id, String version) throws IOException {
+                if (m_generatorResultStream == null) {
+                    throw new IOException("No data for " + id + " " + version);
+                }
+                m_generatorId = id;
+                m_generatorToVersion = version;
+                return m_generatorResultStream;
+            }
+            public InputStream getDeploymentPackage(String id, String fromVersion, String toVersion) throws IOException {
+                if (m_generatorResultStream == null) {
+                    throw new IOException("No delta for " + id + " " + fromVersion + " " + toVersion);
+                }
+                m_generatorId = id;
+                m_generatorFromVersion = fromVersion;
+                m_generatorToVersion = toVersion;
+                return m_generatorResultStream;
+            }
+        };
+
+
+        // create mock deployment provider
+        m_provider = new DeploymentProvider() {
+            public List<ArtifactData> getBundleData(String targetId, String version) throws IllegalArgumentException {
+                return null; // not used
+            }
+            public List<ArtifactData> getBundleData(String targetId, String versionFrom, String versionTo) throws IllegalArgumentException {
+                return null; // not used
+            }
+            public List<String> getVersions(String targetId) throws IllegalArgumentException {
+                if (m_providerVersions == null) {
+                    throw new IllegalArgumentException();
+                }
+                return m_providerVersions;
+            }
+        };
+
+        // create a HttpServletRequest mock object
+        m_request = createMockObjectAdapter(HttpServletRequest.class, new Object() {
+            @SuppressWarnings("unused")
+            public String getParameter(String param) {
+                if (param.equals(DeploymentServlet.CURRENT)) {
+                    return m_requestCurrentParameter;
+                }
+                return null;
+            }
+            @SuppressWarnings("unused")
+            public String getPathInfo() {
+                return m_requestPathInfo;
+            }
+        });
+
+        // create a HttpServletResponse mock object
+        m_response = createMockObjectAdapter(HttpServletResponse.class, new Object() {
+            @SuppressWarnings("unused")
+            public ServletOutputStream getOutputStream() {
+                return new ServletOutputStream() {
+                    @Override
+                    public void write(int b) throws IOException {
+                        m_responseOutputStream.write(b);
+                    }
+                };
+            }
+            @SuppressWarnings("unused")
+            public void sendError(int status) {
+                m_responseStatus = status;
+            }
+            @SuppressWarnings("unused")
+            public void sendError(int status, String desc) {
+                sendError(status);
+            }
+        });
+
+        m_responseStatus = HttpServletResponse.SC_OK;
+        m_responseOutputStream = new ByteArrayOutputStream();
+
+        // create the instance to test
+        m_servlet = new DeploymentServlet();
+        configureObject(m_servlet, LogService.class);
+        configureObject(m_servlet, StreamGenerator.class, m_generator);
+        configureObject(m_servlet, DeploymentProvider.class, m_provider);
+
+    }
+
+    @AfterMethod(alwaysRun = true)
+    public void tearDown() throws Exception {
+    }
+
+    @Test(groups = { UNIT })
+    public void getDataForExistingTarget() throws Exception {
+        m_requestPathInfo = "/T1/versions/2.0.0";
+        m_generatorResultStream = new ByteArrayInputStream(new byte[10]);
+        m_providerVersions = new ArrayList<String>();
+        m_providerVersions.add("2.0.0");
+        m_servlet.doGet(m_request, m_response);
+
+        // make sure the request went fine
+        assert m_responseStatus == HttpServletResponse.SC_OK : "We should have got response code " + HttpServletResponse.SC_OK + " and we got " + m_responseStatus;
+        assert m_responseOutputStream.size() == 10 : "We should have got a (dummy) deployment package of 10 bytes.";
+        assert m_generatorId.equals("T1") : "Wrong target ID.";
+        assert m_generatorToVersion.equals("2.0.0") : "Wrong version.";
+    }
+
+    @Test(groups = { UNIT })
+    public void getFixPackageForExistingTarget() throws Exception {
+        m_requestPathInfo = "/T1/versions/2.0.0";
+        m_requestCurrentParameter = "1.0.0";
+        m_generatorResultStream = new ByteArrayInputStream(new byte[10]);
+        m_providerVersions = new ArrayList<String>();
+        m_providerVersions.add("2.0.0");
+        m_servlet.doGet(m_request, m_response);
+
+        // make sure the request went fine
+        assert m_responseStatus == HttpServletResponse.SC_OK : "We should have got response code " + HttpServletResponse.SC_OK + " and we got " + m_responseStatus;
+        assert m_responseOutputStream.size() == 10 : "We should have got a (dummy) deployment package of 10 bytes.";
+        assert m_generatorId.equals("T1") : "Wrong target ID.";
+        assert m_generatorToVersion.equals("2.0.0") : "Wrong version.";
+        assert m_generatorFromVersion.equals("1.0.0") : "Wrong current version.";
+    }
+
+    @Test(groups = { UNIT })
+    public void getDataForNonExistingTarget() throws Exception {
+        m_requestPathInfo = "/T?/versions/2.0.0";
+        m_servlet.doGet(m_request, m_response);
+        assert m_responseStatus == HttpServletResponse.SC_NOT_FOUND : "We should have gotten response code" + HttpServletResponse.SC_NOT_FOUND + ", actual code: " + m_responseStatus;
+    }
+
+    @Test(groups = { UNIT })
+    public void getDataForBadURL() throws Exception {
+        HttpServletRequest garbage = createMockObjectAdapter(HttpServletRequest.class, new Object() {
+            @SuppressWarnings("unused")
+            public String getPathInfo() {
+                return "/";
+            }
+        });
+        m_servlet.doGet(garbage, m_response);
+        assert m_responseStatus == HttpServletResponse.SC_BAD_REQUEST : "We should have gotten response code " + HttpServletResponse.SC_NOT_FOUND + ", actual code: " + m_responseStatus;
+    }
+
+
+    @Test(groups = { UNIT })
+    public void getVersionsExistingTarget() throws Exception {
+        m_requestPathInfo = "/T1/versions";
+        m_providerVersions = new ArrayList<String>();
+        m_providerVersions.add("2.0.0");
+        m_servlet.doGet(m_request, m_response);
+        assert "2.0.0\n".equals(m_responseOutputStream.toString()) : "Expected to get version 2.0.0 in the response";
+    }
+
+    @Test(groups = { UNIT })
+    public void getVersionsNonExistingTarget() throws Exception {
+        m_requestPathInfo = "/T1/versions";
+        m_servlet.doGet(m_request, m_response);
+        assert "".equals(m_responseOutputStream.toString()) : "Expected to get an empty response";
+    }
+
+}



Mime
View raw message