@@ -97,16 +97,13 @@ public class GenericRestWSServer implements IWSServer {
97
97
protected static org .opencb .cellbase .lib .monitor .Monitor monitor ;
98
98
private static final String ERROR = "error" ;
99
99
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" ;
103
100
104
101
protected static String defaultApiKey ;
105
102
protected static ApiKeyManager apiKeyManager ;
106
103
107
104
public GenericRestWSServer (@ PathParam ("version" ) String version , @ Context UriInfo uriInfo , @ Context HttpServletRequest hsr )
108
105
throws CellBaseServerException {
109
- this (version , DONT_CHECK_SPECIES , DONT_CHECK_ASSEMBLY , uriInfo , hsr );
106
+ this (version , "hsapiens" , null , uriInfo , hsr );
110
107
}
111
108
112
109
public GenericRestWSServer (@ PathParam ("version" ) String version , @ PathParam ("species" ) String species ,
@@ -121,11 +118,13 @@ public GenericRestWSServer(@PathParam("version") String version, @PathParam("spe
121
118
this .assembly = assembly ;
122
119
123
120
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 ();
126
126
}
127
127
128
- init ();
129
128
initQuery ();
130
129
} catch (Exception e ) {
131
130
throw new CellBaseServerException (e .getMessage ());
@@ -205,15 +204,10 @@ private void initQuery() throws CellBaseException {
205
204
checkVersion ();
206
205
207
206
// 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 );
217
211
}
218
212
219
213
// Check API key (expiration date, quota,...)
@@ -237,10 +231,6 @@ protected int getDataRelease() throws CellBaseException {
237
231
}
238
232
}
239
233
// 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
- }
244
234
return defaultDataRelease .getRelease ();
245
235
}
246
236
@@ -284,11 +274,6 @@ private void checkVersion() throws CellBaseException {
284
274
throw new CellBaseException ("Version not valid: '" + version + "'" );
285
275
}
286
276
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("*************************************");
292
277
if (!uriInfo .getPath ().contains ("health" ) && !version .startsWith (cellBaseConfiguration .getVersion ())) {
293
278
logger .error ("URL version '{}' does not match configuration '{}'" , this .version , cellBaseConfiguration .getVersion ());
294
279
throw new CellBaseException ("URL version not valid: '" + version + "'" );
@@ -450,23 +435,8 @@ protected Response createOkResponse(Object obj) {
450
435
return jsonResponse ;
451
436
}
452
437
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
-
465
438
protected Response createJsonResponse (CellBaseDataResponse queryResponse ) {
466
439
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
- // }
470
440
String value = jsonObjectWriter .writeValueAsString (queryResponse );
471
441
ResponseBuilder ok = Response .ok (value , MediaType .APPLICATION_JSON_TYPE .withCharset ("utf-8" ));
472
442
Response response = buildResponse (ok );
0 commit comments