Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Bricon2019-02-19 17:56:01 -0500
committerFred Bricon2019-02-19 17:56:01 -0500
commit7d3582a8d9d5afad32b13004275d667324f81f52 (patch)
tree3f2803a42cd75accbecb471c5ccbcf25b49e3354
parent8df44a1f8ad642e4343696f11660ac9088daab4e (diff)
downloadm2e-core-7d3582a8d9d5afad32b13004275d667324f81f52.tar.gz
m2e-core-7d3582a8d9d5afad32b13004275d667324f81f52.tar.xz
m2e-core-7d3582a8d9d5afad32b13004275d667324f81f52.zip
Bug 530898 : better error message for invalid catalog url
Change-Id: I6bb02059b9eb62b2e360af54578e3ee56ce32d9e Signed-off-by: Fred Bricon <fbricon@gmail.com>
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java2
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties5
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/RemoteArchetypeCatalogDialog.java20
3 files changed, 22 insertions, 5 deletions
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java
index 75178afe..8e4f5fa9 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java
@@ -635,6 +635,8 @@ public class Messages extends NLS {
public static String RemoteArchetypeCatalogDialog_error_required;
+ public static String RemoteArchetypeCatalogDialog_error_invalidUrl;
+
public static String RemoteArchetypeCatalogDialog_job_download;
public static String RemoteArchetypeCatalogDialog_lblCatalog;
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties
index 9f2383c2..369aca11 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties
@@ -356,11 +356,12 @@ ProjectRepositoriesNode_name=Project Repositories
RemoteArchetypeCatalogDialog_btnVerify=&Verify...
RemoteArchetypeCatalogDialog_error_empty=Remote catalog is empty
RemoteArchetypeCatalogDialog_error_read=Unable to read remote catalog;\n{0}
-RemoteArchetypeCatalogDialog_error_required=Archetype catalog url is required
+RemoteArchetypeCatalogDialog_error_required=Archetype catalog URL is required
+RemoteArchetypeCatalogDialog_error_invalidUrl={0} is not a valid URL
RemoteArchetypeCatalogDialog_job_download=Downloading remote catalog
RemoteArchetypeCatalogDialog_lblCatalog=&Catalog File\:
RemoteArchetypeCatalogDialog_lblDesc=Description\:
-RemoteArchetypeCatalogDialog_message=Specify catalog url and description
+RemoteArchetypeCatalogDialog_message=Specify catalog URL and description
RemoteArchetypeCatalogDialog_message_found=Found {0} archetype(s)
RemoteArchetypeCatalogDialog_title=Remote Archetype Catalog
RepositoryNode_updating=\ [updating]
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/RemoteArchetypeCatalogDialog.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/RemoteArchetypeCatalogDialog.java
index 55f0b709..afedca3e 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/RemoteArchetypeCatalogDialog.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/RemoteArchetypeCatalogDialog.java
@@ -11,6 +11,7 @@
package org.eclipse.m2e.core.ui.internal.preferences;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -279,13 +280,26 @@ public class RemoteArchetypeCatalogDialog extends TitleAreaDialog {
setMessage(null, IStatus.WARNING);
String url = catalogUrlCombo.getText().trim();
- boolean isValid = !url.isEmpty();
- if(!isValid) {
+ boolean isValid = false;
+ if(url.isEmpty()) {
setErrorMessage(Messages.RemoteArchetypeCatalogDialog_error_required);
+ } else if(!isWellFormedUrl(url)) {
+ setErrorMessage(NLS.bind(Messages.RemoteArchetypeCatalogDialog_error_invalidUrl, url));
+ } else {
+ isValid = true;
}
-
verifyButton.setEnabled(isValid);
return isValid;
}
+ public boolean isWellFormedUrl(String url) {
+ try {
+ new URL(url).toURI();
+ return true;
+ } catch(Exception O_o) {
+ //Not good enough
+ }
+ return false;
+ }
+
}

Back to the top