From: hansonr Date: Fri, 22 Jun 2018 13:45:10 +0000 (+0100) Subject: fix for no access-control-origin on jalview site X-Git-Tag: Release_2_11_4_0~45^2~18^2~664 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c887190d16483f5776c88ca9233541d731e36c26;p=jalview.git fix for no access-control-origin on jalview site --- diff --git a/src/jalview/bin/JalviewJS.java b/src/jalview/bin/JalviewJS.java index 2f8e61b..a26e182 100644 --- a/src/jalview/bin/JalviewJS.java +++ b/src/jalview/bin/JalviewJS.java @@ -4,7 +4,6 @@ import jalview.analysis.AlignmentUtils; import jalview.datamodel.AlignmentI; import jalview.gui.AlignFrame; import jalview.gui.SplitFrame; -import jalview.io.AppletFormatAdapter; import jalview.io.DataSourceType; import jalview.io.FileFormatException; import jalview.io.FileFormatI; @@ -34,6 +33,20 @@ import javax.swing.JInternalFrame; // TODO or format as file=/examples/uniref50.fa (etc)? public class JalviewJS { + + static + { + /** + * @j2sNative + * + * thisApplet.__Info.args = + * ["file","examples/uniref50.fa","features", + * "examples/exampleFeatures.txt", + * "props","/Users/gmcarstairs/.jalview_properties"]; + */ + + } + private static final String PARAM_FILE = "file"; private static final String PARAM_FILE2 = "file2"; @@ -274,7 +287,7 @@ public class JalviewJS // todo extract helper for protocol resolution from JalviewLite DataSourceType sourceType = featureFile.startsWith("http") ? DataSourceType.URL - : DataSourceType.FILE; + : DataSourceType.LOCALURL; alignFrame.parseFeaturesFile(featureFile, sourceType); } } @@ -294,7 +307,9 @@ public class JalviewJS String file = getParameter(fileParam); if (file != null) { - DataSourceType protocol = AppletFormatAdapter.checkProtocol(file); + DataSourceType protocol = file.startsWith("http") ? DataSourceType.URL + : DataSourceType.LOCALURL; + // DataSourceType protocol = AppletFormatAdapter.checkProtocol(file); FileFormatI format = new IdentifyFile().identify(file, protocol); FileLoader fileLoader = new FileLoader(false); af = fileLoader.LoadFileWaitTillLoaded(file, protocol, format); diff --git a/src/jalview/io/DataSourceType.java b/src/jalview/io/DataSourceType.java index 5d0c462..55e585c 100644 --- a/src/jalview/io/DataSourceType.java +++ b/src/jalview/io/DataSourceType.java @@ -22,5 +22,5 @@ package jalview.io; public enum DataSourceType { - FILE, URL, PASTE, CLASSLOADER; + FILE, URL, PASTE, CLASSLOADER, LOCALURL; } diff --git a/src/jalview/io/FileParse.java b/src/jalview/io/FileParse.java index 7117d0f..1ee1db6 100755 --- a/src/jalview/io/FileParse.java +++ b/src/jalview/io/FileParse.java @@ -39,6 +39,8 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.zip.GZIPInputStream; +import javajs.util.Rdr; + /** * implements a random access wrapper around a particular datasource, for * passing to identifyFile and AlignFile objects. @@ -339,6 +341,23 @@ public class FileParse } } } + else if (sourceType == DataSourceType.LOCALURL) + { + String data = null; + /** + * BH 2018 hack for no support for access-origin + * + * @j2sNative + * + * data = $.ajax({url:fileStr, async:false}).responseText; + * + */ + + System.out.println(data); + dataIn = Rdr.getBR(data); + dataName = fileStr; + + } else if (sourceType == DataSourceType.URL) { try