Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions jbrowse/src/org/labkey/jbrowse/model/JBrowseSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.labkey.jbrowse.JBrowseSchema;

import java.io.File;
import java.net.URI;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
Expand Down Expand Up @@ -361,12 +362,12 @@ public static String getAssemblyName(ReferenceGenome rg)
public static JSONObject getIndexedFastaAdapter(ReferenceGenome rg)
{
ExpData d = ExperimentService.get().getExpData(rg.getFastaExpDataId());
String url = d.getWebDavURL(FileContentService.PathType.full);
URI url = d.getWebDavURL(FileContentService.PathType.full);

JSONObject ret = new JSONObject();
ret.put("type", "IndexedFastaAdapter");
ret.put("fastaLocation", new JSONObject(){{
put("uri", url);
put("uri", url.toString());
}});
ret.put("faiLocation", new JSONObject(){{
put("uri", url + ".fai");
Expand All @@ -378,7 +379,7 @@ public static JSONObject getIndexedFastaAdapter(ReferenceGenome rg)
public static JSONObject getBgZippedIndexedFastaAdapter(ReferenceGenome rg)
{
ExpData d = ExperimentService.get().getExpData(rg.getFastaExpDataId());
String url = d.getWebDavURL(FileContentService.PathType.full);
URI url = d.getWebDavURL(FileContentService.PathType.full);

JSONObject ret = new JSONObject();
ret.put("type", "BgzipFastaAdapter");
Expand Down
28 changes: 19 additions & 9 deletions jbrowse/src/org/labkey/jbrowse/model/JsonFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.labkey.api.util.JobRunner;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.api.util.Path;
import org.labkey.api.util.UnexpectedException;
import org.labkey.api.view.UnauthorizedException;
import org.labkey.jbrowse.JBrowseLuceneSearch;
import org.labkey.jbrowse.JBrowseManager;
Expand All @@ -59,6 +60,8 @@

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.sql.SQLException;
import java.util.Arrays;
Expand Down Expand Up @@ -512,7 +515,7 @@ private JSONObject getVcfTrack(Logger log, ExpData targetFile, ReferenceGenome r
put(JBrowseSession.getAssemblyName(rg));
}});

String url = targetFile.getWebDavURL(FileContentService.PathType.full);
URI url = targetFile.getWebDavURL(FileContentService.PathType.full);
if (url == null)
{
log.info("Unable to create WebDav URL for JBrowse resource with path: " + targetFile.getFile());
Expand All @@ -522,7 +525,7 @@ private JSONObject getVcfTrack(Logger log, ExpData targetFile, ReferenceGenome r
ret.put("adapter", new JSONObject(){{
put("type", "ExtendedVariantAdapter");
put("vcfGzLocation", new JSONObject(){{
put("uri", url);
put("uri", url.toString());
}});

put("index", new JSONObject(){{
Expand Down Expand Up @@ -596,7 +599,7 @@ private JSONObject getBamOrCramTrack(Logger log, ExpData targetFile, ReferenceGe
put(JBrowseSession.getAssemblyName(rg));
}});

String url = targetFile.getWebDavURL(FileContentService.PathType.full);
URI url = targetFile.getWebDavURL(FileContentService.PathType.full);
if (url == null)
{
log.info("Unable to create WebDav URL for JBrowse resource with path: " + targetFile.getFile());
Expand All @@ -612,7 +615,7 @@ private JSONObject getBamOrCramTrack(Logger log, ExpData targetFile, ReferenceGe
put("type", type);
put("bamLocation", new JSONObject()
{{
put("uri", url);
put("uri", url.toString());
}});

put("index", new JSONObject()
Expand Down Expand Up @@ -667,7 +670,7 @@ private JSONObject getBigWigTrack(Logger log, ExpData targetFile, ReferenceGenom
put(getCategory());
}});

String url = targetFile.getWebDavURL(FileContentService.PathType.full);
URI url = targetFile.getWebDavURL(FileContentService.PathType.full);
if (url == null)
{
log.info("Unable to create WebDav URL for JBrowse resource with path: " + targetFile.getFile());
Expand All @@ -677,7 +680,7 @@ private JSONObject getBigWigTrack(Logger log, ExpData targetFile, ReferenceGenom
ret.put("adapter", new JSONObject(){{
put("type", "BigWigAdapter");
put("bigWigLocation", new JSONObject(){{
put("uri", url);
put("uri", url.toString());
put("locationType", "UriLocation");
}});
}});
Expand Down Expand Up @@ -747,7 +750,7 @@ private JSONObject getTabixTrack(User u, Logger log, ExpData targetFile, Referen

// if not gzipped, we need to process it:
File gzipped = prepareResource(u, log, true, false);
final String url;
final URI url;
if (!getExpData().getFile().equals(gzipped))
{
url = getWebDavURL(gzipped);
Expand Down Expand Up @@ -1192,7 +1195,7 @@ public File getExpectedLocationOfIndexFile(String extension, boolean throwIfNotF
return ret;
}

private String getWebDavURL(File input)
private URI getWebDavURL(File input)
{
java.nio.file.Path path = input.toPath();
if (getContainerObj() == null)
Expand Down Expand Up @@ -1221,7 +1224,14 @@ private String getWebDavURL(File input)
relPath = Path.parse(FilenameUtils.separatorsToUnix(relPath)).toString();
}

return AppProps.getInstance().getBaseServerUrl() + root.getWebdavURL() + relPath;
try
{
return new URI(AppProps.getInstance().getBaseServerUrl() + root.getWebdavURL() + relPath);
}
catch (URISyntaxException e)
{
throw UnexpectedException.wrap(e);
}
}

return null;
Expand Down