You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ace.apache.org by br...@apache.org on 2013/07/15 17:22:37 UTC
svn commit: r1503293 - in /ace/sandbox/bramk: cnf/localrepo/
cnf/localrepo/biz.aQute.bnd/ org.apache.ace.cli/
org.apache.ace.cli/src/org/apache/ace/cli/
org.apache.ace.cli/src/org/apache/ace/cli/command/
org.apache.ace.cli/src/org/apache/ace/cli/deploy...
Author: bramk
Date: Mon Jul 15 15:22:36 2013
New Revision: 1503293
URL: http://svn.apache.org/r1503293
Log:
[sandbox] Added gogo repo/math commands
Added:
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/Activator.java
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/CommandRepo.java
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/CommandResource.java
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/MathCommands.java
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/RepoCommands.java
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/repository/RepositoryUtil.java
Modified:
ace/sandbox/bramk/cnf/localrepo/biz.aQute.bnd/biz.aQute.bnd-2.1.0.jar
ace/sandbox/bramk/cnf/localrepo/index.xml
ace/sandbox/bramk/org.apache.ace.cli/bnd.bnd
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/AbstractCommand.java
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/CopyResources.java
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/CreateArtifacts.java
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/DeleteResources.java
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/DeployResources.java
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/ListResources.java
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/ContinuousDeployer.java
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/DeployerUtil.java
ace/sandbox/bramk/org.apache.ace.cli/test/org/apache/ace/cli/deployment/ContinuousDeployerTest.java
Modified: ace/sandbox/bramk/cnf/localrepo/biz.aQute.bnd/biz.aQute.bnd-2.1.0.jar
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/cnf/localrepo/biz.aQute.bnd/biz.aQute.bnd-2.1.0.jar?rev=1503293&r1=1503292&r2=1503293&view=diff
==============================================================================
Binary files - no diff available.
Modified: ace/sandbox/bramk/cnf/localrepo/index.xml
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/cnf/localrepo/index.xml?rev=1503293&r1=1503292&r2=1503293&view=diff
==============================================================================
--- ace/sandbox/bramk/cnf/localrepo/index.xml (original)
+++ ace/sandbox/bramk/cnf/localrepo/index.xml Mon Jul 15 15:22:36 2013
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
-<repository increment='1372749843145' name='Local' xmlns='http://www.osgi.org/xmlns/repository/v1.0.0'>
+<repository increment='1373532164797' name='Local' xmlns='http://www.osgi.org/xmlns/repository/v1.0.0'>
<resource>
<capability namespace='osgi.identity'>
<attribute name='osgi.identity' value='org.apache.felix.framework'/>
@@ -110,30 +110,31 @@
</resource>
<resource>
<capability namespace='osgi.identity'>
- <attribute name='osgi.identity' value='org.apache.ace.log.target'/>
+ <attribute name='osgi.identity' value='org.apache.ace.log.target.store.impl'/>
<attribute name='type' value='osgi.bundle'/>
<attribute name='version' type='Version' value='1.0.0'/>
</capability>
<capability namespace='osgi.content'>
- <attribute name='osgi.content' value='7c6fc394425a18a86b5a82fc6518903cbe3dbd9fb8b3f237e2fe32087f65e598'/>
- <attribute name='url' value='org.apache.ace.log.target/org.apache.ace.log.target-1.0.0.jar'/>
- <attribute name='size' type='Long' value='19895'/>
+ <attribute name='osgi.content' value='969d98e71f9db19e714c9b273249fa96ca3dce48589766a4a7160fad64a0d917'/>
+ <attribute name='url' value='org.apache.ace.log.target.store.impl/org.apache.ace.log.target.store.impl-1.0.0.jar'/>
+ <attribute name='size' type='Long' value='19194'/>
<attribute name='mime' value='application/vnd.osgi.bundle'/>
</capability>
<capability namespace='osgi.wiring.bundle'>
- <attribute name='osgi.wiring.bundle' value='org.apache.ace.log.target'/>
+ <attribute name='osgi.wiring.bundle' value='org.apache.ace.log.target.store.impl'/>
<attribute name='bundle-version' type='Version' value='1.0.0'/>
</capability>
<capability namespace='osgi.wiring.host'>
- <attribute name='osgi.wiring.host' value='org.apache.ace.log.target'/>
+ <attribute name='osgi.wiring.host' value='org.apache.ace.log.target.store.impl'/>
<attribute name='bundle-version' type='Version' value='1.0.0'/>
</capability>
- <requirement namespace='osgi.wiring.package'>
- <directive name='filter' value='(&(osgi.wiring.package=org.apache.ace.connectionfactory)(version>=1.0.0)(!(version>=2.0.0)))'/>
- </requirement>
- <requirement namespace='osgi.wiring.package'>
- <directive name='filter' value='(&(osgi.wiring.package=org.apache.ace.discovery)(version>=1.0.0)(!(version>=2.0.0)))'/>
- </requirement>
+ <capability namespace='osgi.wiring.package'>
+ <attribute name='osgi.wiring.package' value='org.apache.ace.log.target.store'/>
+ <attribute name='version' type='Version' value='1.0.0'/>
+ <attribute name='bundle-symbolic-name' value='org.apache.ace.log.target.store.impl'/>
+ <attribute name='bundle-version' type='Version' value='1.0.0'/>
+ <directive name='uses' value='org.apache.ace.log'/>
+ </capability>
<requirement namespace='osgi.wiring.package'>
<directive name='filter' value='(&(osgi.wiring.package=org.apache.ace.identification)(version>=1.0.0)(!(version>=2.0.0)))'/>
</requirement>
@@ -144,9 +145,6 @@
<directive name='filter' value='(&(osgi.wiring.package=org.apache.ace.log.target.store)(version>=1.0.0)(!(version>=2.0.0)))'/>
</requirement>
<requirement namespace='osgi.wiring.package'>
- <directive name='filter' value='(&(osgi.wiring.package=org.apache.ace.range)(version>=1.0.0)(!(version>=2.0.0)))'/>
- </requirement>
- <requirement namespace='osgi.wiring.package'>
<directive name='filter' value='(&(osgi.wiring.package=org.apache.felix.dm)(version>=3.0.0)(!(version>=4.0.0)))'/>
</requirement>
<requirement namespace='osgi.wiring.package'>
@@ -161,32 +159,31 @@
</resource>
<resource>
<capability namespace='osgi.identity'>
- <attribute name='osgi.identity' value='org.apache.ace.log.target.store.impl'/>
+ <attribute name='osgi.identity' value='org.apache.ace.log.target'/>
<attribute name='type' value='osgi.bundle'/>
<attribute name='version' type='Version' value='1.0.0'/>
</capability>
<capability namespace='osgi.content'>
- <attribute name='osgi.content' value='969d98e71f9db19e714c9b273249fa96ca3dce48589766a4a7160fad64a0d917'/>
- <attribute name='url' value='org.apache.ace.log.target.store.impl/org.apache.ace.log.target.store.impl-1.0.0.jar'/>
- <attribute name='size' type='Long' value='19194'/>
+ <attribute name='osgi.content' value='7c6fc394425a18a86b5a82fc6518903cbe3dbd9fb8b3f237e2fe32087f65e598'/>
+ <attribute name='url' value='org.apache.ace.log.target/org.apache.ace.log.target-1.0.0.jar'/>
+ <attribute name='size' type='Long' value='19895'/>
<attribute name='mime' value='application/vnd.osgi.bundle'/>
</capability>
<capability namespace='osgi.wiring.bundle'>
- <attribute name='osgi.wiring.bundle' value='org.apache.ace.log.target.store.impl'/>
+ <attribute name='osgi.wiring.bundle' value='org.apache.ace.log.target'/>
<attribute name='bundle-version' type='Version' value='1.0.0'/>
</capability>
<capability namespace='osgi.wiring.host'>
- <attribute name='osgi.wiring.host' value='org.apache.ace.log.target.store.impl'/>
- <attribute name='bundle-version' type='Version' value='1.0.0'/>
- </capability>
- <capability namespace='osgi.wiring.package'>
- <attribute name='osgi.wiring.package' value='org.apache.ace.log.target.store'/>
- <attribute name='version' type='Version' value='1.0.0'/>
- <attribute name='bundle-symbolic-name' value='org.apache.ace.log.target.store.impl'/>
+ <attribute name='osgi.wiring.host' value='org.apache.ace.log.target'/>
<attribute name='bundle-version' type='Version' value='1.0.0'/>
- <directive name='uses' value='org.apache.ace.log'/>
</capability>
<requirement namespace='osgi.wiring.package'>
+ <directive name='filter' value='(&(osgi.wiring.package=org.apache.ace.connectionfactory)(version>=1.0.0)(!(version>=2.0.0)))'/>
+ </requirement>
+ <requirement namespace='osgi.wiring.package'>
+ <directive name='filter' value='(&(osgi.wiring.package=org.apache.ace.discovery)(version>=1.0.0)(!(version>=2.0.0)))'/>
+ </requirement>
+ <requirement namespace='osgi.wiring.package'>
<directive name='filter' value='(&(osgi.wiring.package=org.apache.ace.identification)(version>=1.0.0)(!(version>=2.0.0)))'/>
</requirement>
<requirement namespace='osgi.wiring.package'>
@@ -196,6 +193,9 @@
<directive name='filter' value='(&(osgi.wiring.package=org.apache.ace.log.target.store)(version>=1.0.0)(!(version>=2.0.0)))'/>
</requirement>
<requirement namespace='osgi.wiring.package'>
+ <directive name='filter' value='(&(osgi.wiring.package=org.apache.ace.range)(version>=1.0.0)(!(version>=2.0.0)))'/>
+ </requirement>
+ <requirement namespace='osgi.wiring.package'>
<directive name='filter' value='(&(osgi.wiring.package=org.apache.felix.dm)(version>=3.0.0)(!(version>=4.0.0)))'/>
</requirement>
<requirement namespace='osgi.wiring.package'>
@@ -1088,121 +1088,121 @@
<capability namespace='osgi.identity'>
<attribute name='osgi.identity' value='biz.aQute.bnd'/>
<attribute name='type' value='osgi.bundle'/>
- <attribute name='version' type='Version' value='2.1.0.20130510-094525'/>
+ <attribute name='version' type='Version' value='2.1.0.20130613-062523'/>
</capability>
<capability namespace='osgi.content'>
- <attribute name='osgi.content' value='87c67cdd31433b5936b74ce4c19b09c2ba5981229e0cc372eb562cee088e9be3'/>
+ <attribute name='osgi.content' value='c73e781a1fcdd5e841d35c5eb7e3552205702e30edf1044d513d987c46c27abf'/>
<attribute name='url' value='biz.aQute.bnd/biz.aQute.bnd-2.1.0.jar'/>
- <attribute name='size' type='Long' value='1860283'/>
+ <attribute name='size' type='Long' value='1856112'/>
<attribute name='mime' value='application/vnd.osgi.bundle'/>
</capability>
<capability namespace='osgi.wiring.bundle'>
<attribute name='osgi.wiring.bundle' value='biz.aQute.bnd'/>
- <attribute name='bundle-version' type='Version' value='2.1.0.20130510-094525'/>
+ <attribute name='bundle-version' type='Version' value='2.1.0.20130613-062523'/>
</capability>
<capability namespace='osgi.wiring.host'>
<attribute name='osgi.wiring.host' value='biz.aQute.bnd'/>
- <attribute name='bundle-version' type='Version' value='2.1.0.20130510-094525'/>
+ <attribute name='bundle-version' type='Version' value='2.1.0.20130613-062523'/>
</capability>
<capability namespace='osgi.wiring.package'>
<attribute name='osgi.wiring.package' value='aQute.bnd.service'/>
<attribute name='version' type='Version' value='3.0.0'/>
<attribute name='bundle-symbolic-name' value='biz.aQute.bnd'/>
- <attribute name='bundle-version' type='Version' value='2.1.0.20130510-094525'/>
- <directive name='uses' value='aQute.bnd.build,aQute.bnd.version,aQute.service.reporter,aQute.bnd.osgi'/>
+ <attribute name='bundle-version' type='Version' value='2.1.0.20130613-062523'/>
+ <directive name='uses' value='aQute.bnd.osgi,aQute.bnd.build,aQute.bnd.version,aQute.service.reporter'/>
</capability>
<capability namespace='osgi.wiring.package'>
<attribute name='osgi.wiring.package' value='aQute.bnd.service.action'/>
<attribute name='version' type='Version' value='1.43.1'/>
<attribute name='bundle-symbolic-name' value='biz.aQute.bnd'/>
- <attribute name='bundle-version' type='Version' value='2.1.0.20130510-094525'/>
+ <attribute name='bundle-version' type='Version' value='2.1.0.20130613-062523'/>
<directive name='uses' value='aQute.bnd.build'/>
</capability>
<capability namespace='osgi.wiring.package'>
<attribute name='osgi.wiring.package' value='aQute.bnd.service.diff'/>
<attribute name='version' type='Version' value='1.0.0'/>
<attribute name='bundle-symbolic-name' value='biz.aQute.bnd'/>
- <attribute name='bundle-version' type='Version' value='2.1.0.20130510-094525'/>
+ <attribute name='bundle-version' type='Version' value='2.1.0.20130613-062523'/>
<directive name='uses' value='aQute.bnd.osgi'/>
</capability>
<capability namespace='osgi.wiring.package'>
<attribute name='osgi.wiring.package' value='aQute.bnd.service.repository'/>
<attribute name='version' type='Version' value='1.0.0'/>
<attribute name='bundle-symbolic-name' value='biz.aQute.bnd'/>
- <attribute name='bundle-version' type='Version' value='2.1.0.20130510-094525'/>
+ <attribute name='bundle-version' type='Version' value='2.1.0.20130613-062523'/>
<directive name='uses' value='aQute.bnd.version,aQute.service.reporter'/>
</capability>
<capability namespace='osgi.wiring.package'>
<attribute name='osgi.wiring.package' value='aQute.bnd.service.url'/>
<attribute name='version' type='Version' value='1.1.0'/>
<attribute name='bundle-symbolic-name' value='biz.aQute.bnd'/>
- <attribute name='bundle-version' type='Version' value='2.1.0.20130510-094525'/>
+ <attribute name='bundle-version' type='Version' value='2.1.0.20130613-062523'/>
</capability>
<capability namespace='osgi.wiring.package'>
<attribute name='osgi.wiring.package' value='aQute.bnd.header'/>
<attribute name='version' type='Version' value='1.1.0'/>
<attribute name='bundle-symbolic-name' value='biz.aQute.bnd'/>
- <attribute name='bundle-version' type='Version' value='2.1.0.20130510-094525'/>
+ <attribute name='bundle-version' type='Version' value='2.1.0.20130613-062523'/>
<directive name='uses' value='aQute.service.reporter'/>
</capability>
<capability namespace='osgi.wiring.package'>
<attribute name='osgi.wiring.package' value='aQute.bnd.osgi'/>
<attribute name='version' type='Version' value='2.1.0'/>
<attribute name='bundle-symbolic-name' value='biz.aQute.bnd'/>
- <attribute name='bundle-version' type='Version' value='2.1.0.20130510-094525'/>
- <directive name='uses' value='aQute.bnd.service,aQute.bnd.header,aQute.bnd.version,aQute.service.reporter'/>
+ <attribute name='bundle-version' type='Version' value='2.1.0.20130613-062523'/>
+ <directive name='uses' value='aQute.bnd.header,aQute.bnd.service,aQute.bnd.version,aQute.service.reporter'/>
</capability>
<capability namespace='osgi.wiring.package'>
<attribute name='osgi.wiring.package' value='aQute.bnd.build'/>
<attribute name='version' type='Version' value='2.1.0'/>
<attribute name='bundle-symbolic-name' value='biz.aQute.bnd'/>
- <attribute name='bundle-version' type='Version' value='2.1.0.20130510-094525'/>
- <directive name='uses' value='aQute.bnd.service,aQute.bnd.service.action,aQute.bnd.version,aQute.bnd.maven.support,aQute.service.reporter,aQute.bnd.osgi'/>
+ <attribute name='bundle-version' type='Version' value='2.1.0.20130613-062523'/>
+ <directive name='uses' value='aQute.bnd.maven.support,aQute.bnd.osgi,aQute.bnd.service,aQute.bnd.service.action,aQute.bnd.version,aQute.service.reporter'/>
</capability>
<capability namespace='osgi.wiring.package'>
<attribute name='osgi.wiring.package' value='aQute.bnd.version'/>
<attribute name='version' type='Version' value='1.0.0'/>
<attribute name='bundle-symbolic-name' value='biz.aQute.bnd'/>
- <attribute name='bundle-version' type='Version' value='2.1.0.20130510-094525'/>
+ <attribute name='bundle-version' type='Version' value='2.1.0.20130613-062523'/>
</capability>
<capability namespace='osgi.wiring.package'>
<attribute name='osgi.wiring.package' value='aQute.bnd.maven.support'/>
<attribute name='version' type='Version' value='2.0.0'/>
<attribute name='bundle-symbolic-name' value='biz.aQute.bnd'/>
- <attribute name='bundle-version' type='Version' value='2.1.0.20130510-094525'/>
- <directive name='uses' value='aQute.bnd.service,aQute.bnd.version,javax.xml.xpath,org.w3c.dom,aQute.service.reporter'/>
+ <attribute name='bundle-version' type='Version' value='2.1.0.20130613-062523'/>
+ <directive name='uses' value='javax.xml.xpath,org.w3c.dom,aQute.bnd.service,aQute.bnd.version,aQute.service.reporter'/>
</capability>
<capability namespace='osgi.wiring.package'>
<attribute name='osgi.wiring.package' value='org.osgi.service.bindex'/>
<attribute name='version' type='Version' value='1.0.0'/>
<attribute name='bundle-symbolic-name' value='biz.aQute.bnd'/>
- <attribute name='bundle-version' type='Version' value='2.1.0.20130510-094525'/>
+ <attribute name='bundle-version' type='Version' value='2.1.0.20130613-062523'/>
</capability>
<capability namespace='osgi.wiring.package'>
<attribute name='osgi.wiring.package' value='aQute.service.reporter'/>
<attribute name='version' type='Version' value='1.0.0'/>
<attribute name='bundle-symbolic-name' value='biz.aQute.bnd'/>
- <attribute name='bundle-version' type='Version' value='2.1.0.20130510-094525'/>
+ <attribute name='bundle-version' type='Version' value='2.1.0.20130613-062523'/>
</capability>
<capability namespace='osgi.wiring.package'>
<attribute name='osgi.wiring.package' value='aQute.bnd.osgi.resource'/>
<attribute name='version' type='Version' value='1.1.0'/>
<attribute name='bundle-symbolic-name' value='biz.aQute.bnd'/>
- <attribute name='bundle-version' type='Version' value='2.1.0.20130510-094525'/>
+ <attribute name='bundle-version' type='Version' value='2.1.0.20130613-062523'/>
<directive name='uses' value='org.osgi.resource'/>
</capability>
<capability namespace='osgi.wiring.package'>
<attribute name='osgi.wiring.package' value='org.osgi.service.repository'/>
<attribute name='version' type='Version' value='1.0.0'/>
<attribute name='bundle-symbolic-name' value='biz.aQute.bnd'/>
- <attribute name='bundle-version' type='Version' value='2.1.0.20130510-094525'/>
+ <attribute name='bundle-version' type='Version' value='2.1.0.20130613-062523'/>
<directive name='uses' value='org.osgi.resource'/>
</capability>
<capability namespace='osgi.wiring.package'>
<attribute name='osgi.wiring.package' value='org.osgi.resource'/>
<attribute name='version' type='Version' value='1.0.0'/>
<attribute name='bundle-symbolic-name' value='biz.aQute.bnd'/>
- <attribute name='bundle-version' type='Version' value='2.1.0.20130510-094525'/>
+ <attribute name='bundle-version' type='Version' value='2.1.0.20130613-062523'/>
</capability>
<requirement namespace='osgi.wiring.package'>
<directive name='filter' value='(osgi.wiring.package=org.apache.tools.ant)'/>
Modified: ace/sandbox/bramk/org.apache.ace.cli/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/bnd.bnd?rev=1503293&r1=1503292&r2=1503293&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/bnd.bnd (original)
+++ ace/sandbox/bramk/org.apache.ace.cli/bnd.bnd Mon Jul 15 15:22:36 2013
@@ -4,12 +4,62 @@
org.amdatu.ace.client,\
org.apache.commons.cli,\
org.osgi.impl.bundle.repoindex.lib,\
- junit.osgi
+ junit.osgi,\
+ org.apache.felix.dependencymanager,\
+ org.apache.felix.gogo.runtime
-removeheaders: Bnd-LastModified
-Private-Package: \
- org.apache.commons.cli,\
+Private-Package: org.apache.commons.cli,\
+ org.apache.ace.cli.gogo,\
+ aQute.lib.json,\
+ aQute.libg.filelock,\
+ aQute.bnd.annotation.component,\
+ aQute.bnd.help,\
+ aQute.bnd.maven.support,\
+ aQute.bnd.osgi.eclipse,\
+ aQute.bnd.service.action,\
+ aQute.lib.deployer,\
+ aQute.lib.settings,\
+ aQute.lib.tag,\
+ aQute.libg.sed,\
+ aQute.libg.tuple,\
+ aQute.bnd.annotation,\
+ aQute.bnd.annotation.metatype,\
+ aQute.bnd.build,\
+ aQute.bnd.component,\
+ aQute.bnd.deployer.http,\
+ aQute.bnd.deployer.repository.api,\
+ aQute.bnd.deployer.repository.providers,\
+ aQute.bnd.filerepo,\
+ aQute.bnd.header,\
+ aQute.bnd.make,\
+ aQute.bnd.make.component,\
+ aQute.bnd.make.metatype,\
+ aQute.bnd.maven,\
+ aQute.bnd.service.url,\
+ aQute.bnd.version,\
+ aQute.lib.base64,\
+ aQute.lib.collections,\
+ aQute.lib.converter,\
+ aQute.lib.filter,\
+ aQute.lib.hex,\
+ aQute.lib.io,\
+ aQute.libg.command,\
+ aQute.libg.cryptography,\
+ aQute.libg.filters,\
+ aQute.libg.generics,\
+ aQute.libg.glob,\
+ aQute.libg.gzip,\
+ aQute.libg.qtokens,\
+ aQute.libg.reporter,\
+ aQute.service.reporter,\
+ aQute.bnd.deployer.repository,\
+ aQute.bnd.differ,\
+ aQute.bnd.osgi,\
+ aQute.bnd.osgi.resource,\
+ aQute.bnd.service,\
+ aQute.bnd.service.diff,\
org.apache.ace.cli,\
org.apache.ace.cli.command,\
org.apache.ace.cli.repository,\
@@ -17,11 +67,11 @@ Private-Package: \
org.amdatu.ace.client,\
org.amdatu.ace.client.model,\
com.google.gson.*,\
- aQute.*;-split-package:=first,\
org.osgi.service.indexer.*;-split-package:=merge-last,\
org.osgi.*;-split-package:=first,\
org.xmlpull.v1;-split-package:=first,\
org.kxml2.io;-split-package:=first
Main-Class: org.apache.ace.cli.Main
-Bundle-Version: 1.0.0
\ No newline at end of file
+Bundle-Version: 1.0.0
+Bundle-Activator: org.apache.ace.cli.Activator
\ No newline at end of file
Added: ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/Activator.java
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/Activator.java?rev=1503293&view=auto
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/Activator.java (added)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/Activator.java Mon Jul 15 15:22:36 2013
@@ -0,0 +1,37 @@
+package org.apache.ace.cli;
+
+import java.util.Properties;
+
+import org.apache.ace.cli.gogo.MathCommands;
+import org.apache.ace.cli.gogo.RepoCommands;
+import org.apache.felix.dm.DependencyActivatorBase;
+import org.apache.felix.dm.DependencyManager;
+import org.apache.felix.service.command.CommandProcessor;
+import org.osgi.framework.BundleContext;
+
+public class Activator extends DependencyActivatorBase {
+
+ @Override
+ public void init(BundleContext context, DependencyManager manager) throws Exception {
+
+ Properties repoProps = new Properties();
+ repoProps.put(CommandProcessor.COMMAND_SCOPE, RepoCommands.SCOPE);
+ repoProps.put(CommandProcessor.COMMAND_FUNCTION, RepoCommands.FUNCTIONS);
+ manager.add(createComponent()
+ .setInterface(Object.class.getName(), repoProps)
+ .setImplementation(RepoCommands.class)
+ );
+
+ Properties mathProps = new Properties();
+ mathProps.put(CommandProcessor.COMMAND_SCOPE, MathCommands.SCOPE);
+ mathProps.put(CommandProcessor.COMMAND_FUNCTION, MathCommands.FUNCTIONS);
+ manager.add(createComponent()
+ .setInterface(Object.class.getName(), mathProps)
+ .setImplementation(MathCommands.class)
+ );
+ }
+
+ @Override
+ public void destroy(BundleContext arg0, DependencyManager arg1) throws Exception {
+ }
+}
Modified: ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/AbstractCommand.java
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/AbstractCommand.java?rev=1503293&r1=1503292&r2=1503293&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/AbstractCommand.java (original)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/AbstractCommand.java Mon Jul 15 15:22:36 2013
@@ -18,19 +18,9 @@
*/
package org.apache.ace.cli.command;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
import java.util.Map;
-import org.osgi.framework.Version;
-import org.osgi.resource.Capability;
import org.osgi.resource.Requirement;
-import org.osgi.resource.Resource;
-import org.osgi.service.repository.Repository;
import aQute.bnd.deployer.repository.FixedIndexedRepo;
import aQute.bnd.osgi.resource.CapReqBuilder;
@@ -80,69 +70,6 @@ public abstract class AbstractCommand {
return m_repositories.get("release");
}
- protected List<Resource> findResources(Repository repository, String bsn, String version, String type) {
- Requirement requirement = new CapReqBuilder("osgi.identity")
- .addDirective("filter", String.format("(&(osgi.identity=%s)(version=%s)(type=*))", bsn, version, type))
- .buildSyntheticRequirement();
- return findResources(repository, requirement);
- }
-
- protected List<Resource> findResources(Repository repository, Requirement requirement) {
- Map<Requirement, Collection<Capability>> sourceResources = repository.findProviders(Collections.singleton(requirement));
- if (sourceResources.isEmpty() || sourceResources.get(requirement).isEmpty()) {
- return Collections.emptyList();
- }
- List<Resource> resources = new ArrayList<Resource>();
- Iterator<Capability> capabilities = sourceResources.get(requirement).iterator();
- while (capabilities.hasNext()) {
- Capability capability = capabilities.next();
- resources.add(capability.getResource());
- }
- return resources;
- }
-
- protected String getIdentity(Resource resource) {
- Map<String, Object> attrs = getNamespaceAttributes(resource, "osgi.identity");
- if (attrs == null)
- return null;
- return (String) attrs.get("osgi.identity");
-
- }
-
- protected String getVersion(Resource resource) {
- Map<String, Object> attrs = getNamespaceAttributes(resource, "osgi.identity");
- if (attrs == null)
- return null;
- Version version = (Version) attrs.get("version");
- return version == null ? null : version.toString();
- }
-
- protected String getType(Resource resource) {
- Map<String, Object> attrs = getNamespaceAttributes(resource, "osgi.identity");
- if (attrs == null)
- return null;
- return (String) attrs.get("type");
- }
-
- protected String getUrl(Resource resource) {
- Map<String, Object> attrs = getNamespaceAttributes(resource, "osgi.content");
- if (attrs == null)
- return null;
- URI url = (URI) attrs.get("url");
- return url == null ? null : url.toString();
- }
-
- protected String getMimetype(Resource resource) {
- Map<String, Object> attrs = getNamespaceAttributes(resource, "osgi.content");
- if (attrs == null)
- return null;
- return (String) attrs.get("mime");
- }
-
- protected String toString(Resource resource) {
- return getIdentity(resource) + "/" + getVersion(resource);
- }
-
protected String getFilterNamespace() {
String namespace = "osgi.identity";
String argument = getConfiguration().get("filter");
@@ -185,14 +112,4 @@ public abstract class AbstractCommand {
.buildSyntheticRequirement();
return requirement;
}
-
- private Map<String, Object> getNamespaceAttributes(Resource resource, String namespace) {
- List<Capability> caps = resource.getCapabilities(namespace);
- if (caps.isEmpty())
- return null;
- Map<String, Object> attrs = caps.get(0).getAttributes();
- if (attrs == null)
- return null;
- return attrs;
- }
}
Modified: ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/CopyResources.java
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/CopyResources.java?rev=1503293&r1=1503292&r2=1503293&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/CopyResources.java (original)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/CopyResources.java Mon Jul 15 15:22:36 2013
@@ -18,6 +18,12 @@
*/
package org.apache.ace.cli.command;
+import static org.apache.ace.cli.repository.RepositoryUtil.findResources;
+import static org.apache.ace.cli.repository.RepositoryUtil.getIdentity;
+import static org.apache.ace.cli.repository.RepositoryUtil.getMimetype;
+import static org.apache.ace.cli.repository.RepositoryUtil.getUrl;
+import static org.apache.ace.cli.repository.RepositoryUtil.getVersion;
+
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URI;
@@ -66,11 +72,11 @@ public class CopyResources extends Abstr
printVerbose("Copying " + sourceResources.size() + " resources. Directive: " + getFilterNamespace() + ":" + getFilter());
for (Resource sourceResource : sourceResources) {
- Requirement targetRequirement = getIdentityRequirement(getIdentity(sourceResource), getVersion(sourceResource));
+ Requirement targetRequirement = getIdentityRequirement(getIdentity(sourceResource), getVersion(sourceResource).toString());
List<Resource> targetResources = findResources(targetRepo, targetRequirement);
if (!targetResources.isEmpty()) {
String location = getUrl(targetResources.get(0));
- System.out.println("Skipped " + toString(sourceResource) + " => " + location);
+ System.out.println("Skipped " + sourceResource + " => " + location);
skipCount++;
}
else {
@@ -78,7 +84,7 @@ public class CopyResources extends Abstr
ResourceHandle handle = null;
InputStream input = null;
try {
- handle = sourceRepo.getHandle(getIdentity(sourceResource), getVersion(sourceResource), Strategy.EXACT, null);
+ handle = sourceRepo.getHandle(getIdentity(sourceResource), getVersion(sourceResource).toString(), Strategy.EXACT, null);
input = new FileInputStream(handle.request());
// AceObrRepository can accept other types then bundle, but in those cases
@@ -90,12 +96,12 @@ public class CopyResources extends Abstr
}
AceObrRepository aceTargetRepo = (AceObrRepository) targetRepo;
URI location = aceTargetRepo.upload(input, fileName, getMimetype(sourceResource));
- System.out.println("Copied " + toString(sourceResource) + " => " + location.toString());
+ System.out.println("Copied " + sourceResource + " => " + location.toString());
}
else {
PutResult result = targetRepo.put(input, new PutOptions());
- System.out.println("Copied " + toString(sourceResource) + " => " + result.artifact.toString());
+ System.out.println("Copied " + sourceResource + " => " + result.artifact.toString());
}
copyCount++;
}
Modified: ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/CreateArtifacts.java
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/CreateArtifacts.java?rev=1503293&r1=1503292&r2=1503293&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/CreateArtifacts.java (original)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/CreateArtifacts.java Mon Jul 15 15:22:36 2013
@@ -18,6 +18,12 @@
*/
package org.apache.ace.cli.command;
+import static org.apache.ace.cli.repository.RepositoryUtil.findResources;
+import static org.apache.ace.cli.repository.RepositoryUtil.getIdentity;
+import static org.apache.ace.cli.repository.RepositoryUtil.getMimetype;
+import static org.apache.ace.cli.repository.RepositoryUtil.getUrl;
+import static org.apache.ace.cli.repository.RepositoryUtil.getVersion;
+
import java.util.List;
import org.amdatu.ace.client.AceClientWorkspace;
@@ -64,7 +70,7 @@ public class CreateArtifacts extends Abs
for (Resource resource : resources) {
String identity = getIdentity(resource);
- String version = getVersion(resource);
+ String version = getVersion(resource).toString();
String url = getUrl(resource);
String mimetype = getMimetype(resource);
if (mimetype == null) {
@@ -73,11 +79,11 @@ public class CreateArtifacts extends Abs
}
if (findArtifact(artifacts, identity, version) != null) {
- System.out.println("Exists " + toString(resource) + " => skipping");
+ System.out.println("Exists " + resource + " => skipping");
skipCount++;
}
else {
- System.out.println("Created " + toString(resource));
+ System.out.println("Created " + resource);
workspace.createResource(
new ArtifactBuilder()
.setName(identity + version)
Modified: ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/DeleteResources.java
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/DeleteResources.java?rev=1503293&r1=1503292&r2=1503293&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/DeleteResources.java (original)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/DeleteResources.java Mon Jul 15 15:22:36 2013
@@ -18,6 +18,12 @@
*/
package org.apache.ace.cli.command;
+import static org.apache.ace.cli.repository.RepositoryUtil.findResources;
+import static org.apache.ace.cli.repository.RepositoryUtil.getIdentity;
+import static org.apache.ace.cli.repository.RepositoryUtil.getType;
+import static org.apache.ace.cli.repository.RepositoryUtil.getUrl;
+import static org.apache.ace.cli.repository.RepositoryUtil.getVersion;
+
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
Modified: ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/DeployResources.java
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/DeployResources.java?rev=1503293&r1=1503292&r2=1503293&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/DeployResources.java (original)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/DeployResources.java Mon Jul 15 15:22:36 2013
@@ -18,6 +18,12 @@
*/
package org.apache.ace.cli.command;
+import static org.apache.ace.cli.repository.RepositoryUtil.findResources;
+import static org.apache.ace.cli.repository.RepositoryUtil.getIdentity;
+import static org.apache.ace.cli.repository.RepositoryUtil.getMimetype;
+import static org.apache.ace.cli.repository.RepositoryUtil.getUrl;
+import static org.apache.ace.cli.repository.RepositoryUtil.getVersion;
+
import java.util.List;
import org.amdatu.ace.client.AceClientWorkspace;
@@ -32,7 +38,6 @@ import org.amdatu.ace.client.model.Featu
import org.amdatu.ace.client.model.Feature2DistributionBuilder;
import org.amdatu.ace.client.model.FeatureBuilder;
import org.apache.ace.cli.deployment.ContinuousDeployer;
-import org.apache.ace.cli.deployment.DeployerUtil;
import org.apache.ace.cli.repository.AceObrRepository;
import org.osgi.framework.Version;
import org.osgi.resource.Resource;
@@ -143,7 +148,7 @@ public class DeployResources extends Abs
continue;
}
- String version = getVersion(targetResource);
+ String version = getVersion(targetResource).toString();
String mimetype = getMimetype(targetResource);
String url = getUrl(targetResource);
@@ -157,9 +162,9 @@ public class DeployResources extends Abs
}
}
+ System.out.println(url);
String name = identity + "-" + version;
if (mimetype.equals(Artifact.MIMETYPE_BUNDLE)) {
-
workspace.createResource(
new ArtifactBuilder()
.isBundle()
@@ -194,11 +199,11 @@ public class DeployResources extends Abs
}
private Resource getHighestVersion(Repository repository, String identity) throws Exception {
- List<Resource> resources = DeployerUtil.findResources(repository, identity);
+ List<Resource> resources = findResources(repository, identity);
Resource currentResource = null;
Version currentVersion = null;
for (Resource candidateResource : resources) {
- Version candidateVersion = DeployerUtil.getVersion(candidateResource);
+ Version candidateVersion = getVersion(candidateResource);
if (currentResource == null || candidateVersion.compareTo(currentVersion) > 0) {
currentResource = candidateResource;
currentVersion = candidateVersion;
Modified: ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/ListResources.java
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/ListResources.java?rev=1503293&r1=1503292&r2=1503293&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/ListResources.java (original)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/ListResources.java Mon Jul 15 15:22:36 2013
@@ -18,6 +18,11 @@
*/
package org.apache.ace.cli.command;
+import static org.apache.ace.cli.repository.RepositoryUtil.findResources;
+import static org.apache.ace.cli.repository.RepositoryUtil.getIdentity;
+import static org.apache.ace.cli.repository.RepositoryUtil.getType;
+import static org.apache.ace.cli.repository.RepositoryUtil.getVersion;
+
import java.util.List;
import org.osgi.resource.Requirement;
Modified: ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/ContinuousDeployer.java
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/ContinuousDeployer.java?rev=1503293&r1=1503292&r2=1503293&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/ContinuousDeployer.java (original)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/ContinuousDeployer.java Mon Jul 15 15:22:36 2013
@@ -1,20 +1,20 @@
package org.apache.ace.cli.deployment;
-import static org.apache.ace.cli.deployment.DeployerUtil.copyResources;
import static org.apache.ace.cli.deployment.DeployerUtil.filesDiffer;
-import static org.apache.ace.cli.deployment.DeployerUtil.findResources;
import static org.apache.ace.cli.deployment.DeployerUtil.getBundleWithNewVersion;
-import static org.apache.ace.cli.deployment.DeployerUtil.getFileName;
-import static org.apache.ace.cli.deployment.DeployerUtil.getIdentity;
-import static org.apache.ace.cli.deployment.DeployerUtil.getIdentityVersionRequirement;
-import static org.apache.ace.cli.deployment.DeployerUtil.getMimetype;
import static org.apache.ace.cli.deployment.DeployerUtil.getNextSnapshotVersion;
-import static org.apache.ace.cli.deployment.DeployerUtil.getString;
-import static org.apache.ace.cli.deployment.DeployerUtil.getType;
-import static org.apache.ace.cli.deployment.DeployerUtil.getVersion;
import static org.apache.ace.cli.deployment.DeployerUtil.isSameBaseVersion;
import static org.apache.ace.cli.deployment.DeployerUtil.isSnapshotVersion;
import static org.apache.ace.cli.deployment.DeployerUtil.jarsDiffer;
+import static org.apache.ace.cli.repository.RepositoryUtil.copyResources;
+import static org.apache.ace.cli.repository.RepositoryUtil.findResources;
+import static org.apache.ace.cli.repository.RepositoryUtil.getFileName;
+import static org.apache.ace.cli.repository.RepositoryUtil.getIdentity;
+import static org.apache.ace.cli.repository.RepositoryUtil.getIdentityVersionRequirement;
+import static org.apache.ace.cli.repository.RepositoryUtil.getMimetype;
+import static org.apache.ace.cli.repository.RepositoryUtil.getString;
+import static org.apache.ace.cli.repository.RepositoryUtil.getType;
+import static org.apache.ace.cli.repository.RepositoryUtil.getVersion;
import java.io.File;
import java.io.FileInputStream;
@@ -49,6 +49,7 @@ public class ContinuousDeployer {
public List<Resource> deployResources() throws Exception {
List<Resource> resources = findResources(m_developmentRepo, "*", "*");
for (Resource resource : resources) {
+ // FIXME this is the source resource
deployResource(resource);
}
return resources;
Modified: ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/DeployerUtil.java
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/DeployerUtil.java?rev=1503293&r1=1503292&r2=1503293&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/DeployerUtil.java (original)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/DeployerUtil.java Mon Jul 15 15:22:36 2013
@@ -1,3 +1,21 @@
+/*
+ * 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.cli.deployment;
import java.io.BufferedReader;
@@ -5,37 +23,21 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.StringReader;
-import java.net.URI;
import java.nio.ByteBuffer;
import java.security.DigestInputStream;
import java.security.MessageDigest;
-import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
-import org.apache.ace.cli.repository.AceObrRepository;
import org.osgi.framework.Version;
-import org.osgi.resource.Capability;
-import org.osgi.resource.Requirement;
-import org.osgi.resource.Resource;
-import org.osgi.service.repository.Repository;
-import aQute.bnd.deployer.repository.AbstractIndexedRepo;
import aQute.bnd.differ.DiffPluginImpl;
import aQute.bnd.osgi.Jar;
-import aQute.bnd.osgi.resource.CapReqBuilder;
-import aQute.bnd.service.Strategy;
import aQute.bnd.service.diff.Delta;
import aQute.bnd.service.diff.Diff;
import aQute.bnd.service.diff.Differ;
@@ -48,32 +50,6 @@ public final class DeployerUtil {
private static final Pattern QUALIFIER_PATTERN = Pattern.compile(QUALIFIER_PREFIX + "([\\d]{3})$|(.*)(_" + QUALIFIER_PREFIX + "([\\d]{3})?$)");
/**
- * Construct a Resource filename with a specified version in the form that ACE OBR understands.
- *
- * @param resource
- * The resource
- * @param version
- * The version
- * @return The name
- */
- public static String getFileName(Resource resource, Version version) {
- String location = getUrl(resource);
- String extension = location.substring(location.lastIndexOf(".") + 1);
- return getIdentity(resource) + "-" + version + "." + extension;
- }
-
- /**
- * Construct a Resource filename in the form that ACE OBR understands.
- *
- * @param resource
- * The resource
- * @return The name
- */
- public static String getFileName(Resource resource) {
- return getFileName(resource, getVersion(resource));
- }
-
- /**
* Given ad version, creates the 'next' snapshot version. If the version has no snapshot qualifier a new one will be
* added. If it does, it will be incremented.
*
@@ -236,139 +212,6 @@ public final class DeployerUtil {
return targetFile;
}
- public static String getString(Resource resource) {
- return getIdentity(resource) + "/" + getVersion(resource) + "/" + getType(resource) + " - " + getUrl(resource);
- }
-
- public static String getIdentity(Resource resource) {
- Map<String, Object> attrs = getNamespaceAttributes(resource, "osgi.identity");
- if (attrs == null)
- return null;
- return (String) attrs.get("osgi.identity");
-
- }
-
- public static Requirement getIdentityVersionRequirement(Resource resource) {
- Requirement requirement = new CapReqBuilder("osgi.identity")
- .addDirective("filter", String.format("(&(osgi.identity=%s)(version=%s)(type=*))", getIdentity(resource), getVersion(resource)))
- .buildSyntheticRequirement();
- return requirement;
- }
-
- public static List<Resource> copyResources(AbstractIndexedRepo fromRepo, AbstractIndexedRepo toRepo, String bsn) throws Exception {
- return copyResources(fromRepo, toRepo, bsn, "*");
- }
-
- public static List<Resource> copyResources(AbstractIndexedRepo fromRepo, AbstractIndexedRepo toRepo, String bsn, String version) throws Exception {
- return copyResources(fromRepo, toRepo, bsn, version, "*");
- }
-
- public static List<Resource> copyResources(AbstractIndexedRepo fromRepo, AbstractIndexedRepo toRepo, String bsn, String version, String type) throws Exception {
- Requirement requirement = new CapReqBuilder("osgi.identity")
- .addDirective("filter", String.format("(&(osgi.identity=%s)(version=%s)(type=%s))", bsn, version, type))
- .buildSyntheticRequirement();
- return copyResources(fromRepo, toRepo, requirement);
- }
-
- public static List<Resource> copyResources(AbstractIndexedRepo fromRepo, AbstractIndexedRepo toRepo, Requirement requirement) throws Exception {
- List<Resource> resources = findResources(fromRepo, requirement);
- for (Resource resource : resources) {
- File file = fromRepo.get(getIdentity(resource), getVersion(resource).toString(), Strategy.EXACT, null);
-
- InputStream input = null;
- try {
- input = new FileInputStream(file);
- if (toRepo instanceof AceObrRepository) {
- // ACE OBR can handle non bundle resource if we pass a filename
- AceObrRepository aceToRepo = (AceObrRepository) toRepo;
- aceToRepo.upload(input, getFileName(resource), getMimetype(resource));
- }
- else {
- toRepo.put(input, null);
- }
- }
- finally {
- if (input != null)
- input.close();
- }
- }
- return resources;
- }
-
- public static List<Resource> findResources(Repository repository, String bsn) {
- return findResources(repository, bsn, "*");
- }
-
- public static List<Resource> findResources(Repository repository, String bsn, String version) {
- return findResources(repository, bsn, version, "*");
- }
-
- public static List<Resource> findResources(Repository repository, String bsn, String version, String type) {
- Requirement requirement = new CapReqBuilder("osgi.identity")
- .addDirective("filter", String.format("(&(osgi.identity=%s)(version=%s)(type=%s))", bsn, version, type))
- .buildSyntheticRequirement();
- return findResources(repository, requirement);
- }
-
- public static List<Resource> findResources(Repository repository, Requirement requirement) {
- Map<Requirement, Collection<Capability>> sourceResources = repository.findProviders(Collections.singleton(requirement));
- if (sourceResources.isEmpty() || sourceResources.get(requirement).isEmpty()) {
- return Collections.emptyList();
- }
- List<Resource> resources = new ArrayList<Resource>();
- Iterator<Capability> capabilities = sourceResources.get(requirement).iterator();
- while (capabilities.hasNext()) {
- Capability capability = capabilities.next();
- resources.add(capability.getResource());
- }
- return resources;
- }
-
- public static Version getVersion(Resource resource) {
- Map<String, Object> attrs = getNamespaceAttributes(resource, "osgi.identity");
- if (attrs == null)
- return Version.emptyVersion;
- Version version = (Version) attrs.get("version");
- return version == null ? Version.emptyVersion : version;
- }
-
- public static List<Version> getVersions(List<Resource> resources) {
- List<Version> versions = new ArrayList<Version>();
- for (Resource resource : resources) {
- versions.add(getVersion(resource));
- }
- return versions;
- }
-
- public static String getType(Resource resource) {
- Map<String, Object> attrs = getNamespaceAttributes(resource, "osgi.identity");
- if (attrs == null)
- return null;
- return (String) attrs.get("type");
- }
-
- public static String getUrl(Resource resource) {
- Map<String, Object> attrs = getNamespaceAttributes(resource, "osgi.content");
- if (attrs == null)
- return null;
- URI url = (URI) attrs.get("url");
- return url == null ? null : url.toString();
- }
-
- public static String getMimetype(Resource resource) {
- Map<String, Object> attrs = getNamespaceAttributes(resource, "osgi.content");
- if (attrs == null)
- return null;
- return (String) attrs.get("mime");
- }
-
- public static String getSHA(Resource resource) {
- Map<String, Object> attrs = getNamespaceAttributes(resource, "osgi.content");
- if (attrs == null)
- return null;
- return (String) attrs.get("osgi.content");
- }
-
public static boolean isSameBaseVersion(Version left, Version right) {
return left.getMajor() == right.getMajor() && left.getMinor() == right.getMinor() && left.getMicro() == right.getMicro();
}
@@ -381,16 +224,6 @@ public final class DeployerUtil {
return qualifierMatcher.matches();
}
- private static Map<String, Object> getNamespaceAttributes(Resource resource, String namespace) {
- List<Capability> caps = resource.getCapabilities(namespace);
- if (caps.isEmpty())
- return null;
- Map<String, Object> attrs = caps.get(0).getAttributes();
- if (attrs == null)
- return null;
- return attrs;
- }
-
private static String getSnapshotQualifier(String prefix, int i) {
if (!isEmpty(prefix)) {
prefix = prefix + "_";
Added: ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/CommandRepo.java
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/CommandRepo.java?rev=1503293&view=auto
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/CommandRepo.java (added)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/CommandRepo.java Mon Jul 15 15:22:36 2013
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ace.cli.gogo;
+
+import static org.apache.ace.cli.repository.RepositoryUtil.findResources;
+import static org.apache.ace.cli.repository.RepositoryUtil.getRequirement;
+
+import java.util.List;
+
+import org.apache.ace.cli.repository.AceObrRepository;
+import org.osgi.resource.Requirement;
+import org.osgi.resource.Resource;
+
+import aQute.bnd.deployer.repository.FixedIndexedRepo;
+
+public class CommandRepo {
+
+ private final AceObrRepository m_repository;
+
+ public CommandRepo(AceObrRepository repository) {
+ m_repository = repository;
+ }
+
+ public FixedIndexedRepo repo() {
+ return m_repository;
+ }
+
+ public void list() throws Exception {
+ for (Resource resource : findResources(m_repository)) {
+ System.out.println(resource.toString());
+ }
+ }
+
+ public List<CommandResource> find() throws Exception {
+ return find(null);
+ }
+
+ public List<CommandResource> find(String filter) throws Exception {
+ Requirement requirement = getRequirement(filter);
+ return CommandResource.wrap(this, findResources(m_repository, requirement));
+ }
+}
Added: ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/CommandResource.java
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/CommandResource.java?rev=1503293&view=auto
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/CommandResource.java (added)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/CommandResource.java Mon Jul 15 15:22:36 2013
@@ -0,0 +1,82 @@
+/*
+ * 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.cli.gogo;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.ace.cli.repository.RepositoryUtil;
+import org.osgi.resource.Capability;
+import org.osgi.resource.Requirement;
+import org.osgi.resource.Resource;
+
+public class CommandResource {
+
+ public static List<CommandResource> wrap(CommandRepo repo, List<Resource> resources) {
+ List<CommandResource> commandResources = new LinkedList<CommandResource>();
+ for (Resource resource : resources) {
+ commandResources.add(new CommandResource(repo, resource));
+ }
+ return commandResources;
+ }
+
+ public static CommandResource wrap(CommandRepo repo, Resource resource) {
+ return new CommandResource(repo, resource);
+ }
+
+ private final CommandRepo m_repo;
+ private final Resource m_resource;
+
+ public CommandResource(CommandRepo repo, Resource resource) {
+ m_repo = repo;
+ m_resource = resource;
+ }
+
+ public CommandRepo getRepo() {
+ return m_repo;
+ }
+
+ public Resource getResource() {
+ return m_resource;
+ }
+
+ public String getIdentity() {
+ return RepositoryUtil.getIdentity(m_resource);
+ }
+
+ public String getVersion() {
+ return RepositoryUtil.getVersion(m_resource).toString();
+ }
+
+ public String getUrl() {
+ return RepositoryUtil.getUrl(m_resource);
+ }
+
+ public String getMimetype() {
+ return RepositoryUtil.getMimetype(m_resource);
+ }
+
+ public List<Capability> getCapabilities(String namespace) {
+ return m_resource.getCapabilities(namespace);
+ }
+
+ public List<Requirement> getRequirements(String namespace) {
+ return m_resource.getRequirements(namespace);
+ }
+}
Added: ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/MathCommands.java
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/MathCommands.java?rev=1503293&view=auto
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/MathCommands.java (added)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/MathCommands.java Mon Jul 15 15:22:36 2013
@@ -0,0 +1,37 @@
+/*
+ * 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.cli.gogo;
+
+public class MathCommands {
+
+ public final static String SCOPE = "math";
+ public final static String[] FUNCTIONS = new String[] { "lt", "gt", "eq" };
+
+ public static boolean gt(long f, long l) {
+ return f > l;
+ }
+
+ public static boolean lt(long f, long l) {
+ return f < l;
+ }
+
+ public static boolean eq(long f, long l) {
+ return f == l;
+ }
+}
Added: ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/RepoCommands.java
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/RepoCommands.java?rev=1503293&view=auto
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/RepoCommands.java (added)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/RepoCommands.java Mon Jul 15 15:22:36 2013
@@ -0,0 +1,123 @@
+/*
+ * 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.cli.gogo;
+
+import static org.apache.ace.cli.repository.RepositoryUtil.copyResources;
+import static org.apache.ace.cli.repository.RepositoryUtil.createRepository;
+import static org.apache.ace.cli.repository.RepositoryUtil.deleteResource;
+import static org.apache.ace.cli.repository.RepositoryUtil.findResources;
+import static org.apache.ace.cli.repository.RepositoryUtil.getRequirement;
+import static org.apache.ace.cli.repository.RepositoryUtil.getUrl;
+import static org.apache.ace.cli.repository.RepositoryUtil.indexDirectory;
+
+import java.net.URL;
+import java.util.List;
+
+import org.apache.ace.cli.deployment.ContinuousDeployer;
+import org.osgi.resource.Requirement;
+import org.osgi.resource.Resource;
+
+import aQute.bnd.deployer.repository.FixedIndexedRepo;
+
+public class RepoCommands {
+
+ public final static String SCOPE = "repo";
+ public final static String[] FUNCTIONS = new String[] { "repo", "index", "ls", "cp", "rm", "cd" };
+
+ public CommandRepo repo(String type, String location) throws Exception {
+ return new CommandRepo(createRepository(type, location));
+ }
+
+ public URL index(String directory) throws Exception {
+ return indexDirectory(directory);
+ }
+
+ public void ls(CommandRepo fromRepo) throws Exception {
+ ls(fromRepo, null);
+ }
+
+ public void ls(CommandRepo repo, String filter) throws Exception {
+
+ FixedIndexedRepo sourceRepo = repo.repo();
+ sourceRepo.reset();
+
+ Requirement requirement = getRequirement(filter);
+ List<Resource> resources = findResources(sourceRepo, requirement);
+
+ for (Resource resource : resources) {
+ String location = getUrl(resources.get(0));
+ System.out.println(resource + " => " + location);
+ }
+ }
+
+ public void cp(CommandRepo fromRepo, CommandRepo toRepo) throws Exception {
+ cp(fromRepo, toRepo, null);
+ }
+
+ public void cp(CommandRepo fromRepo, CommandRepo toRepo, String filter) throws Exception {
+
+ FixedIndexedRepo sourceRepo = fromRepo.repo();
+ FixedIndexedRepo targetRepo = toRepo.repo();
+ sourceRepo.reset();
+ targetRepo.reset();
+
+ Requirement requirement = getRequirement(filter);
+ List<Resource> resources = findResources(sourceRepo, requirement);
+ copyResources(sourceRepo, targetRepo, resources);
+ }
+
+ public void rm(CommandRepo fromRepo) throws Exception {
+ rm(fromRepo, null);
+ }
+
+ public void rm(CommandRepo fromRepo, String filter) throws Exception {
+
+ FixedIndexedRepo repo = fromRepo.repo();
+ repo.reset();
+
+ Requirement requirement = getRequirement(filter);
+ List<Resource> resources = findResources(repo, requirement);
+
+ for (Resource resource : resources) {
+ String location = getUrl(resources.get(0));
+ System.out.println("rm " + resource + " => " + location);
+ deleteResource(resource);
+ }
+ }
+
+ public List<CommandResource> cd(CommandRepo releaseRepo, CommandRepo sourceRepo, CommandRepo targetRepo) throws Exception {
+
+ FixedIndexedRepo relRepo = releaseRepo.repo();
+ FixedIndexedRepo srcRepo = sourceRepo.repo();
+ FixedIndexedRepo tgtRepo = targetRepo.repo();
+ relRepo.reset();
+ srcRepo.reset();
+ tgtRepo.reset();
+
+ ContinuousDeployer cd = new ContinuousDeployer(tgtRepo, srcRepo, relRepo);
+ try {
+ List<Resource> deployedResources = cd.deployResources();
+ return CommandResource.wrap(targetRepo, deployedResources);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+}
Added: ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/repository/RepositoryUtil.java
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/repository/RepositoryUtil.java?rev=1503293&view=auto
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/repository/RepositoryUtil.java (added)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/repository/RepositoryUtil.java Mon Jul 15 15:22:36 2013
@@ -0,0 +1,358 @@
+/*
+ * 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.cli.repository;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Stack;
+
+import org.osgi.framework.Version;
+import org.osgi.resource.Capability;
+import org.osgi.resource.Requirement;
+import org.osgi.resource.Resource;
+import org.osgi.service.indexer.ResourceIndexer;
+import org.osgi.service.indexer.impl.RepoIndex;
+import org.osgi.service.repository.Repository;
+
+import aQute.bnd.deployer.repository.AbstractIndexedRepo;
+import aQute.bnd.osgi.resource.CapReqBuilder;
+import aQute.bnd.service.Strategy;
+
+public class RepositoryUtil {
+
+ public static AceObrRepository createRepository(String type, String location) throws Exception {
+ Map<String, String> properties = new HashMap<String, String>();
+ properties.put(AceObrRepository.PROP_REPO_TYPE, type);
+ properties.put(AceObrRepository.PROP_LOCATIONS, location);
+ AceObrRepository repository = new AceObrRepository();
+ repository.setProperties(properties);
+ return repository;
+ }
+
+ public static URL indexDirectory(String directory) throws Exception {
+
+ File rootDir = new File(directory);
+ if (!rootDir.exists() || !rootDir.isDirectory()) {
+ throw new IOException("Not a directory: " + directory);
+ }
+
+ File indexFile = new File(rootDir, "index.xml");
+ Set<File> files = new HashSet<File>();
+ Stack<File> dirs = new Stack<File>();
+ dirs.push(rootDir);
+ while (!dirs.isEmpty()) {
+ File dir = dirs.pop();
+ for (File file : dir.listFiles()) {
+ if (file.isDirectory()) {
+ dirs.push(file);
+ }
+ else {
+ files.add(file);
+ }
+ }
+ }
+
+ RepoIndex indexer = new RepoIndex();
+ Map<String, String> config = new HashMap<String, String>();
+ config.put(ResourceIndexer.REPOSITORY_NAME, "empty");
+ config.put(ResourceIndexer.PRETTY, "true");
+ config.put(ResourceIndexer.ROOT_URL, rootDir.getAbsoluteFile().toURI().toURL().toString());
+
+ FileOutputStream out = new FileOutputStream(indexFile);
+ try {
+ indexer.index(files, out, config);
+ }
+ finally {
+ out.close();
+ }
+ return indexFile.toURI().toURL();
+ }
+
+ // FIXME ACE only
+ public static boolean deleteResource(Resource resource) throws Exception {
+ HttpURLConnection connection = null;
+ try {
+ URL endpointUrl = new URL(getUrl(resource));
+ connection = (HttpURLConnection) endpointUrl.openConnection();
+ connection.setDoInput(true);
+ connection.setDoOutput(false);
+ connection.setInstanceFollowRedirects(false);
+ connection.setRequestMethod("DELETE");
+ connection.connect();
+ return connection.getResponseCode() == 200;
+ }
+ finally {
+ if (connection != null) {
+ connection.disconnect();
+ }
+ }
+ }
+
+ public static Requirement getRequirement(String filter) throws Exception {
+
+ if (filter == null || filter.equals("")) {
+ return null;
+ }
+
+ String namespace = "osgi.identity";
+ if (filter.indexOf("(") < 0) {
+ throw new Exception("Illegal filter");
+ }
+ if (filter.indexOf(":") > 0 && filter.indexOf(":") < filter.indexOf("(")) {
+ namespace = filter.substring(0, filter.indexOf(":"));
+ filter = filter.substring(filter.indexOf(":") + 1);
+ }
+ Requirement requirement = new CapReqBuilder(namespace)
+ .addDirective("filter", filter)
+ .buildSyntheticRequirement();
+ return requirement;
+ }
+
+ /**
+ * Construct a Resource filename with a specified version in the form that ACE OBR understands.
+ *
+ * @param resource
+ * The resource
+ * @param version
+ * The version
+ * @return The name
+ */
+ public static String getFileName(Resource resource, Version version) {
+ String location = getUrl(resource);
+ String extension = location.substring(location.lastIndexOf(".") + 1);
+ return getIdentity(resource) + "-" + version + "." + extension;
+ }
+
+ /**
+ * Construct a Resource filename in the form that ACE OBR understands.
+ *
+ * @param resource
+ * The resource
+ * @return The name
+ */
+ public static String getFileName(Resource resource) {
+ return getFileName(resource, getVersion(resource));
+ }
+
+ public static String getString(Resource resource) {
+ return getIdentity(resource) + "/" + getVersion(resource) + "/" + getType(resource) + " - " + getUrl(resource);
+ }
+
+ public static String getIdentity(Resource resource) {
+ Map<String, Object> attrs = getNamespaceAttributes(resource, "osgi.identity");
+ if (attrs == null)
+ return null;
+ return (String) attrs.get("osgi.identity");
+
+ }
+
+ public static Requirement getIdentityVersionRequirement(Resource resource) {
+ Requirement requirement = new CapReqBuilder("osgi.identity")
+ .addDirective("filter", String.format("(&(osgi.identity=%s)(version=%s)(type=*))", getIdentity(resource), getVersion(resource)))
+ .buildSyntheticRequirement();
+ return requirement;
+ }
+
+ public static List<Resource> copyResources(AbstractIndexedRepo fromRepo, AbstractIndexedRepo toRepo, String bsn) throws Exception {
+ return copyResources(fromRepo, toRepo, bsn, "*");
+ }
+
+ public static List<Resource> copyResources(AbstractIndexedRepo fromRepo, AbstractIndexedRepo toRepo, String bsn, String version) throws Exception {
+ return copyResources(fromRepo, toRepo, bsn, version, "*");
+ }
+
+ public static List<Resource> copyResources(AbstractIndexedRepo fromRepo, AbstractIndexedRepo toRepo, String bsn, String version, String type) throws Exception {
+ Requirement requirement = new CapReqBuilder("osgi.identity")
+ .addDirective("filter", String.format("(&(osgi.identity=%s)(version=%s)(type=%s))", bsn, version, type))
+ .buildSyntheticRequirement();
+ return copyResources(fromRepo, toRepo, requirement);
+ }
+
+ public static List<Resource> copyResources(AbstractIndexedRepo fromRepo, AbstractIndexedRepo toRepo, Requirement requirement) throws Exception {
+ List<Resource> resources = findResources(fromRepo, requirement);
+ for (Resource resource : resources) {
+ File file = fromRepo.get(getIdentity(resource), getVersion(resource).toString(), Strategy.EXACT, null);
+
+ InputStream input = null;
+ try {
+ input = new FileInputStream(file);
+ if (toRepo instanceof AceObrRepository) {
+ // ACE OBR can handle non bundle resource if we pass a filename
+ AceObrRepository aceToRepo = (AceObrRepository) toRepo;
+ aceToRepo.upload(input, getFileName(resource), getMimetype(resource));
+ }
+ else {
+ toRepo.put(input, null);
+ }
+ }
+ finally {
+ if (input != null)
+ input.close();
+ }
+ }
+ return resources;
+ }
+
+ public static List<Resource> copyResources(AbstractIndexedRepo fromRepo, AbstractIndexedRepo toRepo, List<Resource> resources) throws Exception {
+ List<Resource> targetResources = new LinkedList<Resource>();
+ for (Resource resource : resources) {
+ Resource targetResource = copyResource(fromRepo, toRepo, resource);
+ targetResources.add(targetResource);
+ }
+ return targetResources;
+ }
+
+ public static Resource copyResource(AbstractIndexedRepo fromRepo, AbstractIndexedRepo toRepo, Resource resource) throws Exception {
+
+ File file = fromRepo.get(getIdentity(resource), getVersion(resource).toString(), Strategy.EXACT, null);
+ InputStream input = null;
+ try {
+ input = new FileInputStream(file);
+ if (toRepo instanceof AceObrRepository) {
+ // ACE OBR can handle non bundle resource if we pass a filename
+ AceObrRepository aceToRepo = (AceObrRepository) toRepo;
+ aceToRepo.upload(input, getFileName(resource), getMimetype(resource));
+ }
+ else {
+ toRepo.put(input, null);
+ }
+
+ List<Resource> resultResources = findResources(toRepo, getIdentity(resource), getVersion(resource).toString());
+ if (resultResources == null || resultResources.size() == 0) {
+ throw new IllegalStateException("Can not find target resource after put: " + resource);
+ }
+ return resultResources.get(0);
+ }
+ finally {
+ if (input != null)
+ input.close();
+ }
+ }
+
+ public static List<Resource> findResources(Repository repository) {
+ return findResources(repository, "*");
+ }
+
+ public static List<Resource> findResources(Repository repository, String bsn) {
+ return findResources(repository, bsn, "*");
+ }
+
+ public static List<Resource> findResources(Repository repository, String bsn, String version) {
+ return findResources(repository, bsn, version, "*");
+ }
+
+ public static List<Resource> findResources(Repository repository, String bsn, String version, String type) {
+ Requirement requirement = new CapReqBuilder("osgi.identity")
+ .addDirective("filter", String.format("(&(osgi.identity=%s)(version=%s)(type=%s))", bsn, version, type))
+ .buildSyntheticRequirement();
+ return findResources(repository, requirement);
+ }
+
+ public static List<Resource> findResources(Repository repository, Requirement requirement) {
+ if (requirement == null) {
+ // FIXME maybe we can just pass null
+ requirement = new CapReqBuilder("osgi.identity")
+ .addDirective("filter", "(&(osgi.identity=*)(version=*)(type=*))")
+ .buildSyntheticRequirement();
+ }
+
+ Map<Requirement, Collection<Capability>> sourceResources = repository.findProviders(Collections.singleton(requirement));
+ if (sourceResources.isEmpty() || sourceResources.get(requirement).isEmpty()) {
+ return Collections.emptyList();
+ }
+ List<Resource> resources = new ArrayList<Resource>();
+ Iterator<Capability> capabilities = sourceResources.get(requirement).iterator();
+ while (capabilities.hasNext()) {
+ Capability capability = capabilities.next();
+ resources.add(capability.getResource());
+ }
+ return resources;
+ }
+
+ public static Version getVersion(Resource resource) {
+ Map<String, Object> attrs = getNamespaceAttributes(resource, "osgi.identity");
+ if (attrs == null)
+ return Version.emptyVersion;
+ Version version = (Version) attrs.get("version");
+ return version == null ? Version.emptyVersion : version;
+ }
+
+ public static List<Version> getVersions(List<Resource> resources) {
+ List<Version> versions = new ArrayList<Version>();
+ for (Resource resource : resources) {
+ versions.add(getVersion(resource));
+ }
+ return versions;
+ }
+
+ public static String getType(Resource resource) {
+ Map<String, Object> attrs = getNamespaceAttributes(resource, "osgi.identity");
+ if (attrs == null)
+ return null;
+ return (String) attrs.get("type");
+ }
+
+ public static String getUrl(Resource resource) {
+ Map<String, Object> attrs = getNamespaceAttributes(resource, "osgi.content");
+ if (attrs == null)
+ return null;
+ URI url = (URI) attrs.get("url");
+ return url == null ? null : url.toString();
+ }
+
+ public static String getMimetype(Resource resource) {
+ Map<String, Object> attrs = getNamespaceAttributes(resource, "osgi.content");
+ if (attrs == null)
+ return null;
+ return (String) attrs.get("mime");
+ }
+
+ public static String getSHA(Resource resource) {
+ Map<String, Object> attrs = getNamespaceAttributes(resource, "osgi.content");
+ if (attrs == null)
+ return null;
+ return (String) attrs.get("osgi.content");
+ }
+
+ private static Map<String, Object> getNamespaceAttributes(Resource resource, String namespace) {
+ List<Capability> caps = resource.getCapabilities(namespace);
+ if (caps.isEmpty())
+ return null;
+ Map<String, Object> attrs = caps.get(0).getAttributes();
+ if (attrs == null)
+ return null;
+ return attrs;
+ }
+}
Modified: ace/sandbox/bramk/org.apache.ace.cli/test/org/apache/ace/cli/deployment/ContinuousDeployerTest.java
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/test/org/apache/ace/cli/deployment/ContinuousDeployerTest.java?rev=1503293&r1=1503292&r2=1503293&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/test/org/apache/ace/cli/deployment/ContinuousDeployerTest.java (original)
+++ ace/sandbox/bramk/org.apache.ace.cli/test/org/apache/ace/cli/deployment/ContinuousDeployerTest.java Mon Jul 15 15:22:36 2013
@@ -1,7 +1,7 @@
package org.apache.ace.cli.deployment;
-import static org.apache.ace.cli.deployment.DeployerUtil.copyResources;
-import static org.apache.ace.cli.deployment.DeployerUtil.findResources;
+import static org.apache.ace.cli.repository.RepositoryUtil.copyResources;
+import static org.apache.ace.cli.repository.RepositoryUtil.findResources;
import java.io.File;
import java.io.FileInputStream;