Author: bramk
Date: Fri Jun 14 11:58:28 2013
New Revision: 1493046
URL: http://svn.apache.org/r1493046
Log:
[sandbox] Added inital create repository command
The command generates on OSGi R5 index for a directory using
a modified repoindex that handles arbitrary file types.
Added:
ace/sandbox/bramk/cnf/localrepo/org.osgi.impl.bundle.repoindex.lib/
ace/sandbox/bramk/cnf/localrepo/org.osgi.impl.bundle.repoindex.lib/org.osgi.impl.bundle.repoindex.lib-0.0.4.jar
(with props)
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/CreateRepository.java
Modified:
ace/sandbox/bramk/cnf/ext/repositories.bnd
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/Main.java
Modified: ace/sandbox/bramk/cnf/ext/repositories.bnd
URL:
http://svn.apache.org/viewvc/ace/sandbox/bramk/cnf/ext/repositories.bnd?rev=1493046&r1=1493045&r2=1493046&view=diff
==============================================================================
--- ace/sandbox/bramk/cnf/ext/repositories.bnd (original)
+++ ace/sandbox/bramk/cnf/ext/repositories.bnd Fri Jun 14 11:58:28 2013
@@ -1,10 +1,13 @@
plugindir: ${workspace}/cnf/plugins
--pluginpath: ${plugindir}/biz.aQute.repository/biz.aQute.repository-2.0.5.jar
+-pluginpath: ${plugindir}/biz.aQute.repository/biz.aQute.repository-2.0.5.jar,\
+ ${workspace}/org.apache.ace.cli/generated/org.apache.ace.cli.jar
-plugin:
aQute.bnd.deployer.repository.LocalIndexedRepo;name=Release;local=${workspace}/cnf/releaserepo;pretty=true,\
aQute.bnd.deployer.repository.LocalIndexedRepo;name=Local;local=${workspace}/cnf/localrepo;pretty=true,\
aQute.bnd.deployer.repository.FixedIndexedRepo;name=Library
Repository;locations='file://${build}/lib/repository.xml',\
-
aQute.lib.deployer.FileRepo;name=Build;location=${workspace}/cnf/buildrepo
+
aQute.lib.deployer.FileRepo;name=Build;location=${workspace}/cnf/buildrepo,\
+ aQute.bnd.deployer.repository.FixedIndexedRepo;name=Library
Repository;locations='file://${build}/lib/repository.xml',\
+ org.apache.ace.cli.repository.AceObrRepository;name=ACE
Repository;locations='http://localhost:8080/obr/repository.xml'
--releaserepo: Release
+-releaserepo: ACE Repository
Modified: ace/sandbox/bramk/cnf/localrepo/index.xml
URL:
http://svn.apache.org/viewvc/ace/sandbox/bramk/cnf/localrepo/index.xml?rev=1493046&r1=1493045&r2=1493046&view=diff
==============================================================================
--- ace/sandbox/bramk/cnf/localrepo/index.xml (original)
+++ ace/sandbox/bramk/cnf/localrepo/index.xml Fri Jun 14 11:58:28 2013
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
-<repository increment='1370936925190' name='Local'
xmlns='http://www.osgi.org/xmlns/repository/v1.0.0'>
+<repository increment='1371210601386' 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'/>
@@ -1686,6 +1686,67 @@
</resource>
<resource>
<capability namespace='osgi.identity'>
+ <attribute name='osgi.identity'
value='org.osgi.impl.bundle.repoindex.lib'/>
+ <attribute name='type' value='osgi.bundle'/>
+ <attribute name='version' type='Version' value='0.0.4.201306141149'/>
+ </capability>
+ <capability namespace='osgi.content'>
+ <attribute name='osgi.content'
value='138a50c41124fd0fd83cd923c465f46f86f1422b5a1e69633349bf065269e843'/>
+ <attribute name='url'
value='org.osgi.impl.bundle.repoindex.lib/org.osgi.impl.bundle.repoindex.lib-0.0.4.jar'/>
+ <attribute name='size' type='Long' value='317937'/>
+ <attribute name='mime' value='application/vnd.osgi.bundle'/>
+ </capability>
+ <capability namespace='osgi.wiring.bundle'>
+ <attribute name='osgi.wiring.bundle'
value='org.osgi.impl.bundle.repoindex.lib'/>
+ <attribute name='bundle-version' type='Version'
value='0.0.4.201306141149'/>
+ </capability>
+ <capability namespace='osgi.wiring.host'>
+ <attribute name='osgi.wiring.host'
value='org.osgi.impl.bundle.repoindex.lib'/>
+ <attribute name='bundle-version' type='Version'
value='0.0.4.201306141149'/>
+ </capability>
+ <capability namespace='osgi.wiring.package'>
+ <attribute name='osgi.wiring.package' value='org.osgi.service.indexer'/>
+ <attribute name='version' type='Version' value='1.0.2'/>
+ <attribute name='bundle-symbolic-name'
value='org.osgi.impl.bundle.repoindex.lib'/>
+ <attribute name='bundle-version' type='Version'
value='0.0.4.201306141149'/>
+ </capability>
+ <capability namespace='osgi.wiring.package'>
+ <attribute name='osgi.wiring.package' value='org.osgi.service.log'/>
+ <attribute name='version' type='Version' value='1.3.0'/>
+ <attribute name='bundle-symbolic-name'
value='org.osgi.impl.bundle.repoindex.lib'/>
+ <attribute name='bundle-version' type='Version'
value='0.0.4.201306141149'/>
+ <directive name='uses' value='org.osgi.framework'/>
+ </capability>
+ <requirement namespace='osgi.wiring.package'>
+ <directive name='filter'
value='(osgi.wiring.package=javax.security.auth.x500)'/>
+ </requirement>
+ <requirement namespace='osgi.wiring.package'>
+ <directive name='filter'
value='(osgi.wiring.package=javax.xml.parsers)'/>
+ </requirement>
+ <requirement namespace='osgi.wiring.package'>
+ <directive name='filter'
value='(&(osgi.wiring.package=org.osgi.service.indexer)(version>=1.0.0)(!(version>=2.0.0)))'/>
+ </requirement>
+ <requirement namespace='osgi.wiring.package'>
+ <directive name='filter'
value='(&(osgi.wiring.package=org.osgi.util.tracker)(version>=1.4.0)(!(version>=2.0.0)))'/>
+ </requirement>
+ <requirement namespace='osgi.wiring.package'>
+ <directive name='filter' value='(osgi.wiring.package=org.xml.sax)'/>
+ </requirement>
+ <requirement namespace='osgi.wiring.package'>
+ <directive name='filter'
value='(osgi.wiring.package=org.xml.sax.helpers)'/>
+ </requirement>
+ <requirement namespace='osgi.wiring.package'>
+ <directive name='filter'
value='(&(osgi.wiring.package=org.osgi.service.log)(version>=1.3.0)(!(version>=2.0.0)))'/>
+ </requirement>
+ <requirement namespace='osgi.wiring.package'>
+ <directive name='filter'
value='(&(osgi.wiring.package=org.osgi.framework)(version>=1.5.0)(!(version>=2.0.0)))'/>
+ </requirement>
+ <requirement namespace='osgi.ee'>
+ <directive name='filter' value='(osgi.ee=J2SE-1.5)'/>
+ </requirement>
+ </resource>
+ <resource>
+ <capability namespace='osgi.identity'>
<attribute name='osgi.identity' value='org.apache.felix.gogo.runtime'/>
<attribute name='type' value='osgi.bundle'/>
<attribute name='version' type='Version' value='0.10.0'/>
Added:
ace/sandbox/bramk/cnf/localrepo/org.osgi.impl.bundle.repoindex.lib/org.osgi.impl.bundle.repoindex.lib-0.0.4.jar
URL:
http://svn.apache.org/viewvc/ace/sandbox/bramk/cnf/localrepo/org.osgi.impl.bundle.repoindex.lib/org.osgi.impl.bundle.repoindex.lib-0.0.4.jar?rev=1493046&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
ace/sandbox/bramk/cnf/localrepo/org.osgi.impl.bundle.repoindex.lib/org.osgi.impl.bundle.repoindex.lib-0.0.4.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
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=1493046&r1=1493045&r2=1493046&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/bnd.bnd (original)
+++ ace/sandbox/bramk/org.apache.ace.cli/bnd.bnd Fri Jun 14 11:58:28 2013
@@ -1,9 +1,9 @@
--buildpath: \
- biz.aQute.bnd;version=2.1.0,\
+-buildpath: biz.aQute.bnd;version=2.1.0,\
biz.aQute.repository;version=2.1.0,\
com.google.gson,\
org.amdatu.ace.client,\
- org.apache.commons.cli
+ org.apache.commons.cli,\
+ org.osgi.impl.bundle.repoindex.lib
Private-Package: \
org.apache.commons.cli,\
@@ -14,8 +14,10 @@ Private-Package: \
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
\ No newline at end of file
+Main-Class: org.apache.ace.cli.Main
+Bundle-Version: 1.0.0
\ No newline at end of file
Modified: ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/Main.java
URL:
http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/Main.java?rev=1493046&r1=1493045&r2=1493046&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/Main.java
(original)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/Main.java Fri
Jun 14 11:58:28 2013
@@ -36,6 +36,7 @@ import org.apache.ace.cli.command.CopyRe
import org.apache.ace.cli.command.CreateArtifacts;
import org.apache.ace.cli.command.CreateDistribution;
import org.apache.ace.cli.command.CreateFeature;
+import org.apache.ace.cli.command.CreateRepository;
import org.apache.ace.cli.command.CreateTarget;
import org.apache.ace.cli.command.DeleteArtifacts;
import org.apache.ace.cli.command.DeleteResources;
@@ -63,6 +64,7 @@ public class Main {
private final static List<AbstractCommand> COMMANDS = new
ArrayList<AbstractCommand>();
static {
COMMANDS.add(new CopyDirectory());
+ COMMANDS.add(new CreateRepository());
COMMANDS.add(new ListResources());
COMMANDS.add(new DeleteResources());
COMMANDS.add(new CopyResources());
Added:
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/CreateRepository.java
URL:
http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/CreateRepository.java?rev=1493046&view=auto
==============================================================================
---
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/CreateRepository.java
(added)
+++
ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/command/CreateRepository.java
Fri Jun 14 11:58:28 2013
@@ -0,0 +1,96 @@
+/*
+ * 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.command;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Stack;
+
+import org.osgi.service.indexer.ResourceIndexer;
+import org.osgi.service.indexer.impl.RepoIndex;
+
+/**
+ * Command that creates an OSGi R5 repository index from a directory.
+ *
+ */
+public class CreateRepository extends AbstractCommand {
+
+ @Override
+ public String getName() {
+ return "create-repository";
+ }
+
+ @Override
+ public String getDescription() {
+ return "create a repository from a directory";
+ }
+
+ @Override
+ public void doCommand(String command) throws Exception {
+
+ String rootDirName = getConfiguration().get("directory");
+ if (rootDirName == null) {
+ throw new IllegalArgumentException("Copying a directory requires
valid -d");
+ }
+ File rootDir = new File(rootDirName);
+ if (!rootDir.exists() || !rootDir.isDirectory()) {
+ throw new IllegalArgumentException("Copying a directory requires
valid -d");
+ }
+
+ File indexFile = new File(rootDirName, "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);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally {
+ out.close();
+ }
+
+ printVerbose("Repository index for " + files.size() + " resources
generated at " + indexFile.getAbsolutePath());
+ }
+}