Skip to content

Commit 06327aa

Browse files
committed
server: set hsapiens as default species, #TASK-5447
1 parent 73727ac commit 06327aa

File tree

1 file changed

+10
-40
lines changed

1 file changed

+10
-40
lines changed

cellbase-server/src/main/java/org/opencb/cellbase/server/rest/GenericRestWSServer.java

+10-40
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,13 @@ public class GenericRestWSServer implements IWSServer {
9797
protected static org.opencb.cellbase.lib.monitor.Monitor monitor;
9898
private static final String ERROR = "error";
9999
private static final String OK = "ok";
100-
// this webservice has no species or assembly, do not validate
101-
private static final String DONT_CHECK_SPECIES = "do not validate species";
102-
private static final String DONT_CHECK_ASSEMBLY = "do not validate assembly";
103100

104101
protected static String defaultApiKey;
105102
protected static ApiKeyManager apiKeyManager;
106103

107104
public GenericRestWSServer(@PathParam("version") String version, @Context UriInfo uriInfo, @Context HttpServletRequest hsr)
108105
throws CellBaseServerException {
109-
this(version, DONT_CHECK_SPECIES, DONT_CHECK_ASSEMBLY, uriInfo, hsr);
106+
this(version, "hsapiens", null, uriInfo, hsr);
110107
}
111108

112109
public GenericRestWSServer(@PathParam("version") String version, @PathParam("species") String species,
@@ -121,11 +118,13 @@ public GenericRestWSServer(@PathParam("version") String version, @PathParam("spe
121118
this.assembly = assembly;
122119

123120
try {
124-
if (this.assembly == null && !DONT_CHECK_SPECIES.equals(species)) {
125-
this.assembly = SpeciesUtils.getDefaultAssembly(cellBaseConfiguration, species).getName();
121+
init();
122+
123+
if (this.assembly == null) {
124+
// Default assembly depends on the CellBaseConfiguration (so it has to be already initialized)
125+
this.assembly = SpeciesUtils.getDefaultAssembly(cellBaseConfiguration, this.species).getName();
126126
}
127127

128-
init();
129128
initQuery();
130129
} catch (Exception e) {
131130
throw new CellBaseServerException(e.getMessage());
@@ -205,15 +204,10 @@ private void initQuery() throws CellBaseException {
205204
checkVersion();
206205

207206
// Set default data release if necessary
208-
if (!DONT_CHECK_SPECIES.equals(species) && defaultDataRelease == null) {
209-
// As the assembly may not be presented in the query, we have to be sure to get it from the CellBase configuration
210-
assembly = SpeciesUtils.getSpecies(cellBaseConfiguration, this.species, assembly).getAssembly();
211-
212-
if (!DONT_CHECK_ASSEMBLY.equals(assembly) && StringUtils.isNotEmpty(assembly)) {
213-
DataReleaseManager releaseManager = cellBaseManagerFactory.getDataReleaseManager(species, assembly);
214-
// getDefault launches an exception if no data release is found for that CellBase version
215-
defaultDataRelease = releaseManager.getDefault(version);
216-
}
207+
if (defaultDataRelease == null) {
208+
DataReleaseManager releaseManager = cellBaseManagerFactory.getDataReleaseManager(species, assembly);
209+
// getDefault launches an exception if no data release is found for that CellBase version
210+
defaultDataRelease = releaseManager.getDefault(version);
217211
}
218212

219213
// Check API key (expiration date, quota,...)
@@ -237,10 +231,6 @@ protected int getDataRelease() throws CellBaseException {
237231
}
238232
}
239233
// If no data release is present in the query, then use the default data release
240-
if (!DONT_CHECK_SPECIES.equals(species)) {
241-
logger.info("No data release present in query: using the default data release '" + defaultDataRelease + "' for CellBase version"
242-
+ " '" + version + "'");
243-
}
244234
return defaultDataRelease.getRelease();
245235
}
246236

@@ -284,11 +274,6 @@ private void checkVersion() throws CellBaseException {
284274
throw new CellBaseException("Version not valid: '" + version + "'");
285275
}
286276

287-
// System.out.println("*************************************");
288-
// System.out.println("cellBaseConfiguration = " + cellBaseConfiguration);
289-
// System.out.println("cellBaseConfiguration.getVersion() = " + cellBaseConfiguration.getVersion());
290-
// System.out.println("version = " + version);
291-
// System.out.println("*************************************");
292277
if (!uriInfo.getPath().contains("health") && !version.startsWith(cellBaseConfiguration.getVersion())) {
293278
logger.error("URL version '{}' does not match configuration '{}'", this.version, cellBaseConfiguration.getVersion());
294279
throw new CellBaseException("URL version not valid: '" + version + "'");
@@ -450,23 +435,8 @@ protected Response createOkResponse(Object obj) {
450435
return jsonResponse;
451436
}
452437

453-
// protected Response createOkResponse(Object obj, MediaType mediaType) {
454-
// return buildResponse(Response.ok(obj, mediaType));
455-
// }
456-
//
457-
// protected Response createOkResponse(Object obj, MediaType mediaType, String fileName) {
458-
// return buildResponse(Response.ok(obj, mediaType).header("content-disposition", "attachment; filename =" + fileName));
459-
// }
460-
//
461-
// protected Response createStringResponse(String str) {
462-
// return buildResponse(Response.ok(str));
463-
// }
464-
465438
protected Response createJsonResponse(CellBaseDataResponse queryResponse) {
466439
try {
467-
// if (CollectionUtils.isNotEmpty(queryResponse.getResponses()) && queryResponse.getResponses().get(0) != null) {
468-
// System.out.println("queryResponse.getResponses().get(0).toString() = " + queryResponse.getResponses().get(0).toString());
469-
// }
470440
String value = jsonObjectWriter.writeValueAsString(queryResponse);
471441
ResponseBuilder ok = Response.ok(value, MediaType.APPLICATION_JSON_TYPE.withCharset("utf-8"));
472442
Response response = buildResponse(ok);

0 commit comments

Comments
 (0)