Skip to content

Commit

Permalink
Merge branch 'develop' into TASK-4988
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarraga committed Oct 27, 2023
2 parents c2379a0 + 81276f6 commit 4622fb9
Show file tree
Hide file tree
Showing 30 changed files with 244 additions and 184 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Build and test the project

on:
workflow_call:
secrets:
Expand Down
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.7.0-SNAPSHOT</version>
<version>5.8.0-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.7.0-SNAPSHOT</version>
<version>5.8.0-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.7.0-SNAPSHOT</version>
<version>5.8.0-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.7.0-SNAPSHOT</version>
<version>5.8.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public void checkQuota(String apiKey, ApiKeyJwtPayload payload) throws CellBaseE
numQueries = quotaResult.first().getNumQueries();
}
if (numQueries >= payload.getQuota().getMaxNumQueries()) {
throw new CellBaseException("Exceeded the maximum number of queries");
throw new CellBaseException("Maximum query limit reached: Your current API key has a quota of "
+ payload.getQuota().getMaxNumQueries() + " queries");
}
}

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.7.0-SNAPSHOT</version>
<version>5.8.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2015-2020 OpenCB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.opencb.cellbase.server.exception;

import javax.ws.rs.WebApplicationException;

public class CellBaseServerException extends WebApplicationException {
public CellBaseServerException(String msg) {
super(msg);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import org.opencb.cellbase.core.ParamConstants;
import org.opencb.cellbase.core.api.FileQuery;
import org.opencb.cellbase.core.api.query.QueryException;
import org.opencb.cellbase.core.exception.CellBaseException;
import org.opencb.cellbase.core.result.CellBaseDataResult;
import org.opencb.cellbase.lib.managers.FileManager;
import org.opencb.cellbase.server.exception.CellBaseServerException;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
Expand All @@ -48,9 +48,13 @@ public FileWSServer(@PathParam("apiVersion")
@ApiParam(name = "apiVersion", value = ParamConstants.VERSION_DESCRIPTION,
defaultValue = ParamConstants.DEFAULT_VERSION) String apiVersion,
@Context UriInfo uriInfo, @Context HttpServletRequest hsr)
throws QueryException, IOException, CellBaseException {
throws CellBaseServerException {
super(apiVersion, uriInfo, hsr);
fileManager = cellBaseManagerFactory.getFileManager();
try {
fileManager = cellBaseManagerFactory.getFileManager();
} catch (Exception e) {
throw new CellBaseServerException(e.getMessage());
}
}

@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
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;
Expand All @@ -40,6 +39,7 @@
import org.opencb.cellbase.lib.managers.DataReleaseManager;
import org.opencb.cellbase.lib.managers.MetaManager;
import org.opencb.cellbase.lib.monitor.Monitor;
import org.opencb.cellbase.server.exception.CellBaseServerException;
import org.opencb.commons.datastore.core.Event;
import org.opencb.commons.datastore.core.ObjectMap;
import org.opencb.commons.datastore.core.Query;
Expand All @@ -60,7 +60,8 @@
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;

import static org.opencb.cellbase.core.ParamConstants.*;
import static org.opencb.cellbase.core.ParamConstants.API_KEY_PARAM;
import static org.opencb.cellbase.core.ParamConstants.DATA_RELEASE_PARAM;

@Path("/{version}/{species}")
@Produces("text/plain")
Expand Down Expand Up @@ -101,21 +102,25 @@ public class GenericRestWSServer implements IWSServer {
protected static ApiKeyManager apiKeyManager;

public GenericRestWSServer(@PathParam("version") String version, @Context UriInfo uriInfo, @Context HttpServletRequest hsr)
throws QueryException, IOException, CellBaseException {
throws CellBaseServerException {
this(version, DONT_CHECK_SPECIES, uriInfo, hsr);
}

public GenericRestWSServer(@PathParam("version") String version, @PathParam("species") String species, @Context UriInfo uriInfo,
@Context HttpServletRequest hsr)
throws QueryException, IOException, CellBaseException {
throws CellBaseServerException {

this.version = version;
this.uriInfo = uriInfo;
this.httpServletRequest = hsr;
this.species = species;

init();
initQuery();
try {
init();
initQuery();
} catch (Exception e) {
throw new CellBaseServerException(e.getMessage());
}
}

private void init() throws IOException, CellBaseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.opencb.cellbase.core.ParamConstants;
import org.opencb.cellbase.core.api.query.QueryException;
import org.opencb.cellbase.core.api.key.ApiKeyJwtPayload;
import org.opencb.cellbase.core.api.key.ApiKeyManager;
import org.opencb.cellbase.core.common.GitRepositoryState;
import org.opencb.cellbase.core.config.DownloadProperties;
import org.opencb.cellbase.core.config.SpeciesConfiguration;
import org.opencb.cellbase.core.config.SpeciesProperties;
import org.opencb.cellbase.core.exception.CellBaseException;
import org.opencb.cellbase.core.models.DataRelease;
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.DataReleaseManager;
import org.opencb.cellbase.lib.managers.MetaManager;
import org.opencb.cellbase.server.exception.CellBaseServerException;
import org.opencb.cellbase.server.rest.clinical.ClinicalWSServer;
import org.opencb.cellbase.server.rest.feature.GeneWSServer;
import org.opencb.cellbase.server.rest.feature.IdWSServer;
Expand All @@ -50,7 +50,6 @@
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import java.io.IOException;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.text.DateFormat;
Expand All @@ -73,9 +72,13 @@ public MetaWSServer(@PathParam("apiVersion")
@ApiParam(name = "apiVersion", value = ParamConstants.VERSION_DESCRIPTION,
defaultValue = ParamConstants.DEFAULT_VERSION) String apiVersion,
@Context UriInfo uriInfo, @Context HttpServletRequest hsr)
throws QueryException, IOException, CellBaseException {
throws CellBaseServerException {
super(apiVersion, uriInfo, hsr);
metaManager = cellBaseManagerFactory.getMetaManager();
try {
metaManager = cellBaseManagerFactory.getMetaManager();
} catch (Exception e) {
throw new CellBaseServerException(e.getMessage());
}
}

@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,17 @@
import org.apache.commons.lang3.StringUtils;
import org.opencb.biodata.models.core.OntologyTerm;
import org.opencb.cellbase.core.api.OntologyQuery;
import org.opencb.cellbase.core.api.query.QueryException;
import org.opencb.cellbase.core.exception.CellBaseException;
import org.opencb.cellbase.core.result.CellBaseDataResult;
import org.opencb.cellbase.core.utils.SpeciesUtils;
import org.opencb.cellbase.lib.managers.OntologyManager;
import org.opencb.cellbase.server.exception.CellBaseServerException;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
Expand All @@ -55,17 +53,21 @@ public OntologyWSServer(@PathParam("apiVersion") @ApiParam(name = "apiVersion",
int dataRelease,
@ApiParam(name = "apiKey", value = API_KEY_DESCRIPTION) @DefaultValue("") @QueryParam("apiKey") String apiKey,
@Context UriInfo uriInfo, @Context HttpServletRequest hsr)
throws QueryException, IOException, CellBaseException {
throws CellBaseServerException {
super(apiVersion, species, uriInfo, hsr);
List<String> assemblies = uriInfo.getQueryParameters().get("assembly");
if (CollectionUtils.isNotEmpty(assemblies)) {
assembly = assemblies.get(0);
}
if (StringUtils.isEmpty(assembly)) {
assembly = SpeciesUtils.getDefaultAssembly(cellBaseConfiguration, species).getName();
}
try {
List<String> assemblies = uriInfo.getQueryParameters().get("assembly");
if (CollectionUtils.isNotEmpty(assemblies)) {
assembly = assemblies.get(0);
}
if (StringUtils.isEmpty(assembly)) {
assembly = SpeciesUtils.getDefaultAssembly(cellBaseConfiguration, species).getName();
}

ontologyManager = cellBaseManagerFactory.getOntologyManager(species, assembly);
ontologyManager = cellBaseManagerFactory.getOntologyManager(species, assembly);
} catch (Exception e) {
throw new CellBaseServerException(e.getMessage());
}
}

@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@
import org.opencb.biodata.formats.pubmed.v233jaxb.PubmedArticle;
import org.opencb.cellbase.core.ParamConstants;
import org.opencb.cellbase.core.api.PublicationQuery;
import org.opencb.cellbase.core.api.query.QueryException;
import org.opencb.cellbase.core.exception.CellBaseException;
import org.opencb.cellbase.core.result.CellBaseDataResult;
import org.opencb.cellbase.lib.managers.PublicationManager;
import org.opencb.cellbase.server.exception.CellBaseServerException;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import java.io.IOException;
import java.util.Map;

import static org.opencb.cellbase.core.ParamConstants.*;
Expand All @@ -55,9 +53,13 @@ public PublicationWSServer(@PathParam("apiVersion")
@ApiParam(name = "apiKey", value = API_KEY_DESCRIPTION) @DefaultValue("") @QueryParam("apiKey")
String apiKey,
@Context UriInfo uriInfo, @Context HttpServletRequest hsr)
throws QueryException, IOException, CellBaseException {
throws CellBaseServerException {
super(apiVersion, uriInfo, hsr);
publicationManager = cellBaseManagerFactory.getPublicationManager();
try {
publicationManager = cellBaseManagerFactory.getPublicationManager();
} catch (Exception e) {
throw new CellBaseServerException(e.getMessage());
}
}

@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@
import io.swagger.annotations.*;
import org.opencb.biodata.models.core.Chromosome;
import org.opencb.cellbase.core.api.GenomeQuery;
import org.opencb.cellbase.core.api.query.QueryException;
import org.opencb.cellbase.core.exception.CellBaseException;
import org.opencb.cellbase.core.result.CellBaseDataResult;
import org.opencb.cellbase.lib.managers.GenomeManager;
import org.opencb.cellbase.server.exception.CellBaseServerException;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import java.io.IOException;

import static org.opencb.cellbase.core.ParamConstants.*;

Expand All @@ -53,10 +51,13 @@ public SpeciesWSServer(@PathParam("apiVersion") @ApiParam(name = "apiVersion", v
int dataRelease,
@ApiParam(name = "apiKey", value = API_KEY_DESCRIPTION) @DefaultValue("") @QueryParam("apiKey") String apiKey,
@Context UriInfo uriInfo,
@Context HttpServletRequest hsr) throws QueryException, IOException, CellBaseException {
@Context HttpServletRequest hsr) throws CellBaseServerException {
super(apiVersion, species, uriInfo, hsr);

genomeManager = cellBaseManagerFactory.getGenomeManager(species, assembly);
try {
genomeManager = cellBaseManagerFactory.getGenomeManager(species, assembly);
} catch (Exception e) {
throw new CellBaseServerException(e.getMessage());
}
}

@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
import io.swagger.annotations.*;
import org.opencb.biodata.models.variant.Variant;
import org.opencb.cellbase.core.api.ClinicalVariantQuery;
import org.opencb.cellbase.core.api.query.QueryException;
import org.opencb.cellbase.core.exception.CellBaseException;
import org.opencb.cellbase.core.result.CellBaseDataResult;
import org.opencb.cellbase.core.utils.SpeciesUtils;
import org.opencb.cellbase.lib.managers.ClinicalManager;
import org.opencb.cellbase.server.exception.CellBaseServerException;
import org.opencb.cellbase.server.rest.GenericRestWSServer;

import javax.servlet.http.HttpServletRequest;
Expand All @@ -32,7 +31,6 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import java.io.IOException;

import static org.opencb.cellbase.core.ParamConstants.*;

Expand All @@ -53,13 +51,17 @@ public ClinicalWSServer(@PathParam("apiVersion") @ApiParam(name = "apiVersion",
int dataRelease,
@ApiParam(name = "apiKey", value = API_KEY_DESCRIPTION) @DefaultValue("") @QueryParam("apiKey") String apiKey,
@Context UriInfo uriInfo, @Context HttpServletRequest hsr)
throws QueryException, IOException, CellBaseException {
throws CellBaseServerException {
super(apiVersion, species, uriInfo, hsr);
if (assembly == null) {
assembly = SpeciesUtils.getDefaultAssembly(cellBaseConfiguration, species).getName();
}
try {
if (assembly == null) {
assembly = SpeciesUtils.getDefaultAssembly(cellBaseConfiguration, species).getName();
}

clinicalManager = cellBaseManagerFactory.getClinicalManager(species, assembly);
clinicalManager = cellBaseManagerFactory.getClinicalManager(species, assembly);
} catch (Exception e) {
throw new CellBaseServerException(e.getMessage());
}
}

@GET
Expand Down
Loading

0 comments on commit 4622fb9

Please sign in to comment.