Skip to content
Snippets Groups Projects
Commit dbdad167 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '258-ebi-via-ssl' into 'devel_11.0.x'

Resolve "ebi pubmed service moved to https"

See merge request piotr.gawron/minerva!162
parents b916ab63 2fa3ac9b
No related branches found
No related tags found
2 merge requests!166Devel 11.0.x,!162Resolve "ebi pubmed service moved to https"
Showing with 70 additions and 54 deletions
......@@ -80,14 +80,16 @@ public class PermanentDatabaseLevelCache extends XmlParser implements PermanentD
@Override
public CacheQuery call() throws Exception {
logger.debug("Query task call");
dbUtils.createSessionForCurrentThread();
logger.debug("Query task session started");
CacheQuery entry = getCacheQueryDao().getByQuery((String) query, type);
logger.debug("Query task data retrieved");
dbUtils.closeSessionForCurrentThread();
logger.debug("Query task return");
return entry;
logger.debug("Query task call");
try {
dbUtils.createSessionForCurrentThread();
logger.debug("Query task session started");
CacheQuery entry = getCacheQueryDao().getByQuery((String) query, type);
logger.debug("Query task data retrieved");
return entry;
} finally {
dbUtils.closeSessionForCurrentThread();
}
}
}
......@@ -227,26 +229,29 @@ public class PermanentDatabaseLevelCache extends XmlParser implements PermanentD
@Override
public CacheQuery call() throws Exception {
logger.debug("Add task call");
dbUtils.createSessionForCurrentThread();
CacheQuery entry = getCacheQueryDao().getByQuery((String) query, type);
if (entry == null) {
entry = new CacheQuery();
entry.setQuery((String) query);
entry.setAccessed(Calendar.getInstance());
} else {
entry.setAccessed(Calendar.getInstance());
}
entry.setValue(value);
entry.setType(type);
Calendar expires = Calendar.getInstance();
expires.add(Calendar.DAY_OF_MONTH, type.getValidity());
entry.setExpires(expires);
getCacheQueryDao().add(entry);
dbUtils.closeSessionForCurrentThread();
return entry;
logger.debug("Add task call");
try {
dbUtils.createSessionForCurrentThread();
CacheQuery entry = getCacheQueryDao().getByQuery((String) query, type);
if (entry == null) {
entry = new CacheQuery();
entry.setQuery((String) query);
entry.setAccessed(Calendar.getInstance());
} else {
entry.setAccessed(Calendar.getInstance());
}
entry.setValue(value);
entry.setType(type);
Calendar expires = Calendar.getInstance();
expires.add(Calendar.DAY_OF_MONTH, type.getValidity());
entry.setExpires(expires);
getCacheQueryDao().add(entry);
return entry;
} finally {
dbUtils.closeSessionForCurrentThread();
}
}
}
......@@ -290,13 +295,16 @@ public class PermanentDatabaseLevelCache extends XmlParser implements PermanentD
@Override
public CacheQuery call() throws Exception {
logger.debug("Remove task call");
dbUtils.createSessionForCurrentThread();
CacheQuery entry = getCacheQueryDao().getByQuery((String) query, type);
if (entry != null) {
getCacheQueryDao().delete(entry);
}
dbUtils.closeSessionForCurrentThread();
return entry;
try {
dbUtils.createSessionForCurrentThread();
CacheQuery entry = getCacheQueryDao().getByQuery((String) query, type);
if (entry != null) {
getCacheQueryDao().delete(entry);
}
return entry;
} finally {
dbUtils.closeSessionForCurrentThread();
}
}
}
......
......@@ -57,18 +57,18 @@ public class ChemicalParser extends CachableInterface implements IExternalServic
/**
* Homepage of drugbank.
*/
static final String URL = "http://ctdbase.org/";
static final String URL = "https://ctdbase.org/";
/**
* URL to get a list of chemicals by disease id.
*/
public static final String DISEASE_URL = "http://ctdbase.org/detail.go?6578706f7274=1&d-1332398-e=5&view=chem&"
public static final String DISEASE_URL = "https://ctdbase.org/detail.go?6578706f7274=1&d-1332398-e=5&view=chem&"
+ "type=disease&acc=MESH%3A";
/**
* URL to get a list of chemicals by gene id.
*/
public static final String DISEASE_GENE_URL = "http://ctdbase.org/detail.go?slimTerm=all&6578706f7274=1&qid=3464576&"
public static final String DISEASE_GENE_URL = "https://ctdbase.org/detail.go?slimTerm=all&6578706f7274=1&qid=3464576&"
+ "d-1332398-e=5&view=disease&type=gene&assnType=curated&acc=";
/**
......@@ -218,7 +218,7 @@ public class ChemicalParser extends CachableInterface implements IExternalServic
}
}
} catch (FileNotFoundException e) {
} catch (WrongResponseCodeIOException e) {
// it means that there are no results for this query
} catch (IOException e) {
throw new ChemicalSearchException("ctdbase service unavailable", e);
......@@ -447,14 +447,14 @@ public class ChemicalParser extends CachableInterface implements IExternalServic
if (entrez == null) {
invalidHgnc.add(md);
} else {
String query = "http://ctdbase.org/detail.go?type=gene&view=ixn&chemAcc=" + chemID.getResource() + "&acc=" + entrez.getResource();
String query = "https://ctdbase.org/detail.go?type=gene&view=ixn&chemAcc=" + chemID.getResource() + "&acc=" + entrez.getResource();
String referencesPage = getWebPageContent(query);
Matcher matcher = pattern.matcher(referencesPage);
while (matcher.find()) {
idx.add(matcher.group(1));
}
for (String string : idx) {
String query2 = "http://ctdbase.org/detail.go?6578706f7274=1&d-1340579-e=5&type=relationship&ixnId=" + string;
String query2 = "https://ctdbase.org/detail.go?6578706f7274=1&d-1340579-e=5&type=relationship&ixnId=" + string;
String referencesPage2 = getWebPageContent(query2);
String[] lines = referencesPage2.split("\n");
for (int i = 1; i < lines.length; i++) {
......
......@@ -29,7 +29,7 @@ import lcsb.mapviewer.model.map.MiriamType;
/**
* This class is a backend to publically available pubmed API in
* <a href="http://europepmc.org/RestfulWebService">Europe PubMed Central </a>.
* <a href="https://europepmc.org/RestfulWebService">Europe PubMed Central </a>.
*
* @author Piotr Gawron
*
......@@ -57,6 +57,8 @@ public class PubmedParser extends CachableInterface implements IExternalService
*/
static final String SUPPORTED_VERSION = "5.2.2";
static final String API_URL = "https://www.ebi.ac.uk/europepmc/webservices/rest/";
/**
* Connector used for accessing data from miriam registry.
*/
......@@ -131,7 +133,7 @@ public class PubmedParser extends CachableInterface implements IExternalService
result = new Article();
try {
String url = "http://www.ebi.ac.uk/europepmc/webservices/rest/search/resulttype=core&query="
String url = API_URL+"search/resulttype=core&query="
+ java.net.URLEncoder.encode("src:med ext_id:" + id, "UTF-8");
String content = getWebPageContent(url);
......@@ -261,7 +263,7 @@ public class PubmedParser extends CachableInterface implements IExternalService
@Override
public ExternalServiceStatus getServiceStatus() {
ExternalServiceStatus status = new ExternalServiceStatus("Europe PubMed Central", "http://europepmc.org/RestfulWebService");
ExternalServiceStatus status = new ExternalServiceStatus("Europe PubMed Central", "https://europepmc.org/RestfulWebService");
GeneralCacheInterface cacheCopy = getCache();
this.setCache(null);
......@@ -292,7 +294,7 @@ public class PubmedParser extends CachableInterface implements IExternalService
*/
public String getApiVersion() throws PubmedSearchException {
try {
String url = "http://www.ebi.ac.uk/europepmc/webservices/rest/search/resulttype=core&query=src%3Amed+ext_id%3A23644949";
String url = API_URL+"search/resulttype=core&query=src%3Amed+ext_id%3A23644949";
String content = getWebPageContent(url);
......
......@@ -29,7 +29,7 @@ import lcsb.mapviewer.modelutils.map.ElementUtils;
/**
* This class is responsible for connecting to
* <a href="http://rest.ensembl.org">Ensembl API</a> and annotate elements with
* <a href="https://rest.ensembl.org">Ensembl API</a> and annotate elements with
* information taken from this service.
*
*
......@@ -46,7 +46,7 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi
/**
* Url address of ensembl restful service.
*/
private static final String REST_SERVICE_URL = "http://rest.ensembl.org/xrefs/id/";
private static final String REST_SERVICE_URL = "https://rest.ensembl.org/xrefs/id/";
/**
* Suffix that is needed for getting proper result using
......@@ -57,7 +57,7 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi
/**
* Url used for retrieving version of the restful API.
*/
private static final String REST_SERVICE_VERSION_URL = "http://rest.ensembl.org/info/rest?content-type=text/xml";
private static final String REST_SERVICE_VERSION_URL = "https://rest.ensembl.org/info/rest?content-type=text/xml";
/**
* Default constructor.
......
......@@ -14,6 +14,7 @@ import lcsb.mapviewer.annotation.cache.WebPageDownloader;
import lcsb.mapviewer.annotation.services.ExternalServiceStatus;
import lcsb.mapviewer.annotation.services.ExternalServiceStatusType;
import lcsb.mapviewer.annotation.services.IExternalService;
import lcsb.mapviewer.annotation.services.WrongResponseCodeIOException;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
import lcsb.mapviewer.model.map.BioEntity;
......@@ -29,7 +30,7 @@ import lcsb.mapviewer.modelutils.map.ElementUtils;
/**
* This class is responsible for connecting to
* <a href="http://rest.genenames.org/">HGNC restfull API</a> and annotate
* <a href="https://rest.genenames.org/">HGNC restfull API</a> and annotate
* elements with information taken from this service.
*
*
......@@ -40,7 +41,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService
/**
* Address of HGNC API that should be used for retrieving data.
*/
private static final String REST_API_URL = "http://rest.genenames.org/fetch/";
private static final String REST_API_URL = "https://rest.genenames.org/fetch/";
/**
* Default constructor.
......@@ -231,6 +232,8 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService
}
}
}
} catch (WrongResponseCodeIOException e) {
logger.warn(prefix + "Cannot find information for element.");
} catch (Exception e) {
throw new AnnotatorException(e);
}
......@@ -314,7 +317,10 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService
}
}
return result;
} catch (Exception e) {
} catch (WrongResponseCodeIOException e) {
logger.warn("No HGNC data found for id: "+miriamData);
return new ArrayList<>();
} catch (Exception e) {
throw new AnnotatorException(e);
}
......
......@@ -43,7 +43,7 @@ public class ReconAnnotator extends ElementAnnotator implements IExternalService
/**
* Address of annotation rest service for reactions.
*/
private static final String REACTION_ANNOTATION_URL_PREFIX = "http://vmh.uni.lu/_api/reactions/?page_size=10000&format=json&search=";
private static final String REACTION_ANNOTATION_URL_PREFIX = "https://vmh.uni.lu/_api/reactions/?page_size=10000&format=json&search=";
/**
* Class used for some simple operations on {@link BioEntity} elements.
......
......@@ -134,7 +134,7 @@ public class UniprotAnnotator extends ElementAnnotator implements IExternalServi
* @return url to uniprot restfull API about uniprot entry
*/
private String getUniprotUrl(String uniprotId) {
return "http://www.uniprot.org/uniprot/" + uniprotId + ".txt";
return "https://www.uniprot.org/uniprot/" + uniprotId + ".txt";
}
/**
......
......@@ -551,7 +551,7 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
// remove info about single publication from cache (so we will have to
// download it)
chemicalParser.getCache().removeByQuery(
"http://ctdbase.org/detail.go?6578706f7274=1&d-1340579-e=5&type=relationship&ixnId=4802115", chemicalParser.getCacheType());
"https://ctdbase.org/detail.go?6578706f7274=1&d-1340579-e=5&type=relationship&ixnId=4802115", chemicalParser.getCacheType());
// disallow to use cache for first query (it will be directly about drug),
// so parser will have to parse results taking data from cache (or
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment