import jalview.schemes.ResidueProperties;
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.PropertyType;
import java.io.InputStream;
+import java.net.HttpURLConnection;
import java.net.URL;
-import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
+ ".xml";
URL url = new URL(downloadstring);
- URLConnection urlconn = url.openConnection();
- InputStream istr = urlconn.getInputStream();
- List<Entry> entries = getUniprotEntries(istr);
- if (entries != null)
+ HttpURLConnection urlconn = (HttpURLConnection)url.openConnection();
+ // 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
+ if (urlconn.getResponseCode() == 200)
{
- List<SequenceI> seqs = new ArrayList<>();
- for (Entry entry : entries)
+ InputStream istr = urlconn.getInputStream();
+ List<Entry> entries = getUniprotEntries(istr);
+ if (entries != null)
{
- seqs.add(uniprotEntryToSequence(entry));
+ List<SequenceI> seqs = new ArrayList<>();
+ for (Entry entry : entries)
+ {
+ seqs.add(uniprotEntryToSequence(entry));
+ }
+ al = new Alignment(seqs.toArray(new SequenceI[seqs.size()]));
}
- al = new Alignment(seqs.toArray(new SequenceI[seqs.size()]));
}
-
stopQuery();
return al;
+
} catch (Exception e)
{
throw (e);
} catch (JAXBException | XMLStreamException
| FactoryConfigurationError e)
{
+ if (e instanceof javax.xml.bind.UnmarshalException && e.getCause()!=null && e.getCause() instanceof XMLStreamException && e.getCause().getMessage().contains("[row,col]:[1,1]"))
+ {
+ // trying to parse an empty stream
+ return null;
+ }
e.printStackTrace();
}
return entries;