248778: [releng] backport changes to Eclipse 3.3
https://bugs.eclipse.org/bugs/show_bug.cgi?id=248778
diff --git a/org.eclipse.mylyn.discovery.core/META-INF/MANIFEST.MF b/org.eclipse.mylyn.discovery.core/META-INF/MANIFEST.MF
index 63ae3e0..8a29e42 100644
--- a/org.eclipse.mylyn.discovery.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.discovery.core/META-INF/MANIFEST.MF
@@ -8,6 +8,3 @@
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.3.0",
org.eclipse.mylyn.commons.core;bundle-version="3.1.0",
org.eclipse.mylyn.commons.net;bundle-version="3.1.0"
-Export-Package: org.eclipse.mylyn.internal.discovery.core;x-friends:="org.eclipse.mylyn.discovery.ui",
- org.eclipse.mylyn.internal.discovery.core.model;x-friends:="org.eclipse.mylyn.discovery.ui",
- org.eclipse.mylyn.internal.discovery.core.util;x-friends:="org.eclipse.mylyn.discovery.ui"
diff --git a/org.eclipse.mylyn.discovery.core/build.properties b/org.eclipse.mylyn.discovery.core/build.properties
index ff37585..163f55c 100644
--- a/org.eclipse.mylyn.discovery.core/build.properties
+++ b/org.eclipse.mylyn.discovery.core/build.properties
@@ -12,7 +12,4 @@
output.. = bin/
bin.includes = META-INF/,\
.,\
- plugin.xml,\
- about.html,\
- xsd/,\
- schema/
+ about.html
diff --git a/org.eclipse.mylyn.discovery.core/plugin.xml b/org.eclipse.mylyn.discovery.core/plugin.xml
deleted file mode 100644
index 2e2d22d..0000000
--- a/org.eclipse.mylyn.discovery.core/plugin.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?><!--
- Copyright (c) 2009 Tasktop Technologies and others.
- All rights reserved. This program and the accompanying materials
- are made available under the terms of the Eclipse Public License v1.0
- which accompanies this distribution, and is available at
- http://www.eclipse.org/legal/epl-v10.html
-
- Contributors:
- Tasktop Technologies - initial API and implementation
- -->
-<plugin>
- <extension-point id="connectorDiscovery" name="Connector Discovery" schema="schema/connectorDiscovery.exsd"/>
-
-</plugin>
diff --git a/org.eclipse.mylyn.discovery.core/schema/connectorDiscovery.exsd b/org.eclipse.mylyn.discovery.core/schema/connectorDiscovery.exsd
deleted file mode 100644
index 666f940..0000000
--- a/org.eclipse.mylyn.discovery.core/schema/connectorDiscovery.exsd
+++ /dev/null
@@ -1,323 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.mylyn.discovery.core" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.mylyn.discovery.core" id="connectorDiscovery" name="Connector Discovery"/>
- </appinfo>
- <documentation>
- An extension point for contributing to the Mylyn connector discovery mechanism.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="connectorCategory" minOccurs="0" maxOccurs="unbounded"/>
- <element ref="connectorDescriptor" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="connectorDescriptor">
- <annotation>
- <documentation>
- A description of a connector, including kind, description, licensing and brand.
- </documentation>
- </annotation>
- <complexType>
- <sequence>
- <element ref="icon" minOccurs="0" maxOccurs="1"/>
- <element ref="overview" minOccurs="0" maxOccurs="1"/>
- </sequence>
- <attribute name="kind" use="required">
- <annotation>
- <documentation>
- must be one of 'document', 'task', 'vcs'
- </documentation>
- </annotation>
- <simpleType>
- <restriction base="string">
- <enumeration value="document">
- </enumeration>
- <enumeration value="task">
- </enumeration>
- <enumeration value="vcs">
- </enumeration>
- </restriction>
- </simpleType>
- </attribute>
- <attribute name="name" type="string" use="required">
- <annotation>
- <documentation>
- the name of the connector including the name of the organization that produces the repository if appropriate, for example 'Mozilla Bugzilla'.
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="provider" type="string" use="required">
- <annotation>
- <documentation>
- The name of the organization that supplies the connector.
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="license" type="string" use="required">
- <annotation>
- <documentation>
- The short name of the license, for example 'EPL 1.0', 'GPL 2.0', or 'Commercial'.
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="description" type="string">
- <annotation>
- <documentation>
- A description of the connector. Plug-ins should provide a description, especially if the description is not self-evident from the @name and @organization.
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="siteUrl" type="string" use="required">
- <annotation>
- <documentation>
- The URL of the update site containing the connector.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- The id of the feature that installs this connector
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="categoryId" type="string" use="required">
- <annotation>
- <documentation>
- the id of the connectorCategory in which this connector belongs
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="platformFilter" type="string">
- <annotation>
- <documentation>
- E.g., "(& (osgi.os=macosx) (osgi.ws=carbon))"
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="connectorCategory">
- <annotation>
- <documentation>
- a category of connectors, which is a way of organizing connectors in top-level groups.
- </documentation>
- </annotation>
- <complexType>
- <sequence>
- <element ref="icon" minOccurs="0" maxOccurs="1"/>
- </sequence>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- an id that uniquely identifies the category
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="name" type="string" use="required">
- <annotation>
- <documentation>
- the name of the category, as it is displayed in the ui.
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="description" type="string">
- <annotation>
- <documentation>
- A description of the category
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="icon">
- <complexType>
- <attribute name="image16" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute kind="resource"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="image32" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute kind="resource"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="image48" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute kind="resource"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="image64" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute kind="resource"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="image128" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute kind="resource"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="overview">
- <complexType>
- <attribute name="summary" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="url" type="string">
- <annotation>
- <documentation>
- HTML
- </documentation>
- </annotation>
- </attribute>
- <attribute name="screenshot" type="string">
- <annotation>
- <documentation>
- 320x240 PNG, JPEG or GIF
- </documentation>
- <appinfo>
- <meta.attribute kind="resource"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- 3.2
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="apiinfo"/>
- </appinfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="implementation"/>
- </appinfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
-
-</schema>
diff --git a/org.eclipse.mylyn.discovery.core/src/.placeholder b/org.eclipse.mylyn.discovery.core/src/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/org.eclipse.mylyn.discovery.core/src/.placeholder
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/DiscoveryCore.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/DiscoveryCore.java
deleted file mode 100644
index 7e198be..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/DiscoveryCore.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core;
-
-/**
- *
- * @author David Green
- */
-public abstract class DiscoveryCore {
- public static final String ID_PLUGIN = "org.eclipse.mylyn.discovery.core"; //$NON-NLS-1$
-
- private DiscoveryCore() {
- }
-
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/AbstractDiscoverySource.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/AbstractDiscoverySource.java
deleted file mode 100644
index d1812be..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/AbstractDiscoverySource.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-import java.net.URL;
-
-/**
- *
- * @author David Green
- */
-public abstract class AbstractDiscoverySource {
- /**
- * an identifier that can be used to determine the origin of the source, typically for logging purposes.
- */
- public abstract Object getId();
-
- /**
- * get a resource by an URL relative to the root of the source.
- *
- * @param relativeUrl
- * the relative resource name
- * @return an URL to the resource, or null if it is known that the resource does not exist.
- */
- public abstract URL getResource(String resourceName);
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/AbstractDiscoveryStrategy.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/AbstractDiscoveryStrategy.java
deleted file mode 100644
index c46ea89..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/AbstractDiscoveryStrategy.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * An abstraction of a strategy for discovering connectors and categories. Strategy design pattern. Note that strategies
- * are not reusable and must be disposed.
- *
- * @author David Green
- */
-public abstract class AbstractDiscoveryStrategy {
-
- protected List<DiscoveryCategory> categories;
-
- protected List<DiscoveryConnector> connectors;
-
- /**
- * Perform discovery and add discovered items to {@link #getCategories() categories} and {@link #getConnectors()}.
- *
- * @param monitor
- * the monitor
- */
- public abstract void performDiscovery(IProgressMonitor monitor) throws CoreException;
-
- public List<DiscoveryCategory> getCategories() {
- return categories;
- }
-
- public void setCategories(List<DiscoveryCategory> categories) {
- this.categories = categories;
- }
-
- public List<DiscoveryConnector> getConnectors() {
- return connectors;
- }
-
- public void setConnectors(List<DiscoveryConnector> connectors) {
- this.connectors = connectors;
- }
-
- public void dispose() {
- }
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/BundleDiscoverySource.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/BundleDiscoverySource.java
deleted file mode 100644
index 1204cbc..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/BundleDiscoverySource.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-import java.net.URL;
-
-import org.osgi.framework.Bundle;
-
-/**
- * @author David Green
- */
-public class BundleDiscoverySource extends AbstractDiscoverySource {
-
- private final Bundle bundle;
-
- public BundleDiscoverySource(Bundle bundle) {
- if (bundle == null) {
- throw new IllegalArgumentException();
- }
- this.bundle = bundle;
- }
-
- @Override
- public Object getId() {
- return "bundle:" + bundle.getSymbolicName(); //$NON-NLS-1$
- }
-
- @Override
- public URL getResource(String relativeUrl) {
- return bundle.getEntry(relativeUrl);
- }
-
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/BundleDiscoveryStrategy.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/BundleDiscoveryStrategy.java
deleted file mode 100644
index 39759a0..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/BundleDiscoveryStrategy.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IContributor;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.mylyn.commons.core.StatusHandler;
-import org.eclipse.mylyn.internal.discovery.core.DiscoveryCore;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Bundle;
-
-/**
- * a strategy for discovering via installed platform {@link Bundle bundles}.
- *
- * @author David Green
- */
-public class BundleDiscoveryStrategy extends AbstractDiscoveryStrategy {
-
- @Override
- public void performDiscovery(IProgressMonitor monitor) throws CoreException {
- if (connectors == null || categories == null) {
- throw new IllegalStateException();
- }
- IExtensionPoint extensionPoint = getExtensionRegistry().getExtensionPoint(
- ConnectorDiscoveryExtensionReader.EXTENSION_POINT_ID);
- IExtension[] extensions = extensionPoint.getExtensions();
- monitor.beginTask(Messages.BundleDiscoveryStrategy_task_loading_local_extensions, extensions.length == 0 ? 1
- : extensions.length);
- try {
- if (extensions.length > 0) {
- processExtensions(new SubProgressMonitor(monitor, extensions.length), extensions);
- }
- } finally {
- monitor.done();
- }
- }
-
- protected void processExtensions(IProgressMonitor monitor, IExtension[] extensions) {
- monitor.beginTask(Messages.BundleDiscoveryStrategy_task_processing_extensions, extensions.length == 0 ? 1
- : extensions.length);
- try {
- ConnectorDiscoveryExtensionReader extensionReader = new ConnectorDiscoveryExtensionReader();
-
- for (IExtension extension : extensions) {
- AbstractDiscoverySource discoverySource = computeDiscoverySource(extension.getContributor());
- IConfigurationElement[] elements = extension.getConfigurationElements();
- for (IConfigurationElement element : elements) {
- if (monitor.isCanceled()) {
- return;
- }
- try {
- if (ConnectorDiscoveryExtensionReader.CONNECTOR_DESCRIPTOR.equals(element.getName())) {
- DiscoveryConnector descriptor = extensionReader.readConnectorDescriptor(element,
- DiscoveryConnector.class);
- descriptor.setSource(discoverySource);
- connectors.add(descriptor);
- } else if (ConnectorDiscoveryExtensionReader.CONNECTOR_CATEGORY.equals(element.getName())) {
- DiscoveryCategory category = extensionReader.readConnectorCategory(element,
- DiscoveryCategory.class);
- category.setSource(discoverySource);
- categories.add(category);
- } else {
- throw new ValidationException(NLS.bind(Messages.BundleDiscoveryStrategy_unexpected_element,
- element.getName()));
- }
- } catch (ValidationException e) {
- StatusHandler.log(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN,
- NLS.bind(Messages.BundleDiscoveryStrategy_3, element.getContributor().getName(),
- e.getMessage()), e));
- }
- }
- monitor.worked(1);
- }
- } finally {
- monitor.done();
- }
- }
-
- protected AbstractDiscoverySource computeDiscoverySource(IContributor contributor) {
- return new BundleDiscoverySource(Platform.getBundle(contributor.getName()));
- }
-
- protected IExtensionRegistry getExtensionRegistry() {
- return Platform.getExtensionRegistry();
- }
-
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/ConnectorCategory.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/ConnectorCategory.java
deleted file mode 100644
index aae4714..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/ConnectorCategory.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-/**
- * a category of connectors, which is a way of organizing connectors in top-level groups.
- *
- * @author David Green
- */
-public class ConnectorCategory {
-
- protected String id;
-
- protected String name;
-
- protected String description;
-
- protected Icon icon;
-
- public ConnectorCategory() {
- }
-
- /**
- * an id that uniquely identifies the category
- */
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- /**
- * the name of the category, as it is displayed in the ui.
- */
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * A description of the category
- */
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Icon getIcon() {
- return icon;
- }
-
- public void setIcon(Icon icon) {
- this.icon = icon;
- }
-
- public void validate() throws ValidationException {
- if (id == null || id.length() == 0) {
- throw new ValidationException(Messages.ConnectorCategory_must_specify_connectorCategory_id);
- }
- if (name == null || name.length() == 0) {
- throw new ValidationException(Messages.ConnectorCategory_must_specify_connectorCategory_name);
- }
- if (icon != null) {
- icon.validate();
- }
- }
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/ConnectorDescriptor.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/ConnectorDescriptor.java
deleted file mode 100644
index 1fa6114..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/ConnectorDescriptor.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-import java.net.MalformedURLException;
-
-/**
- * A description of a connector, including kind, description, licensing and brand.
- *
- * @author David Green
- */
-public class ConnectorDescriptor {
-
- protected ConnectorDescriptorKind kind;
-
- protected String name;
-
- protected String provider;
-
- protected String license;
-
- protected String description;
-
- protected String siteUrl;
-
- protected String id;
-
- protected String categoryId;
-
- protected String platformFilter;
-
- protected Icon icon;
-
- protected Overview overview;
-
- public ConnectorDescriptor() {
- }
-
- /**
- * must be one of 'document', 'task', 'vcs'
- */
- public ConnectorDescriptorKind getKind() {
- return kind;
- }
-
- public void setKind(ConnectorDescriptorKind kind) {
- this.kind = kind;
- }
-
- /**
- * the name of the connector including the name of the organization that produces the repository if appropriate, for
- * example 'Mozilla Bugzilla'.
- */
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * The name of the organization that supplies the connector.
- */
- public String getProvider() {
- return provider;
- }
-
- public void setProvider(String provider) {
- this.provider = provider;
- }
-
- /**
- * The short name of the license, for example 'EPL 1.0', 'GPL 2.0', or 'Commercial'.
- */
- public String getLicense() {
- return license;
- }
-
- public void setLicense(String license) {
- this.license = license;
- }
-
- /**
- * A description of the connector. Plug-ins should provide a description, especially if the description is not
- * self-evident from the @name and
- *
- * @organization.
- */
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- /**
- * The URL of the update site containing the connector.
- */
- public String getSiteUrl() {
- return siteUrl;
- }
-
- public void setSiteUrl(String siteUrl) {
- this.siteUrl = siteUrl;
- }
-
- /**
- * The id of the feature that installs this connector
- */
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- /**
- * the id of the connectorCategory in which this connector belongs
- */
- public String getCategoryId() {
- return categoryId;
- }
-
- public void setCategoryId(String categoryId) {
- this.categoryId = categoryId;
- }
-
- /**
- * E.g., "(& (osgi.os=macosx) (osgi.ws=carbon))"
- */
- public String getPlatformFilter() {
- return platformFilter;
- }
-
- public void setPlatformFilter(String platformFilter) {
- this.platformFilter = platformFilter;
- }
-
- public Icon getIcon() {
- return icon;
- }
-
- public void setIcon(Icon icon) {
- this.icon = icon;
- }
-
- public Overview getOverview() {
- return overview;
- }
-
- public void setOverview(Overview overview) {
- this.overview = overview;
- }
-
- public void validate() throws ValidationException {
- if (kind == null) {
- throw new ValidationException(Messages.ConnectorDescriptor_must_specify_connectorDescriptor_kind);
- }
- if (name == null || name.length() == 0) {
- throw new ValidationException(Messages.ConnectorDescriptor_must_specify_connectorDescriptor_name);
- }
- if (provider == null || provider.length() == 0) {
- throw new ValidationException(Messages.ConnectorDescriptor_must_specify_connectorDescriptor_provider);
- }
- if (license == null || license.length() == 0) {
- throw new ValidationException(Messages.ConnectorDescriptor_must_specify_connectorDescriptor_license);
- }
- if (siteUrl == null || siteUrl.length() == 0) {
- throw new ValidationException(Messages.ConnectorDescriptor_must_specify_connectorDescriptor_siteUrl);
- }
- try {
- new java.net.URL(siteUrl);
- } catch (MalformedURLException e) {
- throw new ValidationException(Messages.ConnectorDescriptor_invalid_connectorDescriptor_siteUrl);
- }
- if (id == null || id.length() == 0) {
- throw new ValidationException(Messages.ConnectorDescriptor_must_specify_connectorDescriptor_id);
- }
- if (categoryId == null || categoryId.length() == 0) {
- throw new ValidationException(Messages.ConnectorDescriptor_must_specify_connectorDescriptor_categoryId);
- }
- if (icon != null) {
- icon.validate();
- }
- if (overview != null) {
- overview.validate();
- }
- }
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/ConnectorDescriptorKind.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/ConnectorDescriptorKind.java
deleted file mode 100644
index 6b5afc8..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/ConnectorDescriptorKind.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-/**
- * @author David Green
- */
-public enum ConnectorDescriptorKind {
-
- DOCUMENT("document"), //$NON-NLS-1$
- TASK("task"), //$NON-NLS-1$
- VCS("vcs"); //$NON-NLS-1$
-
- private final String value;
-
- private ConnectorDescriptorKind(String value) {
- this.value = value;
- }
-
- public String getValue() {
- return value;
- }
-
- /**
- * return the enum constant whose {@link #getValue() value} is the same as the given value.
- *
- * @param value
- * the string value, or null
- *
- * @return the corresponding enum constant or null if the given value was null
- *
- * @throws IllegalArgumentException
- * if the given value does not correspond to any enum constant
- */
- public static ConnectorDescriptorKind fromValue(String value) throws IllegalArgumentException {
- if (value == null) {
- return null;
- }
- for (ConnectorDescriptorKind e : values()) {
- if (e.getValue().equals(value)) {
- return e;
- }
- }
- throw new IllegalArgumentException(value);
- }
-
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/ConnectorDiscovery.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/ConnectorDiscovery.java
deleted file mode 100644
index c57040a..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/ConnectorDiscovery.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.mylyn.commons.core.StatusHandler;
-import org.eclipse.mylyn.internal.discovery.core.DiscoveryCore;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.InvalidSyntaxException;
-
-/**
- * A means of discovering connectors.
- *
- * @author David Green
- */
-public class ConnectorDiscovery {
-
- private List<DiscoveryConnector> connectors = Collections.emptyList();
-
- private List<DiscoveryCategory> categories = Collections.emptyList();
-
- private final List<AbstractDiscoveryStrategy> discoveryStrategies = new ArrayList<AbstractDiscoveryStrategy>();
-
- private Dictionary<Object, Object> environment = System.getProperties();
-
- public ConnectorDiscovery() {
- }
-
- /**
- * get the discovery strategies to use.
- */
- public List<AbstractDiscoveryStrategy> getDiscoveryStrategies() {
- return discoveryStrategies;
- }
-
- /**
- * Initialize this by performing discovery. Discovery may take a long time as it involves network access.
- * PRECONDITION: must add at least one {@link #getDiscoveryStrategies() discovery strategy} prior to calling.
- *
- */
- public void performDiscovery(IProgressMonitor monitor) throws CoreException {
- if (discoveryStrategies.isEmpty()) {
- throw new IllegalStateException();
- }
- connectors = new ArrayList<DiscoveryConnector>();
- categories = new ArrayList<DiscoveryCategory>();
-
- final int totalTicks = 10000;
- monitor.beginTask(Messages.ConnectorDiscovery_task_discovering_connectors, totalTicks);
- try {
- // FIXME: policy for where categories can be declared
- for (AbstractDiscoveryStrategy discoveryStrategy : discoveryStrategies) {
- discoveryStrategy.setCategories(categories);
- discoveryStrategy.setConnectors(connectors);
- discoveryStrategy.performDiscovery(new SubProgressMonitor(monitor, totalTicks
- / discoveryStrategies.size()));
- }
-
- filterDescriptors();
- connectCategoriesToDescriptors();
- } finally {
- monitor.done();
- }
- }
-
- /**
- * get the top-level categories
- *
- * @return the categories, or an empty list if there are none.
- */
- public List<DiscoveryCategory> getCategories() {
- return categories;
- }
-
- /**
- * get the connectors
- *
- * @return the connectors, or an empty list if there are none.
- */
- public List<DiscoveryConnector> getConnectors() {
- return connectors;
- }
-
- /**
- * The environment used to resolve {@link ConnectorDescriptor#getPlatformFilter() platform filters}. Defaults to the
- * current environment.
- */
- public Dictionary<Object, Object> getEnvironment() {
- return environment;
- }
-
- /**
- * The environment used to resolve {@link ConnectorDescriptor#getPlatformFilter() platform filters}. Defaults to the
- * current environment.
- */
- public void setEnvironment(Dictionary<Object, Object> environment) {
- if (environment == null) {
- throw new IllegalArgumentException();
- }
- this.environment = environment;
- }
-
- private void connectCategoriesToDescriptors() {
- Map<String, DiscoveryCategory> idToCategory = new HashMap<String, DiscoveryCategory>();
- for (DiscoveryCategory category : categories) {
- DiscoveryCategory previous = idToCategory.put(category.getId(), category);
- if (previous != null) {
- StatusHandler.log(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, NLS.bind(
- Messages.ConnectorDiscovery_duplicate_category_id, new Object[] { category.getId(),
- category.getSource().getId(), previous.getSource().getId() })));
- }
- }
-
- for (DiscoveryConnector connector : connectors) {
- DiscoveryCategory category = idToCategory.get(connector.getCategoryId());
- if (category != null) {
- category.getConnectors().add(connector);
- connector.setCategory(category);
- } else {
- StatusHandler.log(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, NLS.bind(
- Messages.ConnectorDiscovery_bundle_references_unknown_category, new Object[] {
- connector.getCategoryId(), connector.getId(), connector.getSource().getId() })));
- }
- }
- }
-
- /**
- * eliminate any connectors whose {@link ConnectorDescriptor#getPlatformFilter() platform filters} don't match
- */
- private void filterDescriptors() {
- for (DiscoveryConnector connector : new ArrayList<DiscoveryConnector>(connectors)) {
- if (connector.getPlatformFilter() != null && connector.getPlatformFilter().trim().length() > 0) {
- boolean match = false;
- try {
- Filter filter = FrameworkUtil.createFilter(connector.getPlatformFilter());
- match = filter.match(environment);
- } catch (InvalidSyntaxException e) {
- StatusHandler.log(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, NLS.bind(
- Messages.ConnectorDiscovery_illegal_filter_syntax, new Object[] {
- connector.getPlatformFilter(), connector.getId(), connector.getSource().getId() })));
- }
- if (!match) {
- connectors.remove(connector);
- }
- }
- }
- }
-
- public void dispose() {
- for (final AbstractDiscoveryStrategy strategy : discoveryStrategies) {
- SafeRunner.run(new ISafeRunnable() {
-
- public void run() throws Exception {
- strategy.dispose();
- }
-
- public void handleException(Throwable exception) {
- StatusHandler.log(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN,
- "exception disposing " + strategy.getClass().getName(), exception)); //$NON-NLS-1$
- }
- });
- }
- }
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/ConnectorDiscoveryExtensionReader.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/ConnectorDiscoveryExtensionReader.java
deleted file mode 100644
index 6b28331..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/ConnectorDiscoveryExtensionReader.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-
-/**
- * Connector Discovery extension point reader, for extension points of type
- * <tt>org.eclipse.mylyn.discovery.core.connectorDiscovery</tt>
- *
- * @author David Green
- */
-public class ConnectorDiscoveryExtensionReader {
-
- public static final String EXTENSION_POINT_ID = "org.eclipse.mylyn.discovery.core.connectorDiscovery"; //$NON-NLS-1$
-
- public static final String CONNECTOR_DESCRIPTOR = "connectorDescriptor"; //$NON-NLS-1$
-
- public static final String CONNECTOR_CATEGORY = "connectorCategory"; //$NON-NLS-1$
-
- public static final String ICON = "icon"; //$NON-NLS-1$
-
- public static final String OVERVIEW = "overview"; //$NON-NLS-1$
-
- public ConnectorDescriptor readConnectorDescriptor(IConfigurationElement element) throws ValidationException {
- return readConnectorDescriptor(element, ConnectorDescriptor.class);
- }
-
- public <T extends ConnectorDescriptor> T readConnectorDescriptor(IConfigurationElement element, Class<T> clazz)
- throws ValidationException {
- T connectorDescriptor;
- try {
- connectorDescriptor = clazz.newInstance();
- } catch (Exception e) {
- throw new IllegalStateException(e);
- }
-
- try {
- connectorDescriptor.setKind(ConnectorDescriptorKind.fromValue(element.getAttribute("kind"))); //$NON-NLS-1$
- } catch (IllegalArgumentException e) {
- throw new ValidationException(Messages.ConnectorDiscoveryExtensionReader_unexpected_value_kind);
- }
- connectorDescriptor.setName(element.getAttribute("name")); //$NON-NLS-1$
- connectorDescriptor.setProvider(element.getAttribute("provider")); //$NON-NLS-1$
- connectorDescriptor.setLicense(element.getAttribute("license")); //$NON-NLS-1$
- connectorDescriptor.setDescription(element.getAttribute("description")); //$NON-NLS-1$
- connectorDescriptor.setSiteUrl(element.getAttribute("siteUrl")); //$NON-NLS-1$
- connectorDescriptor.setId(element.getAttribute("id")); //$NON-NLS-1$
- connectorDescriptor.setCategoryId(element.getAttribute("categoryId")); //$NON-NLS-1$
- connectorDescriptor.setPlatformFilter(element.getAttribute("platformFilter")); //$NON-NLS-1$
-
- for (IConfigurationElement child : element.getChildren("icon")) { //$NON-NLS-1$
- Icon iconItem = readIcon(child);
- iconItem.setConnectorDescriptor(connectorDescriptor);
- if (connectorDescriptor.getIcon() != null) {
- throw new ValidationException(Messages.ConnectorDiscoveryExtensionReader_unexpected_element_icon);
- }
- connectorDescriptor.setIcon(iconItem);
- }
- for (IConfigurationElement child : element.getChildren("overview")) { //$NON-NLS-1$
- Overview overviewItem = readOverview(child);
- overviewItem.setConnectorDescriptor(connectorDescriptor);
- if (connectorDescriptor.getOverview() != null) {
- throw new ValidationException(Messages.ConnectorDiscoveryExtensionReader_unexpected_element_overview);
- }
- connectorDescriptor.setOverview(overviewItem);
- }
-
- connectorDescriptor.validate();
-
- return connectorDescriptor;
- }
-
- public ConnectorCategory readConnectorCategory(IConfigurationElement element) throws ValidationException {
- return readConnectorCategory(element, ConnectorCategory.class);
- }
-
- public <T extends ConnectorCategory> T readConnectorCategory(IConfigurationElement element, Class<T> clazz)
- throws ValidationException {
- T connectorCategory;
- try {
- connectorCategory = clazz.newInstance();
- } catch (Exception e) {
- throw new IllegalStateException(e);
- }
-
- connectorCategory.setId(element.getAttribute("id")); //$NON-NLS-1$
- connectorCategory.setName(element.getAttribute("name")); //$NON-NLS-1$
- connectorCategory.setDescription(element.getAttribute("description")); //$NON-NLS-1$
-
- for (IConfigurationElement child : element.getChildren("icon")) { //$NON-NLS-1$
- Icon iconItem = readIcon(child);
- iconItem.setConnectorCategory(connectorCategory);
- if (connectorCategory.getIcon() != null) {
- throw new ValidationException(Messages.ConnectorDiscoveryExtensionReader_unexpected_element_icon);
- }
- connectorCategory.setIcon(iconItem);
- }
-
- connectorCategory.validate();
-
- return connectorCategory;
- }
-
- public Icon readIcon(IConfigurationElement element) throws ValidationException {
- Icon icon = new Icon();
-
- icon.setImage16(element.getAttribute("image16")); //$NON-NLS-1$
- icon.setImage32(element.getAttribute("image32")); //$NON-NLS-1$
- icon.setImage48(element.getAttribute("image48")); //$NON-NLS-1$
- icon.setImage64(element.getAttribute("image64")); //$NON-NLS-1$
- icon.setImage128(element.getAttribute("image128")); //$NON-NLS-1$
-
- icon.validate();
-
- return icon;
- }
-
- public Overview readOverview(IConfigurationElement element) throws ValidationException {
- Overview overview = new Overview();
-
- overview.setSummary(element.getAttribute("summary")); //$NON-NLS-1$
- overview.setUrl(element.getAttribute("url")); //$NON-NLS-1$
- overview.setScreenshot(element.getAttribute("screenshot")); //$NON-NLS-1$
-
- overview.validate();
-
- return overview;
- }
-
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/Directory.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/Directory.java
deleted file mode 100644
index 37c33c7..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/Directory.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * A directory representing locations of discovery sources.
- *
- * @author David Green
- */
-public class Directory {
- /**
- * an entry in the directory, which represents a specific discovery source. Future versions of this class may
- * include policy or other attributes declared by the directory.
- */
- public static final class Entry {
- private String location;
-
- public Entry() {
- }
-
- public String getLocation() {
- return location;
- }
-
- public void setLocation(String location) {
- this.location = location;
- }
- }
-
- private final List<Entry> entries = new ArrayList<Entry>();
-
- public List<Entry> getEntries() {
- return entries;
- }
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/DirectoryParser.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/DirectoryParser.java
deleted file mode 100644
index d431e4f..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/DirectoryParser.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-import java.io.IOException;
-import java.io.Reader;
-
-import org.eclipse.mylyn.internal.discovery.core.model.Directory.Entry;
-import org.eclipse.mylyn.internal.discovery.core.util.DefaultSaxErrorHandler;
-import org.eclipse.mylyn.internal.discovery.core.util.IOWithCauseException;
-import org.eclipse.osgi.util.NLS;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
-
-/**
- * A parser for {@link Directory directories}.
- *
- * @author David Green
- */
-public class DirectoryParser {
- /**
- * parse the contents of a directory. The caller must close the given reader.
- *
- * @param directoryContents
- * the contents of the directory
- * @return a directory with 0 or more entries
- * @throws IOException
- * if the directory cannot be read.
- */
- public Directory parse(Reader directoryContents) throws IOException {
- XMLReader xmlReader;
- try {
- xmlReader = XMLReaderFactory.createXMLReader();
- } catch (SAXException e) {
- throw new IOWithCauseException(e.getMessage(), e);
- }
- xmlReader.setErrorHandler(new DefaultSaxErrorHandler());
-
- DirectoryContentHandler contentHandler = new DirectoryContentHandler();
- xmlReader.setContentHandler(contentHandler);
-
- try {
- xmlReader.parse(new InputSource(directoryContents));
- } catch (SAXException e) {
- throw new IOWithCauseException(e.getMessage(), e);
- }
-
- if (contentHandler.directory == null) {
- throw new IOException(Messages.DirectoryParser_no_directory);
- }
-
- return contentHandler.directory;
- }
-
- private class DirectoryContentHandler implements ContentHandler {
-
- Directory directory;
-
- public void characters(char[] ch, int start, int length) throws SAXException {
- // ignore
- }
-
- public void endDocument() throws SAXException {
- // ignore
- }
-
- public void endElement(String uri, String localName, String qName) throws SAXException {
- // ignore
- }
-
- public void endPrefixMapping(String prefix) throws SAXException {
- // ignore
- }
-
- public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
- // ignore
- }
-
- public void processingInstruction(String target, String data) throws SAXException {
- // ignore
- }
-
- public void setDocumentLocator(Locator locator) {
- // ignore
- }
-
- public void skippedEntity(String name) throws SAXException {
- // ignore
- }
-
- public void startDocument() throws SAXException {
- // ignore
- }
-
- public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
- if ("directory".equals(localName)) { //$NON-NLS-1$
- if (directory != null) {
- unexpectedElement(localName);
- }
- directory = new Directory();
- } else if (directory != null && "entry".equals(localName)) { //$NON-NLS-1$
- String url = atts.getValue("", "url"); //$NON-NLS-1$ //$NON-NLS-2$
- if (url != null && url.length() > 0) {
- Entry entry = new Entry();
- entry.setLocation(url);
- directory.getEntries().add(entry);
- }
- }
- // else ignore
- }
-
- private void unexpectedElement(String localName) throws SAXException {
- throw new SAXException(NLS.bind(Messages.DirectoryParser_unexpected_element, localName));
- }
-
- public void startPrefixMapping(String prefix, String uri) throws SAXException {
- // ignore
- }
- }
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/DiscoveryCategory.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/DiscoveryCategory.java
deleted file mode 100644
index 453e808..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/DiscoveryCategory.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * @author David Green
- */
-public class DiscoveryCategory extends ConnectorCategory {
- private AbstractDiscoverySource source;
-
- private List<DiscoveryConnector> connectors = new ArrayList<DiscoveryConnector>();
-
- public List<DiscoveryConnector> getConnectors() {
- return connectors;
- }
-
- public AbstractDiscoverySource getSource() {
- return source;
- }
-
- public void setSource(AbstractDiscoverySource source) {
- this.source = source;
- }
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/DiscoveryConnector.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/DiscoveryConnector.java
deleted file mode 100644
index d9faab8..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/DiscoveryConnector.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-/**
- *
- * @author David Green
- */
-public class DiscoveryConnector extends ConnectorDescriptor {
- private AbstractDiscoverySource source;
-
- private DiscoveryCategory category;
-
- private boolean selected;
-
- public DiscoveryCategory getCategory() {
- return category;
- }
-
- public void setCategory(DiscoveryCategory category) {
- this.category = category;
- }
-
- public AbstractDiscoverySource getSource() {
- return source;
- }
-
- public void setSource(AbstractDiscoverySource source) {
- this.source = source;
- }
-
- /**
- * support selection
- *
- * @return true if the item is selected, otherwise false
- */
- public boolean isSelected() {
- return selected;
- }
-
- /**
- * support selection
- *
- * @param selected
- * true if the item is selected, otherwise false
- */
- public void setSelected(boolean selected) {
- this.selected = selected;
- }
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/DiscoveryRegistryStrategy.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/DiscoveryRegistryStrategy.java
deleted file mode 100644
index 74d346e..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/DiscoveryRegistryStrategy.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.PropertyResourceBundle;
-import java.util.ResourceBundle;
-import java.util.Set;
-import java.util.jar.JarFile;
-import java.util.zip.ZipEntry;
-
-import org.eclipse.core.runtime.IContributor;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.spi.IDynamicExtensionRegistry;
-import org.eclipse.core.runtime.spi.RegistryContributor;
-import org.eclipse.core.runtime.spi.RegistryStrategy;
-import org.eclipse.mylyn.commons.core.StatusHandler;
-import org.eclipse.mylyn.internal.discovery.core.DiscoveryCore;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Bundle;
-
-/**
- *
- * @author David Green
- */
-public class DiscoveryRegistryStrategy extends RegistryStrategy {
-
- private Set<File> bundleFiles = new HashSet<File>();
-
- private final List<JarFile> jars = new ArrayList<JarFile>();
-
- private final Map<IContributor, File> contributorToJarFile = new HashMap<IContributor, File>();
-
- private final Object token;
-
- public DiscoveryRegistryStrategy(File[] storageDirs, boolean[] cacheReadOnly, Object token) {
- super(storageDirs, cacheReadOnly);
- this.token = token;
- }
-
- @Override
- public void onStart(IExtensionRegistry registry, boolean loadedFromCache) {
- super.onStart(registry, loadedFromCache);
- if (!loadedFromCache) {
- processDiscoveryCoreBundle(registry);
- processBundles(registry);
- }
- }
-
- private void processDiscoveryCoreBundle(IExtensionRegistry registry) {
- // we must add a contribution from the core bundle so that we get the
- // extension point itself
- try {
- Bundle bundle = Platform.getBundle(DiscoveryCore.ID_PLUGIN);
- IContributor contributor = new RegistryContributor(bundle.getSymbolicName(), bundle.getSymbolicName(),
- null, null);
-
- InputStream inputStream = bundle.getEntry("plugin.xml").openStream(); //$NON-NLS-1$
- try {
- registry.addContribution(inputStream, contributor, false, bundle.getSymbolicName(), null, token);
- } finally {
- inputStream.close();
- }
- } catch (IOException e) {
- throw new IllegalStateException();
- }
- }
-
- public Set<File> getBundleFiles() {
- return bundleFiles;
- }
-
- public void setBundleFiles(Set<File> bundleFiles) {
- this.bundleFiles = bundleFiles;
- }
-
- private void processBundles(IExtensionRegistry registry) {
- if (bundleFiles == null) {
- throw new IllegalStateException();
- }
- for (File bundleFile : bundleFiles) {
- try {
- processBundle(registry, bundleFile);
- } catch (Exception e) {
- StatusHandler.log(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, NLS.bind(
- Messages.DiscoveryRegistryStrategy_cannot_load_bundle, bundleFile.getName(), e.getMessage()), e));
- }
- }
- }
-
- private void processBundle(IExtensionRegistry registry, File bundleFile) throws IOException {
- JarFile jarFile = new JarFile(bundleFile);
- jars.add(jarFile);
-
- ZipEntry pluginXmlEntry = jarFile.getEntry("plugin.xml"); //$NON-NLS-1$
- if (pluginXmlEntry == null) {
- throw new IOException(Messages.DiscoveryRegistryStrategy_missing_pluginxml);
- }
- IContributor contributor = new RegistryContributor(bundleFile.getName(), bundleFile.getName(), null, null);
- if (((IDynamicExtensionRegistry) registry).hasContributor(contributor)) {
- jarFile.close();
- return;
- }
- contributorToJarFile.put(contributor, bundleFile);
-
- ResourceBundle translationBundle = loadTranslationBundle(jarFile);
-
- InputStream inputStream = jarFile.getInputStream(pluginXmlEntry);
- try {
- registry.addContribution(inputStream, contributor, false, bundleFile.getPath(), translationBundle, token);
- } finally {
- inputStream.close();
- }
- }
-
- private ResourceBundle loadTranslationBundle(JarFile jarFile) throws IOException {
- List<String> bundleNames = computeBundleNames("plugin"); //$NON-NLS-1$
- for (String bundleName : bundleNames) {
- ZipEntry entry = jarFile.getEntry(bundleName);
- if (entry != null) {
- InputStream inputStream = jarFile.getInputStream(entry);
- try {
- PropertyResourceBundle resourceBundle = new PropertyResourceBundle(inputStream);
- return resourceBundle;
- } finally {
- inputStream.close();
- }
- }
- }
- return null;
- }
-
- private List<String> computeBundleNames(String baseName) {
- String suffix = ".properties"; //$NON-NLS-1$
- String name = baseName;
- List<String> bundleNames = new ArrayList<String>();
- Locale locale = Locale.getDefault();
- bundleNames.add(name + suffix);
- if (locale.getLanguage() != null && locale.getLanguage().length() > 0) {
- name = name + '_' + locale.getLanguage();
- bundleNames.add(0, name + suffix);
- }
- if (locale.getCountry() != null && locale.getCountry().length() > 0) {
- name = name + '_' + locale.getCountry();
- bundleNames.add(0, name + suffix);
- }
- if (locale.getVariant() != null && locale.getVariant().length() > 0) {
- name = name + '_' + locale.getVariant();
- bundleNames.add(0, name + suffix);
- }
- return bundleNames;
- }
-
- @Override
- public void onStop(IExtensionRegistry registry) {
- try {
- super.onStop(registry);
- } finally {
- for (JarFile jar : jars) {
- try {
- jar.close();
- } catch (Exception e) {
- }
- }
- jars.clear();
- }
- }
-
- /**
- * get the jar file that corresponds to the given contributor.
- *
- * @throws IllegalArgumentException
- * if the given contributor is unknown
- */
- public File getJarFile(IContributor contributor) {
- File file = contributorToJarFile.get(contributor);
- if (file == null) {
- throw new IllegalArgumentException(contributor.getName());
- }
- return file;
- }
-
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/Icon.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/Icon.java
deleted file mode 100644
index 4058f60..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/Icon.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-/**
- * @author David Green
- */
-public class Icon {
-
- protected String image16;
-
- protected String image32;
-
- protected String image48;
-
- protected String image64;
-
- protected String image128;
-
- protected ConnectorDescriptor connectorDescriptor;
-
- protected ConnectorCategory connectorCategory;
-
- public Icon() {
- }
-
- public String getImage16() {
- return image16;
- }
-
- public void setImage16(String image16) {
- this.image16 = image16;
- }
-
- public String getImage32() {
- return image32;
- }
-
- public void setImage32(String image32) {
- this.image32 = image32;
- }
-
- public String getImage48() {
- return image48;
- }
-
- public void setImage48(String image48) {
- this.image48 = image48;
- }
-
- public String getImage64() {
- return image64;
- }
-
- public void setImage64(String image64) {
- this.image64 = image64;
- }
-
- public String getImage128() {
- return image128;
- }
-
- public void setImage128(String image128) {
- this.image128 = image128;
- }
-
- public ConnectorDescriptor getConnectorDescriptor() {
- return connectorDescriptor;
- }
-
- public void setConnectorDescriptor(ConnectorDescriptor connectorDescriptor) {
- this.connectorDescriptor = connectorDescriptor;
- }
-
- public ConnectorCategory getConnectorCategory() {
- return connectorCategory;
- }
-
- public void setConnectorCategory(ConnectorCategory connectorCategory) {
- this.connectorCategory = connectorCategory;
- }
-
- public void validate() throws ValidationException {
- }
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/JarDiscoverySource.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/JarDiscoverySource.java
deleted file mode 100644
index 5c44acd..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/JarDiscoverySource.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLEncoder;
-
-/**
- *
- * @author David Green
- */
-public class JarDiscoverySource extends AbstractDiscoverySource {
-
- private final String id;
-
- private final File jarFile;
-
- public JarDiscoverySource(String id, File jarFile) {
- this.id = id;
- this.jarFile = jarFile;
- }
-
- @Override
- public Object getId() {
- return id;
- }
-
- @Override
- public URL getResource(String resourceName) {
- try {
- String prefix = jarFile.toURI().toURL().toExternalForm();
-
- return new URL("jar:" + prefix + "!/" + URLEncoder.encode(resourceName, "utf-8")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } catch (MalformedURLException e) {
- throw new IllegalStateException(e);
- } catch (UnsupportedEncodingException e) {
- throw new IllegalStateException(e);
- }
- }
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/Messages.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/Messages.java
deleted file mode 100644
index a692e9c..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/Messages.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- *
- * @author David Green
- */
-class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.discovery.core.model.messages"; //$NON-NLS-1$
-
- public static String BundleDiscoveryStrategy_3;
-
- public static String BundleDiscoveryStrategy_task_loading_local_extensions;
-
- public static String BundleDiscoveryStrategy_task_processing_extensions;
-
- public static String BundleDiscoveryStrategy_unexpected_element;
-
- public static String ConnectorCategory_must_specify_connectorCategory_id;
-
- public static String ConnectorCategory_must_specify_connectorCategory_name;
-
- public static String ConnectorDescriptor_invalid_connectorDescriptor_siteUrl;
-
- public static String ConnectorDescriptor_must_specify_connectorDescriptor_categoryId;
-
- public static String ConnectorDescriptor_must_specify_connectorDescriptor_id;
-
- public static String ConnectorDescriptor_must_specify_connectorDescriptor_kind;
-
- public static String ConnectorDescriptor_must_specify_connectorDescriptor_license;
-
- public static String ConnectorDescriptor_must_specify_connectorDescriptor_name;
-
- public static String ConnectorDescriptor_must_specify_connectorDescriptor_provider;
-
- public static String ConnectorDescriptor_must_specify_connectorDescriptor_siteUrl;
-
- public static String ConnectorDiscovery_bundle_references_unknown_category;
-
- public static String ConnectorDiscovery_duplicate_category_id;
-
- public static String ConnectorDiscovery_illegal_filter_syntax;
-
- public static String ConnectorDiscovery_task_discovering_connectors;
-
- public static String ConnectorDiscoveryExtensionReader_unexpected_element_icon;
-
- public static String ConnectorDiscoveryExtensionReader_unexpected_element_overview;
-
- public static String ConnectorDiscoveryExtensionReader_unexpected_value_kind;
-
- public static String DirectoryParser_no_directory;
-
- public static String DirectoryParser_unexpected_element;
-
- public static String DiscoveryRegistryStrategy_cannot_load_bundle;
-
- public static String DiscoveryRegistryStrategy_missing_pluginxml;
-
- public static String RemoteBundleDiscoveryStrategy_cannot_download_bundle;
-
- public static String RemoteBundleDiscoveryStrategy_empty_directory;
-
- public static String RemoteBundleDiscoveryStrategy_io_failure_discovery_directory;
-
- public static String RemoteBundleDiscoveryStrategy_io_failure_temp_storage;
-
- public static String RemoteBundleDiscoveryStrategy_task_remote_discovery;
-
- public static String RemoteBundleDiscoveryStrategy_unrecognized_discovery_url;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/Overview.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/Overview.java
deleted file mode 100644
index ba3f9bd..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/Overview.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-/**
- * @author David Green
- */
-public class Overview {
-
- protected String summary;
-
- protected String url;
-
- protected String screenshot;
-
- protected ConnectorDescriptor connectorDescriptor;
-
- public Overview() {
- }
-
- public String getSummary() {
- return summary;
- }
-
- public void setSummary(String summary) {
- this.summary = summary;
- }
-
- /**
- * HTML
- */
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- /**
- * 320x240 PNG, JPEG or GIF
- */
- public String getScreenshot() {
- return screenshot;
- }
-
- public void setScreenshot(String screenshot) {
- this.screenshot = screenshot;
- }
-
- public ConnectorDescriptor getConnectorDescriptor() {
- return connectorDescriptor;
- }
-
- public void setConnectorDescriptor(ConnectorDescriptor connectorDescriptor) {
- this.connectorDescriptor = connectorDescriptor;
- }
-
- public void validate() throws ValidationException {
- }
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/RemoteBundleDiscoveryStrategy.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/RemoteBundleDiscoveryStrategy.java
deleted file mode 100644
index 604d453..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/RemoteBundleDiscoveryStrategy.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Reader;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.internal.registry.ExtensionRegistry;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IContributor;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.mylyn.commons.core.StatusHandler;
-import org.eclipse.mylyn.commons.net.WebLocation;
-import org.eclipse.mylyn.internal.discovery.core.DiscoveryCore;
-import org.eclipse.mylyn.internal.discovery.core.util.WebUtil;
-import org.eclipse.mylyn.internal.discovery.core.util.WebUtil.TextContentProcessor;
-import org.eclipse.osgi.util.NLS;
-
-/**
- * A discovery strategy that downloads a simple directory of remote jars. The directory is first downloaded, then each
- * remote jar is downloaded.
- *
- * @author David Green
- */
-@SuppressWarnings("restriction")
-public class RemoteBundleDiscoveryStrategy extends BundleDiscoveryStrategy {
-
- private String directoryUrl;
-
- private DiscoveryRegistryStrategy registryStrategy;
-
- private File temporaryStorage;
-
- @Override
- public void performDiscovery(IProgressMonitor monitor) throws CoreException {
- if (connectors == null || categories == null || directoryUrl == null) {
- throw new IllegalStateException();
- }
- if (registryStrategy != null) {
- throw new IllegalStateException();
- }
-
- final int totalTicks = 100000;
- final int ticksTenPercent = totalTicks / 10;
- monitor.beginTask(Messages.RemoteBundleDiscoveryStrategy_task_remote_discovery, totalTicks);
- try {
- File registryCacheFolder;
- try {
- if (temporaryStorage != null && temporaryStorage.exists()) {
- delete(temporaryStorage);
- }
- temporaryStorage = File.createTempFile(RemoteBundleDiscoveryStrategy.class.getSimpleName(), ".tmp"); //$NON-NLS-1$
- temporaryStorage.delete();
- if (!temporaryStorage.mkdirs()) {
- throw new IOException();
- }
- registryCacheFolder = new File(temporaryStorage, ".rcache"); //$NON-NLS-1$
- if (!registryCacheFolder.mkdirs()) {
- throw new IOException();
- }
- } catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN,
- Messages.RemoteBundleDiscoveryStrategy_io_failure_temp_storage, e));
- }
- if (monitor.isCanceled()) {
- return;
- }
-
- Directory directory;
-
- // FIXME: Eclipse network/proxy settings
- WebLocation webLocation = new WebLocation(directoryUrl);
- try {
- final Directory[] temp = new Directory[1];
- WebUtil.readResource(webLocation, new TextContentProcessor() {
- public void process(Reader reader) throws IOException {
- DirectoryParser parser = new DirectoryParser();
- temp[0] = parser.parse(reader);
- }
- }, new SubProgressMonitor(monitor, ticksTenPercent));
- directory = temp[0];
- if (directory == null) {
- throw new IllegalStateException();
- }
- } catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN,
- Messages.RemoteBundleDiscoveryStrategy_io_failure_discovery_directory, e));
- }
- if (monitor.isCanceled()) {
- return;
- }
- if (directory.getEntries().isEmpty()) {
- throw new CoreException(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN,
- Messages.RemoteBundleDiscoveryStrategy_empty_directory));
- }
-
- Set<File> bundles = new HashSet<File>();
-
- // TODO: multithreaded downloading
- for (Directory.Entry entry : directory.getEntries()) {
- String bundleUrl = entry.getLocation();
- try {
- if (!bundleUrl.startsWith("http://") && !bundleUrl.startsWith("https://")) { //$NON-NLS-1$//$NON-NLS-2$
- StatusHandler.log(new Status(IStatus.WARNING, DiscoveryCore.ID_PLUGIN, NLS.bind(
- Messages.RemoteBundleDiscoveryStrategy_unrecognized_discovery_url, bundleUrl)));
- continue;
- }
- String lastPathElement = bundleUrl.lastIndexOf('/') == -1 ? bundleUrl
- : bundleUrl.substring(bundleUrl.lastIndexOf('/'));
- File target = File.createTempFile(
- lastPathElement.replaceAll("^[a-zA-Z0-9_.]", "_") + "_", ".jar", temporaryStorage); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
-
- if (monitor.isCanceled()) {
- return;
- }
-
- // FIXME: Eclipse network/proxy settings
- WebUtil.downloadResource(target, new WebLocation(bundleUrl), new SubProgressMonitor(monitor,
- ticksTenPercent * 4 / directory.getEntries().size()));
- bundles.add(target);
- } catch (IOException e) {
- StatusHandler.log(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, NLS.bind(
- Messages.RemoteBundleDiscoveryStrategy_cannot_download_bundle, bundleUrl, e.getMessage()),
- e));
- }
- }
- try {
- registryStrategy = new DiscoveryRegistryStrategy(new File[] { registryCacheFolder },
- new boolean[] { false }, this);
- registryStrategy.setBundleFiles(bundles);
- IExtensionRegistry extensionRegistry = new ExtensionRegistry(registryStrategy, this, this);
- try {
- IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(ConnectorDiscoveryExtensionReader.EXTENSION_POINT_ID);
- if (extensionPoint != null) {
- IExtension[] extensions = extensionPoint.getExtensions();
- if (extensions.length > 0) {
- processExtensions(new SubProgressMonitor(monitor, ticksTenPercent * 3), extensions);
- }
- }
- } finally {
- extensionRegistry.stop(this);
- }
- } finally {
- registryStrategy = null;
- }
- } finally {
- monitor.done();
- }
- }
-
- private void delete(File file) {
- if (file.exists()) {
- if (file.isDirectory()) {
- File[] children = file.listFiles();
- if (children != null) {
- for (File child : children) {
- delete(child);
- }
- }
- }
- if (!file.delete()) {
- // fail quietly
- }
- }
- }
-
- @Override
- public void dispose() {
- super.dispose();
- if (temporaryStorage != null) {
- delete(temporaryStorage);
- }
- }
-
- public String getDirectoryUrl() {
- return directoryUrl;
- }
-
- public void setDirectoryUrl(String directoryUrl) {
- this.directoryUrl = directoryUrl;
- }
-
- @Override
- protected AbstractDiscoverySource computeDiscoverySource(IContributor contributor) {
- return new JarDiscoverySource(contributor.getName(), registryStrategy.getJarFile(contributor));
- }
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/ValidationException.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/ValidationException.java
deleted file mode 100644
index 1b59235..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/ValidationException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core.model;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.mylyn.internal.discovery.core.DiscoveryCore;
-
-/**
- * Indicate that a validation has occurred on the model.
- *
- * @author David Green
- */
-public class ValidationException extends CoreException {
-
- private static final long serialVersionUID = -7542361242327905294L;
-
- public ValidationException(String message) {
- super(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, message));
- }
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/messages.properties b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/messages.properties
deleted file mode 100644
index 73a4867..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/model/messages.properties
+++ /dev/null
@@ -1,31 +0,0 @@
-BundleDiscoveryStrategy_3={0}: {1}
-BundleDiscoveryStrategy_task_loading_local_extensions=Loading local extensions
-BundleDiscoveryStrategy_task_processing_extensions=Processing extensions
-BundleDiscoveryStrategy_unexpected_element=unexpected element ''{0}''
-ConnectorCategory_must_specify_connectorCategory_id=Must specify connectorCategory/@id
-ConnectorCategory_must_specify_connectorCategory_name=Must specify connectorCategory/@name
-ConnectorDescriptor_invalid_connectorDescriptor_siteUrl=Invalid connectorDescriptor/@siteUrl
-ConnectorDescriptor_must_specify_connectorDescriptor_categoryId=Must specify connectorDescriptor/@categoryId
-ConnectorDescriptor_must_specify_connectorDescriptor_id=Must specify connectorDescriptor/@id
-ConnectorDescriptor_must_specify_connectorDescriptor_kind=Must specify connectorDescriptor/@kind
-ConnectorDescriptor_must_specify_connectorDescriptor_license=Must specify connectorDescriptor/@license
-ConnectorDescriptor_must_specify_connectorDescriptor_name=Must specify connectorDescriptor/@name
-ConnectorDescriptor_must_specify_connectorDescriptor_provider=Must specify connectorDescriptor/@provider
-ConnectorDescriptor_must_specify_connectorDescriptor_siteUrl=Must specify connectorDescriptor/@siteUrl
-ConnectorDiscovery_bundle_references_unknown_category=Unknown category ''{0}'' referenced by connector ''{1}'' declared in {2}
-ConnectorDiscovery_duplicate_category_id=Duplicate category id ''{0}'': declaring sources: {1}, {2}
-ConnectorDiscovery_illegal_filter_syntax=Illegal filter syntax ''{0}'' in connector ''{1}'' declared in {2}
-ConnectorDiscovery_task_discovering_connectors=Discovering connectors
-ConnectorDiscoveryExtensionReader_unexpected_element_icon=Unexpected element icon
-ConnectorDiscoveryExtensionReader_unexpected_element_overview=Unexpected element overview
-ConnectorDiscoveryExtensionReader_unexpected_value_kind=Unexpected value for kind
-DirectoryParser_no_directory=Unexpected content: no directory available
-DirectoryParser_unexpected_element=Unexpected element ''{0}''
-DiscoveryRegistryStrategy_cannot_load_bundle=Cannot load bundle {0}: {1}
-DiscoveryRegistryStrategy_missing_pluginxml=no plugin.xml in bundle
-RemoteBundleDiscoveryStrategy_cannot_download_bundle=Cannot download bundle at {0}: {1}
-RemoteBundleDiscoveryStrategy_empty_directory=Discovery directory is empty
-RemoteBundleDiscoveryStrategy_io_failure_discovery_directory=IO failure: cannot load discovery directory
-RemoteBundleDiscoveryStrategy_io_failure_temp_storage=IO failure: cannot create temporary storage area
-RemoteBundleDiscoveryStrategy_task_remote_discovery=remote discovery
-RemoteBundleDiscoveryStrategy_unrecognized_discovery_url=Unrecognized discovery bundle URL: {0}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/util/DefaultSaxErrorHandler.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/util/DefaultSaxErrorHandler.java
deleted file mode 100644
index b3756d9..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/util/DefaultSaxErrorHandler.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.discovery.core.util;
-
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * A default implementation of an error handler that throws exceptions on all errors.
- *
- * @author David Green
- */
-public class DefaultSaxErrorHandler implements ErrorHandler {
- public void warning(SAXParseException exception) throws SAXException {
- // ignore
- }
-
- public void fatalError(SAXParseException exception) throws SAXException {
- throw exception;
- }
-
- public void error(SAXParseException exception) throws SAXException {
- throw exception;
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/util/IOWithCauseException.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/util/IOWithCauseException.java
deleted file mode 100644
index f28aed0..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/util/IOWithCauseException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.discovery.core.util;
-
-import java.io.IOException;
-
-/**
- * An IO Exception that allows for {@link #getCause() a cause}.
- *
- * @author David Green
- */
-public class IOWithCauseException extends IOException {
-
- private static final long serialVersionUID = 1L;
-
- private final Throwable cause;
-
- public IOWithCauseException(String message, Throwable cause) {
- super(message);
- this.cause = cause;
- }
-
- public IOWithCauseException(Throwable cause) {
- this.cause = cause;
- }
-
- @Override
- public Throwable getCause() {
- return cause;
- }
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/util/Messages.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/util/Messages.java
deleted file mode 100644
index b43f64b..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/util/Messages.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.discovery.core.util;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- *
- * @author David Green
- */
-class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.discovery.core.util.messages"; //$NON-NLS-1$
-
- public static String WebUtil_cannotDownload;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/util/WebUtil.java b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/util/WebUtil.java
deleted file mode 100644
index dfb213d..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/util/WebUtil.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.discovery.core.util;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.Reader;
-
-import org.apache.commons.httpclient.HostConfiguration;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.mylyn.commons.net.AbstractWebLocation;
-import org.eclipse.mylyn.commons.net.Policy;
-import org.eclipse.osgi.util.NLS;
-
-/**
- * A utility for accessing web resources
- *
- * @author David Green
- */
-public class WebUtil {
- /**
- * implementors are capable of processing character content
- *
- * @see WebUtil#readResource(AbstractWebLocation, TextContentProcessor, IProgressMonitor)
- */
- public interface TextContentProcessor {
- public void process(Reader reader) throws IOException;
- }
-
- /**
- * Download an HTTP-based resource
- *
- * @param target
- * the target file to which the content is saved
- * @param location
- * the web location of the content
- * @param monitor
- * the monitor
- *
- * @throws IOException
- * if a network or IO problem occurs
- */
- public static void downloadResource(File target, AbstractWebLocation location, IProgressMonitor monitor)
- throws IOException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask("Retrieving " + location.getUrl(), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
- try {
- HttpClient client = new HttpClient();
- org.eclipse.mylyn.commons.net.WebUtil.configureHttpClient(client, ""); //$NON-NLS-1$
-
- GetMethod method = new GetMethod(location.getUrl());
- try {
- HostConfiguration hostConfiguration = org.eclipse.mylyn.commons.net.WebUtil.createHostConfiguration(
- client, location, monitor);
- int result = org.eclipse.mylyn.commons.net.WebUtil.execute(client, hostConfiguration, method, monitor);
- if (result == HttpStatus.SC_OK) {
- InputStream in = org.eclipse.mylyn.commons.net.WebUtil.getResponseBodyAsStream(method, monitor);
- try {
- in = new BufferedInputStream(in);
- OutputStream out = new BufferedOutputStream(new FileOutputStream(target));
- try {
- int i;
- while ((i = in.read()) != -1) {
- out.write(i);
- }
- } catch (IOException e) {
- // avoid partial content
- out.close();
- target.delete();
- throw e;
- } finally {
- out.close();
- }
- } finally {
- in.close();
- }
- } else {
- throw new IOException(NLS.bind(Messages.WebUtil_cannotDownload, location.getUrl(), result));
- }
- } finally {
- method.releaseConnection();
- }
- } finally {
- monitor.done();
- }
- }
-
- public static void readResource(AbstractWebLocation location, TextContentProcessor processor,
- IProgressMonitor monitor) throws IOException {
- monitor = Policy.monitorFor(monitor);
- monitor.beginTask("Retrieving " + location.getUrl(), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
- try {
- HttpClient client = new HttpClient();
- org.eclipse.mylyn.commons.net.WebUtil.configureHttpClient(client, ""); //$NON-NLS-1$
-
- GetMethod method = new GetMethod(location.getUrl());
- try {
- HostConfiguration hostConfiguration = org.eclipse.mylyn.commons.net.WebUtil.createHostConfiguration(
- client, location, monitor);
- int result = org.eclipse.mylyn.commons.net.WebUtil.execute(client, hostConfiguration, method, monitor);
- if (result == HttpStatus.SC_OK) {
- InputStream in = org.eclipse.mylyn.commons.net.WebUtil.getResponseBodyAsStream(method, monitor);
- try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(in,
- method.getResponseCharSet()));
- processor.process(reader);
- } finally {
- in.close();
- }
- }
- } finally {
- method.releaseConnection();
- }
- } finally {
- monitor.done();
- }
- }
-}
diff --git a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/util/messages.properties b/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/util/messages.properties
deleted file mode 100644
index 18726fa..0000000
--- a/org.eclipse.mylyn.discovery.core/src/org/eclipse/mylyn/internal/discovery/core/util/messages.properties
+++ /dev/null
@@ -1 +0,0 @@
-WebUtil_cannotDownload=Cannot download {0}: HTTP response {1}
diff --git a/org.eclipse.mylyn.discovery.core/xsd/directory.xsd b/org.eclipse.mylyn.discovery.core/xsd/directory.xsd
deleted file mode 100644
index 25fe712..0000000
--- a/org.eclipse.mylyn.discovery.core/xsd/directory.xsd
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<schema xmlns:tns="http://www.eclipse.org/mylyn/discovery/directory/"
- xmlns="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://www.eclipse.org/mylyn/discovery/directory/">
-
- <annotation>
- <documentation>
- Describes the XML format used by a Mylyn discovery directory.
- </documentation>
- </annotation>
-
- <complexType name="OpenAttrsComplex">
- <annotation>
- <documentation>extend this type to allow for attributes from other namespaces</documentation>
- </annotation>
- <complexContent>
- <restriction base="anyType">
- <anyAttribute namespace="##other" processContents="lax"/>
- </restriction>
- </complexContent>
- </complexType>
-
-
- <element name="directory">
- <complexType>
- <complexContent>
- <extension base="tns:OpenAttrsComplex">
- <sequence>
- <element ref="tns:entry" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </extension>
- </complexContent>
- </complexType>
- </element>
-
- <element name="entry">
- <complexType>
- <complexContent>
- <extension base="tns:OpenAttrsComplex">
- <attribute name="url" type="anyURI"/>
- </extension>
- </complexContent>
- </complexType>
- </element>
-</schema>
\ No newline at end of file