Skip to content

Commit

Permalink
Resolve conflicts, #TASK-5447
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarraga committed Jan 24, 2024
2 parents 06327aa + 8be81e7 commit e1cc66c
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 25 deletions.
2 changes: 1 addition & 1 deletion cellbase-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase</artifactId>
<version>5.8.1-SNAPSHOT</version>
<version>5.8.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion cellbase-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase</artifactId>
<version>5.8.1-SNAPSHOT</version>
<version>5.8.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion cellbase-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase</artifactId>
<version>5.8.1-SNAPSHOT</version>
<version>5.8.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion cellbase-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase</artifactId>
<version>5.8.1-SNAPSHOT</version>
<version>5.8.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@

package org.opencb.cellbase.lib.impl.core;

import com.mongodb.ReadPreference;
import com.mongodb.WriteConcern;
import com.mongodb.client.model.Filters;
import com.mongodb.client.model.Updates;
import org.bson.BsonDocument;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.codehaus.jackson.map.ObjectMapper;
import org.opencb.cellbase.core.api.key.ApiKeyStats;
import org.opencb.cellbase.core.api.query.AbstractQuery;
import org.opencb.cellbase.core.api.query.ProjectionQueryOptions;
import org.opencb.cellbase.core.exception.CellBaseException;
import org.opencb.cellbase.core.result.CellBaseDataResult;
import org.opencb.cellbase.core.api.key.ApiKeyStats;
import org.opencb.cellbase.lib.iterator.CellBaseIterator;
import org.opencb.commons.datastore.core.FacetField;
import org.opencb.commons.datastore.core.QueryOptions;
Expand Down Expand Up @@ -55,7 +57,7 @@ public MetaMongoDBAdaptor(MongoDataStore mongoDataStore) {
private void init() {
logger.debug("MetaMongoDBAdaptor: in 'constructor'");
mongoDBCollection = mongoDataStore.getCollection("metadata");
apiKeyStatsMongoDBCollection = mongoDataStore.getCollection("apikey_stats");
apiKeyStatsMongoDBCollection = mongoDataStore.getCollection("apikey_stats", WriteConcern.ACKNOWLEDGED, ReadPreference.primary());
}

public CellBaseDataResult getAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,9 +615,9 @@ private List<VariantAnnotation> runAnnotationProcess(List<Variant> normalizedVar
}
}
} catch (Exception e) {
e.printStackTrace();
variantAnnotation.setDisplayConsequenceType(VariantAnnotationUtils.FUNCTION_UNCERTAIN_VARIANT);
variantAnnotation.setConsequenceTypes(Collections.emptyList());
logger.error("Something wrong happened when calculation consequence type for variant " + variant, e);
throw e;
}
}

Expand Down
2 changes: 1 addition & 1 deletion cellbase-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase</artifactId>
<version>5.8.1-SNAPSHOT</version>
<version>5.8.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ public GenericRestWSServer(@PathParam("version") String version, @PathParam("spe
this.assembly = assembly;

try {
init();
if (!INITIALIZED.get()) {
init();
}

if (this.assembly == null) {
// Default assembly depends on the CellBaseConfiguration (so it has to be already initialized)
Expand All @@ -131,9 +133,9 @@ public GenericRestWSServer(@PathParam("version") String version, @PathParam("spe
}
}

private void init() throws IOException, CellBaseException {
private synchronized void init() throws IOException, CellBaseException {
// we need to make sure we only init one single time
if (INITIALIZED.compareAndSet(false, true)) {
if (!INITIALIZED.get()) {
SERVICE_START_DATE = new SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime());
WATCH = new StopWatch();
WATCH.start();
Expand Down Expand Up @@ -167,19 +169,21 @@ private void init() throws IOException, CellBaseException {
cellBaseManagerFactory = new CellBaseManagerFactory(cellBaseConfiguration);
logger.info("***************************************************");

// Get default API key (for anonymous queries)
if (apiKeyManager == null) {
apiKeyManager = new ApiKeyManager(cellBaseConfiguration.getSecretKey());
defaultApiKey = apiKeyManager.getDefaultApiKey();
logger.info("default API key {}", defaultApiKey);
}

// Initialize Monitor
monitor = new Monitor(cellBaseManagerFactory.getMetaManager());

INITIALIZED.set(true);
}
}

private void initQuery() throws CellBaseException {
// Get default API key (for anonymous queries)
if (apiKeyManager == null) {
apiKeyManager = new ApiKeyManager(cellBaseConfiguration.getSecretKey());
defaultApiKey = apiKeyManager.getDefaultApiKey();
logger.info("default API key {}", defaultApiKey);
}

startTime = System.currentTimeMillis();
query = new Query();
uriParams = convertMultiToMap(uriInfo.getQueryParameters());
Expand All @@ -191,12 +195,10 @@ private void initQuery() throws CellBaseException {

// Set default API key, if necessary
String apiKey = uriParams.getOrDefault(API_KEY_PARAM, null);
logger.info("Before checking, API key {}", apiKey);
if (StringUtils.isEmpty(apiKey)) {
apiKey = defaultApiKey;
uriParams.put(API_KEY_PARAM, apiKey);
}
logger.info("After checking, API key {}", uriParams.get(API_KEY_PARAM));

checkLimit();

Expand Down Expand Up @@ -281,7 +283,8 @@ private void checkVersion() throws CellBaseException {
}

private void checkApiKey() throws CellBaseException {
if (!uriInfo.getPath().contains("health")) {
// Update the API key content only for non-meta endpoints
if (!uriInfo.getPath().contains("/meta/")) {
String apiKey = getApiKey();
ApiKeyJwtPayload payload = apiKeyManager.decode(apiKey);

Expand Down Expand Up @@ -422,7 +425,7 @@ protected Response createOkResponse(Object obj) {

// Update API key stats, if necessary
try {
if (!uriInfo.getPath().contains("health")) {
if (!uriInfo.getPath().contains("/meta/")) {
String apiKey = getApiKey();
MetaManager metaManager = cellBaseManagerFactory.getMetaManager();
long bytes = (jsonResponse.getEntity() != null) ? jsonResponse.getEntity().toString().length() : 0;
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase</artifactId>
<version>5.8.1-SNAPSHOT</version>
<version>5.8.2-SNAPSHOT</version>
<packaging>pom</packaging>

<name>CellBase project</name>
Expand All @@ -24,7 +24,7 @@
<properties>
<pycellbase.version>${project.version}</pycellbase.version>
<java-common-libs.version>4.12.1-SNAPSHOT</java-common-libs.version>
<biodata.version>2.12.1-SNAPSHOT</biodata.version>
<biodata.version>2.12.2-SNAPSHOT</biodata.version>
<bionetdb.version>0.1.0</bionetdb.version>
<jackson.version>2.11.4</jackson.version>
<jackson-asl.version>1.9.13</jackson-asl.version>
Expand Down

0 comments on commit e1cc66c

Please sign in to comment.