[400036] Restrict supported servers for client and service runtimes
[415168] Restrict supported servers for client and service runtimes -
supportedServers bug
diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/ClientRuntimeDescriptor.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/ClientRuntimeDescriptor.java
index 39b5413..3134364 100644
--- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/ClientRuntimeDescriptor.java
+++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/ClientRuntimeDescriptor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 IBM Corporation 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
@@ -49,6 +49,7 @@
private Set<String> suitableProjectTemplates;
private Set<String> unsuitableProjectTemplates;
private boolean allowClientServerRestriction;
+ private List<String> supportedServers;
private List<String> unsupportedServers;
public ClientRuntimeDescriptor(IConfigurationElement elem, Hashtable allWebServiceClientImpls, Hashtable allRuntimes)
@@ -229,7 +230,39 @@
public boolean allowClientServersRestriction() {
return allowClientServerRestriction;
}
-
+
+ /**
+ * Note that only the supported or unsupported attribute should be used, not both.
+ */
+ public boolean isSupportedServer(String id) {
+ if(!allowClientServerRestriction)
+ return false;
+
+ String serverElements = elem.getAttribute("supportedServers");
+ // Extension defines supportedServers
+ if (supportedServers == null)
+ supportedServers = parseServers(serverElements);
+ // If the extension does not define supportedServers but defines unsupportedServers
+ // This is for the case when a server does not support a particular client runtime
+ if (serverElements == null)
+ {
+ String unsupportedServerElements = elem.getAttribute("unsupportedServers");
+ if (unsupportedServers == null)
+ unsupportedServers = parseServers(unsupportedServerElements);
+ // If it is not in the unsupported list, then it must be supported, as extensions should
+ // not have to list off all the possible supported servers (and since currently only one
+ // of unsupportedServer or supportedServers is recognized).
+ if (!unsupportedServers.contains(id) && !supportedServers.contains(id))
+ {
+ supportedServers.add(id);
+ }
+ }
+ return supportedServers.contains(id);
+ }
+
+ /**
+ * Note that only the supported or unsupported attribute should be used, not both.
+ */
public boolean isUnsupportedServer(String id) {
if(!allowClientServerRestriction)
return false;
diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/ServiceRuntimeDescriptor.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/ServiceRuntimeDescriptor.java
index 2397cbe..b653469 100644
--- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/ServiceRuntimeDescriptor.java
+++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/ServiceRuntimeDescriptor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 IBM Corporation 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
@@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Hashtable;
+import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
@@ -39,6 +40,7 @@
private IConfigurationElement elem;
private Hashtable allWebServiceImpls;
private Hashtable allRuntimes;
+ private boolean allowServiceServerRestriction;
private String id;
private WebServiceImpl serviceImplementationType;
private RuntimeDescriptor runtime;
@@ -52,6 +54,7 @@
private String runtimePreferredServerType;
private Set<String> suitableProjectTemplates;
private Set<String> unsuitableProjectTemplates;
+ private List<String> supportedServers;
public ServiceRuntimeDescriptor(IConfigurationElement elem, Hashtable allWebServiceImpls, Hashtable allRuntimes)
{
@@ -59,6 +62,7 @@
this.allWebServiceImpls = allWebServiceImpls;
this.allRuntimes = allRuntimes;
+ allowServiceServerRestriction = Boolean.parseBoolean(elem.getAttribute("allowServiceServerRestriction"));
bottomUp = (Boolean.valueOf(elem.getAttribute("bottomUp"))).booleanValue();
topDown = (Boolean.valueOf(elem.getAttribute("topDown"))).booleanValue();
}
@@ -252,4 +256,30 @@
}
return runtimePreferredServerType;
}
+
+ public boolean allowServiceServersRestriction() {
+ return allowServiceServerRestriction;
+ }
+
+ public boolean isSupportedServer(String id) {
+ if(!allowServiceServerRestriction)
+ return false;
+ if(supportedServers == null) {
+ String serverElements = elem.getAttribute("supportedServers");
+ supportedServers = parseServers(serverElements);
+ }
+ return supportedServers.contains(id);
+ }
+
+ private List<String> parseServers(String serverElements) {
+ List<String> serverList = new ArrayList<String>();
+ if(serverElements != null) {
+ String[] servers = serverElements.split("\\s+");
+ for (int i = 0; i < servers.length; i++) {
+ if (servers[i].length() > 0)
+ serverList.add(servers[i]);
+ }
+ }
+ return serverList;
+ }
}
diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/WebServiceRuntimeExtensionUtils2.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/WebServiceRuntimeExtensionUtils2.java
index 5342c09..ef21872 100644
--- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/WebServiceRuntimeExtensionUtils2.java
+++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/WebServiceRuntimeExtensionUtils2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 IBM Corporation 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
@@ -753,6 +753,13 @@
{
if (serverIds[i].equals(serverFactoryId))
{
+ ServiceRuntimeDescriptor desc = getServiceRuntimeDescriptorById(serviceRuntimeId);
+ if(desc.allowServiceServersRestriction()) {
+ if(desc.isSupportedServer(serverFactoryId))
+ return true;
+ else
+ continue;
+ }
return true;
}
}
@@ -967,6 +974,12 @@
{
if (fIds[j].equals(serverFactoryId))
{
+ if(desc.allowServiceServersRestriction()) {
+ if(desc.isSupportedServer(serverFactoryId))
+ return true;
+ else
+ continue;
+ }
return true;
}
}
@@ -1639,6 +1652,13 @@
{
if (serverIds[i].equals(serverFactoryId))
{
+ ClientRuntimeDescriptor desc = getClientRuntimeDescriptorById(clientRuntimeId);
+ if(desc.allowClientServersRestriction()) {
+ if(desc.isSupportedServer(serverFactoryId))
+ return true;
+ else
+ continue;
+ }
return true;
}
}