5050import org .labkey .api .util .JobRunner ;
5151import org .labkey .api .util .PageFlowUtil ;
5252import org .labkey .api .util .Path ;
53+ import org .labkey .api .util .UnexpectedException ;
5354import org .labkey .api .view .UnauthorizedException ;
5455import org .labkey .jbrowse .JBrowseLuceneSearch ;
5556import org .labkey .jbrowse .JBrowseManager ;
5960
6061import java .io .File ;
6162import java .io .IOException ;
63+ import java .net .URI ;
64+ import java .net .URISyntaxException ;
6265import java .nio .file .Files ;
6366import java .sql .SQLException ;
6467import java .util .Arrays ;
@@ -512,7 +515,7 @@ private JSONObject getVcfTrack(Logger log, ExpData targetFile, ReferenceGenome r
512515 put (JBrowseSession .getAssemblyName (rg ));
513516 }});
514517
515- String url = targetFile .getWebDavURL (FileContentService .PathType .full );
518+ URI url = targetFile .getWebDavURL (FileContentService .PathType .full );
516519 if (url == null )
517520 {
518521 log .info ("Unable to create WebDav URL for JBrowse resource with path: " + targetFile .getFile ());
@@ -522,7 +525,7 @@ private JSONObject getVcfTrack(Logger log, ExpData targetFile, ReferenceGenome r
522525 ret .put ("adapter" , new JSONObject (){{
523526 put ("type" , "ExtendedVariantAdapter" );
524527 put ("vcfGzLocation" , new JSONObject (){{
525- put ("uri" , url );
528+ put ("uri" , url . toString () );
526529 }});
527530
528531 put ("index" , new JSONObject (){{
@@ -596,7 +599,7 @@ private JSONObject getBamOrCramTrack(Logger log, ExpData targetFile, ReferenceGe
596599 put (JBrowseSession .getAssemblyName (rg ));
597600 }});
598601
599- String url = targetFile .getWebDavURL (FileContentService .PathType .full );
602+ URI url = targetFile .getWebDavURL (FileContentService .PathType .full );
600603 if (url == null )
601604 {
602605 log .info ("Unable to create WebDav URL for JBrowse resource with path: " + targetFile .getFile ());
@@ -612,7 +615,7 @@ private JSONObject getBamOrCramTrack(Logger log, ExpData targetFile, ReferenceGe
612615 put ("type" , type );
613616 put ("bamLocation" , new JSONObject ()
614617 {{
615- put ("uri" , url );
618+ put ("uri" , url . toString () );
616619 }});
617620
618621 put ("index" , new JSONObject ()
@@ -667,7 +670,7 @@ private JSONObject getBigWigTrack(Logger log, ExpData targetFile, ReferenceGenom
667670 put (getCategory ());
668671 }});
669672
670- String url = targetFile .getWebDavURL (FileContentService .PathType .full );
673+ URI url = targetFile .getWebDavURL (FileContentService .PathType .full );
671674 if (url == null )
672675 {
673676 log .info ("Unable to create WebDav URL for JBrowse resource with path: " + targetFile .getFile ());
@@ -677,7 +680,7 @@ private JSONObject getBigWigTrack(Logger log, ExpData targetFile, ReferenceGenom
677680 ret .put ("adapter" , new JSONObject (){{
678681 put ("type" , "BigWigAdapter" );
679682 put ("bigWigLocation" , new JSONObject (){{
680- put ("uri" , url );
683+ put ("uri" , url . toString () );
681684 put ("locationType" , "UriLocation" );
682685 }});
683686 }});
@@ -747,7 +750,7 @@ private JSONObject getTabixTrack(User u, Logger log, ExpData targetFile, Referen
747750
748751 // if not gzipped, we need to process it:
749752 File gzipped = prepareResource (u , log , true , false );
750- final String url ;
753+ final URI url ;
751754 if (!getExpData ().getFile ().equals (gzipped ))
752755 {
753756 url = getWebDavURL (gzipped );
@@ -1192,7 +1195,7 @@ public File getExpectedLocationOfIndexFile(String extension, boolean throwIfNotF
11921195 return ret ;
11931196 }
11941197
1195- private String getWebDavURL (File input )
1198+ private URI getWebDavURL (File input )
11961199 {
11971200 java .nio .file .Path path = input .toPath ();
11981201 if (getContainerObj () == null )
@@ -1221,7 +1224,14 @@ private String getWebDavURL(File input)
12211224 relPath = Path .parse (FilenameUtils .separatorsToUnix (relPath )).toString ();
12221225 }
12231226
1224- return AppProps .getInstance ().getBaseServerUrl () + root .getWebdavURL () + relPath ;
1227+ try
1228+ {
1229+ return new URI (AppProps .getInstance ().getBaseServerUrl () + root .getWebdavURL () + relPath );
1230+ }
1231+ catch (URISyntaxException e )
1232+ {
1233+ throw UnexpectedException .wrap (e );
1234+ }
12251235 }
12261236
12271237 return null ;
0 commit comments