Author: bramk
Date: Wed Aug 7 08:08:17 2013
New Revision: 1511209
URL: http://svn.apache.org/r1511209
Log:
ACE-405 Split out ACE Bnd repository from gogo bundle
Added:
ace/trunk/org.apache.ace.bnd/
ace/trunk/org.apache.ace.bnd/.classpath
ace/trunk/org.apache.ace.bnd/.gitignore
ace/trunk/org.apache.ace.bnd/.project
ace/trunk/org.apache.ace.bnd/.settings/
ace/trunk/org.apache.ace.bnd/.settings/org.eclipse.jdt.core.prefs
ace/trunk/org.apache.ace.bnd/bnd.bnd
ace/trunk/org.apache.ace.bnd/build.xml
ace/trunk/org.apache.ace.bnd/repository.bnd
ace/trunk/org.apache.ace.bnd/src/
ace/trunk/org.apache.ace.bnd/src/.gitignore
ace/trunk/org.apache.ace.bnd/src/org/
ace/trunk/org.apache.ace.bnd/src/org/apache/
ace/trunk/org.apache.ace.bnd/src/org/apache/ace/
ace/trunk/org.apache.ace.bnd/src/org/apache/ace/bnd/
ace/trunk/org.apache.ace.bnd/src/org/apache/ace/bnd/repository/
ace/trunk/org.apache.ace.bnd/src/org/apache/ace/bnd/repository/AceObrRepository.java
ace/trunk/org.apache.ace.bnd/src/org/apache/ace/bnd/repository/packageinfo
ace/trunk/org.apache.ace.bnd/test/
ace/trunk/org.apache.ace.bnd/test/.gitignore
Removed:
ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/AceObrRepository.java
Modified:
ace/trunk/build/bnd.bnd
ace/trunk/org.apache.ace.gogo/bnd.bnd
ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/CommandRepo.java
ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/ContinuousDeployer.java
ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepoCommands.java
ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepositoryUtil.java
Modified: ace/trunk/build/bnd.bnd
URL:
http://svn.apache.org/viewvc/ace/trunk/build/bnd.bnd?rev=1511209&r1=1511208&r2=1511209&view=diff
==============================================================================
--- ace/trunk/build/bnd.bnd (original)
+++ ace/trunk/build/bnd.bnd Wed Aug 7 08:08:17 2013
@@ -3,6 +3,7 @@
org.apache.ace.ant.tasks,\
org.apache.ace.authentication,\
org.apache.ace.authentication.itest,\
+ org.apache.ace.bnd,\
org.apache.ace.builder,\
org.apache.ace.client.automation,\
org.apache.ace.client.repository,\
Added: ace/trunk/org.apache.ace.bnd/.classpath
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.bnd/.classpath?rev=1511209&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.bnd/.classpath (added)
+++ ace/trunk/org.apache.ace.bnd/.classpath Wed Aug 7 08:08:17 2013
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="bin" path="src"/>
+ <classpathentry kind="src" output="bin_test" path="test"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="aQute.bnd.classpath.container"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: ace/trunk/org.apache.ace.bnd/.gitignore
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.bnd/.gitignore?rev=1511209&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.bnd/.gitignore (added)
+++ ace/trunk/org.apache.ace.bnd/.gitignore Wed Aug 7 08:08:17 2013
@@ -0,0 +1,3 @@
+/bin/
+/bin_test/
+/generated/
Added: ace/trunk/org.apache.ace.bnd/.project
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.bnd/.project?rev=1511209&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.bnd/.project (added)
+++ ace/trunk/org.apache.ace.bnd/.project Wed Aug 7 08:08:17 2013
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.apache.ace.bnd</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/trunk/org.apache.ace.bnd/.settings/org.eclipse.jdt.core.prefs
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.bnd/.settings/org.eclipse.jdt.core.prefs?rev=1511209&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.bnd/.settings/org.eclipse.jdt.core.prefs (added)
+++ ace/trunk/org.apache.ace.bnd/.settings/org.eclipse.jdt.core.prefs Wed Aug
7 08:08:17 2013
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: ace/trunk/org.apache.ace.bnd/bnd.bnd
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.bnd/bnd.bnd?rev=1511209&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.bnd/bnd.bnd (added)
+++ ace/trunk/org.apache.ace.bnd/bnd.bnd Wed Aug 7 08:08:17 2013
@@ -0,0 +1,3 @@
+-sub: *.bnd
+-buildpath: biz.aQute.bnd;version=2.1.0,\
+ biz.aQute.repository;version=2.1.0
\ No newline at end of file
Added: ace/trunk/org.apache.ace.bnd/build.xml
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.bnd/build.xml?rev=1511209&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.bnd/build.xml (added)
+++ ace/trunk/org.apache.ace.bnd/build.xml Wed Aug 7 08:08:17 2013
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="project" default="build">
+
+ <!-- -->
+
+ <import file="../cnf/build.xml" />
+</project>
Added: ace/trunk/org.apache.ace.bnd/repository.bnd
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.bnd/repository.bnd?rev=1511209&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.bnd/repository.bnd (added)
+++ ace/trunk/org.apache.ace.bnd/repository.bnd Wed Aug 7 08:08:17 2013
@@ -0,0 +1,4 @@
+Bundle-Version: 1.0.0
+Bundle-Name: Apache ACE OBR Repository
+Bundle-Description: Provides an ACE Bnd Repository implementation
+Export-Package: org.apache.ace.bnd.repository
\ No newline at end of file
Added: ace/trunk/org.apache.ace.bnd/src/.gitignore
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.bnd/src/.gitignore?rev=1511209&view=auto
==============================================================================
(empty)
Added:
ace/trunk/org.apache.ace.bnd/src/org/apache/ace/bnd/repository/AceObrRepository.java
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.bnd/src/org/apache/ace/bnd/repository/AceObrRepository.java?rev=1511209&view=auto
==============================================================================
---
ace/trunk/org.apache.ace.bnd/src/org/apache/ace/bnd/repository/AceObrRepository.java
(added)
+++
ace/trunk/org.apache.ace.bnd/src/org/apache/ace/bnd/repository/AceObrRepository.java
Wed Aug 7 08:08:17 2013
@@ -0,0 +1,150 @@
+/*
+ * 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.bnd.repository;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Map;
+
+import aQute.bnd.deployer.repository.FixedIndexedRepo;
+
+/**
+ * BND repository implementation that supports write capabilities to an Apache
ACE OBR.
+ *
+ */
+public class AceObrRepository extends FixedIndexedRepo {
+
+ private URL m_endpoint;
+ private boolean m_verbose;
+
+ @Override
+ public synchronized void setProperties(Map<String, String> map) {
+ super.setProperties(map);
+
+ String location = getLocation();
+ try {
+ m_endpoint = new URL(location.substring(0,
location.lastIndexOf("/") + 1));
+ }
+ catch (MalformedURLException e) {
+ throw new IllegalArgumentException("Failed to determin location
endpoint", e);
+ }
+ m_verbose = map.get("verbose") == null ? false :
Boolean.parseBoolean(map.get("verbose"));
+ }
+
+ @Override
+ public boolean canWrite() {
+ return true;
+ }
+
+ @Override
+ public synchronized PutResult put(InputStream stream, PutOptions options)
throws Exception {
+
+ if (options == null)
+ options = DEFAULTOPTIONS;
+
+ if (options.type == null)
+ options.type = PutOptions.BUNDLE;
+
+ if (stream == null)
+ throw new IllegalArgumentException("No stream and/or options
specified");
+
+ PutResult result = new PutResult();
+ result.artifact = upload(stream, "", options.type);
+
+ reset();
+ return result;
+ }
+
+ public URL getEndpoint() {
+ return m_endpoint;
+ }
+
+ public URI upload(InputStream stream, String filename, String mimetype)
throws Exception {
+
+ OutputStream output = null;
+ String location = null;
+ try {
+
+ URL url = new URL(m_endpoint, "?filename=" + filename);
+ URLConnection connection = url.openConnection();
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+ connection.setUseCaches(false);
+
+ if (mimetype != null) {
+ connection.setRequestProperty("Content-Type", mimetype);
+ }
+ else {
+ // We need a mimetype or Jetty will throw a 500 Form too large
+
+ connection.setRequestProperty("Content-Type",
"application/octet-stream");
+ }
+
+ if (connection instanceof HttpURLConnection) {
+ ((HttpURLConnection) connection).setChunkedStreamingMode(8192);
+ }
+
+ int size = 0;
+ output = connection.getOutputStream();
+ byte[] buffer = new byte[4 * 1024];
+ for (int count = stream.read(buffer); count != -1; count =
stream.read(buffer)) {
+ output.write(buffer, 0, count);
+ size += count;
+ if (m_verbose)
+ System.out.println("Uploaded bytes... " + size);
+ }
+ output.close();
+
+ if (connection instanceof HttpURLConnection) {
+ int responseCode = ((HttpURLConnection)
connection).getResponseCode();
+ String responseMessage = ((HttpURLConnection)
connection).getResponseMessage();
+ switch (responseCode) {
+ case HttpURLConnection.HTTP_CREATED:
+ location = connection.getHeaderField("Location");
+ break;
+ case HttpURLConnection.HTTP_CONFLICT:
+ throw new IOException("Resource already exists: " +
responseMessage);
+ case HttpURLConnection.HTTP_INTERNAL_ERROR:
+ throw new IOException("Internal server error: " +
responseMessage);
+ default:
+ throw new IOException("Unexpected server response: " +
responseMessage);
+ }
+ }
+ }
+ catch (IOException e) {
+ throw new IOException("Error importing resource: " +
e.getMessage(), e);
+ }
+ finally {
+ if (output != null) {
+ try {
+ output.close();
+ }
+ catch (Exception ex) {
+ }
+ }
+ }
+ return new URI(location);
+ }
+}
Added:
ace/trunk/org.apache.ace.bnd/src/org/apache/ace/bnd/repository/packageinfo
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.bnd/src/org/apache/ace/bnd/repository/packageinfo?rev=1511209&view=auto
==============================================================================
--- ace/trunk/org.apache.ace.bnd/src/org/apache/ace/bnd/repository/packageinfo
(added)
+++ ace/trunk/org.apache.ace.bnd/src/org/apache/ace/bnd/repository/packageinfo
Wed Aug 7 08:08:17 2013
@@ -0,0 +1 @@
+version 1.0
\ No newline at end of file
Added: ace/trunk/org.apache.ace.bnd/test/.gitignore
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.bnd/test/.gitignore?rev=1511209&view=auto
==============================================================================
(empty)
Modified: ace/trunk/org.apache.ace.gogo/bnd.bnd
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.gogo/bnd.bnd?rev=1511209&r1=1511208&r2=1511209&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.gogo/bnd.bnd (original)
+++ ace/trunk/org.apache.ace.gogo/bnd.bnd Wed Aug 7 08:08:17 2013
@@ -3,13 +3,15 @@
biz.aQute.bnd;version=2.1.0,\
org.osgi.impl.bundle.repoindex.lib,\
org.apache.felix.dependencymanager,\
- org.apache.felix.gogo.runtime
+ org.apache.felix.gogo.runtime,\
+ org.apache.ace.bnd.repository;version=latest
Bundle-Name: Apache ACE OBR Gogo commands
Bundle-Description: Provides Gogo commands for working with repositories
Bundle-Version: 1.0.0
Bundle-Activator: org.apache.ace.gogo.Activator
-Private-Package: org.apache.ace.gogo,\
+Private-Package: org.apache.ace.bnd.repository,\
+ org.apache.ace.gogo,\
org.apache.ace.gogo.math,\
org.apache.ace.gogo.misc,\
org.apache.ace.gogo.repo,\
Modified:
ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/CommandRepo.java
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/CommandRepo.java?rev=1511209&r1=1511208&r2=1511209&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/CommandRepo.java
(original)
+++ ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/CommandRepo.java
Wed Aug 7 08:08:17 2013
@@ -23,6 +23,7 @@ import static org.apache.ace.gogo.repo.R
import java.util.List;
+import org.apache.ace.bnd.repository.AceObrRepository;
import org.osgi.resource.Requirement;
import org.osgi.resource.Resource;
Modified:
ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/ContinuousDeployer.java
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/ContinuousDeployer.java?rev=1511209&r1=1511208&r2=1511209&view=diff
==============================================================================
---
ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/ContinuousDeployer.java
(original)
+++
ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/ContinuousDeployer.java
Wed Aug 7 08:08:17 2013
@@ -22,6 +22,7 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
+import org.apache.ace.bnd.repository.AceObrRepository;
import org.osgi.framework.Version;
import org.osgi.resource.Resource;
Modified:
ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepoCommands.java
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepoCommands.java?rev=1511209&r1=1511208&r2=1511209&view=diff
==============================================================================
---
ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepoCommands.java
(original)
+++
ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepoCommands.java
Wed Aug 7 08:08:17 2013
@@ -18,7 +18,6 @@
*/
package org.apache.ace.gogo.repo;
-import static org.apache.ace.gogo.repo.RepositoryUtil.copyResources;
import static org.apache.ace.gogo.repo.RepositoryUtil.copyResource;
import static org.apache.ace.gogo.repo.RepositoryUtil.createRepository;
import static org.apache.ace.gogo.repo.RepositoryUtil.deleteResource;
Modified:
ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepositoryUtil.java
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepositoryUtil.java?rev=1511209&r1=1511208&r2=1511209&view=diff
==============================================================================
---
ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepositoryUtil.java
(original)
+++
ace/trunk/org.apache.ace.gogo/src/org/apache/ace/gogo/repo/RepositoryUtil.java
Wed Aug 7 08:08:17 2013
@@ -38,6 +38,7 @@ import java.util.Map;
import java.util.Set;
import java.util.Stack;
+import org.apache.ace.bnd.repository.AceObrRepository;
import org.osgi.framework.Version;
import org.osgi.resource.Capability;
import org.osgi.resource.Requirement;