Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 410843
Collapse All | Expand All

(-)src/org/eclipse/jst/ws/internal/consumption/ui/widgets/runtime/ProjectSelectionWidget.java (-1 / +2 lines)
Lines 289-301 Link Here
289
    listenersOff();
289
    listenersOff();
290
    String selectedModuleProject = moduleProject_.getText();    
290
    String selectedModuleProject = moduleProject_.getText();    
291
    String runtimeId = trsIds_.getRuntimeId();
291
    String runtimeId = trsIds_.getRuntimeId();
292
    String serverId = trsIds_.getServerId();
292
    String typeId = trsIds_.getTypeId();
293
    String typeId = trsIds_.getTypeId();
293
    
294
    
294
    //Get all the projects that are compatible with the type and runtime
295
    //Get all the projects that are compatible with the type and runtime
295
    String[] projectNames = null;
296
    String[] projectNames = null;
296
    if (isClient_)
297
    if (isClient_)
297
    {
298
    {
298
      projectNames = WebServiceRuntimeExtensionUtils2.getProjectsForClientTypeAndRuntime(typeId, runtimeId);
299
      projectNames = WebServiceRuntimeExtensionUtils2.getProjectsForClientTypeAndRuntime(typeId, runtimeId, serverId);
299
    }
300
    }
300
    else
301
    else
301
    {
302
    {
(-)src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/ClientRuntimeDescriptor.java (-1 / +49 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
2
 * Copyright (c) 2005, 2013 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 20-25 Link Here
20
import java.util.ArrayList;
20
import java.util.ArrayList;
21
import java.util.HashSet;
21
import java.util.HashSet;
22
import java.util.Hashtable;
22
import java.util.Hashtable;
23
import java.util.List;
23
import java.util.Set;
24
import java.util.Set;
24
25
25
import org.eclipse.core.runtime.CoreException;
26
import org.eclipse.core.runtime.CoreException;
Lines 47-58 Link Here
47
  private String runtimePreferredServerType;
48
  private String runtimePreferredServerType;
48
  private  Set<String> suitableProjectTemplates;
49
  private  Set<String> suitableProjectTemplates;
49
  private  Set<String> unsuitableProjectTemplates;
50
  private  Set<String> unsuitableProjectTemplates;
51
  private boolean allowClientServerRestriction;
52
  private List<String> supportedServers;
53
  private List<String> unsupportedServers;
50
  
54
  
51
  public ClientRuntimeDescriptor(IConfigurationElement elem, Hashtable allWebServiceClientImpls, Hashtable allRuntimes)
55
  public ClientRuntimeDescriptor(IConfigurationElement elem, Hashtable allWebServiceClientImpls, Hashtable allRuntimes)
52
  {
56
  {
53
    this.elem = elem;
57
    this.elem = elem;
54
    this.allWebServiceClientImpls = allWebServiceClientImpls;
58
    this.allWebServiceClientImpls = allWebServiceClientImpls;
55
    this.allRuntimes = allRuntimes;
59
    this.allRuntimes = allRuntimes;
60
    
61
    allowClientServerRestriction = Boolean.parseBoolean(elem.getAttribute("allowClientServerRestriction"));
56
  }
62
  }
57
  
63
  
58
  public WebServiceClientImpl getClientImplementationType()
64
  public WebServiceClientImpl getClientImplementationType()
Lines 220-223 Link Here
220
    }
226
    }
221
    return runtimePreferredServerType;
227
    return runtimePreferredServerType;
222
  }
228
  }
229
  
230
  public boolean allowClientServersRestriction() {
231
	  return allowClientServerRestriction;
232
  }
233
   
234
  /**
235
   * Note that only the supported or unsupported attribute should be used, not both.
236
   */
237
  public boolean isSupportedServer(String id) {
238
	if(!allowClientServerRestriction)
239
		return false;
240
	if(supportedServers == null) {
241
		String serverElements = elem.getAttribute("supportedServers");
242
		supportedServers = parseServers(serverElements);
243
	}
244
	return supportedServers.contains(id);
245
  }
246
  
247
  /**
248
   * Note that only the supported or unsupported attribute should be used, not both.
249
   */
250
  public boolean isUnsupportedServer(String id) {
251
	if(!allowClientServerRestriction)
252
		return false;
253
	if(unsupportedServers == null) {
254
		String serverElements = elem.getAttribute("unsupportedServers");
255
		unsupportedServers = parseServers(serverElements);
256
	}
257
	return unsupportedServers.contains(id);
258
  }
259
  
260
  private List<String> parseServers(String serverElements) {
261
	List<String> serverList = new ArrayList<String>();
262
	if(serverElements != null) {
263
		String[] servers = serverElements.split("\\s+");
264
		for (int i = 0; i < servers.length; i++)  {
265
			if (servers[i].length() > 0)
266
				serverList.add(servers[i]);
267
		}
268
	}
269
	return serverList;
270
  }
