import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
-import java.net.URLConnection;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.AbstractMap;
import jalview.bin.Cache;
import jalview.bin.Console;
import jalview.util.ChannelProperties;
+import jalview.util.HttpUtils;
import jalview.util.UserAgent;
public class Plausible
try
{
URL url = new URL(urlSb.toString());
- URLConnection urlConnection = url.openConnection();
- HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection;
+ HttpURLConnection httpURLConnection = HttpUtils.openConnection(url);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
try
{
URL url = new URL(CONFIG_API_BASE_URL);
- URLConnection urlConnection = url.openConnection();
- HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection;
+ HttpURLConnection httpURLConnection = HttpUtils.openConnection(url);
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setRequestProperty("User-Agent", USER_AGENT);
httpURLConnection.setConnectTimeout(5000);
import org.json.simple.parser.ParseException;
+import jalview.util.HttpUtils;
import jalview.util.Platform;
import jalview.util.StringUtils;
{
// jalview.bin.Console.outPrintln(System.currentTimeMillis() + " " + url);
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ HttpURLConnection connection = HttpUtils.openConnection(url);
/*
* POST method allows multiple queries in one request; it is supported for
import jalview.bin.Console;
import jalview.gui.Preferences;
import jalview.structure.StructureCommandI;
+import jalview.util.HttpUtils;
import jalview.util.Platform;
public class PymolManager
try
{
URL realUrl = new URL(rpcUrl);
- HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
+ HttpURLConnection conn = HttpUtils.openConnection(realUrl);
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("content-type", "text/xml");
conn.setDoOutput(true);
{
errormessage = "URL NOT FOUND";
URL url = new URL(urlStr);
- URLConnection _conn = url.openConnection();
+ URLConnection _conn = HttpUtils.openConnection(url);
if (_conn instanceof HttpURLConnection)
{
HttpURLConnection conn = HttpUtils
*/
package jalview.ws.dbsources;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Locale;
+import java.util.Vector;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import com.stevesoft.pat.Regex;
import jalview.bin.Cache;
import jalview.datamodel.Alignment;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.schemes.ResidueProperties;
+import jalview.util.HttpUtils;
import jalview.util.StringUtils;
import jalview.ws.seqfetcher.DbSourceProxyImpl;
-import jalview.xml.binding.embl.ROOT;
import jalview.xml.binding.uniprot.DbReferenceType;
import jalview.xml.binding.uniprot.Entry;
import jalview.xml.binding.uniprot.FeatureType;
import jalview.xml.binding.uniprot.PositionType;
import jalview.xml.binding.uniprot.PropertyType;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Vector;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-import com.stevesoft.pat.Regex;
-
/**
* This class queries the Uniprot database for sequence data, unmarshals the
* returned XML, and converts it to Jalview Sequence records (including attached
// String downloadstring = getDomain() + queries + ".json";
URL url = new URL(downloadstring);
- URLConnection urlconn = url.openConnection();
+ URLConnection urlconn = HttpUtils.openConnection(url);
InputStream istr = urlconn.getInputStream();
List<Entry> entries = getUniprotEntries(istr);
if (entries != null)
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.schemes.ResidueProperties;
+import jalview.util.HttpUtils;
import jalview.util.StringUtils;
import jalview.ws.seqfetcher.DbSourceProxyImpl;
import jalview.xml.binding.uniprot.DbReferenceType;
"(UNIPROT\\|?|UNIPROT_|UNIREF\\d+_|UNIREF\\d+\\|?)", "");
AlignmentI al = null;
- String downloadstring = getDomain() + "/uniprotkb/" + queries + ".xml";
+ String downloadstring = getDomain() + "/uniprotkb/" + queries
+ + ".xml";
URL url = new URL(downloadstring);
- HttpURLConnection urlconn = (HttpURLConnection) url.openConnection();
+ HttpURLConnection urlconn = HttpUtils.openConnection(url);
// anything other than 200 means we don't have data
// TODO: JAL-3882 reuse the EnsemblRestClient's fair
// use/backoff logic to retry when the server tells us to go away
*/
package jalview.ws.ebi;
-import java.util.Locale;
-
-import jalview.datamodel.DBRefSource;
-import jalview.util.MessageManager;
-import jalview.util.Platform;
-
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
import java.util.StringTokenizer;
+import jalview.datamodel.DBRefSource;
+import jalview.util.HttpUtils;
+import jalview.util.MessageManager;
+import jalview.util.Platform;
+
/**
* DOCUMENT ME!
*
try
{
URL rcall = new URL(url);
- HttpURLConnection conn = (HttpURLConnection) rcall.openConnection();
+ HttpURLConnection conn = HttpUtils.openConnection(rcall);
int responseCode = conn.getResponseCode();
if (responseCode == 200)
{
*/
package jalview.ws.sifts;
-import java.util.Locale;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import jalview.util.Comparison;
import jalview.util.DBRefUtils;
import jalview.util.Format;
+import jalview.util.HttpUtils;
import jalview.util.Platform;
import jalview.xml.binding.sifts.Entry;
import jalview.xml.binding.sifts.Entry.Entity;
// siftsFileFTPURL);
// long now = System.currentTimeMillis();
URL url = new URL(siftsFileFTPURL);
- URLConnection conn = url.openConnection();
+ URLConnection conn = HttpUtils.openConnection(url);
InputStream inputStream = conn.getInputStream();
FileOutputStream outputStream = new FileOutputStream(downloadTo);
byte[] buffer = new byte[BUFFER_SIZE];