ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1042666 - in /incubator/ace/trunk: ace-client-repository-configuration/ ace-client-repository-helper-base/ ace-client-repository-helper-base/src/main/java/org/apache/ace/client/repository/helper/base/ ace-client-repository-impl/src/main/ja...
Date Mon, 06 Dec 2010 14:55:13 GMT
Author: marrs
Date: Mon Dec  6 14:55:12 2010
New Revision: 1042666

URL: http://svn.apache.org/viewvc?rev=1042666&view=rev
Log:
ACE-103 Initial implementation of this new feature.

Added:
    incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/GatewayPropertyResolver.java
    incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/RepoPropertyResolver.java
Modified:
    incubator/ace/trunk/ace-client-repository-configuration/osgi.bnd
    incubator/ace/trunk/ace-client-repository-helper-base/osgi.bnd
    incubator/ace/trunk/ace-client-repository-helper-base/pom.xml
    incubator/ace/trunk/ace-client-repository-helper-base/src/main/java/org/apache/ace/client/repository/helper/base/VelocityArtifactPreprocessor.java
    incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactRepositoryImpl.java

Modified: incubator/ace/trunk/ace-client-repository-configuration/osgi.bnd
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-repository-configuration/osgi.bnd?rev=1042666&r1=1042665&r2=1042666&view=diff
==============================================================================
--- incubator/ace/trunk/ace-client-repository-configuration/osgi.bnd (original)
+++ incubator/ace/trunk/ace-client-repository-configuration/osgi.bnd Mon Dec  6 14:55:12 2010
@@ -10,3 +10,5 @@ Bundle-SymbolicName:\
 Export-Package:\
   ${bundle.namespace}; version="${pom.version}"
 
+Deployment-ProvidesResourceProcessor:\
+  org.osgi.deployment.rp.autoconf
\ No newline at end of file

Modified: incubator/ace/trunk/ace-client-repository-helper-base/osgi.bnd
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-repository-helper-base/osgi.bnd?rev=1042666&r1=1042665&r2=1042666&view=diff
==============================================================================
--- incubator/ace/trunk/ace-client-repository-helper-base/osgi.bnd (original)
+++ incubator/ace/trunk/ace-client-repository-helper-base/osgi.bnd Mon Dec  6 14:55:12 2010
@@ -50,4 +50,4 @@ Import-Package: \
 	*
 
 Embed-Dependency: \
-	velocity, xpp3
+	velocity, xpp3, commons-collections, commons-lang

Modified: incubator/ace/trunk/ace-client-repository-helper-base/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-repository-helper-base/pom.xml?rev=1042666&r1=1042665&r2=1042666&view=diff
==============================================================================
--- incubator/ace/trunk/ace-client-repository-helper-base/pom.xml (original)
+++ incubator/ace/trunk/ace-client-repository-helper-base/pom.xml Mon Dec  6 14:55:12 2010
@@ -78,6 +78,16 @@
             <artifactId>velocity</artifactId>
         </dependency>
         <dependency>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
+            <version>3.2</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.4</version>
+        </dependency>
+        <dependency>
             <groupId>xpp3</groupId>
             <artifactId>xpp3</artifactId>
             <version>1.1.4c</version>

Modified: incubator/ace/trunk/ace-client-repository-helper-base/src/main/java/org/apache/ace/client/repository/helper/base/VelocityArtifactPreprocessor.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-repository-helper-base/src/main/java/org/apache/ace/client/repository/helper/base/VelocityArtifactPreprocessor.java?rev=1042666&r1=1042665&r2=1042666&view=diff
==============================================================================
--- incubator/ace/trunk/ace-client-repository-helper-base/src/main/java/org/apache/ace/client/repository/helper/base/VelocityArtifactPreprocessor.java
(original)
+++ incubator/ace/trunk/ace-client-repository-helper-base/src/main/java/org/apache/ace/client/repository/helper/base/VelocityArtifactPreprocessor.java
Mon Dec  6 14:55:12 2010
@@ -217,7 +217,6 @@ public class VelocityArtifactPreprocesso
         }
 
         // process the template
-
         // first check: did we need any processing at all?
         if (Arrays.equals(result, input)) {
             return false;

Modified: incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactRepositoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactRepositoryImpl.java?rev=1042666&r1=1042665&r2=1042666&view=diff
==============================================================================
--- incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactRepositoryImpl.java
(original)
+++ incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/ArtifactRepositoryImpl.java
Mon Dec  6 14:55:12 2010
@@ -32,17 +32,13 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.ace.client.repository.RepositoryObject;
 import org.apache.ace.client.repository.RepositoryUtil;
 import org.apache.ace.client.repository.helper.ArtifactHelper;
 import org.apache.ace.client.repository.helper.ArtifactPreprocessor;
 import org.apache.ace.client.repository.helper.ArtifactRecognizer;
-import org.apache.ace.client.repository.helper.PropertyResolver;
 import org.apache.ace.client.repository.helper.bundle.BundleHelper;
 import org.apache.ace.client.repository.object.ArtifactObject;
 import org.apache.ace.client.repository.object.GatewayObject;
-import org.apache.ace.client.repository.object.GroupObject;
-import org.apache.ace.client.repository.object.LicenseObject;
 import org.apache.ace.client.repository.repository.ArtifactRepository;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
@@ -495,70 +491,7 @@ public class ArtifactRepositoryImpl exte
             return preprocessor.needsNewVersion(artifact.getURL(), new GatewayPropertyResolver(gateway),
gatewayID, fromVersion);
         }
     }
