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/10 17:36:37 UTC

svn commit: r1501797 - in /ace/sandbox/bramk: cnf/ext/ cnf/localrepo/ cnf/localrepo/org.osgi.impl.bundle.repoindex.lib/ org.apache.ace.cli/src/org/apache/ace/cli/command/ org.apache.ace.cli/src/org/apache/ace/cli/deployment/

Author: bramk
Date: Wed Jul 10 15:36:37 2013
New Revision: 1501797

URL: http://svn.apache.org/r1501797
Log:
[sandbox] Added ace client integration / fixed false diff positives

Modified:
    ace/sandbox/bramk/cnf/ext/repositories.bnd
    ace/sandbox/bramk/cnf/localrepo/index.xml
    ace/sandbox/bramk/cnf/localrepo/org.osgi.impl.bundle.repoindex.lib/org.osgi.impl.bundle.repoindex.lib-0.0.4.jar
    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/deployment/ContinuousDeployer.java
    ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/deployment/DeployerUtil.java

Modified: ace/sandbox/bramk/cnf/ext/repositories.bnd
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/cnf/ext/repositories.bnd?rev=1501797&r1=1501796&r2=1501797&view=diff
==============================================================================
--- ace/sandbox/bramk/cnf/ext/repositories.bnd (original)
+++ ace/sandbox/bramk/cnf/ext/repositories.bnd Wed Jul 10 15:36:37 2013
@@ -5,7 +5,6 @@ plugindir: ${workspace}/cnf/plugins
 
 -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.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'

Modified: ace/sandbox/bramk/cnf/localrepo/index.xml
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/cnf/localrepo/index.xml?rev=1501797&r1=1501796&r2=1501797&view=diff
==============================================================================
--- ace/sandbox/bramk/cnf/localrepo/index.xml (original)
+++ ace/sandbox/bramk/cnf/localrepo/index.xml Wed Jul 10 15:36:37 2013
@@ -1,5 +1,5 @@
 <?xml version='1.0' encoding='utf-8'?>
-<repository increment='1371210601386' name='Local' xmlns='http://www.osgi.org/xmlns/repository/v1.0.0'>
+<repository increment='1372749843145' 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'/>
@@ -1688,33 +1688,33 @@
     <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'/>
+      <attribute name='version' type='Version' value='0.0.4.201306141305'/>
     </capability>
     <capability namespace='osgi.content'>
-      <attribute name='osgi.content' value='138a50c41124fd0fd83cd923c465f46f86f1422b5a1e69633349bf065269e843'/>
+      <attribute name='osgi.content' value='7804a3ae6d774f224bc1a2d8b642ebbe715a0141afd524215d37dbf710761936'/>
       <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='size' type='Long' value='317844'/>
       <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'/>
+      <attribute name='bundle-version' type='Version' value='0.0.4.201306141305'/>
     </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'/>
+      <attribute name='bundle-version' type='Version' value='0.0.4.201306141305'/>
     </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'/>
+      <attribute name='bundle-version' type='Version' value='0.0.4.201306141305'/>
     </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'/>
+      <attribute name='bundle-version' type='Version' value='0.0.4.201306141305'/>
       <directive name='uses' value='org.osgi.framework'/>
     </capability>
     <requirement namespace='osgi.wiring.package'>
@@ -1736,10 +1736,10 @@
       <directive name='filter' value='(osgi.wiring.package=org.xml.sax.helpers)'/>
     </requirement>
     <requirement namespace='osgi.wiring.package'>
-      <directive name='filter' value='(&amp;(osgi.wiring.package=org.osgi.service.log)(version&gt;=1.3.0)(!(version&gt;=2.0.0)))'/>
+      <directive name='filter' value='(&amp;(osgi.wiring.package=org.osgi.framework)(version&gt;=1.5.0)(!(version&gt;=2.0.0)))'/>
     </requirement>
     <requirement namespace='osgi.wiring.package'>
-      <directive name='filter' value='(&amp;(osgi.wiring.package=org.osgi.framework)(version&gt;=1.5.0)(!(version&gt;=2.0.0)))'/>
+      <directive name='filter' value='(&amp;(osgi.wiring.package=org.osgi.service.log)(version&gt;=1.3.0)(!(version&gt;=2.0.0)))'/>
     </requirement>
     <requirement namespace='osgi.ee'>
       <directive name='filter' value='(osgi.ee=J2SE-1.5)'/>

Modified: 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=1501797&r1=1501796&r2=1501797&view=diff
==============================================================================
Binary files - no diff available.

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=1501797&r1=1501796&r2=1501797&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 Wed Jul 10 15:36:37 2013
@@ -20,8 +20,23 @@ package org.apache.ace.cli.command;
 
 import java.util.List;
 
+import org.amdatu.ace.client.AceClientWorkspace;
+import org.amdatu.ace.client.model.Artifact;
+import org.amdatu.ace.client.model.Artifact2Feature;
+import org.amdatu.ace.client.model.Artifact2FeatureBuilder;
+import org.amdatu.ace.client.model.ArtifactBuilder;
+import org.amdatu.ace.client.model.Distribution;
+import org.amdatu.ace.client.model.DistributionBuilder;
+import org.amdatu.ace.client.model.Feature;
+import org.amdatu.ace.client.model.Feature2Distribution;
+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;
+import org.osgi.service.repository.Repository;
 
 import aQute.bnd.deployer.repository.FixedIndexedRepo;
 
@@ -29,7 +44,7 @@ import aQute.bnd.deployer.repository.Fix
  * Command that copies resources from the source repository to the target repository.
  * 
  */
-public class DeployResources extends AbstractCommand {
+public class DeployResources extends AbstractClientCommand {
 
     @Override
     public String getName() {
@@ -42,7 +57,7 @@ public class DeployResources extends Abs
     }
 
     @Override
-    public void doCommand(String command) throws Exception {
+    public void doClientCommand(String command, AceObrRepository repository, AceClientWorkspace workspace) throws Exception {
 
         FixedIndexedRepo releaseRepo = getReleaseRepository();
         FixedIndexedRepo sourceRepo = getSourceRepository();
@@ -52,14 +67,143 @@ public class DeployResources extends Abs
         }
 
         ContinuousDeployer cd = new ContinuousDeployer(targetRepo, sourceRepo, releaseRepo);
-
         try {
+
             List<Resource> deployed = cd.deployResources();
-            printVerbose("Deployed " + deployed.size() + " artifacts");
+            targetRepo.reset();
+
+            // remove all artifacts
+            workspace.deleteResources(Artifact.class);
+
+            // ensure feature exists
+            boolean featureExists = false;
+            Feature[] features = workspace.getResources(Feature.class);
+            for (Feature feature : features) {
+                featureExists |= feature.getName().equals("cdfeature");
+                if (featureExists)
+                    break;
+            }
+            if (!featureExists) {
+                workspace.createResource(
+                    new FeatureBuilder().setName("cdfeature").build());
+            }
+
+            // ensure a2f exists
+            boolean associationExists = false;
+            Artifact2Feature[] a2features = workspace.getResources(Artifact2Feature.class);
+            for (Artifact2Feature a2feature : a2features) {
+                associationExists |= a2feature.getRightEndpoint().equals("(name=cdfeature)");
+            }
+            if (!associationExists) {
+                workspace.createResource(
+                    new Artifact2FeatureBuilder()
+                        .setLeftCardinality("" + Integer.MAX_VALUE)
+                        .setLeftEndpoint("(cdartifact=true)")
+                        .setRightCardinality("1")
+                        .setRightEndpoint("(name=cdfeature)")
+                        .build());
+            }
+
+            // ensure distribution exists
+            boolean distributionExists = false;
+            Distribution[] distributions = workspace.getResources(Distribution.class);
+            for (Distribution distribution : distributions) {
+                distributionExists |= distribution.getName().equals("cddistribution");
+                if (featureExists)
+                    break;
+            }
+            if (!distributionExists) {
+                workspace.createResource(
+                    new DistributionBuilder().setName("cddistribution").build());
+            }
+
+            // ensure f2d exists
+            associationExists = false;
+            Feature2Distribution[] f2distributions = workspace.getResources(Feature2Distribution.class);
+            for (Feature2Distribution f2distribution : f2distributions) {
+                associationExists |= f2distribution.getRightEndpoint().equals("(name=cddistribution)");
+            }
+            if (!associationExists) {
+                workspace.createResource(
+                    new Feature2DistributionBuilder()
+                        .setLeftCardinality("1")
+                        .setLeftEndpoint("(name=cdfeature)")
+                        .setRightCardinality("1")
+                        .setRightEndpoint("(name=cddistribution)")
+                        .build());
+            }
+
+            for (Resource resource : deployed) {
+                Resource targetResource = getHighestVersion(targetRepo, getIdentity(resource));
+
+                String identity = getIdentity(targetResource);
+                
+                if(identity.equals("org.apache.felix.deployment.rp.autoconf")){
+                    // ACE will break
+                    continue;
+                }
+                
+                String version = getVersion(targetResource);
+                String mimetype = getMimetype(targetResource);
+                String url = getUrl(targetResource);
+
+                if (mimetype == null) {
+                    // OBR does not return mime
+                    if (url.endsWith(".xml")) {
+                        mimetype = Artifact.MIMETYPE_CONFIG;
+                    }
+                    else {
+                        mimetype = Artifact.MIMETYPE_BUNDLE;
+                    }
+                }
+
+                String name = identity + "-" + version;
+                if (mimetype.equals(Artifact.MIMETYPE_BUNDLE)) {
+
+                    workspace.createResource(
+                        new ArtifactBuilder()
+                            .isBundle()
+                            .setName(name)
+                            .setDescription("")
+                            .setMimeType(mimetype)
+                            .setBundleName(identity)
+                            .setBundleSymbolicName(identity)
+                            .setBundleVersion(version)
+                            .setUrl(url)
+                            .setAttribute("cdartifact", "true")
+                            .build());
+                }
+                else {
+                    workspace.createResource(
+                        new ArtifactBuilder()
+                            .isConfig()
+                            .setName(name)
+                            .setDescription("")
+                            .setConfigFileName(name)
+                            .setProcessorPid("org.osgi.deployment.rp.autoconf")
+                            .setUrl(url)
+                            .setAttribute("cdartifact", "true")
+                            .build());
+                }
+            }
+            workspace.commit();
         }
         catch (Exception e) {
             e.printStackTrace();
         }
+    }
 
+    private Resource getHighestVersion(Repository repository, String identity) throws Exception {
+        List<Resource> resources = DeployerUtil.findResources(repository, identity);
+        Resource currentResource = null;
+        Version currentVersion = null;
+        for (Resource candidateResource : resources) {
+            Version candidateVersion = DeployerUtil.getVersion(candidateResource);
+            if (currentResource == null || candidateVersion.compareTo(currentVersion) > 0) {
+                currentResource = candidateResource;
+                currentVersion = candidateVersion;
+            }
+        }
+        return currentResource;
     }
 }

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=1501797&r1=1501796&r2=1501797&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 Wed Jul 10 15:36:37 2013
@@ -112,15 +112,20 @@ public class ContinuousDeployer {
             deploySnapshotResource(resource, getNextSnapshotVersion(releasedBaseVersion));
         }
         else {
-
             System.out.println("Found existing snapshot:  " + getString(snapshotResource));
             File developmentResource = m_developmentRepo.get(getIdentity(resource), getVersion(resource).toString(), Strategy.EXACT, null);
             File deployedResource = m_deploymentRepo.get(getIdentity(snapshotResource), getVersion(snapshotResource).toString(), Strategy.EXACT, null);
 
             boolean snapshotModified = false;
             if (getType(resource).equals("osgi.bundle")) {
+
+                // Get a copy of the dep resource with the same version as the dev resource so we can diff diff.
                 File comparableDeployedResource = getBundleWithNewVersion(deployedResource, getVersion(resource).toString());
-                snapshotModified = jarsDiffer(comparableDeployedResource, developmentResource);
+
+                // This may seem strange but the value in the dev resource manifest may be "0" which will not match
+                // "0.0.0" during diff.
+                File comparableDevelopmentResource = getBundleWithNewVersion(developmentResource, getVersion(resource).toString());
+                snapshotModified = jarsDiffer(comparableDeployedResource, comparableDevelopmentResource);
             }
             else {
                 snapshotModified = filesDiffer(developmentResource, deployedResource);
@@ -163,16 +168,17 @@ public class ContinuousDeployer {
     }
 
     private Resource getHighestSnapshotResource(Resource resource, Version base) throws Exception {
+
         List<Resource> resources = findResources(m_deploymentRepo, getIdentity(resource));
         Resource matchedResource = null;
         for (Resource candidateResource : resources) {
             Version candidateVersion = getVersion(candidateResource);
-
             if (isSnapshotVersion(candidateVersion) && isSameBaseVersion(getVersion(candidateResource), base)
                 && (matchedResource == null || getVersion(matchedResource).compareTo(getVersion(candidateResource)) < 0)) {
                 matchedResource = candidateResource;
             }
         }
+
         return matchedResource;
     }
 

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=1501797&r1=1501796&r2=1501797&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 Wed Jul 10 15:36:37 2013
@@ -126,6 +126,12 @@ public final class DeployerUtil {
                 if (childc.getDelta() == Delta.UNCHANGED || childc.getDelta() == Delta.IGNORED) {
                     continue;
                 }
+                System.out.println(childc);
+//                if(childc.getChildren() != null)
+//                    for(Diff qq : childc.getChildren()){
+//                        System.out.println(" " + qq);
+//                    }
+                
                 return true;
             }
         }
@@ -191,7 +197,6 @@ public final class DeployerUtil {
 
         File targetFile = File.createTempFile("bundle", ".jar");
         byte[] buf = new byte[1024];
-
         ZipInputStream zin = new ZipInputStream(new FileInputStream(sourceJar));
         ZipOutputStream out = new ZipOutputStream(new FileOutputStream(targetFile));
         ZipEntry entry = zin.getNextEntry();
@@ -232,7 +237,7 @@ public final class DeployerUtil {
     }
 
     public static String getString(Resource resource) {
-        return getIdentity(resource) + "/" + getVersion(resource) + "/" + getType(resource);
+        return getIdentity(resource) + "/" + getVersion(resource) + "/" + getType(resource) + " - " + getUrl(resource);
     }
 
     public static String getIdentity(Resource resource) {