You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2018/02/24 23:27:34 UTC
[isis] branch master updated: ISIS-1880 add path syntax validation
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new da21d61 ISIS-1880 add path syntax validation
da21d61 is described below
commit da21d613338773621019f0a75f41c8e7d6332a04
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sun Feb 25 00:27:32 2018 +0100
ISIS-1880 add path syntax validation
---
.../isis/applib/value/LocalResourcePath.java | 23 +++++++++++++++++-----
.../wicket/viewer/IsisWicketApplication.java | 2 --
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/core/applib/src/main/java/org/apache/isis/applib/value/LocalResourcePath.java b/core/applib/src/main/java/org/apache/isis/applib/value/LocalResourcePath.java
index d166281..e2564ba 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/value/LocalResourcePath.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/value/LocalResourcePath.java
@@ -20,7 +20,7 @@
package org.apache.isis.applib.value;
import java.io.Serializable;
-import java.nio.file.InvalidPathException;
+import java.net.URISyntaxException;
import javax.annotation.Nonnull;
@@ -34,14 +34,14 @@ public final class LocalResourcePath implements Serializable {
private static final long serialVersionUID = 1L;
private final String path;
- public LocalResourcePath(final String path) throws InvalidPathException {
+ public LocalResourcePath(final String path) throws IllegalArgumentException {
- //TODO throw InvalidPathException if path is not sane
+ validate(path); // may throw IllegalArgumentException
- this.path = path != null ? path : "";
+ this.path = (path != null) ? path : "";
}
- @Nonnull
+ @Nonnull
public Object getValue() {
return path;
}
@@ -71,6 +71,19 @@ public final class LocalResourcePath implements Serializable {
return this.getPath().equals(other.getPath());
}
+ // -- HELPER
+
+ private void validate(String path) throws IllegalArgumentException {
+ if(path==null)
+ return;
+ try {
+ // used for syntax testing
+ new java.net.URI("http://localhost/"+path);
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException("the given local path has an invalid syntax: '"+path+"'", e);
+ }
+
+ }
}
\ No newline at end of file
diff --git a/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication.java b/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication.java
index 9707076..fffc9c6 100644
--- a/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication.java
+++ b/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication.java
@@ -30,8 +30,6 @@ import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
-import javax.servlet.ServletContext;
-
import org.apache.isis.applib.internal.context._Context;
import org.apache.isis.applib.internal.resources._Resource;
import org.apache.isis.core.commons.authentication.AuthenticationSession;
--
To stop receiving notification emails like this one, please contact
ahuber@apache.org.