Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[376506] New Server wizard doesn't block user from creating server with

existing name
  • Loading branch information...
commit 3c14acd1335783085ff32a84dbc47dfb17f6c5a4 1 parent b41467c
@elsony elsony authored
View
116 features/org.eclipse.wst.server_ui.feature/feature.xml
@@ -1,58 +1,58 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.eclipse.wst.server_ui.feature"
- label="%featureName"
- version="3.3.100.qualifier"
- provider-name="%providerName"
- license-feature="org.eclipse.license"
- license-feature-version="1.0.0.qualifier">
-
- <description>
- %description
- </description>
-
- <copyright>
- %copyright
- </copyright>
-
- <license url="%licenseURL">
- %license
- </license>
-
- <includes
- id="org.eclipse.wst.server_userdoc.feature"
- version="0.0.0"/>
-
- <includes
- id="org.eclipse.wst.server_core.feature"
- version="0.0.0"/>
-
- <plugin
- id="org.eclipse.wst.internet.monitor.ui"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
- id="org.eclipse.wst.server.ui.infopop"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
- id="org.eclipse.wst.server.ui"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
- id="org.eclipse.wst.server.discovery"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
-</feature>
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.eclipse.wst.server_ui.feature"
+ label="%featureName"
+ version="3.3.101.qualifier"
+ provider-name="%providerName"
+ license-feature="org.eclipse.license"
+ license-feature-version="1.0.0.qualifier">
+
+ <description>
+ %description
+ </description>
+
+ <copyright>
+ %copyright
+ </copyright>
+
+ <license url="%licenseURL">
+ %license
+ </license>
+
+ <includes
+ id="org.eclipse.wst.server_userdoc.feature"
+ version="0.0.0"/>
+
+ <includes
+ id="org.eclipse.wst.server_core.feature"
+ version="0.0.0"/>
+
+ <plugin
+ id="org.eclipse.wst.internet.monitor.ui"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.wst.server.ui.infopop"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.wst.server.ui"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.wst.server.discovery"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
View
2  plugins/org.eclipse.wst.server.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.wst.server.ui; singleton:=true
-Bundle-Version: 1.4.0.qualifier
+Bundle-Version: 1.4.1.qualifier
Bundle-Activator: org.eclipse.wst.server.ui.internal.ServerUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
View
3  plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2012 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
@@ -268,6 +268,7 @@
public static String editorRenameFiles;
public static String errorEditorCantSave;
public static String errorDuplicateName;
+ public static String errorDuplicateServerName;
public static String editorReadOnly;
public static String editorWritable;
public static String editorResourceModifiedTitle;
View
3  plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2004, 2011 IBM Corporation and others.
+# Copyright (c) 2004, 2012 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
@@ -401,6 +401,7 @@ errorMissingConfiguration=The server configuration is missing or invalid
errorConfigurationNotAccessible=The server configuration is not accessible. The {0} project is closed.
errorRootModule=Could not find a valid parent module to add to the server.
errorDuplicateName=The name is already in use. Specify a different name.
+errorDuplicateServerName=The server name is already in use. Specify a different name.
# Info messages
infoNoRuntimesFound=No new server runtime environments were found.
View
15 ...e.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * Copyright (c) 2003, 2012 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
@@ -149,10 +149,15 @@ public boolean isComplete() {
if(getServer().getServerType() == null)
return false;
- return checkHostAndServerType();
+ return checkValidInput();
}
- private boolean checkHostAndServerType(){
+ /*
+ * Checks for valid host name, server type, and server name
+ *
+ * @return true if input is valid, false otherwise
+ */
+ private boolean checkValidInput(){
boolean isComplete = false;
boolean supportsRemote = getServer().getServerType().supportsRemoteHosts();
@@ -165,6 +170,10 @@ private boolean checkHostAndServerType(){
return false;
}
+ if (manualComp.isServerNameInUse()){
+ return false;
+ }
+
if (manualComp.getCurrentHostname().trim().length() == 0){
isComplete = false;
} else if(!supportsRemote && !SocketUtil.isLocalhost(manualComp.getCurrentHostname())){
View
57 ...ipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * Copyright (c) 2003, 2012 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
@@ -40,6 +40,7 @@
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.ui.help.IWorkbenchHelpSystem;
import org.eclipse.wst.server.core.*;
+import org.eclipse.wst.server.core.internal.ServerPlugin;
import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
import org.eclipse.wst.server.core.util.SocketUtil;
import org.eclipse.wst.server.ui.AbstractUIControl;
@@ -110,6 +111,10 @@
private boolean canSupportModule=true;
+ // These variables deal with caching server name checks
+ private boolean isServerNameInUse=false;
+ private String cacheServerNameCheck="";
+
/**
* Creates a new server and server configuration. If the initial
* resource selection contains exactly one container resource then it will be
@@ -236,6 +241,13 @@ public void modifyText(ModifyEvent e) {
return;
String name = serverName.getText();
+
+ IServerType selectedServerType = serverTypeComposite.getSelectedServerType();
+ if (validate(selectedServerType)) {
+ // Do not set the server name if it is invalid
+ return;
+ }
+
if (server != null) {
server.setName(name);
IRuntime runtime2 = server.getRuntime();
@@ -392,7 +404,7 @@ public void setHost(String host) {
protected void handleHostnameChange(IServerType serverType) {
wizard.setMessage(null, IMessageProvider.NONE);
- if (!checkHostAndServerType(serverType)) {
+ if (!validate(serverType)) {
return;// Host name validation failed, so there is no need to continue handling hostname change event
}
loadServerImpl(serverType);
@@ -438,10 +450,23 @@ protected boolean checkHostAndServerType(IServerType selectedServerType){
wizard.setMessage(NLS.bind(Messages.wizCheckRemoteSupport, new Object[0]), IMessageProvider.ERROR);
return false;
}
-
+
return true;
}
+ protected boolean checkServerName(){
+ if (isServerNameInUse()){
+ wizard.setMessage(Messages.errorDuplicateServerName, IMessageProvider.ERROR);
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean validate(IServerType selectedServerType){
+ wizard.setMessage(null, IMessageProvider.NONE);
+ return (checkHostAndServerType(selectedServerType) & checkServerName());
+ }
+
/**
* Load a server of the given type.
*/
@@ -723,7 +748,7 @@ else if (status.getSeverity() == IStatus.INFO)
// Update the old server type value.
oldServerType = serverType;
- checkHostAndServerType(serverType);
+ validate(serverType);
wizard.update();
}
@@ -883,4 +908,28 @@ void setHostName(String host) {
hostName = host;
}
}
+
+ /**
+ * Determines if the server name is in use. The server name that is checked
+ * is cached to increase performance on multiple calls.
+ *
+ * @return true if name is in use, false otherwise
+ */
+ public boolean isServerNameInUse(){
+ String myServerName="";
+ if (serverName != null){
+ myServerName = serverName.getText().trim();
+ // If the server name is equal to the cached server name, then return the
+ // previously cached value. If the server name is not equal to the cached
+ // server name, check to see if the name is in use
+ if (!cacheServerNameCheck.equals(myServerName)){
+ cacheServerNameCheck = myServerName;
+ isServerNameInUse = ServerPlugin.isNameInUse(server, serverName.getText().trim());
+ }
+ return isServerNameInUse;
+ }
+
+ // If the widget is null, return false
+ return false;
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.