use of gov.ca.cwds.rest.api.ApiException in project API by ca-cwds.
the class SmartyStreet method getSmartyStreetsCandidates.
/**
* @param street incoming street address
* @param city incoming city name
* @param state incoming state
* @param zipCode incoming zip code
* @return returns a address back
*/
public List<Candidate> getSmartyStreetsCandidates(String street, String city, String state, Integer zipCode) {
Client client = new ClientBuilder(smartyStreetsDao.getClientId(), smartyStreetsDao.getToken()).build();
Lookup lookup = createSmartyStreetsLookup(street, city, state, zipCode);
try {
client.send(lookup);
} catch (SmartyException e) {
LOGGER.error("SmartyStreet error, Unable to validate the address", e);
throw new ApiException("ERROR calling SmartyStreet - ", e);
} catch (IOException e) {
LOGGER.error("SmartyStreet IO error, Unable to validate the address", e);
throw new ApiException("ERROR calling SmartyStreet - ", e);
}
return lookup.getResult();
}
use of gov.ca.cwds.rest.api.ApiException in project API by ca-cwds.
the class PersonService method create.
/**
* {@inheritDoc}
*
* @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
*/
@Override
@UnitOfWork(value = "ns")
public PostedPerson create(Request request) {
assert request instanceof Person;
Person person = (Person) request;
gov.ca.cwds.data.persistence.ns.Person managedPerson = new gov.ca.cwds.data.persistence.ns.Person(person, null, null);
managedPerson = personDao.create(managedPerson);
populatePersonDetails(person, managedPerson);
managedPerson = personDao.find(managedPerson.getId());
PostedPerson postedPerson = new PostedPerson(managedPerson);
try {
final gov.ca.cwds.rest.api.domain.es.Person esPerson = new gov.ca.cwds.rest.api.domain.es.Person(managedPerson.getId().toString(), managedPerson.getFirstName(), managedPerson.getLastName(), managedPerson.getGender(), DomainChef.cookDate(managedPerson.getDateOfBirth()), managedPerson.getSsn(), managedPerson.getClass().getName(), MAPPER.writeValueAsString(managedPerson));
final String document = MAPPER.writeValueAsString(esPerson);
// If the people index is missing, create it.
elasticsearchDao.createIndexIfNeeded(elasticsearchDao.getDefaultAlias());
// The ES Dao manages its own connections. No need to manually start or stop.
// elasticsearchDao.index(elasticsearchDao.getDefaultAlias(),
// elasticsearchDao.getDefaultDocType(), document, esPerson.getId());
} catch (Exception e) {
LOGGER.error("Unable to Index Person in ElasticSearch", e);
throw new ApiException("Unable to Index Person in ElasticSearch", e);
}
return postedPerson;
}
use of gov.ca.cwds.rest.api.ApiException in project API by ca-cwds.
the class Db2XASample method buildDB2DataSource.
private static DB2XADataSource buildDB2DataSource(String user, String password, String serverName, int port, String databaseName) {
DB2XADataSource ds = new DB2XADataSource();
ds.setUser(user);
ds.setPassword(password);
ds.setServerName(serverName);
ds.setPortNumber(port);
ds.setDatabaseName(databaseName);
ds.setDriverType(4);
try {
ds.getProperties().setProperty(DB2XADataSource.propertyKey_serverName, serverName);
ds.getProperties().setProperty(DB2XADataSource.propertyKey_portNumber, String.valueOf(port));
ds.getProperties().setProperty(DB2XADataSource.propertyKey_databaseName, databaseName);
ds.getProperties().setProperty(DB2XADataSource.propertyKey_driverType, "4");
} catch (SQLException e) {
e.printStackTrace();
throw new ApiException("datasource property error", e);
}
return ds;
}
use of gov.ca.cwds.rest.api.ApiException in project API by ca-cwds.
the class XASample method buildDB2DataSource.
private static DB2XADataSource buildDB2DataSource(String user, String password, String serverName, int port, String databaseName) {
DB2XADataSource ds = new DB2XADataSource();
ds.setUser(user);
ds.setPassword(password);
ds.setServerName(serverName);
ds.setPortNumber(port);
ds.setDatabaseName(databaseName);
ds.setDriverType(4);
try {
ds.getProperties().setProperty(DB2XADataSource.propertyKey_serverName, serverName);
ds.getProperties().setProperty(DB2XADataSource.propertyKey_portNumber, String.valueOf(port));
ds.getProperties().setProperty(DB2XADataSource.propertyKey_databaseName, databaseName);
ds.getProperties().setProperty(DB2XADataSource.propertyKey_driverType, "4");
} catch (SQLException e) {
e.printStackTrace();
throw new ApiException("datasource property error", e);
}
return ds;
}
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