223
}
271
}
(-)src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/ServiceRuntimeDescriptor.java (-1 / +31 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
2
 * Copyright (c) 2005, 2013 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 22-27 Link Here
22
import java.util.ArrayList;
22
import java.util.ArrayList;
23
import java.util.HashSet;
23
import java.util.HashSet;
24
import java.util.Hashtable;
24
import java.util.Hashtable;
25
import java.util.List;
25
import java.util.Set;
26
import java.util.Set;
26
27
27
import org.eclipse.core.runtime.CoreException;
28
import org.eclipse.core.runtime.CoreException;
Lines 39-44 Link Here
39
  private IConfigurationElement elem;
40
  private IConfigurationElement elem;
40
  private Hashtable allWebServiceImpls;
41
  private Hashtable allWebServiceImpls;
41
  private Hashtable allRuntimes;
42
  private Hashtable allRuntimes;
43
  private boolean allowServiceServerRestriction;
42
  private String id;
44
  private String id;
43
  private WebServiceImpl serviceImplementationType;
45
  private WebServiceImpl serviceImplementationType;
44
  private RuntimeDescriptor runtime;
46
  private RuntimeDescriptor runtime;
Lines 52-57 Link Here
52
  private String runtimePreferredServerType;
54
  private String runtimePreferredServerType;
53
  private  Set<String> suitableProjectTemplates;
55
  private  Set<String> suitableProjectTemplates;
54
  private  Set<String> unsuitableProjectTemplates;
56
  private  Set<String> unsuitableProjectTemplates;
57
  private List<String> supportedServers;
55
  
58
  
56
  public ServiceRuntimeDescriptor(IConfigurationElement elem, Hashtable allWebServiceImpls, Hashtable allRuntimes)
59
  public ServiceRuntimeDescriptor(IConfigurationElement elem, Hashtable allWebServiceImpls, Hashtable allRuntimes)
57
  {
60
  {
Lines 59-64 Link Here
59
    this.allWebServiceImpls = allWebServiceImpls;
62
    this.allWebServiceImpls = allWebServiceImpls;
60
    this.allRuntimes = allRuntimes;
63
    this.allRuntimes = allRuntimes;
61
64
65
    allowServiceServerRestriction = Boolean.parseBoolean(elem.getAttribute("allowServiceServerRestriction"));
62
    bottomUp = (Boolean.valueOf(elem.getAttribute("bottomUp"))).booleanValue();
66
    bottomUp = (Boolean.valueOf(elem.getAttribute("bottomUp"))).booleanValue();
63
    topDown = (Boolean.valueOf(elem.getAttribute("topDown"))).booleanValue();    
67
    topDown = (Boolean.valueOf(elem.getAttribute("topDown"))).booleanValue();    
64
  }
68
  }
Lines 252-255 Link Here
252
    }
256
    }
253
    return runtimePreferredServerType;
257
    return runtimePreferredServerType;
254
  }
258
  }
259
  
260
  public boolean allowServiceServersRestriction() {
261
	  return allowServiceServerRestriction;
262
  }
263
    
264
  public boolean isSupportedServer(String id) {
265
	if(!allowServiceServerRestriction)
266
		return false;
267
	if(supportedServers == null) {
268
		String serverElements = elem.getAttribute("supportedServers");
269
		supportedServers = parseServers(serverElements);
270
	}
271
	return supportedServers.contains(id);
272
  }
273
  
274
  private List<String> parseServers(String serverElements) {
275
	List<String> serverList = new ArrayList<String>();
276
	if(serverElements != null) {
277
		String[] servers = serverElements.split("\\s+");
278
		for (int i = 0; i < servers.length; i++)  {
279
			if (servers[i].length() > 0)
280
				serverList.add(servers[i]);
281
		}
282
	}
283
	return serverList;
284
  }
