ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1056288 - in /ant/ivy/core/trunk: src/java/org/apache/ivy/osgi/updatesite/ src/java/org/apache/ivy/osgi/updatesite/xml/ test/java/org/apache/ivy/osgi/updatesite/
Date Fri, 07 Jan 2011 12:39:33 GMT
Author: hibou
Date: Fri Jan  7 12:39:32 2011
New Revision: 1056288

URL: http://svn.apache.org/viewvc?rev=1056288&view=rev
Log:
Add a first implementation of a parser of an Eclipse update site

Added:
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/PluginAdapter.java   (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteDescriptor.java   (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java   (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/Archive.java   (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/CategoryDef.java   (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseFeature.java   (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipsePlugin.java   (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseUpdateSiteParser.java   (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/FeatureParser.java   (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/Require.java   (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSite.java   (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSiteDigestParser.java   (with props)
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/
    ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoaderTest.java   (with props)

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/PluginAdapter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/PluginAdapter.java?rev=1056288&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/PluginAdapter.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/PluginAdapter.java Fri Jan  7 12:39:32 2011
@@ -0,0 +1,80 @@
+/*
+ *  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.ivy.osgi.updatesite;
+
+import java.util.Iterator;
+
+import org.apache.ivy.osgi.core.BundleInfo;
+import org.apache.ivy.osgi.core.BundleRequirement;
+import org.apache.ivy.osgi.updatesite.xml.EclipseFeature;
+import org.apache.ivy.osgi.updatesite.xml.EclipsePlugin;
+import org.apache.ivy.osgi.updatesite.xml.Require;
+import org.apache.ivy.osgi.util.VersionRange;
+
+public class PluginAdapter {
+
+    public static BundleInfo featureAsBundle(String baseUrl, EclipseFeature feature) {
+        BundleInfo b = new BundleInfo(feature.getId(), feature.getVersion());
+
+        if (feature.getUrl() == null) {
+            b.setUri(baseUrl + "features/" + feature.getId() + '_' + feature.getVersion() + ".jar");
+        } else {
+            b.setUri(baseUrl + feature.getUrl());
+        }
+
+        b.setDescription(feature.getDescription());
+        b.setLicense(feature.getLicense());
+
+        Iterator itPlugins = feature.getPlugins().iterator();
+        while (itPlugins.hasNext()) {
+            EclipsePlugin plugin = (EclipsePlugin) itPlugins.next();
+            BundleRequirement r = new BundleRequirement(BundleInfo.BUNDLE_TYPE, plugin.getId(),
+                    new VersionRange(plugin.getVersion()), null);
+            b.addRequirement(r);
+        }
+
+        Iterator itRequires = feature.getRequires().iterator();
+        while (itRequires.hasNext()) {
+            Require require = (Require) itRequires.next();
+            String id;
+            if (require.getPlugin() != null) {
+                id = require.getPlugin();
+            } else {
+                id = require.getFeature();
+            }
+            VersionRange range;
+            if (require.getMatch().equals("greaterOrEqual")) {
+                range = new VersionRange(require.getVersion());
+            } else {
+                throw new IllegalStateException("unsupported match " + require.getMatch());
+            }
+            BundleRequirement r = new BundleRequirement(BundleInfo.BUNDLE_TYPE, id, range, null);
+            b.addRequirement(r);
+        }
+
+        return b;
+    }
+
+    public static BundleInfo pluginAsBundle(String baseUrl, EclipsePlugin plugin) {
+        BundleInfo b = new BundleInfo(plugin.getId(), plugin.getVersion());
+
+        b.setUri(baseUrl + "plugins/" + plugin.getId() + '_' + plugin.getVersion() + ".jar");
+
+        return b;
+    }
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/PluginAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/PluginAdapter.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/PluginAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteDescriptor.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteDescriptor.java?rev=1056288&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteDescriptor.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteDescriptor.java Fri Jan  7 12:39:32 2011
@@ -0,0 +1,42 @@
+/*
+ *  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.ivy.osgi.updatesite;
+
+import java.util.Iterator;
+
+import org.apache.ivy.osgi.core.ExecutionEnvironmentProfileProvider;
+import org.apache.ivy.osgi.repo.RepoDescriptor;
+import org.apache.ivy.osgi.updatesite.xml.EclipseFeature;
+import org.apache.ivy.osgi.updatesite.xml.EclipsePlugin;
+
+public class UpdateSiteDescriptor extends RepoDescriptor {
+
+    public UpdateSiteDescriptor(ExecutionEnvironmentProfileProvider profileProvider) {
+        super(profileProvider);
+    }
+
+    public void addFeature(String baseUrl, EclipseFeature feature) {
+        addBundle(PluginAdapter.featureAsBundle(baseUrl, feature));
+
+        Iterator itPlugins = feature.getPlugins().iterator();
+        while (itPlugins.hasNext()) {
+            addBundle(PluginAdapter.pluginAsBundle(baseUrl, (EclipsePlugin) itPlugins.next()));
+        }
+    }
+
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteDescriptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteDescriptor.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteDescriptor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java?rev=1056288&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java Fri Jan  7 12:39:32 2011
@@ -0,0 +1,208 @@
+/*
+ *  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.ivy.osgi.updatesite;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.text.ParseException;
+import java.util.Iterator;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import org.apache.ivy.osgi.core.ExecutionEnvironmentProfileProvider;
+import org.apache.ivy.osgi.p2.P2ArtifactParser;
+import org.apache.ivy.osgi.p2.P2Descriptor;
+import org.apache.ivy.osgi.p2.P2MetadataParser;
+import org.apache.ivy.osgi.p2.XMLInputParser;
+import org.apache.ivy.osgi.repo.RepoDescriptor;
+import org.apache.ivy.osgi.updatesite.xml.EclipseFeature;
+import org.apache.ivy.osgi.updatesite.xml.EclipseUpdateSiteParser;
+import org.apache.ivy.osgi.updatesite.xml.FeatureParser;
+import org.apache.ivy.osgi.updatesite.xml.UpdateSite;
+import org.apache.ivy.osgi.updatesite.xml.UpdateSiteDigestParser;
+import org.xml.sax.SAXException;
+
+public class UpdateSiteLoader {
+
+    public RepoDescriptor load(String url) throws IOException, ParseException, SAXException {
+        // first look for a p2 repository
+        RepoDescriptor repo = loadP2(url);
+        if (repo != null) {
+            return repo;
+        }
+        // then try the old update site
+        UpdateSite site = loadSite(url);
+        repo = loadFromDigest(site);
+        if (repo != null) {
+            return repo;
+        }
+        return loadFromSite(site);
+    }
+
+    private P2Descriptor loadP2(String url) throws IOException, ParseException, SAXException {
+        P2Descriptor p2Descriptor = new P2Descriptor(
+                ExecutionEnvironmentProfileProvider.getInstance());
+
+        if (!readJarOrXml(url, "artifacts", new P2ArtifactParser(p2Descriptor))) {
+            return null;
+        }
+
+        if (!readJarOrXml(url, "content", new P2MetadataParser(p2Descriptor))) {
+            return null;
+        }
+
+        return p2Descriptor;
+    }
+
+    private boolean readJarOrXml(String url, String baseName, XMLInputParser reader)
+            throws IOException, ParseException, SAXException {
+        URL contentUrl = new URL(url + baseName + ".jar");
+        InputStream in;
+        InputStream readIn = null; // the input stream from which the xml should be read
+        try {
+            in = contentUrl.openStream();
+        } catch (FileNotFoundException e) {
+            // no jar file, try the xml one
+            contentUrl = new URL(url + baseName + ".xml");
+            try {
+                in = contentUrl.openStream();
+            } catch (FileNotFoundException e2) {
+                // no xml either
+                return false;
+            }
+            // we will then read directly from that input stream
+            readIn = in;
+        }
+        try {
+            if (readIn == null) {
+                // compressed, let's get the pointer on the actual xml
+                readIn = findEntry(in, baseName + ".xml");
+                if (readIn == null) {
+                    return false;
+                }
+            }
+            reader.parse(readIn);
+            return true;
+        } finally {
+            in.close();
+        }
+    }
+
+    private UpdateSite loadSite(String url) throws IOException, ParseException, SAXException {
+        String siteUrl = normalizeSiteUrl(url, null);
+        URL u = new URL(siteUrl + "site.xml");
+        InputStream in = u.openStream();
+        try {
+            UpdateSite site = EclipseUpdateSiteParser.parse(in);
+            site.setUrl(normalizeSiteUrl(site.getUrl(), siteUrl));
+            return site;
+        } finally {
+            in.close();
+        }
+    }
+
+    private String normalizeSiteUrl(String url, String defaultValue) {
+        if (url == null) {
+            return defaultValue;
+        }
+        if (url.endsWith("site.xml")) {
+            return url.substring(0, url.length() - 8);
+        }
+        if (!url.endsWith("/")) {
+            return url + "/";
+        }
+        return url;
+    }
+
+    private UpdateSiteDescriptor loadFromDigest(UpdateSite site) throws IOException,
+            ParseException, SAXException {
+        String baseUrl = site.getDigestURL();
+        String siteUrl = site.getUrl();
+        if (baseUrl == null) {
+            baseUrl = siteUrl;
+        } else if (baseUrl.startsWith(".")) {
+            if (baseUrl.length() > 1 && baseUrl.charAt(1) == '/') {
+                baseUrl = siteUrl + baseUrl.substring(2);
+            } else {
+                baseUrl = siteUrl + baseUrl.substring(1);
+            }
+        }
+        String digestUrl;
+        if (baseUrl.endsWith("/")) {
+            digestUrl = baseUrl + "digest.zip";
+        } else {
+            digestUrl = baseUrl + "/digest.zip";
+        }
+        URL digest = new URL(digestUrl);
+        InputStream in;
+        try {
+            in = digest.openStream();
+        } catch (FileNotFoundException e) {
+            return null;
+        }
+        try {
+            ZipInputStream zipped = findEntry(in, "digest.xml");
+            if (zipped == null) {
+                return null;
+            }
+            return UpdateSiteDigestParser.parse(zipped, site);
+        } finally {
+            in.close();
+        }
+    }
+
+    private UpdateSiteDescriptor loadFromSite(UpdateSite site) throws IOException, ParseException,
+            SAXException {
+        UpdateSiteDescriptor repoDescriptor = new UpdateSiteDescriptor(
+                ExecutionEnvironmentProfileProvider.getInstance());
+
+        Iterator itFeatures = site.getFeatures().iterator();
+        while (itFeatures.hasNext()) {
+            EclipseFeature feature = (EclipseFeature) itFeatures.next();
+            URL url = new URL(site.getUrl() + feature.getUrl());
+            InputStream in = url.openStream();
+            try {
+                ZipInputStream zipped = findEntry(in, "feature.xml");
+                if (zipped == null) {
+                    return null;
+                }
+                EclipseFeature f = FeatureParser.parse(zipped);
+                f.setURL(feature.getUrl());
+                repoDescriptor.addFeature(site.getUrl(), f);
+            } finally {
+                in.close();
+            }
+        }
+
+        return repoDescriptor;
+    }
+
+    private ZipInputStream findEntry(InputStream in, String entryName) throws IOException {
+        ZipInputStream zipped = new ZipInputStream(in);
+        ZipEntry zipEntry = zipped.getNextEntry();
+        while (zipEntry != null && !zipEntry.getName().equals(entryName)) {
+            zipEntry = zipped.getNextEntry();
+        }
+        if (zipEntry == null) {
+            return null;
+        }
+        return zipped;
+    }
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/Archive.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/Archive.java?rev=1056288&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/Archive.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/Archive.java Fri Jan  7 12:39:32 2011
@@ -0,0 +1,34 @@
+/*
+ *  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.ivy.osgi.updatesite.xml;
+
+public class Archive {
+
+    public void setPath(String path) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void setURL(String url) {
+        // TODO Auto-generated method stub
+        
+    }
+    
+    
+
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/Archive.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/Archive.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/Archive.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/CategoryDef.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/CategoryDef.java?rev=1056288&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/CategoryDef.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/CategoryDef.java Fri Jan  7 12:39:32 2011
@@ -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.ivy.osgi.updatesite.xml;
+
+public class CategoryDef {
+
+    public void setLabel(String label) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void setName(String name) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void setDescription(String trim) {
+        // TODO Auto-generated method stub
+        
+    }
+
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/CategoryDef.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/CategoryDef.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/CategoryDef.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseFeature.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseFeature.java?rev=1056288&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseFeature.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseFeature.java Fri Jan  7 12:39:32 2011
@@ -0,0 +1,176 @@
+/*
+ *  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.ivy.osgi.updatesite.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ivy.osgi.util.Version;
+
+public class EclipseFeature {
+
+    private String id;
+
+    private Version version;
+
+    private List/* <EclipsePlugin> */plugins = new ArrayList();
+
+    private List/* <Require> */requires = new ArrayList();
+
+    private String url;
+
+    private String description;
+
+    private String license;
+
+    public EclipseFeature(String id, Version version) {
+        this.id = id;
+        this.version = version;
+        this.url = "features/" + id + '_' + version + ".jar";
+    }
+
+    public void setURL(String url) {
+        this.url = url;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setType(String type) {
+        // TODO Auto-generated method stub
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public Version getVersion() {
+        return version;
+    }
+
+    public void setLabel(String label) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setOS(String os) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setWS(String ws) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setNL(String nl) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setArch(String arch) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setPatch(String patch) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void addCategory(String name) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setCopyright(String trim) {
+        // not useful
+    }
+
+    public void setLicense(String license) {
+        this.license = license;
+    }
+
+    public String getLicense() {
+        return license;
+    }
+
+    public void addPlugin(EclipsePlugin plugin) {
+        plugins.add(plugin);
+    }
+
+    public List getPlugins() {
+        return plugins;
+    }
+
+    public void addRequire(Require require) {
+        requires.add(require);
+    }
+
+    public List getRequires() {
+        return requires;
+    }
+
+    public void setApplication(String value) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setPlugin(String value) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setExclusive(boolean booleanValue) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setPrimary(boolean booleanValue) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setColocationAffinity(String value) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setProviderName(String value) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setImage(String value) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public String toString() {
+        return id + "#" + version;
+    }
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseFeature.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseFeature.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseFeature.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipsePlugin.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipsePlugin.java?rev=1056288&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipsePlugin.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipsePlugin.java Fri Jan  7 12:39:32 2011
@@ -0,0 +1,59 @@
+/*
+ *  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.ivy.osgi.updatesite.xml;
+
+import org.apache.ivy.osgi.util.Version;
+
+public class EclipsePlugin {
+
+    private String id;
+
+    private Version version;
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setVersion(Version version) {
+        this.version = version;
+    }
+
+    public Version getVersion() {
+        return version;
+    }
+
+    public void setUnpack(boolean valueOf) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setFragment(String value) {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void setFilter(String value) {
+        // TODO Auto-generated method stub
+
+    }
+
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipsePlugin.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipsePlugin.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipsePlugin.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseUpdateSiteParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseUpdateSiteParser.java?rev=1056288&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseUpdateSiteParser.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseUpdateSiteParser.java Fri Jan  7 12:39:32 2011
@@ -0,0 +1,257 @@
+/*
+ *  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.ivy.osgi.updatesite.xml;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.ParseException;
+import java.util.ArrayList;
+
+import org.apache.ivy.osgi.util.DelegetingHandler;
+import org.apache.ivy.osgi.util.Version;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+public class EclipseUpdateSiteParser {
+
+    public static UpdateSite parse(InputStream in) throws ParseException, IOException, SAXException {
+        XMLReader reader = XMLReaderFactory.createXMLReader();
+        SiteHandler handler = new SiteHandler();
+        reader.setContentHandler(handler);
+        reader.parse(new InputSource(in));
+        return handler.updatesite;
+    }
+
+    static class SiteHandler extends DelegetingHandler {
+
+        private static final String SITE = "site";
+
+        private static final String URL = "url";
+
+        private static final String PACK200 = "pack200";
+
+        private static final String MIRRORS_URL = "mirrorsURL";
+
+        private static final String ASSOCIATE_SITES_URL = "associateSitesURL";
+
+        private static final String DIGEST_URL = "digestURL";
+
+        UpdateSite updatesite;
+
+        public SiteHandler() {
+            super(SITE);
+            // addChild(new DescriptionHandler(), new ChildElementHandler() {
+            // public void childHanlded(DelegetingHandler child) {
+            // updateSite.setDescription(child.getBufferedChars().trim());
+            // }
+            // });
+            addChild(new FeatureHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    updatesite.addFeature(((FeatureHandler) child).feature);
+                }
+            });
+            // addChild(new ArchiveHandler(), new ChildElementHandler() {
+            // public void childHanlded(DelegetingHandler child) {
+            // updateSite.addArchive(((ArchiveHandler) child).archive);
+            // }
+            // });
+            // addChild(new CategoryDefHandler(), new ChildElementHandler() {
+            // public void childHanlded(DelegetingHandler child) {
+            // updateSite.addCategoryDef(((CategoryDefHandler) child).categoryDef);
+            // }
+            // });
+        }
+
+        protected void handleAttributes(Attributes atts) {
+            String url = atts.getValue(URL);
+            if (url != null && !("".equals(url.trim()))) {
+                if (!url.endsWith("/") && !url.endsWith(File.separator)) {
+                    url += "/";
+                }
+                updatesite.setUrl(url);
+            }
+
+            String mirrorsURL = atts.getValue(MIRRORS_URL);
+            if (mirrorsURL != null && mirrorsURL.trim().length() > 0) {
+                updatesite.setMirrorsURL(mirrorsURL);
+            }
+
+            String pack200 = atts.getValue(PACK200);
+            if (pack200 != null && new Boolean(pack200).booleanValue()) {
+                updatesite.setPack200(true);
+            }
+
+            String digestURL = atts.getValue(DIGEST_URL);
+            if (digestURL != null) {
+                updatesite.setDigestURL(digestURL);
+            }
+
+            String associateSitesURL = atts.getValue(ASSOCIATE_SITES_URL);
+            if (associateSitesURL != null) {
+                updatesite.setAssociateSitesURL(associateSitesURL);
+            }
+        }
+    }
+
+    static class DescriptionHandler extends DelegetingHandler {
+
+        private static final String DESCRIPTION = "description";
+
+        private static final String URL = "url";
+
+        public DescriptionHandler() {
+            super(DESCRIPTION);
+            setBufferingChar(true);
+        }
+
+        protected void handleAttributes(Attributes atts) {
+            String url = atts.getValue(URL);
+        }
+    }
+
+    static class FeatureHandler extends DelegetingHandler {
+
+        private static final String FEATURE = "feature";
+
+        private static final String VERSION = "version";
+
+        private static final String ID = "id";
+
+        private static final String URL = "url";
+
+        private static final String PATCH = "patch";
+
+        private static final String ARCH = "arch";
+
+        private static final String NL = "nl";
+
+        private static final String WS = "ws";
+
+        private static final String OS = "os";
+
+        private static final String LABEL = "label";
+
+        private static final String TYPE = "type";
+
+        private EclipseFeature feature;
+
+        public FeatureHandler() {
+            super(FEATURE);
+            addChild(new CategoryHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    feature.addCategory(((CategoryHandler) child).name);
+                }
+            });
+        }
+
+        protected void handleAttributes(Attributes atts) throws SAXException {
+            feature = new EclipseFeature(atts.getValue(ID), new Version(atts.getValue(VERSION)));
+
+            String url = atts.getValue(URL);
+            if (url != null) {
+                feature.setURL(url);
+            }
+            feature.setType(atts.getValue(TYPE));
+            feature.setLabel(atts.getValue(LABEL));
+            feature.setOS(atts.getValue(OS));
+            feature.setWS(atts.getValue(WS));
+            feature.setNL(atts.getValue(NL));
+            feature.setArch(atts.getValue(ARCH));
+            feature.setPatch(atts.getValue(PATCH));
+        }
+
+    }
+
+    static class CategoryHandler extends DelegetingHandler {
+
+        private static final String CATEGORY = "category";
+
+        private static final String NAME = "name";
+
+        String name;
+
+        public CategoryHandler() {
+            super(CATEGORY);
+        }
+
+        protected void handleAttributes(Attributes atts) throws SAXException {
+            name = atts.getValue(NAME);
+        }
+    }
+
+    static class ArchiveHandler extends DelegetingHandler {
+
+        private static final String ARCHIVE = "archive";
+
+        private static final String URL = "url";
+
+        private static final String PATH = "path";
+
+        private Archive archive;
+
+        public ArchiveHandler() {
+            super(ARCHIVE);
+        }
+
+        protected void handleAttributes(Attributes atts) throws SAXException {
+            archive = new Archive();
+
+            String path = atts.getValue(PATH);
+            archive.setPath(path);
+
+            String url = atts.getValue(URL);
+            archive.setURL(url);
+
+        }
+    }
+
+    static class CategoryDefHandler extends DelegetingHandler {
+
+        private static final String CATEGORY_DEF = "category-def";
+
+        private static final String NAME = "name";
+
+        private static final String LABEL = "label";
+
+        private CategoryDef categoryDef;
+
+        public CategoryDefHandler() {
+            super(CATEGORY_DEF);
+            addChild(new DescriptionHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    categoryDef.setDescription(child.getBufferedChars().trim());
+                }
+            });
+        }
+
+        protected void handleAttributes(Attributes atts) throws SAXException {
+            categoryDef = new CategoryDef();
+
+            String name = atts.getValue(NAME);
+            categoryDef.setName(name);
+
+            String label = atts.getValue(LABEL);
+            categoryDef.setLabel(label);
+        }
+    }
+
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseUpdateSiteParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseUpdateSiteParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/EclipseUpdateSiteParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/FeatureParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/FeatureParser.java?rev=1056288&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/FeatureParser.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/FeatureParser.java Fri Jan  7 12:39:32 2011
@@ -0,0 +1,373 @@
+/*
+ *  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.ivy.osgi.updatesite.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.ivy.osgi.util.DelegetingHandler;
+import org.apache.ivy.osgi.util.Version;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+public class FeatureParser {
+
+    public static EclipseFeature parse(InputStream in) throws ParseException, IOException,
+            SAXException {
+        XMLReader reader;
+        try {
+            reader = XMLReaderFactory.createXMLReader();
+        } catch (SAXException e) {
+            throw new ParseException(e.getMessage(), 0);
+        }
+        FeatureHandler handler = new FeatureHandler();
+        reader.setContentHandler(handler);
+        reader.parse(new InputSource(in));
+        return handler.feature;
+    }
+
+    static class FeatureHandler extends DelegetingHandler {
+
+        private static final String FEATURE = "feature";
+
+        private static final String COLOCATION_AFFINITY = "colocation-affinity";
+
+        private static final String PRIMARY = "primary";
+
+        private static final String EXCLUSIVE = "exclusive";
+
+        private static final String PLUGIN = "plugin";
+
+        private static final String APPLICATION = "application";
+
+        private static final String ARCH = "arch";
+
+        private static final String NL = "nl";
+
+        private static final String WS = "ws";
+
+        private static final String OS = "os";
+
+        private static final String VERSION = "version";
+
+        private static final String ID = "id";
+
+        private static final String PROVIDER_NAME = "provider-name";
+
+        private static final String LABEL = "label";
+
+        private static final String IMAGE = "image";
+
+        EclipseFeature feature;
+
+        public FeatureHandler() {
+            super(FEATURE);
+            addChild(new DescriptionHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    feature.setDescription(child.getBufferedChars().trim());
+                }
+            });
+            addChild(new LicenseHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    feature.setLicense(child.getBufferedChars().trim());
+                }
+            });
+            addChild(new CopyrightHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    feature.setCopyright(child.getBufferedChars().trim());
+                }
+            });
+            addChild(new PluginHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    feature.addPlugin(((PluginHandler) child).plugin);
+                }
+            });
+            addChild(new RequiresHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    Iterator itRequire = ((RequiresHandler) child).requires.iterator();
+                    while (itRequire.hasNext()) {
+                        feature.addRequire((Require) itRequire.next());
+                    }
+                }
+            });
+            addChild(new UrlHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                }
+            });
+        }
+
+        protected void handleAttributes(Attributes atts) throws SAXException {
+            feature = new EclipseFeature(atts.getValue(ID), new Version(atts.getValue(VERSION)));
+
+            feature.setOS(atts.getValue(OS));
+            feature.setWS(atts.getValue(WS));
+            feature.setNL(atts.getValue(NL));
+            feature.setArch(atts.getValue(ARCH));
+            feature.setApplication(atts.getValue(APPLICATION));
+            feature.setPlugin(atts.getValue(PLUGIN));
+            feature.setExclusive(Boolean.valueOf(atts.getValue(EXCLUSIVE)).booleanValue());
+            feature.setPrimary(Boolean.valueOf(atts.getValue(PRIMARY)).booleanValue());
+            feature.setColocationAffinity(atts.getValue(COLOCATION_AFFINITY));
+            feature.setProviderName(atts.getValue(PROVIDER_NAME));
+            feature.setLabel(atts.getValue(LABEL));
+            feature.setImage(atts.getValue(IMAGE));
+        }
+
+    }
+
+    static class PluginHandler extends DelegetingHandler {
+
+        private static final String PLUGIN = "plugin";
+
+        private static final String FILTER = "filter";
+
+        private static final String FRAGMENT = "fragment";
+
+        private static final String UNPACK = "unpack";
+
+        private static final String VERSION = "version";
+
+        private static final String ID = "id";
+
+        private EclipsePlugin plugin;
+
+        public PluginHandler() {
+            super(PLUGIN);
+        }
+
+        protected void handleAttributes(Attributes atts) throws SAXException {
+            plugin = new EclipsePlugin();
+
+            plugin.setId(atts.getValue(ID));
+            plugin.setVersion(new Version(atts.getValue(VERSION)));
+            plugin.setUnpack(Boolean.valueOf(atts.getValue(UNPACK)).booleanValue());
+            plugin.setFragment(atts.getValue(FRAGMENT));
+            plugin.setFilter(atts.getValue(FILTER));
+        }
+    }
+
+    static class DescriptionHandler extends DelegetingHandler {
+
+        private static final String DESCRIPTION = "description";
+
+        private static final String URL = "url";
+
+        public DescriptionHandler() {
+            super(DESCRIPTION);
+            setBufferingChar(true);
+        }
+
+        protected void handleAttributes(Attributes atts) throws SAXException {
+            String url = atts.getValue(URL);
+        }
+    }
+
+    static class LicenseHandler extends DelegetingHandler {
+
+        private static final String LICENSE = "license";
+
+        private static final String URL = "url";
+
+        public LicenseHandler() {
+            super(LICENSE);
+            setBufferingChar(true);
+        }
+
+        protected void handleAttributes(Attributes atts) throws SAXException {
+            String url = atts.getValue(URL);
+        }
+
+    }
+
+    static class CopyrightHandler extends DelegetingHandler {
+
+        private static final String COPYRIGHT = "copyright";
+
+        private static final String URL = "url";
+
+        public CopyrightHandler() {
+            super(COPYRIGHT);
+            setBufferingChar(true);
+        }
+
+        protected void handleAttributes(Attributes atts) throws SAXException {
+            String url = atts.getValue(URL);
+        }
+    }
+
+    static class RequiresHandler extends DelegetingHandler {
+
+        private static final String REQUIRES = "requires";
+
+        List requires = new ArrayList();
+
+        public RequiresHandler() {
+            super(REQUIRES);
+            addChild(new ImportHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    requires.add(((ImportHandler) child).require);
+                }
+            });
+        }
+    }
+
+    static class ImportHandler extends DelegetingHandler {
+
+        Require require;
+
+        private static final String IMPORT = "import";
+
+        private static final String FILTER = "filter";
+
+        private static final String MATCH = "match";
+
+        private static final String VERSION = "version";
+
+        private static final String PLUGIN = "plugin";
+
+        private static final String FEATURE = "feature";
+
+        public ImportHandler() {
+            super(IMPORT);
+        }
+
+        protected void handleAttributes(Attributes atts) throws SAXException {
+            require = new Require();
+
+            require.setFeature(atts.getValue(FEATURE));
+            require.setPlugin(atts.getValue(PLUGIN));
+            require.setVersion(new Version(atts.getValue(VERSION)));
+            require.setMatch(atts.getValue(MATCH));
+            require.setFilter(atts.getValue(FILTER));
+        }
+    }
+
+    static class IncludesHandler extends DelegetingHandler {
+
+        private static final String INCLUDES = "includes";
+
+        private static final String FILTER = "filter";
+
+        private static final String OPTIONAL = "optional";
+
+        private static final String VERSION = "version";
+
+        private static final String ID = "id";
+
+        public IncludesHandler() {
+            super(INCLUDES);
+        }
+
+        protected void handleAttributes(Attributes atts) throws SAXException {
+            String id = atts.getValue(ID);
+            String version = atts.getValue(VERSION);
+            String optional = atts.getValue(OPTIONAL);
+            String filter = atts.getValue(FILTER);
+        }
+
+    }
+
+    static class InstallHandlerHandler extends DelegetingHandler {
+
+        private static final String INSTALL_HANDLER = "install-handler";
+
+        private static final String URL = "url";
+
+        private static final String LIBRARY = "library";
+
+        private static final String HANDLER = "handler";
+
+        public InstallHandlerHandler() {
+            super(INSTALL_HANDLER);
+        }
+
+        protected void handleAttributes(Attributes atts) throws SAXException {
+            String handler = atts.getValue(HANDLER);
+            String library = atts.getValue(LIBRARY);
+            String url = atts.getValue(URL);
+        }
+
+    }
+
+    static class UrlHandler extends DelegetingHandler {
+
+        private static final String URL = "url";
+
+        public UrlHandler() {
+            super(URL);
+            addChild(new UpdateHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                }
+            });
+            addChild(new DiscoveryHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                }
+            });
+        }
+
+    }
+
+    static class UpdateHandler extends DelegetingHandler {
+
+        private static final String UPDATE = "update";
+
+        private static final String LABEL = "label";
+
+        private static final String URL = "url";
+
+        public UpdateHandler() {
+            super(UPDATE);
+        }
+
+        protected void handleAttributes(Attributes atts) throws SAXException {
+            String label = atts.getValue(LABEL);
+            String url = atts.getValue(URL);
+        }
+
+    }
+
+    static class DiscoveryHandler extends DelegetingHandler {
+
+        private static final String DISCOVERY = "discovery";
+
+        private static final String URL = "url";
+
+        private static final String LABEL = "label";
+
+        private static final String TYPE = "type";
+
+        public DiscoveryHandler() {
+            super(DISCOVERY);
+        }
+
+        protected void handleAttributes(Attributes atts) throws SAXException {
+            String type = atts.getValue(TYPE);
+            String label = atts.getValue(LABEL);
+            String url = atts.getValue(URL);
+        }
+
+    }
+
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/FeatureParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/FeatureParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/FeatureParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/Require.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/Require.java?rev=1056288&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/Require.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/Require.java Fri Jan  7 12:39:32 2011
@@ -0,0 +1,73 @@
+/*
+ *  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.ivy.osgi.updatesite.xml;
+
+import org.apache.ivy.osgi.util.Version;
+
+public class Require {
+
+    private String plugin;
+
+    private String feature;
+
+    private Version version;
+
+    private String match;
+
+    private String filter;
+
+    public void setFeature(String feature) {
+        this.feature = feature;
+    }
+
+    public String getFeature() {
+        return feature;
+    }
+
+    public void setPlugin(String plugin) {
+        this.plugin = plugin;
+    }
+
+    public String getPlugin() {
+        return plugin;
+    }
+
+    public void setVersion(Version version) {
+        this.version = version;
+    }
+
+    public Version getVersion() {
+        return version;
+    }
+
+    public void setMatch(String match) {
+        this.match = match;
+    }
+
+    public String getMatch() {
+        return match;
+    }
+
+    public void setFilter(String filter) {
+        this.filter = filter;
+    }
+
+    public String getFilter() {
+        return filter;
+    }
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/Require.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/Require.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/Require.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSite.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSite.java?rev=1056288&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSite.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSite.java Fri Jan  7 12:39:32 2011
@@ -0,0 +1,71 @@
+/*
+ *  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.ivy.osgi.updatesite.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class UpdateSite {
+
+    private String url;
+
+    private String mirrorsURL;
+
+    private boolean pack200;
+
+    private String digestUrl;
+
+    private List/* <EclipseFeature> */features = new ArrayList();
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setMirrorsURL(String mirrorsURL) {
+        this.mirrorsURL = mirrorsURL;
+    }
+
+    public void setPack200(boolean pack200) {
+        this.pack200 = pack200;
+    }
+
+    public void setDigestURL(String digestURL) {
+        this.digestUrl = digestURL;
+    }
+
+    public String getDigestURL() {
+        return digestUrl;
+    }
+
+    public void addFeature(EclipseFeature feature) {
+        features.add(feature);
+    }
+
+    public List getFeatures() {
+        return features;
+    }
+
+    public void setAssociateSitesURL(String associateSitesURL) {
+        // TODO what's that ?
+    }
+
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSite.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSite.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSite.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSiteDigestParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSiteDigestParser.java?rev=1056288&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSiteDigestParser.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSiteDigestParser.java Fri Jan  7 12:39:32 2011
@@ -0,0 +1,62 @@
+/*
+ *  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.ivy.osgi.updatesite.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.ParseException;
+
+import org.apache.ivy.osgi.core.ExecutionEnvironmentProfileProvider;
+import org.apache.ivy.osgi.updatesite.UpdateSiteDescriptor;
+import org.apache.ivy.osgi.updatesite.xml.FeatureParser.FeatureHandler;
+import org.apache.ivy.osgi.util.DelegetingHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+public class UpdateSiteDigestParser {
+
+    public static UpdateSiteDescriptor parse(InputStream in, UpdateSite site)
+            throws ParseException, IOException, SAXException {
+        XMLReader reader = XMLReaderFactory.createXMLReader();
+        DigestHandler handler = new DigestHandler(site);
+        reader.setContentHandler(handler);
+        reader.parse(new InputSource(in));
+        return handler.repoDescriptor;
+    }
+
+    static class DigestHandler extends DelegetingHandler {
+
+        private static final String DIGEST = "digest";
+
+        UpdateSiteDescriptor repoDescriptor = new UpdateSiteDescriptor(
+                ExecutionEnvironmentProfileProvider.getInstance());
+
+        public DigestHandler(final UpdateSite site) {
+            super(DIGEST);
+            addChild(new FeatureHandler(), new ChildElementHandler() {
+                public void childHanlded(DelegetingHandler child) {
+                    repoDescriptor.addFeature(site.getUrl(), ((FeatureHandler) child).feature);
+                }
+            });
+        }
+
+    }
+
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSiteDigestParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSiteDigestParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/xml/UpdateSiteDigestParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoaderTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoaderTest.java?rev=1056288&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoaderTest.java (added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoaderTest.java Fri Jan  7 12:39:32 2011
@@ -0,0 +1,42 @@
+/*
+ *  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.ivy.osgi.updatesite;
+
+import java.io.IOException;
+import java.text.ParseException;
+
+import junit.framework.TestCase;
+
+import org.apache.ivy.osgi.repo.RepoDescriptor;
+import org.xml.sax.SAXException;
+
+public class UpdateSiteLoaderTest extends TestCase {
+
+    public void testIvyDE() throws IOException, ParseException, SAXException {
+        UpdateSiteLoader loader = new UpdateSiteLoader();
+        RepoDescriptor site = loader.load("http://www.apache.org/dist/ant/ivyde/updatesite/");
+        assertEquals(13, site.getModules().size());
+    }
+    
+
+    public void testEclipse() throws IOException, ParseException, SAXException {
+        UpdateSiteLoader loader = new UpdateSiteLoader();
+        RepoDescriptor site = loader.load("http://download.eclipse.org/releases/helios/");
+        assertEquals(13, site.getModules().size());
+    }
+}

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoaderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoaderTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoaderTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message