use of gov.ca.cwds.rest.api.ApiException in project API by ca-cwds.
the class IndexQueryResource method searchIndex.
/**
* Endpoint for Intake Person Query Search.
*
* @param index {@link IndexQueryRequest}
* @param req JSON {@link IndexQueryRequest}
* @return web service response
*/
@POST
@Path("/{index}/_search")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Unable to process JSON"), @ApiResponse(code = 401, message = "Not Authorized"), @ApiResponse(code = 406, message = "Accept Header not supported") })
@ApiOperation(value = "Query ElasticSearch Persons on given search terms", code = HttpStatus.SC_OK, response = JSONObject.class)
@Consumes(value = MediaType.APPLICATION_JSON)
public Response searchIndex(@PathParam("index") @ApiParam(required = true, name = "index", value = "The index of the search") String index, @Valid @ApiParam(hidden = false, required = true) Object req) {
Response ret;
try {
IndexQueryRequest personQueryRequest = new IndexQueryRequest(index, req);
IndexQueryResponse personQueryResponse = (IndexQueryResponse) resourceDelegate.handle(personQueryRequest).getEntity();
if (personQueryResponse != null) {
ret = Response.status(Response.Status.OK).entity(personQueryResponse.getPersons()).build();
} else {
ret = null;
}
} catch (Exception e) {
LOGGER.error("Intake Person Query ERROR: {}", e.getMessage(), e);
throw new ApiException("Intake Person Query ERROR. " + e.getMessage(), e);
}
return ret;
}
use of gov.ca.cwds.rest.api.ApiException in project API by ca-cwds.
the class XASample method buildPGDataSource.
private static PGXADataSource buildPGDataSource(String user, String password, String serverName, int port, String databaseName) {
PGXADataSource ds = new PGXADataSource();
ds.setUser(user);
ds.setPassword(password);
ds.setServerName(serverName);
ds.setPortNumber(port);
ds.setDatabaseName(databaseName);
try {
ds.setProperty("user", user);
ds.setProperty("password", password);
ds.setProperty(PGProperty.PG_DBNAME, databaseName);
ds.setProperty(PGProperty.PG_HOST, serverName);
ds.setProperty(PGProperty.PG_PORT, String.valueOf(port));
} catch (SQLException e) {
e.printStackTrace();
throw new ApiException("datasource property error", e);
}
System.out.println("pgxa data source");
return ds;
}
Aggregations