Skip to content

Commit

Permalink
Update conversion of URL to path to support Windows
Browse files Browse the repository at this point in the history
When using Path.of() we need to pass a URI on a Windows machine, not the Path.

Resolves #809
  • Loading branch information
jordanpadams committed Jan 24, 2024
1 parent 42e0764 commit 92966b8
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gov.nasa.pds.tools.validate;

import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -14,9 +15,9 @@

public class CrossLabelFileAreaReferenceChecker {
final private static HashMap<String,List<String>> knownRefs = new HashMap<String,List<String>>();
private static String resolve (String name, ValidationTarget target) {
private static String resolve (String name, ValidationTarget target) throws URISyntaxException {
if (!name.startsWith ("/")) {
name = Path.of(target.getUrl().getPath()).getParent().resolve(name).toString();
name = Path.of(target.getUrl().toURI()).getParent().resolve(name).toString();
}
return name;
}
Expand All @@ -30,8 +31,9 @@ private static String resolve (String name, ValidationTarget target) {
* @throws IOException
* @throws ParserConfigurationException
* @throws SAXException
* @throws URISyntaxException
*/
public static boolean add (String name, ValidationTarget target) throws IOException, ParserConfigurationException, SAXException {
public static boolean add (String name, ValidationTarget target) throws IOException, ParserConfigurationException, SAXException, URISyntaxException {
boolean success = false;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
Document xml = dbf.newDocumentBuilder().parse(target.getUrl().openStream());
Expand All @@ -49,10 +51,10 @@ public static boolean add (String name, ValidationTarget target) throws IOExcept
}
return success;
}
public static String getOtherId (String name, ValidationTarget target) {
public static String getOtherId (String name, ValidationTarget target) throws URISyntaxException {
return knownRefs.get(resolve(name, target)).get(0);
}
public static String getOtherFilename (String name, ValidationTarget target) {
public static String getOtherFilename (String name, ValidationTarget target) throws URISyntaxException {
return knownRefs.get(resolve(name, target)).get(1);
}
public static void reset() {
Expand Down

0 comments on commit 92966b8

Please sign in to comment.