Skip to content

Commit da44684

Browse files
author
Christopher Raquet
committed
Fix exception when checking URL validity
1 parent 6998c98 commit da44684

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/main/java/edu/kit/datamanager/ro_crate/entities/data/DataEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public T addContent(Path path, String id) {
118118
public T addContent(URI uri) {
119119
if (isUrl(uri.toString())) {
120120
this.setId(uri.toString());
121-
}
121+
} else throw new IllegalArgumentException("This Data Entity remote ID does not resolve to a valid URL.");
122122
return self();
123123
}
124124

src/main/java/edu/kit/datamanager/ro_crate/special/UriUtil.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ public static boolean isValidUri(String uri) {
5656
* @return true if it is a url, false otherwise.
5757
*/
5858
public static boolean isUrl(String uri) {
59-
return asUrl(uri).isPresent();
59+
try {
60+
return asUrl(uri).isPresent();
61+
} catch (Exception e) {
62+
return false;
63+
}
6064
}
6165

6266
/**

0 commit comments

Comments
 (0)