-
-    private static class GatewayPropertyResolver implements PropertyResolver {
-
-        private final GatewayObject m_go;
-
-        public GatewayPropertyResolver(GatewayObject go) {
-            m_go = go;
-        }
-
-        public String get(String key) {
-            return get(key, m_go);
-        }
-
-        private String get(String key, RepositoryObject ro) {
-            // Is it in this object?
-            String result = findKeyInObject(ro, key);
-            if (result != null) {
-                return result;
-            }
-
-            // Is it in one of the children?
-            List<RepositoryObject> children = getChildren(ro);
-            for (RepositoryObject child : children) {
-                result = findKeyInObject(child, key);
-                if (result != null) {
-                    return result;
-                }
-            }
-
-            // Not found yet? then continue to the next level recursively.
-            for (RepositoryObject child : children) {
-                result = get(key, child);
-                if (result != null) {
-                    return result;
-                }
-            }
-            return result;
-        }
-
-        private List getChildren(RepositoryObject ob) {
-            if (ob instanceof GatewayObject) {
-                return ((GatewayObject) ob).getLicenses();
-            }
-            else if (ob instanceof LicenseObject) {
-                return ((LicenseObject) ob).getGroups();
-            }
-            else if (ob instanceof GroupObject) {
-                return ((GroupObject) ob).getArtifacts();
-            }
-            return new ArrayList();
-        }
-
-        private String findKeyInObject(RepositoryObject ro, String key) {
-            String result;
-            if ((result = ro.getAttribute(key)) != null) {
-                return result;
-            }
-            if ((result = ro.getTag(key)) != null) {
-                return result;
-            }
-            return null;
-        }
-
-    }
+    
 
     public URL getObrBase() {
         return m_obrBase;

Added: incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/GatewayPropertyResolver.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/GatewayPropertyResolver.java?rev=1042666&view=auto
==============================================================================
--- incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/GatewayPropertyResolver.java
(added)
+++ incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/GatewayPropertyResolver.java
Mon Dec  6 14:55:12 2010
@@ -0,0 +1,81 @@
+package org.apache.ace.client.repository.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.ace.client.repository.RepositoryObject;
+import org.apache.ace.client.repository.helper.PropertyResolver;
+import org.apache.ace.client.repository.object.GatewayObject;
+
+
+
+/**
+ * 
+ * Top-level property resolver, also able to return collections
+ * of distributions, features and artifacts linked to this target
+ * repository object.
+ * 
+ * 
+ * @author dennisg
+ *
+ */
+public class GatewayPropertyResolver extends RepoPropertyResolver {
+
+		
+        public GatewayPropertyResolver(GatewayObject go) {
+        	super(go);
+        }
+
+
+        public Collection<PropertyResolver> getDistributions() {
+        	List<PropertyResolver> list = new ArrayList<PropertyResolver>();
+        	
+        	List<RepositoryObject> distributions = (List<RepositoryObject>)getChildren();
+        	
+        	for (RepositoryObject repo : distributions) {
+				list.add(new RepoPropertyResolver(repo));
+			}
+        	
+        	return list;
+        }
+        
+        public Collection<PropertyResolver> getFeatures() {
+        	List<PropertyResolver> list = new ArrayList<PropertyResolver>();
+        	
+        	List<RepositoryObject> features = new ArrayList<RepositoryObject>();
+        	
+        	for (RepositoryObject repositoryObject : getChildren()) {
+        		features.addAll(getChildren(repositoryObject));
+			}
+        	
+        	for (RepositoryObject repo : features) {
+				list.add(new RepoPropertyResolver(repo));
+			}
+        	return list;
+        }
+        
+        public Collection<PropertyResolver> getArtifacts() {
+        	List<PropertyResolver> list = new ArrayList<PropertyResolver>();
+        	
+        	List<RepositoryObject> artifacts = new ArrayList<RepositoryObject>();
+        	
+        	
+        	List<RepositoryObject> features = new ArrayList<RepositoryObject>();
+        	
+        	for (RepositoryObject repositoryObject : getChildren()) {
+        		features.addAll(getChildren(repositoryObject));
+			}        	
+        	
+        	for (RepositoryObject repositoryObject : features) {
+				artifacts.addAll(getChildren(repositoryObject));
+			}
+        	
+        	
+        	for (RepositoryObject repo : artifacts) {
+				list.add(new RepoPropertyResolver(repo));
+			}
+        	return list;
+        }
+
+}

Added: incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/RepoPropertyResolver.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/RepoPropertyResolver.java?rev=1042666&view=auto
==============================================================================
--- incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/RepoPropertyResolver.java
(added)
+++ incubator/ace/trunk/ace-client-repository-impl/src/main/java/org/apache/ace/client/repository/impl/RepoPropertyResolver.java
Mon Dec  6 14:55:12 2010
@@ -0,0 +1,88 @@
+package org.apache.ace.client.repository.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ace.client.repository.RepositoryObject;
+import org.apache.ace.client.repository.helper.PropertyResolver;
+import org.apache.ace.client.repository.object.GatewayObject;
+import org.apache.ace.client.repository.object.GroupObject;
+import org.apache.ace.client.repository.object.LicenseObject;
+
+/**
+ * 
+ * This PropertyResolver first tries to resolve the key in the
+ * current repository object. If not found, it looks for the key
+ * in its children. 
+ * 
+ * @author dennisg
+ *
+ */
+public class RepoPropertyResolver implements PropertyResolver {
+	
+	private final RepositoryObject m_repo;
+	
+	public RepoPropertyResolver(RepositoryObject obj) {
+		m_repo = obj;
+	}
+	
+    public String get(String key) {
+		return get(key, m_repo);
+    }
+
+    private String get(String key, RepositoryObject ro) {
+        // Is it in this object?
+        String result = findKeyInObject(ro, key);
+        if (result != null) {
+            return result;
+        }
+
+        // Is it in one of the children?
+        List<? extends RepositoryObject> children = getChildren(ro);
+        for (RepositoryObject child : children) {
+            result = findKeyInObject(child, key);
+            if (result != null) {
+                return result;
+            }
+        }
+
+        // Not found yet? then continue to the next level recursively.
+        for (RepositoryObject child : children) {
+            result = get(key, child);
+            if (result != null) {
+                return result;
+            }
+        }
+        return result;
+    }
+
+    protected List<? extends RepositoryObject> getChildren() {
+    	return getChildren(m_repo);
+    }
+    
+    protected List<? extends RepositoryObject> getChildren(RepositoryObject ob) {
+        if (ob instanceof GatewayObject) {
+            return ((GatewayObject) ob).getLicenses();
+        }
+        else if (ob instanceof LicenseObject) {
+            return ((LicenseObject) ob).getGroups();
+        }
+        else if (ob instanceof GroupObject) {
+            return ((GroupObject) ob).getArtifacts();
+        }
+        return new ArrayList<RepositoryObject>();
+    }
+
+    private String findKeyInObject(RepositoryObject ro, String key) {
+        String result;
+        if ((result = ro.getAttribute(key)) != null) {
+            return result;
+        }
+        if ((result = ro.getTag(key)) != null) {
+            return result;
+        }
+        return null;
+    }	
+}
+
+



Mime
View raw message