use of org.cerberus.engine.entity.MessageGeneral in project cerberus-source by cerberustesting.
the class AppServiceDAO method findAppServiceByKey.
@Override
public AppService findAppServiceByKey(String service) throws CerberusException {
boolean throwEx = false;
AppService result = null;
final String query = "SELECT * FROM appservice srv WHERE `service` = ?";
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query);
try {
preStat.setString(1, service);
ResultSet resultSet = preStat.executeQuery();
try {
if (resultSet.first()) {
String group = resultSet.getString("Group");
String serviceRequest = resultSet.getString("ServiceRequest");
String description = resultSet.getString("Description");
String servicePath = resultSet.getString("servicePath");
String attachementURL = resultSet.getString("AttachementURL");
String operation = resultSet.getString("Operation");
String application = resultSet.getString("Application");
String type = resultSet.getString("Type");
String method = resultSet.getString("Method");
String usrModif = resultSet.getString("UsrModif");
String usrCreated = resultSet.getString("UsrCreated");
Timestamp dateCreated = resultSet.getTimestamp("DateCreated");
Timestamp dateModif = resultSet.getTimestamp("DateModif");
result = this.factoryAppService.create(service, type, method, application, group, serviceRequest, description, servicePath, attachementURL, operation, usrCreated, dateCreated, usrModif, dateModif);
} else {
throwEx = true;
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
resultSet.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
preStat.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn("Exception closing connection : " + e.toString());
}
}
if (throwEx) {
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.NO_DATA_FOUND));
}
return result;
}
Aggregations