diff --git a/cellbase-client/src/main/java/org/opencb/cellbase/client/rest/ParentRestClient.java b/cellbase-client/src/main/java/org/opencb/cellbase/client/rest/ParentRestClient.java index 2ab955eac..0097f642f 100644 --- a/cellbase-client/src/main/java/org/opencb/cellbase/client/rest/ParentRestClient.java +++ b/cellbase-client/src/main/java/org/opencb/cellbase/client/rest/ParentRestClient.java @@ -447,8 +447,8 @@ private CellBaseDataResponse restCall(List hosts, String version, if (assembly != null && StringUtils.isEmpty(queryOptions.getString("assembly"))) { callUrl = callUrl.queryParam("assembly", assembly); } - if (dataRelease != null && StringUtils.isEmpty(queryOptions.getString(AbstractQuery.DATA_RELEASE))) { - callUrl = callUrl.queryParam(AbstractQuery.DATA_RELEASE, dataRelease); + if (dataRelease != null && StringUtils.isEmpty(queryOptions.getString(AbstractQuery.DATA_RELEASE_PARAM))) { + callUrl = callUrl.queryParam(AbstractQuery.DATA_RELEASE_PARAM, dataRelease); } if (apiKey != null && StringUtils.isEmpty(queryOptions.getString(AbstractQuery.API_KEY_PARAM))) { callUrl = callUrl.queryParam(AbstractQuery.API_KEY_PARAM, apiKey); @@ -458,7 +458,7 @@ private CellBaseDataResponse restCall(List hosts, String version, callUrl = callUrl.queryParam("assembly", assembly); } if (dataRelease != null) { - callUrl = callUrl.queryParam(AbstractQuery.DATA_RELEASE, dataRelease); + callUrl = callUrl.queryParam(AbstractQuery.DATA_RELEASE_PARAM, dataRelease); } if (apiKey != null) { callUrl = callUrl.queryParam(AbstractQuery.API_KEY_PARAM, apiKey); diff --git a/cellbase-core/src/main/java/org/opencb/cellbase/core/api/key/ApiKeyManager.java b/cellbase-core/src/main/java/org/opencb/cellbase/core/api/key/ApiKeyManager.java index ba8b0b913..255359ac5 100644 --- a/cellbase-core/src/main/java/org/opencb/cellbase/core/api/key/ApiKeyManager.java +++ b/cellbase-core/src/main/java/org/opencb/cellbase/core/api/key/ApiKeyManager.java @@ -64,6 +64,10 @@ public ApiKeyManager(String algorithm, Key secretKey) { defaultApiKey = encode(payload); } + public ApiKeyManager() { + jwtParser = Jwts.parserBuilder().build(); + } + public String encode(ApiKeyJwtPayload payload) { JwtBuilder jwtBuilder = Jwts.builder(); diff --git a/cellbase-core/src/main/java/org/opencb/cellbase/core/api/query/AbstractQuery.java b/cellbase-core/src/main/java/org/opencb/cellbase/core/api/query/AbstractQuery.java index 6fa4cf7b9..0d771e306 100644 --- a/cellbase-core/src/main/java/org/opencb/cellbase/core/api/query/AbstractQuery.java +++ b/cellbase-core/src/main/java/org/opencb/cellbase/core/api/query/AbstractQuery.java @@ -45,10 +45,10 @@ public abstract class AbstractQuery extends CellBaseQueryOptions { // public static final int DEFAULT_LIMIT = 50; public static final int DEFAULT_SKIP = 0; - public static final String DATA_RELEASE = "dataRelease"; + public static final String DATA_RELEASE_PARAM = "dataRelease"; public static final String API_KEY_PARAM = "apiKey"; - @Deprecated - public static final String TOKEN_PARAM = "token"; +// @Deprecated +// public static final String TOKEN_PARAM = "token"; // list of fields in this class private Map classFields; @@ -59,7 +59,7 @@ public abstract class AbstractQuery extends CellBaseQueryOptions { // key = camelCase name (transcriptsBiotype) to annotations private Map annotations; - @QueryParameter(id = DATA_RELEASE) + @QueryParameter(id = DATA_RELEASE_PARAM) private Integer dataRelease; @QueryParameter(id = API_KEY_PARAM) @@ -469,15 +469,4 @@ public AbstractQuery setApiKey(String apiKey) { this.apiKey = apiKey; return this; } - - @Deprecated - public String getToken() { - return apiKey; - } - - @Deprecated - public AbstractQuery setToken(String token) { - this.apiKey = token; - return this; - } } diff --git a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/ClinicalMongoDBAdaptor.java b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/ClinicalMongoDBAdaptor.java index e614640f4..c5c4a2fd7 100644 --- a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/ClinicalMongoDBAdaptor.java +++ b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/ClinicalMongoDBAdaptor.java @@ -103,7 +103,7 @@ public CellBaseDataResult count(Query query) throws CellBaseException { Bson bson = parseQuery(query); MongoDBCollection mongoDBCollection = getCollectionByRelease(mongoDBCollectionByRelease, - (Integer) query.getOrDefault(AbstractQuery.DATA_RELEASE, 0)); + (Integer) query.getOrDefault(AbstractQuery.DATA_RELEASE_PARAM, 0)); return new CellBaseDataResult<>(mongoDBCollection.count(bson)); } @@ -111,7 +111,7 @@ public CellBaseDataResult distinct(Query query, String field) throws CellBaseExc Bson bson = parseQuery(query); MongoDBCollection mongoDBCollection = getCollectionByRelease(mongoDBCollectionByRelease, - (Integer) query.getOrDefault(AbstractQuery.DATA_RELEASE, 0)); + (Integer) query.getOrDefault(AbstractQuery.DATA_RELEASE_PARAM, 0)); return new CellBaseDataResult<>(mongoDBCollection.distinct(field, bson)); } @@ -128,7 +128,7 @@ public CellBaseDataResult get(Query query, QueryOptions options) throws logger.debug("queryOptions: {}", options.toJson()); MongoDBCollection mongoDBCollection = getCollectionByRelease(mongoDBCollectionByRelease, - (Integer) query.getOrDefault(AbstractQuery.DATA_RELEASE, 0)); + (Integer) query.getOrDefault(AbstractQuery.DATA_RELEASE_PARAM, 0)); return new CellBaseDataResult<>(mongoDBCollection.find(bson, null, Variant.class, parsedOptions)); } @@ -140,7 +140,7 @@ public CellBaseDataResult nativeGet(Query query, QueryOptions options) throws Ce logger.debug("queryOptions: {}", options.toJson()); MongoDBCollection mongoDBCollection = getCollectionByRelease(mongoDBCollectionByRelease, - (Integer) query.getOrDefault(AbstractQuery.DATA_RELEASE, 0)); + (Integer) query.getOrDefault(AbstractQuery.DATA_RELEASE_PARAM, 0)); return new CellBaseDataResult<>(mongoDBCollection.find(bson, parsedOptions)); } @@ -152,7 +152,7 @@ public Iterator nativeIterator(Query query, QueryOptions options) throws CellBas Bson bson = parseQuery(query); MongoDBCollection mongoDBCollection = getCollectionByRelease(mongoDBCollectionByRelease, - (Integer) query.getOrDefault(AbstractQuery.DATA_RELEASE, 0)); + (Integer) query.getOrDefault(AbstractQuery.DATA_RELEASE_PARAM, 0)); return mongoDBCollection.nativeQuery().find(bson, options); } @@ -223,6 +223,7 @@ public Bson parseQuery(ClinicalVariantQuery query) { Object value = entry.getValue(); switch (dotNotationName) { case "token": + case "apiKey": case "dataRelease": // Do nothing break; @@ -416,8 +417,8 @@ private CellBaseDataResult getClinicalVariant(Variant variant, GenomeMa } // Add data release to query - if (!query.containsKey(AbstractQuery.DATA_RELEASE)) { - query.put(AbstractQuery.DATA_RELEASE, dataRelease); + if (!query.containsKey(AbstractQuery.DATA_RELEASE_PARAM)) { + query.put(AbstractQuery.DATA_RELEASE_PARAM, dataRelease); } } @@ -471,7 +472,7 @@ public CellBaseIterator iterator(ClinicalVariantQuery query) throws CellBaseExce @Override public List> info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, - String token) { + String apiKey) { return null; } diff --git a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/GeneMongoDBAdaptor.java b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/GeneMongoDBAdaptor.java index d2b9cb9ec..94a686310 100644 --- a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/GeneMongoDBAdaptor.java +++ b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/GeneMongoDBAdaptor.java @@ -82,13 +82,13 @@ public CellBaseDataResult aggregationStats(GeneQuery query) { } @Override - public List> info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, String token) + public List> info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, String apiKey) throws CellBaseException { - return info(ids, queryOptions, null, dataRelease, token); + return info(ids, queryOptions, null, dataRelease, apiKey); } public List> info(List ids, ProjectionQueryOptions queryOptions, String source, int dataRelease, - String token) throws CellBaseException { + String apiKey) throws CellBaseException { List> results = new ArrayList<>(); Bson projection = getProjection(queryOptions); for (String id : ids) { @@ -205,9 +205,10 @@ public Bson parseQuery(GeneQuery geneQuery) { case "mirna": createMirnaQuery(value, andBsonList); break; + case "token": + case "apiKey": case "source": case "dataRelease": - case "token": // do nothing break; default: diff --git a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/GenomeMongoDBAdaptor.java b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/GenomeMongoDBAdaptor.java index 32c9aba03..e8d40c802 100644 --- a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/GenomeMongoDBAdaptor.java +++ b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/GenomeMongoDBAdaptor.java @@ -523,7 +523,7 @@ public CellBaseDataResult distinct(GenomeQuery query) throws CellBaseExc } @Override - public List> info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, String token) + public List> info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, String apiKey) throws CellBaseException { List> results = new ArrayList<>(); MongoDBCollection mongoDBCollection = getCollectionByRelease(mongoDBCollectionByRelease, dataRelease); @@ -548,8 +548,9 @@ public Bson parseQuery(GenomeQuery query) { case "name": createAndOrQuery(value, "chromosomes.name", QueryParam.Type.STRING, andBsonList); break; - case "dataRelease": case "token": + case "apiKey": + case "dataRelease": // Do nothing break; default: diff --git a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/OntologyMongoDBAdaptor.java b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/OntologyMongoDBAdaptor.java index a3465c53a..7632a0565 100644 --- a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/OntologyMongoDBAdaptor.java +++ b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/OntologyMongoDBAdaptor.java @@ -69,8 +69,8 @@ public CellBaseIterator iterator(OntologyQuery query) throws CellB } @Override - public List> info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, String token) - throws CellBaseException { + public List> info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, + String apiKey) throws CellBaseException { List> results = new ArrayList<>(); Bson projection = getProjection(queryOptions); MongoDBCollection mongoDBCollection = getCollectionByRelease(mongoDBCollectionByRelease, dataRelease); diff --git a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/PharmacogenomicsMongoDBAdaptor.java b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/PharmacogenomicsMongoDBAdaptor.java index aabf539ea..3154f0c5c 100644 --- a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/PharmacogenomicsMongoDBAdaptor.java +++ b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/PharmacogenomicsMongoDBAdaptor.java @@ -69,7 +69,7 @@ public CellBaseDataResult aggregationStats(PharmaChemicalQuery q @Override public List> info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, - String token) throws CellBaseException { + String apiKey) throws CellBaseException { List> results = new ArrayList<>(); Bson projection = getProjection(queryOptions); for (String id : ids) { @@ -114,8 +114,9 @@ public Bson parseQuery(PharmaChemicalQuery pharmaQuery) { String dotNotationName = entry.getKey(); Object value = entry.getValue(); switch (dotNotationName) { - case "dataRelease": case "token": + case "apiKey": + case "dataRelease": // do nothing break; default: diff --git a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/ProteinMongoDBAdaptor.java b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/ProteinMongoDBAdaptor.java index c5d2bd599..353b4042c 100644 --- a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/ProteinMongoDBAdaptor.java +++ b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/ProteinMongoDBAdaptor.java @@ -300,7 +300,7 @@ public CellBaseIterator iterator(ProteinQuery query) throws CellBaseExcep } @Override - public List> info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, String token) + public List> info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, String apiKey) throws CellBaseException { List> results = new ArrayList<>(); MongoDBCollection mongoDBCollection = getCollectionByRelease(mongoDBCollectionByRelease, dataRelease); @@ -364,8 +364,9 @@ public Bson parseQuery(ProteinQuery proteinQuery) { case "keyword": createAndOrQuery(value, "keyword.value", QueryParam.Type.STRING, andBsonList); break; - case "dataRelease": case "token": + case "apiKey": + case "dataRelease": // Do nothing break; default: diff --git a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/PublicationMongoDBAdaptor.java b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/PublicationMongoDBAdaptor.java index 7168bbcbe..a279f0765 100644 --- a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/PublicationMongoDBAdaptor.java +++ b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/PublicationMongoDBAdaptor.java @@ -73,7 +73,7 @@ public CellBaseIterator iterator(PublicationQuery query) throws C @Override public List> info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, - String token) throws CellBaseException { + String apiKey) throws CellBaseException { List> results = new ArrayList<>(); Bson projection = getProjection(queryOptions); MongoDBCollection mongoDBCollection = getCollectionByRelease(mongoDBCollectionByRelease, dataRelease); diff --git a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/RegulationMongoDBAdaptor.java b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/RegulationMongoDBAdaptor.java index 38901a83e..e7373b57b 100644 --- a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/RegulationMongoDBAdaptor.java +++ b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/RegulationMongoDBAdaptor.java @@ -71,8 +71,9 @@ public Bson parseQuery(RegulationQuery query) { case "region": createRegionQuery(query, value, MongoDBCollectionConfiguration.REGULATORY_REGION_CHUNK_SIZE, andBsonList); break; - case "dataRelease": case "token": + case "apiKey": + case "dataRelease": // Do nothing break; default: @@ -104,7 +105,7 @@ public CellBaseIterator iterator(RegulationQuery query) throw @Override public List> info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, - String token) { + String apiKey) { return null; } diff --git a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/ReleaseMongoDBAdaptor.java b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/ReleaseMongoDBAdaptor.java index 48fda65d2..4098f9c53 100644 --- a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/ReleaseMongoDBAdaptor.java +++ b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/ReleaseMongoDBAdaptor.java @@ -152,7 +152,7 @@ public CellBaseDataResult distinct(AbstractQuery query) { } @Override - public List info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, String token) { + public List info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, String apiKey) { return null; } diff --git a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/RepeatsMongoDBAdaptor.java b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/RepeatsMongoDBAdaptor.java index c57e0459d..7105be25b 100644 --- a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/RepeatsMongoDBAdaptor.java +++ b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/RepeatsMongoDBAdaptor.java @@ -67,8 +67,9 @@ public Bson parseQuery(RepeatsQuery query) { case "region": createRegionQuery(query, value, MongoDBCollectionConfiguration.REPEATS_CHUNK_SIZE, andBsonList); break; - case "dataRelease": case "token": + case "apiKey": + case "dataRelease": // Do nothing break; default: @@ -100,7 +101,7 @@ public CellBaseIterator iterator(RepeatsQuery query) throws CellBaseException { } @Override - public List> info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, String token) { + public List> info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, String apiKey) { return null; } diff --git a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/TranscriptMongoDBAdaptor.java b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/TranscriptMongoDBAdaptor.java index 4e0e70aeb..9fc26d1c5 100644 --- a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/TranscriptMongoDBAdaptor.java +++ b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/TranscriptMongoDBAdaptor.java @@ -84,12 +84,12 @@ public CellBaseIterator iterator(TranscriptQuery query) throws CellB @Override public List> info(List ids, ProjectionQueryOptions projectionQueryOptions, int dataRelease, - String token) throws CellBaseException { - return info(ids, projectionQueryOptions, null, dataRelease, token); + String apiKey) throws CellBaseException { + return info(ids, projectionQueryOptions, null, dataRelease, apiKey); } public List> info(List ids, ProjectionQueryOptions projectionQueryOptions, String source, - int dataRelease, String token) throws CellBaseException { + int dataRelease, String apiKey) throws CellBaseException { List> results = new ArrayList<>(); QueryOptions queryOptions = getInfoQueryOptions(projectionQueryOptions); for (String id : ids) { @@ -221,9 +221,10 @@ public Bson parseQuery(TranscriptQuery query) { case "transcripts.supportLevel": andBsonList.add(Filters.regex("transcripts.supportLevel", "^" + value)); break; + case "token": case "source": + case "apiKey": case "dataRelease": - case "token": // Do nothing break; default: diff --git a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/VariantMongoDBAdaptor.java b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/VariantMongoDBAdaptor.java index 599822f78..e9a8db0e8 100644 --- a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/VariantMongoDBAdaptor.java +++ b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/VariantMongoDBAdaptor.java @@ -252,7 +252,7 @@ public Bson parseQuery(VariantQuery query) { case "region": createRegionQuery(query, query.getRegions(), MongoDBCollectionConfiguration.VARIATION_CHUNK_SIZE, andBsonList); break; - case VariantQuery.DATA_RELEASE: + case VariantQuery.DATA_RELEASE_PARAM: case "svType": // don't do anything, this is parsed later break; @@ -740,7 +740,7 @@ public CellBaseDataResult distinct(VariantQuery query) { } @Override - public List> info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, String token) + public List> info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, String apiKey) throws CellBaseException { List> results = new ArrayList<>(); MongoDBCollection mongoDBCollection = getCollectionByRelease(mongoDBCollectionByRelease, dataRelease); diff --git a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/XRefMongoDBAdaptor.java b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/XRefMongoDBAdaptor.java index 29536be64..42889fb02 100644 --- a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/XRefMongoDBAdaptor.java +++ b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/impl/core/XRefMongoDBAdaptor.java @@ -67,7 +67,7 @@ public CellBaseIterator iterator(XrefQuery query) throws CellBaseException } @Override - public List> info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, String token) + public List> info(List ids, ProjectionQueryOptions queryOptions, int dataRelease, String apiKey) throws CellBaseException { List> results = new ArrayList<>(); for (String id : ids) { @@ -153,8 +153,9 @@ public Bson parseQuery(XrefQuery query) { case "dbname": createAndOrQuery(value, "transcripts.xrefs.dbName", QueryParam.Type.STRING, andBsonList); break; - case "dataRelease": case "token": + case "apiKey": + case "dataRelease": // Do nothing break; default: diff --git a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/managers/AbstractManager.java b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/managers/AbstractManager.java index 9e5b0744a..df982e2f6 100644 --- a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/managers/AbstractManager.java +++ b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/managers/AbstractManager.java @@ -33,7 +33,6 @@ import java.util.List; import static org.opencb.cellbase.core.api.query.AbstractQuery.API_KEY_PARAM; -import static org.opencb.cellbase.core.api.query.AbstractQuery.TOKEN_PARAM; public class AbstractManager implements AutoCloseable { @@ -84,10 +83,7 @@ public AbstractManager(String species, String assembly, CellBaseConfiguration co } protected String getApiKey(QueryOptions queryOptions) { - if (queryOptions.containsKey(API_KEY_PARAM)) { - return queryOptions.getString(API_KEY_PARAM); - } - return queryOptions.getString(TOKEN_PARAM); + return queryOptions.getString(API_KEY_PARAM); } @Deprecated diff --git a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/managers/FeatureApi.java b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/managers/FeatureApi.java index a06b904e9..815aaef50 100644 --- a/cellbase-lib/src/main/java/org/opencb/cellbase/lib/managers/FeatureApi.java +++ b/cellbase-lib/src/main/java/org/opencb/cellbase/lib/managers/FeatureApi.java @@ -45,9 +45,9 @@ default List> search(List queries) throws QueryExceptio return results; } - default List> info(List ids, CellBaseQueryOptions queryOptions, int dataRelease, String token) + default List> info(List ids, CellBaseQueryOptions queryOptions, int dataRelease, String apiKey) throws CellBaseException { - return getDBAdaptor().info(ids, queryOptions, dataRelease, token); + return getDBAdaptor().info(ids, queryOptions, dataRelease, apiKey); } default CellBaseDataResult distinct(Q query) throws CellBaseException { diff --git a/cellbase-lib/src/test/java/org/opencb/cellbase/lib/GenericMongoDBAdaptorTest.java b/cellbase-lib/src/test/java/org/opencb/cellbase/lib/GenericMongoDBAdaptorTest.java index 332f59252..42e5cedd7 100644 --- a/cellbase-lib/src/test/java/org/opencb/cellbase/lib/GenericMongoDBAdaptorTest.java +++ b/cellbase-lib/src/test/java/org/opencb/cellbase/lib/GenericMongoDBAdaptorTest.java @@ -16,7 +16,6 @@ package org.opencb.cellbase.lib; -import com.fasterxml.jackson.core.JsonProcessingException; import org.apache.commons.collections4.CollectionUtils; import org.opencb.biodata.models.variant.Variant; import org.opencb.cellbase.core.common.GitRepositoryState; @@ -25,12 +24,10 @@ import org.opencb.cellbase.core.models.DataRelease; import org.opencb.cellbase.core.result.CellBaseDataResult; import org.opencb.cellbase.lib.db.MongoDBManager; -import org.opencb.cellbase.lib.impl.core.CellBaseDBAdaptor; import org.opencb.cellbase.lib.loader.LoadRunner; import org.opencb.cellbase.lib.loader.LoaderException; import org.opencb.cellbase.lib.managers.CellBaseManagerFactory; import org.opencb.cellbase.lib.managers.DataReleaseManager; -import org.opencb.commons.datastore.mongodb.MongoDataStore; import org.opencb.commons.exec.Command; import org.opencb.commons.utils.URLUtils; import org.slf4j.Logger; @@ -47,8 +44,6 @@ import java.util.List; import java.util.concurrent.ExecutionException; -import static org.opencb.cellbase.lib.db.MongoDBManager.DBNAME_SEPARATOR; - /** * Created by fjlopez on 18/09/15. */ @@ -73,13 +68,13 @@ public class GenericMongoDBAdaptorTest { protected CellBaseConfiguration cellBaseConfiguration; protected CellBaseManagerFactory cellBaseManagerFactory; - protected String UNIVERSAL_ACDES_TOKEN = "eyJhbGciOiJIUzI1NiJ9.eyJzb3VyY2VzIjp7ImNvc21pYyI6OTIyMzM3MjAzNjg1NDc3NTgwNywiaGdtZCI6OTIyMzM3MjAzNjg1NDc3NTgwNywic3BsaWNlYWkiOjkyMjMzNzIwMzY4NTQ3NzU4MDd9LCJtYXhOdW1RdWVyaWVzIjoxMDAwMDAwMCwidmVyc2lvbiI6IjEuMCIsInN1YiI6IlRFU1QiLCJpYXQiOjE2ODk4MzczODZ9.ALdEFGmVuatoUEj-K3HAHt2KlqeNm2Fv7m-DODhz0LU"; - protected String HGMD_ACCESS_TOKEN = "eyJhbGciOiJIUzI1NiJ9.eyJzb3VyY2VzIjp7ImhnbWQiOjkyMjMzNzIwMzY4NTQ3NzU4MDd9LCJtYXhOdW1RdWVyaWVzIjoxMDAwMDAwMCwidmVyc2lvbiI6IjEuMCIsInN1YiI6IlRFU1QiLCJpYXQiOjE2ODk4Mzc0MjZ9.zqEU-WhIzhbpbmwGWnAjgmgfOtBbP5nXq2uqX5wV5uY"; - protected String COSMIC_ACCESS_TOKEN = "eyJhbGciOiJIUzI1NiJ9.eyJzb3VyY2VzIjp7ImNvc21pYyI6OTIyMzM3MjAzNjg1NDc3NTgwN30sIm1heE51bVF1ZXJpZXMiOjEwMDAwMDAwLCJ2ZXJzaW9uIjoiMS4wIiwic3ViIjoiVEVTVCIsImlhdCI6MTY4OTgzNzQ2MX0.K6SEGvScpJ2a99SLPaUi4KRJ8FJ_LNPduoHW_LSSNGU"; - protected String SPLICEAI_ACCESS_TOKEN = "eyJhbGciOiJIUzI1NiJ9.eyJzb3VyY2VzIjp7InNwbGljZWFpIjo5MjIzMzcyMDM2ODU0Nzc1ODA3fSwibWF4TnVtUXVlcmllcyI6MTAwMDAwMDAsInZlcnNpb24iOiIxLjAiLCJzdWIiOiJURVNUIiwiaWF0IjoxNjg5ODM3NDc4fQ.zDECxkcPrIA4czkpRHYmS3dSJZkr0aXT9XF2KqkTIRU"; - protected String HGMD_COSMIC_ACCESS_TOKEN = "eyJhbGciOiJIUzI1NiJ9.eyJzb3VyY2VzIjp7ImNvc21pYyI6OTIyMzM3MjAzNjg1NDc3NTgwNywiaGdtZCI6OTIyMzM3MjAzNjg1NDc3NTgwN30sIm1heE51bVF1ZXJpZXMiOjEwMDAwMDAwLCJ2ZXJzaW9uIjoiMS4wIiwic3ViIjoiVEVTVCIsImlhdCI6MTY4OTgzNzQ5OX0.ZsTxFaSzsLwyQMLwNIODerfaOTLywoRwkxvpsnjVTSE"; - protected String HGMD_SPLICEAI_ACCESS_TOKEN = "eyJhbGciOiJIUzI1NiJ9.eyJzb3VyY2VzIjp7ImhnbWQiOjkyMjMzNzIwMzY4NTQ3NzU4MDcsInNwbGljZWFpIjo5MjIzMzcyMDM2ODU0Nzc1ODA3fSwibWF4TnVtUXVlcmllcyI6MTAwMDAwMDAsInZlcnNpb24iOiIxLjAiLCJzdWIiOiJURVNUIiwiaWF0IjoxNjg5ODM3NTE4fQ.rDH2BR2EkUgs3fz7hAuCbmAHgE0rHmp9JhD-5gFZmfI"; - protected String COSMIC_SPLICEAI_ACCESS_TOKEN = "eyJhbGciOiJIUzI1NiJ9.eyJzb3VyY2VzIjp7ImNvc21pYyI6OTIyMzM3MjAzNjg1NDc3NTgwNywic3BsaWNlYWkiOjkyMjMzNzIwMzY4NTQ3NzU4MDd9LCJtYXhOdW1RdWVyaWVzIjoxMDAwMDAwMCwidmVyc2lvbiI6IjEuMCIsInN1YiI6IlRFU1QiLCJpYXQiOjE2ODk4Mzc1MzZ9.CkXvpNg0NWAXL3N06R2gCqe0kF4ptBk0MPvaAdDSEpQ"; + protected String UNIVERSAL_ACCES_API_KEY = "eyJhbGciOiJIUzI1NiJ9.eyJzb3VyY2VzIjp7ImNvc21pYyI6OTIyMzM3MjAzNjg1NDc3NTgwNywiaGdtZCI6OTIyMzM3MjAzNjg1NDc3NTgwNywic3BsaWNlYWkiOjkyMjMzNzIwMzY4NTQ3NzU4MDd9LCJtYXhOdW1RdWVyaWVzIjoxMDAwMDAwMCwidmVyc2lvbiI6IjEuMCIsInN1YiI6IlRFU1QiLCJpYXQiOjE2ODk4MzczODZ9.ALdEFGmVuatoUEj-K3HAHt2KlqeNm2Fv7m-DODhz0LU"; + protected String HGMD_ACCESS_API_KEY = "eyJhbGciOiJIUzI1NiJ9.eyJzb3VyY2VzIjp7ImhnbWQiOjkyMjMzNzIwMzY4NTQ3NzU4MDd9LCJtYXhOdW1RdWVyaWVzIjoxMDAwMDAwMCwidmVyc2lvbiI6IjEuMCIsInN1YiI6IlRFU1QiLCJpYXQiOjE2ODk4Mzc0MjZ9.zqEU-WhIzhbpbmwGWnAjgmgfOtBbP5nXq2uqX5wV5uY"; + protected String COSMIC_ACCESS_API_KEY = "eyJhbGciOiJIUzI1NiJ9.eyJzb3VyY2VzIjp7ImNvc21pYyI6OTIyMzM3MjAzNjg1NDc3NTgwN30sIm1heE51bVF1ZXJpZXMiOjEwMDAwMDAwLCJ2ZXJzaW9uIjoiMS4wIiwic3ViIjoiVEVTVCIsImlhdCI6MTY4OTgzNzQ2MX0.K6SEGvScpJ2a99SLPaUi4KRJ8FJ_LNPduoHW_LSSNGU"; + protected String SPLICEAI_ACCESS_API_KEY = "eyJhbGciOiJIUzI1NiJ9.eyJzb3VyY2VzIjp7InNwbGljZWFpIjo5MjIzMzcyMDM2ODU0Nzc1ODA3fSwibWF4TnVtUXVlcmllcyI6MTAwMDAwMDAsInZlcnNpb24iOiIxLjAiLCJzdWIiOiJURVNUIiwiaWF0IjoxNjg5ODM3NDc4fQ.zDECxkcPrIA4czkpRHYmS3dSJZkr0aXT9XF2KqkTIRU"; + protected String HGMD_COSMIC_ACCESS_API_KEY = "eyJhbGciOiJIUzI1NiJ9.eyJzb3VyY2VzIjp7ImNvc21pYyI6OTIyMzM3MjAzNjg1NDc3NTgwNywiaGdtZCI6OTIyMzM3MjAzNjg1NDc3NTgwN30sIm1heE51bVF1ZXJpZXMiOjEwMDAwMDAwLCJ2ZXJzaW9uIjoiMS4wIiwic3ViIjoiVEVTVCIsImlhdCI6MTY4OTgzNzQ5OX0.ZsTxFaSzsLwyQMLwNIODerfaOTLywoRwkxvpsnjVTSE"; + protected String HGMD_SPLICEAI_ACCESS_API_KEY = "eyJhbGciOiJIUzI1NiJ9.eyJzb3VyY2VzIjp7ImhnbWQiOjkyMjMzNzIwMzY4NTQ3NzU4MDcsInNwbGljZWFpIjo5MjIzMzcyMDM2ODU0Nzc1ODA3fSwibWF4TnVtUXVlcmllcyI6MTAwMDAwMDAsInZlcnNpb24iOiIxLjAiLCJzdWIiOiJURVNUIiwiaWF0IjoxNjg5ODM3NTE4fQ.rDH2BR2EkUgs3fz7hAuCbmAHgE0rHmp9JhD-5gFZmfI"; + protected String COSMIC_SPLICEAI_ACCESS_API_KEY = "eyJhbGciOiJIUzI1NiJ9.eyJzb3VyY2VzIjp7ImNvc21pYyI6OTIyMzM3MjAzNjg1NDc3NTgwNywic3BsaWNlYWkiOjkyMjMzNzIwMzY4NTQ3NzU4MDd9LCJtYXhOdW1RdWVyaWVzIjoxMDAwMDAwMCwidmVyc2lvbiI6IjEuMCIsInN1YiI6IlRFU1QiLCJpYXQiOjE2ODk4Mzc1MzZ9.CkXvpNg0NWAXL3N06R2gCqe0kF4ptBk0MPvaAdDSEpQ"; protected LoadRunner loadRunner = null; // protected MongoDBAdaptorFactory dbAdaptorFactory; diff --git a/cellbase-lib/src/test/java/org/opencb/cellbase/lib/impl/core/GeneMongoDBAdaptorTest.java b/cellbase-lib/src/test/java/org/opencb/cellbase/lib/impl/core/GeneMongoDBAdaptorTest.java index 9b643ad68..c9a749837 100644 --- a/cellbase-lib/src/test/java/org/opencb/cellbase/lib/impl/core/GeneMongoDBAdaptorTest.java +++ b/cellbase-lib/src/test/java/org/opencb/cellbase/lib/impl/core/GeneMongoDBAdaptorTest.java @@ -17,8 +17,6 @@ package org.opencb.cellbase.lib.impl.core; import org.hamcrest.CoreMatchers; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.opencb.biodata.models.core.Gene; import org.opencb.biodata.models.variant.avro.Constraint; @@ -32,8 +30,6 @@ import org.opencb.cellbase.lib.managers.GeneManager; import java.io.IOException; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.*; import java.util.stream.Collectors; @@ -57,7 +53,7 @@ public void testQueryId() throws Exception { Map paramMap = new HashMap<>(); paramMap.put("id", "ENSG00000248746"); paramMap.put("include", "id,name,start,end"); - paramMap.put(AbstractQuery.DATA_RELEASE, String.valueOf(dataRelease)); + paramMap.put(AbstractQuery.DATA_RELEASE_PARAM, String.valueOf(dataRelease)); GeneQuery geneQuery = new GeneQuery(paramMap); geneQuery.setCount(Boolean.TRUE); @@ -77,7 +73,7 @@ public void testQuery() throws Exception { paramMap.put("annotation.expression.tissue", "brain"); paramMap.put("annotation.expression.value", "UP"); paramMap.put("include", "id,name"); - paramMap.put(AbstractQuery.DATA_RELEASE, String.valueOf(dataRelease)); + paramMap.put(AbstractQuery.DATA_RELEASE_PARAM, String.valueOf(dataRelease)); GeneQuery geneQuery = new GeneQuery(paramMap); geneQuery.setCount(Boolean.TRUE); @@ -129,7 +125,7 @@ public void testConstraints() throws Exception { Map paramMap = new HashMap<>(); paramMap.put("constraints", "oe_lof<=0.85585"); - paramMap.put(AbstractQuery.DATA_RELEASE, String.valueOf(dataRelease)); + paramMap.put(AbstractQuery.DATA_RELEASE_PARAM, String.valueOf(dataRelease)); GeneQuery geneQuery = new GeneQuery(paramMap); CellBaseDataResult cellBaseDataResult = geneManager.search(geneQuery); assertEquals(12, cellBaseDataResult.getNumResults()); @@ -138,28 +134,28 @@ public void testConstraints() throws Exception { paramMap = new HashMap<>(); paramMap.put("constraints", "oe_mis>0.8"); - paramMap.put(AbstractQuery.DATA_RELEASE, String.valueOf(dataRelease)); + paramMap.put(AbstractQuery.DATA_RELEASE_PARAM, String.valueOf(dataRelease)); geneQuery = new GeneQuery(paramMap); cellBaseDataResult = geneManager.search(geneQuery); assertEquals(9, cellBaseDataResult.getNumResults()); paramMap = new HashMap<>(); paramMap.put("constraints", "oe_syn=0.91766"); - paramMap.put(AbstractQuery.DATA_RELEASE, String.valueOf(dataRelease)); + paramMap.put(AbstractQuery.DATA_RELEASE_PARAM, String.valueOf(dataRelease)); geneQuery = new GeneQuery(paramMap); cellBaseDataResult = geneManager.search(geneQuery); assertEquals(0, cellBaseDataResult.getNumResults()); paramMap = new HashMap<>(); paramMap.put("constraints", " exac_pLI<0.17633"); - paramMap.put(AbstractQuery.DATA_RELEASE, String.valueOf(dataRelease)); + paramMap.put(AbstractQuery.DATA_RELEASE_PARAM, String.valueOf(dataRelease)); geneQuery = new GeneQuery(paramMap); cellBaseDataResult = geneManager.search(geneQuery); assertEquals(0, cellBaseDataResult.getNumResults()); paramMap = new HashMap<>(); paramMap.put("constraints", "exac_oe_lof>=0.45091"); - paramMap.put(AbstractQuery.DATA_RELEASE, String.valueOf(dataRelease)); + paramMap.put(AbstractQuery.DATA_RELEASE_PARAM, String.valueOf(dataRelease)); geneQuery = new GeneQuery(paramMap); cellBaseDataResult = geneManager.search(geneQuery); assertEquals(7, cellBaseDataResult.getNumResults()); diff --git a/cellbase-lib/src/test/java/org/opencb/cellbase/lib/impl/core/VariantAnnotationCalculatorTest.java b/cellbase-lib/src/test/java/org/opencb/cellbase/lib/impl/core/VariantAnnotationCalculatorTest.java index 5f11b6da7..10aecf635 100644 --- a/cellbase-lib/src/test/java/org/opencb/cellbase/lib/impl/core/VariantAnnotationCalculatorTest.java +++ b/cellbase-lib/src/test/java/org/opencb/cellbase/lib/impl/core/VariantAnnotationCalculatorTest.java @@ -22,7 +22,6 @@ import com.fasterxml.jackson.databind.ObjectReader; import org.apache.commons.collections4.CollectionUtils; import org.hamcrest.CoreMatchers; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; @@ -1042,7 +1041,7 @@ null, new Breakend(new BreakendMate("2", 10000, 10000 - 100, @Test public void testLicensedClinicalHGMDAnnotation() throws Exception { - variantAnnotationCalculator = new VariantAnnotationCalculator(SPECIES, ASSEMBLY, dataRelease, HGMD_ACCESS_TOKEN, cellBaseManagerFactory); + variantAnnotationCalculator = new VariantAnnotationCalculator(SPECIES, ASSEMBLY, dataRelease, HGMD_ACCESS_API_KEY, cellBaseManagerFactory); QueryOptions queryOptions = new QueryOptions("useCache", false); queryOptions.put("include", "clinical"); @@ -1061,7 +1060,7 @@ public void testLicensedClinicalHGMDAnnotation() throws Exception { @Test public void testLicensedClinicalHGMDandCOSMICAnnotation() throws Exception { - variantAnnotationCalculator = new VariantAnnotationCalculator(SPECIES, ASSEMBLY, dataRelease, HGMD_COSMIC_ACCESS_TOKEN, cellBaseManagerFactory); + variantAnnotationCalculator = new VariantAnnotationCalculator(SPECIES, ASSEMBLY, dataRelease, HGMD_COSMIC_ACCESS_API_KEY, cellBaseManagerFactory); QueryOptions queryOptions = new QueryOptions("useCache", false); queryOptions.put("include", "clinical"); @@ -1947,7 +1946,7 @@ public void testLicensedDataUnisersalTokenAnnotation() throws Exception { queryOptions.put("exclude", "pharmacogenomics"); queryOptions.put("normalize", true); - variantAnnotationCalculator.setToken(UNIVERSAL_ACDES_TOKEN); + variantAnnotationCalculator.setToken(UNIVERSAL_ACCES_API_KEY); Variant variant = new Variant("10", 113588287, "G", "A"); CellBaseDataResult cellBaseDataResult = variantAnnotationCalculator @@ -1974,7 +1973,7 @@ public void testLicensedDataHgmdTokenAnnotation() throws Exception { queryOptions.put("exclude", "pharmacogenomics"); queryOptions.put("normalize", true); - variantAnnotationCalculator.setToken(HGMD_ACCESS_TOKEN); + variantAnnotationCalculator.setToken(HGMD_ACCESS_API_KEY); Variant variant = new Variant("10", 113588287, "G", "A"); CellBaseDataResult cellBaseDataResult = variantAnnotationCalculator @@ -2001,7 +2000,7 @@ public void testLicensedDataCosmicTokenAnnotation() throws Exception { queryOptions.put("exclude", "pharmacogenomics"); queryOptions.put("normalize", true); - variantAnnotationCalculator.setToken(COSMIC_ACCESS_TOKEN); + variantAnnotationCalculator.setToken(COSMIC_ACCESS_API_KEY); Variant variant = new Variant("10", 113588287, "G", "A"); CellBaseDataResult cellBaseDataResult = variantAnnotationCalculator @@ -2028,7 +2027,7 @@ public void testLicensedDataSpliceTokenAnnotation() throws Exception { queryOptions.put("exclude", "pharmacogenomics"); queryOptions.put("normalize", true); - variantAnnotationCalculator.setToken(SPLICEAI_ACCESS_TOKEN); + variantAnnotationCalculator.setToken(SPLICEAI_ACCESS_API_KEY); Variant variant = new Variant("10", 113588287, "G", "A"); CellBaseDataResult cellBaseDataResult = variantAnnotationCalculator @@ -2055,7 +2054,7 @@ public void testLicensedDataHgmdCosmicTokenAnnotation() throws Exception { queryOptions.put("exclude", "pharmacogenomics"); queryOptions.put("normalize", true); - variantAnnotationCalculator.setToken(HGMD_COSMIC_ACCESS_TOKEN); + variantAnnotationCalculator.setToken(HGMD_COSMIC_ACCESS_API_KEY); Variant variant = new Variant("10", 113588287, "G", "A"); CellBaseDataResult cellBaseDataResult = variantAnnotationCalculator @@ -2082,7 +2081,7 @@ public void testLicensedDataHgmdSpliceAiTokenAnnotation() throws Exception { queryOptions.put("exclude", "pharmacogenomics"); queryOptions.put("normalize", true); - variantAnnotationCalculator.setToken(HGMD_SPLICEAI_ACCESS_TOKEN); + variantAnnotationCalculator.setToken(HGMD_SPLICEAI_ACCESS_API_KEY); Variant variant = new Variant("10", 113588287, "G", "A"); CellBaseDataResult cellBaseDataResult = variantAnnotationCalculator @@ -2109,7 +2108,7 @@ public void testLicensedDataCosmicSpliceTokenAnnotation() throws Exception { queryOptions.put("exclude", "pharmacogenomics"); queryOptions.put("normalize", true); - variantAnnotationCalculator.setToken(COSMIC_SPLICEAI_ACCESS_TOKEN); + variantAnnotationCalculator.setToken(COSMIC_SPLICEAI_ACCESS_API_KEY); Variant variant = new Variant("10", 113588287, "G", "A"); CellBaseDataResult cellBaseDataResult = variantAnnotationCalculator diff --git a/cellbase-lib/src/test/java/org/opencb/cellbase/lib/variant/ClinicalManagerTest.java b/cellbase-lib/src/test/java/org/opencb/cellbase/lib/variant/ClinicalManagerTest.java index 0a6536cf5..cd20457f4 100644 --- a/cellbase-lib/src/test/java/org/opencb/cellbase/lib/variant/ClinicalManagerTest.java +++ b/cellbase-lib/src/test/java/org/opencb/cellbase/lib/variant/ClinicalManagerTest.java @@ -25,6 +25,7 @@ import org.opencb.biodata.models.core.Region; import org.opencb.biodata.models.variant.Variant; import org.opencb.cellbase.core.api.ClinicalVariantQuery; +import org.opencb.cellbase.core.api.key.ApiKeyManager; import org.opencb.cellbase.core.api.query.QueryException; import org.opencb.cellbase.core.exception.CellBaseException; import org.opencb.cellbase.core.result.CellBaseDataResult; @@ -63,7 +64,7 @@ public void testLicensedHGMD() throws CellBaseException, QueryException, Illegal regions.add(Region.parseRegion("10:113588287-113588287")); query.setRegions(regions); query.setDataRelease(dataRelease); - query.setToken(HGMD_ACCESS_TOKEN); + query.setApiKey(HGMD_ACCESS_API_KEY); CellBaseDataResult results = clinicalManager.search(query); Assert.assertEquals(1, results.getResults().size()); @@ -101,10 +102,13 @@ public void testIteratorOnlyClinvar() throws CellBaseException, QueryException, query.setDataRelease(dataRelease); CellBaseIterator iterator = clinicalManager.iterator(query); + int count = 0; while (iterator.hasNext()) { Variant variant = iterator.next(); Assert.assertEquals(1, variant.getAnnotation().getTraitAssociation().size()); + count++; } + Assert.assertEquals(1, count); } @Test @@ -116,12 +120,15 @@ public void testIteratorLicensedHGMD() throws CellBaseException { regions.add(Region.parseRegion("10:113588287-113588287")); query.setRegions(regions); query.setDataRelease(dataRelease); - query.setToken(HGMD_ACCESS_TOKEN); + query.setApiKey(HGMD_ACCESS_API_KEY); + int count = 0; CellBaseIterator iterator = clinicalManager.iterator(query); while (iterator.hasNext()) { Variant variant = iterator.next(); Assert.assertEquals(2, variant.getAnnotation().getTraitAssociation().size()); + count++; } + Assert.assertEquals(1, count); } } diff --git a/cellbase-server/src/main/java/org/opencb/cellbase/server/rest/GenericRestWSServer.java b/cellbase-server/src/main/java/org/opencb/cellbase/server/rest/GenericRestWSServer.java index 00514f334..22b1317f5 100755 --- a/cellbase-server/src/main/java/org/opencb/cellbase/server/rest/GenericRestWSServer.java +++ b/cellbase-server/src/main/java/org/opencb/cellbase/server/rest/GenericRestWSServer.java @@ -28,13 +28,13 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.StopWatch; import org.opencb.cellbase.core.ParamConstants; +import org.opencb.cellbase.core.api.key.ApiKeyJwtPayload; +import org.opencb.cellbase.core.api.key.ApiKeyManager; import org.opencb.cellbase.core.api.query.QueryException; import org.opencb.cellbase.core.config.CellBaseConfiguration; import org.opencb.cellbase.core.exception.CellBaseException; import org.opencb.cellbase.core.result.CellBaseDataResponse; import org.opencb.cellbase.core.result.CellBaseDataResult; -import org.opencb.cellbase.core.api.key.ApiKeyManager; -import org.opencb.cellbase.core.api.key.ApiKeyJwtPayload; import org.opencb.cellbase.core.utils.SpeciesUtils; import org.opencb.cellbase.lib.managers.CellBaseManagerFactory; import org.opencb.cellbase.lib.managers.DataReleaseManager; @@ -60,7 +60,7 @@ import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; -import static org.opencb.cellbase.core.api.query.AbstractQuery.*; +import static org.opencb.cellbase.core.api.query.AbstractQuery.API_KEY_PARAM; @Path("/{version}/{species}") @Produces("text/plain") @@ -179,7 +179,7 @@ private void initQuery() throws CellBaseException { // Set default API key, if necessary // For back-compatibility, we get 'token' parameter after checking 'apiKey' parameter - String apiKey = uriParams.containsKey(API_KEY_PARAM) ? uriParams.get(API_KEY_PARAM) : uriParams.get(TOKEN_PARAM); + String apiKey = uriParams.containsKey(API_KEY_PARAM) ? uriParams.get(API_KEY_PARAM) : uriParams.get("token"); logger.info("before checking, API key {}", apiKey); if (StringUtils.isEmpty(apiKey)) { apiKey = defaultApiKey;