Source:
public Response execute(LinkedHashMap<String, Object> json) throws ApiException { String datasource = null, resultType = null, query = null, queryType = "select", result = "", returnType = MediaType.APPLICATION_XML; Object returnEntity = null; for (Entry<String, Object> entry : json.entrySet()) { String key = entry.getKey(); if(key.equalsIgnoreCase("datasource")) { datasource = entry.getValue().toString(); } if(key.equalsIgnoreCase("resultType")) { resultType = entry.getValue().toString().toLowerCase(); if(resultType.equalsIgnoreCase("csv")) { returnType = MediaType.TEXT_PLAIN; } if(resultType.equalsIgnoreCase("json")) { returnType = MediaType.APPLICATION_JSON; } } if(key.equalsIgnoreCase("query")) { query = entry.getValue().toString(); if(query.toLowerCase().indexOf("select") == -1) queryType = "other"; } } if(datasource == null || resultType == null || query == null) { throw new ApiException("Missing data, datasource, resultType and query are expected.", 400); } DirectQuerySender qs; try { qs = (DirectQuerySender) getIbisContext().createBeanAutowireByName(DirectQuerySender.class); } catch (Exception e) { throw new ApiException("An error occured on creating or closing the connection", e); } try { qs.setName("QuerySender"); qs.setDatasourceName(datasource); qs.setQueryType(queryType); qs.setBlobSmartGet(true); qs.configure(true); qs.open(); Message message = qs.sendMessage(new Message(query), null); result = message.asString(); if (resultType.equalsIgnoreCase("csv")) { AbstractQueryOutputTransformer filter = new QueryOutputToCSV(); result = filter.parse(message); } if (resultType.equalsIgnoreCase("json")) { AbstractQueryOutputTransformer filter = new QueryOutputToJson(); result = filter.parse(message); } } catch (Throwable t) { throw new ApiException("Error executing query", t); } finally { qs.close(); } return Response.status(Response.Status.CREATED).type(returnType).entity(result).build(); }

Target:
public Response execute(LinkedHashMap<String, Object> json) throws ApiException { String datasource = null, resultType = null, query = null, queryType = "select", result = "", returnType = MediaType.APPLICATION_XML; for (Entry<String, Object> entry : json.entrySet()) { String key = entry.getKey(); if(key.equalsIgnoreCase("datasource")) { datasource = entry.getValue().toString(); } if(key.equalsIgnoreCase("resultType")) { resultType = entry.getValue().toString().toLowerCase(); if(resultType.equalsIgnoreCase("csv")) { returnType = MediaType.TEXT_PLAIN; } if(resultType.equalsIgnoreCase("json")) { returnType = MediaType.APPLICATION_JSON; } } if(key.equalsIgnoreCase("query")) { query = entry.getValue().toString(); if(query.toLowerCase().indexOf("select") == -1) queryType = "other"; } } if(datasource == null || resultType == null || query == null) { throw new ApiException("Missing data, datasource, resultType and query are expected.", 400); } DirectQuerySender qs; try { qs = (DirectQuerySender) getIbisContext().createBeanAutowireByName(DirectQuerySender.class); } catch (Exception e) { throw new ApiException("An error occured on creating or closing the connection", e); } try { qs.setName("QuerySender"); qs.setDatasourceName(datasource); qs.setQueryType(queryType); qs.setBlobSmartGet(true); qs.configure(true); qs.open(); Message message = qs.sendMessage(new Message(query), null); if (resultType.equalsIgnoreCase("csv")) { AbstractQueryOutputTransformer filter = new QueryOutputToCSV(); result = filter.parse(message); } else if (resultType.equalsIgnoreCase("json")) { AbstractQueryOutputTransformer filter = new QueryOutputToJson(); result = filter.parse(message); } else { result = message.asString(); } } catch (Throwable t) { throw new ApiException("Error executing query", t); } finally { qs.close(); } return Response.status(Response.Status.CREATED).type(returnType).entity(result).build(); }