ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1503728 - in /ace/sandbox/bramk/org.apache.ace.cli: deploy.gosh src/org/apache/ace/cli/gogo/RepoCommands.java src/org/apache/ace/cli/repository/RepositoryUtil.java
Date Tue, 16 Jul 2013 14:20:38 GMT
Author: bramk
Date: Tue Jul 16 14:20:38 2013
New Revision: 1503728

URL: http://svn.apache.org/r1503728
Log:
[sandbox] Extended with target create/register/approve and autoconf deploy/create

Modified:
    ace/sandbox/bramk/org.apache.ace.cli/deploy.gosh
    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/org.apache.ace.cli/deploy.gosh
URL: http://svn.apache.org/viewvc/ace/sandbox/bramk/org.apache.ace.cli/deploy.gosh?rev=1503728&r1=1503727&r2=1503728&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/deploy.gosh (original)
+++ ace/sandbox/bramk/org.apache.ace.cli/deploy.gosh Tue Jul 16 14:20:38 2013
@@ -1,53 +1,68 @@
 
 
+autoconfurl = "file:/tmp/org.apache.ace.deployment.rp.autoconf.jar"
 sourceindex = (repo:index /tmp/testrepo)
 sourcerepo  = (repo:repo R5 $sourceindex)
 targetrepo = (repo:repo OBR http://localhost:8080/obr/repository.xml)
 releaserepo = (repo:repo OBR http://localhost:9091/obr/repository.xml)
 
-#repo:ls $sourcerepo "(osgi.identity=org.amdatu.opensocial)"
-#repo:ls $targetrepo "(osgi.identity=org.amdatu.opensocial)"
-#echo "delete"
-#repo:rm $targetrepo "(osgi.identity=org.amdatu.opensocial)"
-#echo "copy"
-#repo:cp $sourcerepo $targetrepo "(osgi.identity=org.amdatu.opensocial)"
-
 echo "Deploying release"
 deployed = repo:cd $releaserepo $sourcerepo $targetrepo
 
+echo "Ensuring autoconf resource"
+autoconf = (coll:first ($targetrepo find "(osgi.identity=org.apache.ace.deployment.rp.autoconf)"))
+if { $autoconf } { echo " -> exists" } \
+{ 
+  repo:d $targetrepo $autoconfurl
+  autoconf = (coll:first ($targetrepo find "(osgi.identity=org.apache.ace.deployment.rp.autoconf)"))
+  echo " -> deployed"
+} 
+
 echo "Opening workspace"
 workspace = (ace:cw)
 
+echo "Ensuring autoconf artifact"
+if { (coll:first ($workspace lrp)) } { echo " -> exists" } \
+{ 
+  identity = $autoconf getIdentity
+  version = $autoconf getVersion
+  name = "$identity - $version"
+  url = $autoconf getUrl
+  mimetype = $autoconf getMimetype
+  mimetype = "application/vnd.osgi.bundle"
+  $workspace ca [ artifactName="$name" url="$url" mimetype="$mimetype" Bundle-SymbolicName="$identity"
Bundle-Version="$version" Deployment-ProvidesResourceProcessor="org.osgi.deployment.rp.autoconf"
]
+  echo " -> created"
+}
+
 echo "Purging artifacts"
 artifacts = ($workspace la)
 each $artifacts {
   $workspace da $it
 }
 
-echo "Checking cdfeature"
-feature = $workspace lf "(name=cdfeature)"
-if { math:eq ($feature size) 0 } { $workspace cf "cdfeature" }
-
-echo "Checking cddistribution"
-distribution = $workspace ld "(name=cddistribution)"
-if { math:eq ($distribution size) 0 } { $workspace cd "cddistribution" }
-
-echo "Checking f2d association"
-associations = $workspace lf2d
-found = 0
-each $associations {
-  if { ($it getAttribute "leftEndpoint") equals "(name=cdfeature)" } { echo "FOUND"; found
= 1 }
-}
-if { math:eq $found 0 } { $workspace cf2d "(name=cdfeature)" "(name=cddistribution)" "1"
"1" }
+echo "Ensuring cdfeature exists"
+if { (coll:first ($workspace lf "(name=cdfeature)")) } { echo " -> exists" } { $workspace
cf "cdfeature"; echo " -> created" }
 
-echo "Checking a2f association"
-associations = $workspace la2f
-found = 0
-each $associations {
-  if { ($it getAttribute "rightEndpoint") equals "(name=cdfeature)" } { echo "FOUND"; found
= 1 }
-}
-if { math:eq $found 0 } { $workspace ca2f "(cdartifact=true)" "(name=cdfeature)" "10000"
"1" }
+echo "Ensuring cddistribution exists"
+if { (coll:first ($workspace ld "(name=cddistribution)")) } { echo " -> exists" } { $workspace
cd "cddistribution"; echo " -> created" }
+
+echo "Ensuring cdtarget exists"
+if { (coll:first ($workspace lt "(id=cdtarget)")) } { echo " -> exists" } { $workspace
ct "cdtarget"; echo " -> created" }
+
+echo "Ensuring cdtarget"
+target = (coll:first ($workspace lt "(id=cdtarget)"))
+if { $target isRegistered } { } { $target register }
+$target setAutoApprove false
 
+echo "Ensuring f2d association"
+if { (coll:first ($workspace lf2d "(leftEndpoint=*name=cdfeature*)")) } { echo " -> exists"
} { $workspace cf2d "(name=cdfeature)" "(name=cddistribution)" "1" "1"; echo " -> created"
}
+
+echo "Ensuring a2f association"
+if { (coll:first ($workspace la2f "(rightEndpoint=*name=cdfeature*)")) } { echo " -> exists"
} { $workspace ca2f "(cdartifact=true)" "(name=cdfeature)" "10000" "1"; echo " -> created"
}
+
+echo "Ensuring d2t association"
+if { (coll:first ($workspace ld2t "(leftEndpoint=*name=cddistribution*)")) } { echo " ->
exists" } \
+  { $workspace cd2t "(name=cddistribution)" "(id=cdtarget)" "1" "1"; echo " -> created"
}
 
 echo "Creating artifacts"
 each $deployed {
@@ -63,6 +78,9 @@ each $deployed {
   { $workspace ca [ artifactName="$name" url="$url" mimetype="$mimetype" Bundle-SymbolicName="$identity"
Bundle-Version="$version" cdartifact="true" ] }
 }
 
+echo "Ensuring approval on target"
+if { $target needsApprove } { echo " approving"; $target approve } { echo " no changes" }
+
 echo "Comitting workspace"
 $workspace commit
 ace:rw $workspace

Modified: 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=1503728&r1=1503727&r2=1503728&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/RepoCommands.java (original)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/gogo/RepoCommands.java Tue
Jul 16 14:20:38 2013
@@ -25,6 +25,7 @@ import static org.apache.ace.cli.reposit
 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 static org.apache.ace.cli.repository.RepositoryUtil.uploadResource;
 
 import java.net.URL;
 import java.util.List;
@@ -38,7 +39,7 @@ import aQute.bnd.deployer.repository.Fix
 public class RepoCommands {
 
     public final static String SCOPE = "repo";
-    public final static String[] FUNCTIONS = new String[] { "repo", "index", "ls", "cp",
"rm", "cd" };
+    public final static String[] FUNCTIONS = new String[] { "repo", "index", "ls", "cp",
"rm", "cd", "d" };
 
     public CommandRepo repo(String type, String location) throws Exception {
         return new CommandRepo(createRepository(type, location));
@@ -120,4 +121,15 @@ public class RepoCommands {
         }
         return null;
     }
+
+    public void d(CommandRepo repo, String url) throws Exception {
+        d(repo, url, null);
+    }
+    
+    public void d(CommandRepo repo, String url, String filename) throws Exception {
+        FixedIndexedRepo toRepo = repo.repo();
+        URL location = new URL(url);
+        uploadResource(toRepo, location, filename);
+        toRepo.reset();
+    }
 }

Modified: 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=1503728&r1=1503727&r2=1503728&view=diff
==============================================================================
--- ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/repository/RepositoryUtil.java
(original)
+++ ace/sandbox/bramk/org.apache.ace.cli/src/org/apache/ace/cli/repository/RepositoryUtil.java
Tue Jul 16 14:20:38 2013
@@ -225,6 +225,25 @@ public class RepositoryUtil {
         return resources;
     }
 
+    public static void uploadResource(AbstractIndexedRepo toRepo, URL location, String filename)
throws Exception {
+        InputStream input = null;
+        try {
+            input = location.openStream();
+            if (toRepo instanceof AceObrRepository) {
+                // ACE OBR can handle non bundle resource if we pass a filename
+                AceObrRepository aceToRepo = (AceObrRepository) toRepo;
+                aceToRepo.upload(input, filename, null);
+            }
+            else {
+                toRepo.put(input, null);
+            }
+        }
+        finally {
+            if (input != null)
+                input.close();
+        }
+    }
+
     public static List<Resource> copyResources(AbstractIndexedRepo fromRepo, AbstractIndexedRepo
toRepo, List<Resource> resources) throws Exception {
         List<Resource> targetResources = new LinkedList<Resource>();
         for (Resource resource : resources) {



Mime
View raw message