255
}
285
}
(-)src/org/eclipse/jst/ws/internal/consumption/ui/wsrt/WebServiceRuntimeExtensionUtils2.java (-7 / +87 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
2
 * Copyright (c) 2005, 2013 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 753-758 Link Here
753
    {
753
    {
754
      if (serverIds[i].equals(serverFactoryId))
754
      if (serverIds[i].equals(serverFactoryId))
755
      {
755
      {
756
      	  ServiceRuntimeDescriptor desc = getServiceRuntimeDescriptorById(serviceRuntimeId);
757
    	  if(desc.allowServiceServersRestriction()) {
758
    		  if(desc.isSupportedServer(serverFactoryId))
759
    			  return true;
760
    		  else
761
    			  continue;
762
    	  }
756
        return true;
763
        return true;
757
      }
764
      }
758
    }
765
    }
Lines 967-972 Link Here
967
          {
974
          {
968
            if (fIds[j].equals(serverFactoryId))
975
            if (fIds[j].equals(serverFactoryId))
969
            {
976
            {
977
            	if(desc.allowServiceServersRestriction()) {
978
            		if(desc.isSupportedServer(serverFactoryId))
979
            			return true;
980
            		else
981
            			continue;
982
            	}
970
              return true;
983
              return true;
971
            }
984
            }
972
          }          
985
          }          
Lines 1639-1644 Link Here
1639
    {
1652
    {
1640
      if (serverIds[i].equals(serverFactoryId))
1653
      if (serverIds[i].equals(serverFactoryId))
1641
      {
1654
      {
1655
        ClientRuntimeDescriptor desc = getClientRuntimeDescriptorById(clientRuntimeId);
1656
    	if(desc.allowClientServersRestriction()) {
1657
    		if(desc.isSupportedServer(serverFactoryId))
1658
    			return true;
1659
    		else
1660
    			continue;
1661
    	}
1642
        return true;
1662
        return true;
1643
      }
1663
      }
1644
    }
1664
    }
Lines 1741-1747 Link Here
1741
          String[] factoryIds = getServerFactoryIdsByClientRuntime(desc.getId());
1761
          String[] factoryIds = getServerFactoryIdsByClientRuntime(desc.getId());
1742
          for (int j=0; j<factoryIds.length; j++)
1762
          for (int j=0; j<factoryIds.length; j++)
1743
          {
1763
          {
1744
            if (factoryIds[j].equals(serverFactoryId))
1764
          	// Check if the IDs match and the server is supported by the client.
1765
            if (factoryIds[j].equals(serverFactoryId) && !desc.isUnsupportedServer(serverFactoryId))
1745
            {
1766
            {
1746
              return true;
1767
              return true;
1747
            }
1768
            }
Lines 1779-1785 Link Here
1779
    	if (serverId == null || doesClientRuntimeSupportServer(crIds[i], serverId)) { 
1800
    	if (serverId == null || doesClientRuntimeSupportServer(crIds[i], serverId)) { 
1780
	      ClientRuntimeDescriptor desc = getClientRuntimeDescriptorById(crIds[i]);
1801
	      ClientRuntimeDescriptor desc = getClientRuntimeDescriptorById(crIds[i]);
1781
	      String thisRuntimeId = desc.getRuntime().getId();
1802
	      String thisRuntimeId = desc.getRuntime().getId();
1782
	      if (thisRuntimeId.equals(runtimeId))
1803
	      // Check if the IDs match and the server is supported by the runtime.
1804
	      if (thisRuntimeId.equals(runtimeId) && !desc.isUnsupportedServer(serverId))
1783
	      {
1805
	      {
1784
	        //Get the templates for this clientRuntime
1806
	        //Get the templates for this clientRuntime
1785
	        Set templates = FacetMatchCache.getInstance().getTemplatesForClientRuntime(desc.getId());
1807
	        Set templates = FacetMatchCache.getInstance().getTemplatesForClientRuntime(desc.getId());
Lines 1985-1996 Link Here
1985
   */
2007
   */
1986
  public static String[] getProjectsForClientTypeAndRuntime(String typeId, String runtimeId)
2008
  public static String[] getProjectsForClientTypeAndRuntime(String typeId, String runtimeId)
1987
  {
2009
  {
2010
	  return getProjectsForClientTypeAndRuntime(typeId, runtimeId, null);
2011
  }
2012
  
2013
  /**
2014
   * Returns the names of all projects in the workspace which support the given Web service client 
2015
   * implementation type and Web service runtime.
2016
   * 
2017
   * @param typeId id of a Web service client implementation type
2018
   * @param runtimeId id of a Web service runtime
2019
   * @param serverId id of the target server for filtering unsupported server runtimes
2020
   * @return String[] array of project names. The array may have 0 elements.
2021
   */
2022
  public static String[] getProjectsForClientTypeAndRuntime(String typeId, String runtimeId, String serverId)
2023
  {
1988
    IProject[] projects = FacetUtils.getAllProjects();
2024
    IProject[] projects = FacetUtils.getAllProjects();
1989
    ArrayList validProjects = new ArrayList();
2025
    ArrayList validProjects = new ArrayList();
1990
    
2026
    
1991
    for (int i=0; i<projects.length;i++)
2027
    for (int i=0; i<projects.length;i++)
1992
    {
2028
    {
1993
      if (doesClientTypeAndRuntimeSupportProject(typeId, runtimeId, projects[i].getName()))
2029
      if (doesClientTypeAndRuntimeSupportProject(typeId, runtimeId, projects[i].getName(), serverId))
1994
      {
2030
      {
1995
        validProjects.add(projects[i].getName());        
2031
        validProjects.add(projects[i].getName());        
1996
      }      
2032
      }      
Lines 2016-2022 Link Here
2016
   * <li>if projectName is null or empty</li>
2052
   * <li>if projectName is null or empty</li>
2017
   * </ul>
2053
   * </ul>
2018
   */
2054
   */
2019
  public static boolean doesClientTypeAndRuntimeSupportProject(String typeId, String runtimeId, String projectName)
2055
  public static boolean doesClientTypeAndRuntimeSupportProject(String typeId, String runtimeId, String projectName) {
2056
	  return doesClientTypeAndRuntimeSupportProject(typeId, runtimeId, projectName, null);
2057
  }
2058
  
2059
  /**
2060
   * Returns whether or not the given project supports the given Web service client implementation type 
2061
   * and Web service runtime.
2062
   * 
2063
   * @param typeId id of a Web service client implementation type
2064
   * @param runtimeId id of a Web service runtime
2065
   * @param projectName name of an IProject in the workspace
2066
   * @param serverId id of the target server for filtering unsupported server runtimes
2067
   * @return boolean <code>true</code> if the project supports the given Web service type and 
2068
   * Web service runtime. Returns <code>false</code>
2069
   * <ul> 
2070
   * <li>if the project does not support the given Web service client implementation type and 
2071
   * Web service runtime or</li>
2072
   * <li>if the project does not exist or</li>
2073
   * <li>if projectName is null or empty</li>
2074
   * </ul>
2075
   */
2076
  public static boolean doesClientTypeAndRuntimeSupportProject(String typeId, String runtimeId, String projectName, String serverId)
2020
  {
2077
  {
2021
    String[] descs = getClientRuntimesByType(typeId);
2078
    String[] descs = getClientRuntimesByType(typeId);
2022
    for (int j = 0; j < descs.length; j++)
2079
    for (int j = 0; j < descs.length; j++)
Lines 2024-2030 Link Here
2024
      ClientRuntimeDescriptor desc = getClientRuntimeDescriptorById(descs[j]);
2081
      ClientRuntimeDescriptor desc = getClientRuntimeDescriptorById(descs[j]);
2025
      if (desc.getRuntime().getId().equals(runtimeId))
2082
      if (desc.getRuntime().getId().equals(runtimeId))
2026
      {
2083
      {
2027
        if (doesClientRuntimeSupportProject(descs[j], projectName))
2084
        if (doesClientRuntimeSupportProject(descs[j], projectName, serverId))
2028
        {
2085
        {
2029
          return true;
2086
          return true;
2030
        }
2087
        }
Lines 2049-2056 Link Here
2049
   * <li>if projectName is null or empty</li>
2106
   * <li>if projectName is null or empty</li>
2050
   * </ul>
2107
   * </ul>
2051
   */
2108
   */
2052
  public static boolean doesClientRuntimeSupportProject(String clientRuntimeId, String projectName)
2109
  public static boolean doesClientRuntimeSupportProject(String clientRuntimeId, String projectName) {
2110
	  return doesClientRuntimeSupportProject(clientRuntimeId, projectName, null);
2111
  }
2112
  
2113
  /**
2114
   * Returns whether or not the given project supports the given clientRuntime.
2115
   * @param clientRuntimeId id of a clientRuntime
2116
   * @param projectName name of an IProject in the workspace
2117
   * @param serverId id of the target server for filtering unsupported server runtimes
2118
   * @return boolean <code>true</code> if the project supports the given
2119
   * clientRuntime. Returns <code>false</code>
2120
   * <ul> 
2121
   * <li>if the project does not support the given clientRuntime or</li>
2122
   * <li>if the project does not exist or</li>
2123
   * <li>if projectName is null or empty</li>
2124
   * </ul>
2125
   */
2126
  public static boolean doesClientRuntimeSupportProject(String clientRuntimeId, String projectName, String serverId)
2053
  {
2127
  {
2128
  	// Check if there is an unsupported server to filter
2129
	if(serverId != null) {
2130
		ClientRuntimeDescriptor desc = getClientRuntimeDescriptorById(clientRuntimeId);
2131
		if(desc.isUnsupportedServer(serverId))
2132
			return false;
2133
	}
2054
    FacetMatcher fm = FacetMatchCache.getInstance().getMatchForProject(true, clientRuntimeId, projectName);
2134
    FacetMatcher fm = FacetMatchCache.getInstance().getMatchForProject(true, clientRuntimeId, projectName);
2055
    if (fm != null)
2135
    if (fm != null)
2056
    {
2136
    {

Return to bug 410843