Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 221649 Details for
Bug 390695
New Server wizard doesn't block user from creating server with existing name
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
v1.0
file_390695.txt (text/plain), 8.85 KB, created by
Elson Yuen
on 2012-09-28 11:07:47 EDT
(
hide
)
Description:
v1.0
Filename:
MIME Type:
Creator:
Elson Yuen
Created:
2012-09-28 11:07:47 EDT
Size:
8.85 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.server.ui >Index: serverui/org/eclipse/wst/server/ui/internal/Messages.java >=================================================================== >RCS file: /cvsroot/webtools/servertools/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java,v >retrieving revision 1.71 >diff -u -r1.71 Messages.java >--- serverui/org/eclipse/wst/server/ui/internal/Messages.java 28 Dec 2011 19:13:25 -0000 1.71 >+++ serverui/org/eclipse/wst/server/ui/internal/Messages.java 24 May 2012 18:58:57 -0000 >@@ -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; >Index: serverui/org/eclipse/wst/server/ui/internal/Messages.properties >=================================================================== >RCS file: /cvsroot/webtools/servertools/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties,v >retrieving revision 1.99 >diff -u -r1.99 Messages.properties >--- serverui/org/eclipse/wst/server/ui/internal/Messages.properties 28 Dec 2011 19:13:25 -0000 1.99 >+++ serverui/org/eclipse/wst/server/ui/internal/Messages.properties 24 May 2012 18:58:57 -0000 >@@ -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 @@ > 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. >Index: serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java >=================================================================== >RCS file: /cvsroot/webtools/servertools/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java,v >retrieving revision 1.30 >diff -u -r1.30 NewServerWizardFragment.java >--- serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java 23 Aug 2011 21:06:37 -0000 1.30 >+++ serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java 24 May 2012 18:58:57 -0000 >@@ -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 @@ > 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 @@ > return false; > } > >+ if (manualComp.isServerNameInUse()){ >+ return false; >+ } >+ > if (manualComp.getCurrentHostname().trim().length() == 0){ > isComplete = false; > } else if(!supportsRemote && !SocketUtil.isLocalhost(manualComp.getCurrentHostname())){ >Index: serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java >=================================================================== >RCS file: /cvsroot/webtools/servertools/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java,v >retrieving revision 1.57 >diff -u -r1.57 NewManualServerComposite.java >--- serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java 12 Apr 2012 19:02:00 -0000 1.57 >+++ serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewManualServerComposite.java 24 May 2012 18:58:57 -0000 >@@ -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 @@ > 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 @@ > 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 @@ > 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 @@ > // Update the old server type value. > oldServerType = serverType; > >- checkHostAndServerType(serverType); >+ validate(serverType); > wizard.update(); > } > >@@ -883,4 +908,28 @@ > 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; >+ } > } >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 390695
:
221649
|
221839