|
|
e62044 |
diff --git org.eclipse.mylyn.builds/org.eclipse.mylyn.hudson.ui/META-INF/MANIFEST.MF org.eclipse.mylyn.builds/org.eclipse.mylyn.hudson.ui/META-INF/MANIFEST.MF
|
|
|
e62044 |
index dc4a512..ab101b8 100644
|
|
|
e62044 |
--- org.eclipse.mylyn.builds/org.eclipse.mylyn.hudson.ui/META-INF/MANIFEST.MF
|
|
|
e62044 |
+++ org.eclipse.mylyn.builds/org.eclipse.mylyn.hudson.ui/META-INF/MANIFEST.MF
|
|
|
e62044 |
@@ -20,5 +20,4 @@ Require-Bundle: org.eclipse.core.runtime,
|
|
|
e62044 |
Bundle-ActivationPolicy: lazy
|
|
|
e62044 |
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
|
|
e62044 |
Bundle-Localization: plugin
|
|
|
e62044 |
-Export-Package: org.eclipse.mylyn.internal.hudson.ui;x-internal:=true
|
|
|
e62044 |
-Bundle-Activator: org.eclipse.mylyn.internal.hudson.ui.HudsonUiPlugin
|
|
|
e62044 |
+
|
|
|
e62044 |
diff --git org.eclipse.mylyn.builds/org.eclipse.mylyn.hudson.ui/build.properties org.eclipse.mylyn.builds/org.eclipse.mylyn.hudson.ui/build.properties
|
|
|
e62044 |
index 5ea1ded..aa184c6 100644
|
|
|
e62044 |
--- org.eclipse.mylyn.builds/org.eclipse.mylyn.hudson.ui/build.properties
|
|
|
e62044 |
+++ org.eclipse.mylyn.builds/org.eclipse.mylyn.hudson.ui/build.properties
|
|
|
e62044 |
@@ -18,4 +18,4 @@ bin.includes = META-INF/,\
|
|
|
e62044 |
icons/
|
|
|
e62044 |
src.includes = about.html
|
|
|
e62044 |
|
|
|
e62044 |
-jars.extra.classpath = platform:/plugin/org.eclipse.ecf,platform:/plugin/org.eclipse.ecf.discovery,platform:/plugin/org.eclipse.ecf.provider.discovery,platform:/plugin/org.eclipse.ecf.provider.jmdns
|
|
|
e62044 |
+#jars.extra.classpath = platform:/plugin/org.eclipse.ecf,platform:/plugin/org.eclipse.ecf.discovery,platform:/plugin/org.eclipse.ecf.provider.discovery,platform:/plugin/org.eclipse.ecf.provider.jmdns
|
|
|
e62044 |
diff --git org.eclipse.mylyn.builds/org.eclipse.mylyn.hudson.ui/plugin.xml org.eclipse.mylyn.builds/org.eclipse.mylyn.hudson.ui/plugin.xml
|
|
|
e62044 |
index d3f9f4f..27afb29 100644
|
|
|
e62044 |
--- org.eclipse.mylyn.builds/org.eclipse.mylyn.hudson.ui/plugin.xml
|
|
|
e62044 |
+++ org.eclipse.mylyn.builds/org.eclipse.mylyn.hudson.ui/plugin.xml
|
|
|
e62044 |
@@ -34,11 +34,4 @@
|
|
|
e62044 |
</description>
|
|
|
e62044 |
</wizard>
|
|
|
e62044 |
</extension>
|
|
|
e62044 |
-
|
|
|
e62044 |
- point="org.eclipse.mylyn.builds.ui.startup">
|
|
|
e62044 |
-
|
|
|
e62044 |
- class="org.eclipse.mylyn.internal.hudson.ui.HudsonStartup">
|
|
|
e62044 |
- </startup>
|
|
|
e62044 |
- </extension>
|
|
|
e62044 |
-
|
|
|
e62044 |
</plugin>
|
|
|
e62044 |
diff --git org.eclipse.mylyn.builds/org.eclipse.mylyn.hudson.ui/src/org/eclipse/mylyn/internal/hudson/ui/HudsonDiscovery.java org.eclipse.mylyn.builds/org.eclipse.mylyn.hudson.ui/src/org/eclipse/mylyn/internal/hudson/ui/HudsonDiscovery.java
|
|
|
e62044 |
deleted file mode 100644
|
|
|
e62044 |
index 9500904..0000000
|
|
|
e62044 |
--- org.eclipse.mylyn.builds/org.eclipse.mylyn.hudson.ui/src/org/eclipse/mylyn/internal/hudson/ui/HudsonDiscovery.java
|
|
|
e62044 |
+++ /dev/null
|
|
|
e62044 |
@@ -1,208 +0,0 @@
|
|
|
e62044 |
-/*******************************************************************************
|
|
|
e62044 |
- * Copyright (c) 2010, 2011 Itema AS and others.
|
|
|
e62044 |
- * All rights reserved. This program and the accompanying materials
|
|
|
e62044 |
- * are made available under the terms of the Eclipse Public License v1.0
|
|
|
e62044 |
- * which accompanies this distribution, and is available at
|
|
|
e62044 |
- * http://www.eclipse.org/legal/epl-v10.html
|
|
|
e62044 |
- *
|
|
|
e62044 |
- * Contributors:
|
|
|
e62044 |
- * Torkild U. Resheim - initial API and implementation
|
|
|
e62044 |
- * Torkild U. Resheim - Uniquely identify Jenkins servers, bug 341725
|
|
|
e62044 |
- * Torkild U. Resheim - Distinguish between Hudson and Jenkins, bug 353861
|
|
|
e62044 |
- * Tasktop Technologies - improvements
|
|
|
e62044 |
- *******************************************************************************/
|
|
|
e62044 |
-
|
|
|
e62044 |
-package org.eclipse.mylyn.internal.hudson.ui;
|
|
|
e62044 |
-
|
|
|
e62044 |
-import java.net.URISyntaxException;
|
|
|
e62044 |
-import java.util.List;
|
|
|
e62044 |
-import java.util.UUID;
|
|
|
e62044 |
-
|
|
|
e62044 |
-import org.eclipse.core.runtime.IStatus;
|
|
|
e62044 |
-import org.eclipse.core.runtime.Status;
|
|
|
e62044 |
-import org.eclipse.ecf.core.ContainerConnectException;
|
|
|
e62044 |
-import org.eclipse.ecf.core.ContainerCreateException;
|
|
|
e62044 |
-import org.eclipse.ecf.core.ContainerFactory;
|
|
|
e62044 |
-import org.eclipse.ecf.core.IContainer;
|
|
|
e62044 |
-import org.eclipse.ecf.discovery.IDiscoveryLocator;
|
|
|
e62044 |
-import org.eclipse.ecf.discovery.IServiceEvent;
|
|
|
e62044 |
-import org.eclipse.ecf.discovery.IServiceInfo;
|
|
|
e62044 |
-import org.eclipse.ecf.discovery.IServiceListener;
|
|
|
e62044 |
-import org.eclipse.ecf.discovery.IServiceProperties;
|
|
|
e62044 |
-import org.eclipse.ecf.discovery.identity.IServiceID;
|
|
|
e62044 |
-import org.eclipse.ecf.discovery.identity.IServiceTypeID;
|
|
|
e62044 |
-import org.eclipse.mylyn.builds.ui.BuildsUi;
|
|
|
e62044 |
-import org.eclipse.mylyn.commons.core.StatusHandler;
|
|
|
e62044 |
-import org.eclipse.mylyn.commons.repositories.core.RepositoryLocation;
|
|
|
e62044 |
-import org.eclipse.osgi.util.NLS;
|
|
|
e62044 |
-
|
|
|
e62044 |
-/**
|
|
|
e62044 |
- * This class implements a mechanism for discovering Hudson and Jenkins servers through the use of Multicast DNS (MDNS).
|
|
|
e62044 |
- *
|
|
|
e62044 |
- * @author Torkild U. Resheim, Itema AS
|
|
|
e62044 |
- * @author Steffen Pingel
|
|
|
e62044 |
- */
|
|
|
e62044 |
-public class HudsonDiscovery {
|
|
|
e62044 |
- /**
|
|
|
e62044 |
- * This class works around a source incompatibility between the org.eclipse.ecf.discovery version in Luna and
|
|
|
e62044 |
- * earlier versions. Version 5.0 added the triggerDiscovery method to IServiceListener. This class can be extended
|
|
|
e62044 |
- * in order to implement this method without the @Overide annotation causing compilation to fail against earlier
|
|
|
e62044 |
- * versions (e.g. Kepler).
|
|
|
e62044 |
- */
|
|
|
e62044 |
- private static abstract class AbstractServiceListener {
|
|
|
e62044 |
- public abstract boolean triggerDiscovery();
|
|
|
e62044 |
- }
|
|
|
e62044 |
-
|
|
|
e62044 |
- private final class HudsonServiceListener extends AbstractServiceListener implements IServiceListener {
|
|
|
e62044 |
- public void serviceDiscovered(IServiceEvent anEvent) {
|
|
|
e62044 |
- IServiceInfo serviceInfo = anEvent.getServiceInfo();
|
|
|
e62044 |
- IServiceID serviceId = serviceInfo.getServiceID();
|
|
|
e62044 |
- IServiceTypeID serviceTypeId = serviceId.getServiceTypeID();
|
|
|
e62044 |
- // Note that Jenkins will claim that it's both Jenkins and
|
|
|
e62044 |
- // Hudson for backward compatibility.
|
|
|
e62044 |
- if (serviceTypeId.getName().equals(JENKINS_MDNS_ID)) {
|
|
|
e62044 |
- IServiceProperties properties = serviceInfo.getServiceProperties();
|
|
|
e62044 |
- try {
|
|
|
e62044 |
- if (properties.getProperty(URL_PROPERTY) == null) {
|
|
|
e62044 |
- notifyMessage(Messages.JenkinsDiscovery_MessageTitle, NLS.bind(
|
|
|
e62044 |
- Messages.JenkinsDiscovery_MissingURL, new Object[] { serviceInfo.getLocation()
|
|
|
e62044 |
- .getHost() }));
|
|
|
e62044 |
- } else {
|
|
|
e62044 |
- issueJenkinsNotification(properties);
|
|
|
e62044 |
- }
|
|
|
e62044 |
- } catch (URISyntaxException e) {
|
|
|
e62044 |
- StatusHandler.log(new Status(IStatus.ERROR, HudsonConnectorUi.ID_PLUGIN, NLS.bind(
|
|
|
e62044 |
- Messages.Discovery_IncorrectURI, new Object[] { properties.getProperty(URL_PROPERTY)
|
|
|
e62044 |
- .toString() }), e));
|
|
|
e62044 |
- }
|
|
|
e62044 |
- }
|
|
|
e62044 |
- if (serviceTypeId.getName().equals(HUDSON_MDNS_ID)) {
|
|
|
e62044 |
- IServiceProperties properties = serviceInfo.getServiceProperties();
|
|
|
e62044 |
- try {
|
|
|
e62044 |
- if (properties.getProperty(URL_PROPERTY) == null) {
|
|
|
e62044 |
- notifyMessage(Messages.HudsonDiscovery_MessageTitle, NLS.bind(
|
|
|
e62044 |
- Messages.HudsonDiscovery_MissingURL,
|
|
|
e62044 |
- new Object[] { serviceInfo.getLocation().getHost() }));
|
|
|
e62044 |
- } else {
|
|
|
e62044 |
- issueHudsonNotification(properties);
|
|
|
e62044 |
- }
|
|
|
e62044 |
- } catch (URISyntaxException e) {
|
|
|
e62044 |
- StatusHandler.log(new Status(IStatus.ERROR, HudsonConnectorUi.ID_PLUGIN, NLS.bind(
|
|
|
e62044 |
- Messages.Discovery_IncorrectURI, new Object[] { properties.getProperty(URL_PROPERTY)
|
|
|
e62044 |
- .toString() }), e));
|
|
|
e62044 |
- }
|
|
|
e62044 |
- }
|
|
|
e62044 |
- }
|
|
|
e62044 |
-
|
|
|
e62044 |
- public void serviceUndiscovered(IServiceEvent anEvent) {
|
|
|
e62044 |
- // Ignore this for now
|
|
|
e62044 |
- }
|
|
|
e62044 |
-
|
|
|
e62044 |
- @Override
|
|
|
e62044 |
- public boolean triggerDiscovery() {
|
|
|
e62044 |
- return false;
|
|
|
e62044 |
- }
|
|
|
e62044 |
- }
|
|
|
e62044 |
-
|
|
|
e62044 |
- private static final String ECF_DISCOVERY_JMDNS = "ecf.discovery.jmdns"; //$NON-NLS-1$
|
|
|
e62044 |
-
|
|
|
e62044 |
- private static final String HUDSON_MDNS_ID = "_hudson._tcp.local._iana"; //$NON-NLS-1$
|
|
|
e62044 |
-
|
|
|
e62044 |
- private static final String JENKINS_MDNS_ID = "_jenkins._tcp.local._iana"; //$NON-NLS-1$
|
|
|
e62044 |
-
|
|
|
e62044 |
- private static final String URL_PROPERTY = "url"; //$NON-NLS-1$
|
|
|
e62044 |
-
|
|
|
e62044 |
- /** Server id property name (Jenkins only). */
|
|
|
e62044 |
- private static final String SERVER_ID_PROPERTY = "server-id"; //$NON-NLS-1$
|
|
|
e62044 |
-
|
|
|
e62044 |
- private IContainer container;
|
|
|
e62044 |
-
|
|
|
e62044 |
- public HudsonDiscovery() {
|
|
|
e62044 |
- }
|
|
|
e62044 |
-
|
|
|
e62044 |
- protected IContainer getContainer() throws ContainerCreateException {
|
|
|
e62044 |
- return ContainerFactory.getDefault().createContainer(ECF_DISCOVERY_JMDNS);
|
|
|
e62044 |
- }
|
|
|
e62044 |
-
|
|
|
e62044 |
- /**
|
|
|
e62044 |
- * Determines whether or not the detected server is a new server or not.
|
|
|
e62044 |
- *
|
|
|
e62044 |
- * @param url
|
|
|
e62044 |
- * the server URL
|
|
|
e62044 |
- * @param id
|
|
|
e62044 |
- * the server identifier
|
|
|
e62044 |
- * @return true if the detected server is new.
|
|
|
e62044 |
- */
|
|
|
e62044 |
- private boolean isNew(String url, String id) {
|
|
|
e62044 |
- if (url == null) {
|
|
|
e62044 |
- return false;
|
|
|
e62044 |
- }
|
|
|
e62044 |
- List<RepositoryLocation> locations = BuildsUi.getServerLocations();
|
|
|
e62044 |
- for (RepositoryLocation location : locations) {
|
|
|
e62044 |
- if (location.hasUrl(url) || location.getId().equals(id)) {
|
|
|
e62044 |
- return false;
|
|
|
e62044 |
- }
|
|
|
e62044 |
- }
|
|
|
e62044 |
- return true;
|
|
|
e62044 |
- }
|
|
|
e62044 |
-
|
|
|
e62044 |
- public void start() {
|
|
|
e62044 |
- try {
|
|
|
e62044 |
- container = getContainer();
|
|
|
e62044 |
- final IDiscoveryLocator adapter = (IDiscoveryLocator) container.getAdapter(IDiscoveryLocator.class);
|
|
|
e62044 |
- adapter.addServiceListener(new HudsonServiceListener());
|
|
|
e62044 |
- container.connect(null, null);
|
|
|
e62044 |
-
|
|
|
e62044 |
- } catch (ContainerCreateException e) {
|
|
|
e62044 |
- StatusHandler.log(new Status(IStatus.WARNING, HudsonConnectorUi.ID_PLUGIN,
|
|
|
e62044 |
- Messages.Discovery_CouldNotStartService, e));
|
|
|
e62044 |
- } catch (ContainerConnectException e) {
|
|
|
e62044 |
- StatusHandler.log(new Status(IStatus.WARNING, HudsonConnectorUi.ID_PLUGIN,
|
|
|
e62044 |
- Messages.Discovery_CouldNotStartService, e));
|
|
|
e62044 |
- }
|
|
|
e62044 |
- }
|
|
|
e62044 |
-
|
|
|
e62044 |
- public void stop() {
|
|
|
e62044 |
- if (container != null) {
|
|
|
e62044 |
- container.disconnect();
|
|
|
e62044 |
- container = null;
|
|
|
e62044 |
- }
|
|
|
e62044 |
- }
|
|
|
e62044 |
-
|
|
|
e62044 |
- private void notifyMessage(String title, String description) {
|
|
|
e62044 |
- BuildsUi.serverDiscovered(title, description);
|
|
|
e62044 |
- }
|
|
|
e62044 |
-
|
|
|
e62044 |
- private void issueHudsonNotification(IServiceProperties properties) throws URISyntaxException {
|
|
|
e62044 |
- String url = properties.getProperty(URL_PROPERTY).toString();
|
|
|
e62044 |
- String id = getId(properties);
|
|
|
e62044 |
- if (isNew(url, id)) {
|
|
|
e62044 |
- notifyMessage(
|
|
|
e62044 |
- Messages.HudsonDiscovery_MessageTitle,
|
|
|
e62044 |
- NLS.bind(Messages.HudsonDiscovery_MessageText, new Object[] { url,
|
|
|
e62044 |
- Messages.HudsonDiscovery_ServerName, url, id }));
|
|
|
e62044 |
- }
|
|
|
e62044 |
- }
|
|
|
e62044 |
-
|
|
|
e62044 |
- private void issueJenkinsNotification(IServiceProperties properties) throws URISyntaxException {
|
|
|
e62044 |
- String url = properties.getProperty(URL_PROPERTY).toString();
|
|
|
e62044 |
- String id = getId(properties);
|
|
|
e62044 |
- if (isNew(url, id)) {
|
|
|
e62044 |
- // Change the first segment (org.eclipse.mylyn.hudson) to the id of
|
|
|
e62044 |
- // the new repository type when we start differentiation between the two
|
|
|
e62044 |
- notifyMessage(
|
|
|
e62044 |
- Messages.JenkinsDiscovery_MessageTitle,
|
|
|
e62044 |
- NLS.bind(Messages.JenkinsDiscovery_MessageText, new Object[] { url,
|
|
|
e62044 |
- Messages.JenkinsDiscovery_ServerName, url, id }));
|
|
|
e62044 |
- }
|
|
|
e62044 |
- }
|
|
|
e62044 |
-
|
|
|
e62044 |
- private String getId(IServiceProperties properties) {
|
|
|
e62044 |
- String id = (String) properties.getProperty(SERVER_ID_PROPERTY);
|
|
|
e62044 |
- if (id == null) {
|
|
|
e62044 |
- id = UUID.randomUUID().toString();
|
|
|
e62044 |
- }
|
|
|
e62044 |
- return id;
|
|
|
e62044 |
- }
|
|
|
e62044 |
-
|
|
|
e62044 |
-}
|
|
|
e62044 |
diff --git org.eclipse.mylyn.builds/org.eclipse.mylyn.hudson.ui/src/org/eclipse/mylyn/internal/hudson/ui/HudsonUiPlugin.java org.eclipse.mylyn.builds/org.eclipse.mylyn.hudson.ui/src/org/eclipse/mylyn/internal/hudson/ui/HudsonUiPlugin.java
|
|
|
e62044 |
deleted file mode 100644
|
|
|
e62044 |
index a160eb0..0000000
|
|
|
e62044 |
--- org.eclipse.mylyn.builds/org.eclipse.mylyn.hudson.ui/src/org/eclipse/mylyn/internal/hudson/ui/HudsonUiPlugin.java
|
|
|
e62044 |
+++ /dev/null
|
|
|
e62044 |
@@ -1,35 +0,0 @@
|
|
|
e62044 |
-/*******************************************************************************
|
|
|
e62044 |
- * Copyright (c) 2011 Tasktop Technologies.
|
|
|
e62044 |
- * All rights reserved. This program and the accompanying materials
|
|
|
e62044 |
- * are made available under the terms of the Eclipse Public License v1.0
|
|
|
e62044 |
- * which accompanies this distribution, and is available at
|
|
|
e62044 |
- * http://www.eclipse.org/legal/epl-v10.html
|
|
|
e62044 |
- *
|
|
|
e62044 |
- * Contributors:
|
|
|
e62044 |
- * Tasktop Technologies - initial API and implementation
|
|
|
e62044 |
- *******************************************************************************/
|
|
|
e62044 |
-
|
|
|
e62044 |
-package org.eclipse.mylyn.internal.hudson.ui;
|
|
|
e62044 |
-
|
|
|
e62044 |
-import org.eclipse.ui.plugin.AbstractUIPlugin;
|
|
|
e62044 |
-import org.osgi.framework.BundleContext;
|
|
|
e62044 |
-
|
|
|
e62044 |
-/**
|
|
|
e62044 |
- * @author Steffen Pingel
|
|
|
e62044 |
- */
|
|
|
e62044 |
-public class HudsonUiPlugin extends AbstractUIPlugin {
|
|
|
e62044 |
-
|
|
|
e62044 |
- public static String ID_PLUGIN = "org.eclipse.mylyn.hudson.ui";
|
|
|
e62044 |
-
|
|
|
e62044 |
- public HudsonUiPlugin() {
|
|
|
e62044 |
- }
|
|
|
e62044 |
-
|
|
|
e62044 |
- @Override
|
|
|
e62044 |
- public void stop(BundleContext context) throws Exception {
|
|
|
e62044 |
- if (HudsonStartup.getInstance() != null) {
|
|
|
e62044 |
- HudsonStartup.getInstance().stop();
|
|
|
e62044 |
- }
|
|
|
e62044 |
- super.stop(context);
|
|
|
e62044 |
- }
|
|
|
e62044 |
-
|
|
|
e62044 |
-}
|