Skip to content

Commit 0194d3c

Browse files
committed
Windows compatibility, use bundle:// paths instead of file://
as bundle always uses / separator
1 parent bf5a4b9 commit 0194d3c

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

src/main/java/org/commonwl/view/researchobject/ROBundleService.java

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,33 @@
1919

2020
package org.commonwl.view.researchobject;
2121

22+
import static org.apache.commons.io.FileUtils.readFileToString;
23+
24+
import java.io.File;
25+
import java.io.IOException;
26+
import java.net.URI;
27+
import java.net.URISyntaxException;
28+
import java.nio.file.Files;
29+
import java.nio.file.Path;
30+
import java.nio.file.Paths;
31+
import java.util.ArrayList;
32+
import java.util.HashSet;
33+
import java.util.List;
34+
import java.util.Set;
35+
import java.util.regex.Matcher;
36+
import java.util.regex.Pattern;
37+
2238
import org.apache.commons.io.FileUtils;
2339
import org.apache.commons.io.FilenameUtils;
2440
import org.apache.jena.query.QuerySolution;
2541
import org.apache.jena.query.ResultSet;
2642
import org.apache.taverna.robundle.Bundle;
2743
import org.apache.taverna.robundle.Bundles;
28-
import org.apache.taverna.robundle.manifest.*;
44+
import org.apache.taverna.robundle.manifest.Agent;
45+
import org.apache.taverna.robundle.manifest.Manifest;
46+
import org.apache.taverna.robundle.manifest.PathAnnotation;
47+
import org.apache.taverna.robundle.manifest.PathMetadata;
48+
import org.apache.taverna.robundle.manifest.Proxy;
2949
import org.commonwl.view.cwl.CWLTool;
3050
import org.commonwl.view.cwl.CWLValidationException;
3151
import org.commonwl.view.cwl.RDFService;
@@ -42,22 +62,6 @@
4262
import org.springframework.beans.factory.annotation.Value;
4363
import org.springframework.stereotype.Service;
4464

45-
import java.io.File;
46-
import java.io.IOException;
47-
import java.net.URI;
48-
import java.net.URISyntaxException;
49-
import java.nio.file.Files;
50-
import java.nio.file.Path;
51-
import java.nio.file.Paths;
52-
import java.util.ArrayList;
53-
import java.util.HashSet;
54-
import java.util.List;
55-
import java.util.Set;
56-
import java.util.regex.Matcher;
57-
import java.util.regex.Pattern;
58-
59-
import static org.apache.commons.io.FileUtils.readFileToString;
60-
6165
/**
6266
* Service handling Research Object Bundles
6367
*/
@@ -197,8 +201,11 @@ public Bundle createBundle(Workflow workflow, GitDetails gitInfo) throws IOExcep
197201

198202
// Git2prov history
199203
List<Path> history = new ArrayList<>();
200-
history.add(Paths.get("http://git2prov.org/git2prov?giturl=" +
201-
gitInfo.getRepoUrl() + "&serialization=PROV-JSON"));
204+
// FIXME: Below is a a hack to pretend the URI is a Path
205+
String git2prov = "http://git2prov.org/git2prov?giturl=" + gitInfo.getRepoUrl()
206+
+ "&serialization=PROV-JSON";
207+
Path git2ProvPath = bundle.getRoot().relativize(bundle.getRoot().resolve(git2prov));
208+
history.add(git2ProvPath);
202209
bundle.getManifest().setHistory(history);
203210

204211
} catch (URISyntaxException ex) {
@@ -246,8 +253,9 @@ private void addFilesToBundle(GitDetails gitDetails, Bundle bundle, Path bundleP
246253
try {
247254
// Where to store the new file
248255
Path bundleFilePath = bundlePath.resolve(file.getName());
249-
Path gitPath = Paths.get(gitDetails.getPath()).resolve(file.getName());
250-
256+
Path gitFolder = Paths.get(gitDetails.getPath());
257+
Path gitPath = bundlePath.getRoot().resolve(gitFolder.resolve(file.getName()));
258+
251259
// Get direct URL permalink
252260
URI rawURI = new URI("https://w3id.org/cwl/view/git/" + workflow.getLastCommit() +
253261
"/" + gitPath + "?format=raw");

0 commit comments

Comments
 (0)