use of org.cerberus.crud.service.IApplicationService in project cerberus-source by cerberustesting.
the class GetNumberOfExecutions method processRequest.
/**
* Processes requests for both HTTP
* <code>GET</code> and
* <code>POST</code> methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
// Loading Services.
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
IApplicationService myApplicationService = appContext.getBean(ApplicationService.class);
IInvariantService myInvariantService = appContext.getBean(InvariantService.class);
// Calling Servlet Transversal Util.
ServletUtil.servletStart(request);
/**
* Adding Log entry.
*/
ILogEventService logEventService = appContext.getBean(LogEventService.class);
logEventService.createForPublicCalls("/GetNumberOfExecutions", "CALL", "GetNumberOfExecutions called : " + request.getRequestURL(), request);
// Parsing all parameters.
String environment = ParameterParserUtil.parseStringParam(request.getParameter("environment"), "PROD");
String test = ParameterParserUtil.parseStringParam(request.getParameter("test"), "");
String application = ParameterParserUtil.parseStringParam(request.getParameter("application"), "");
String country = ParameterParserUtil.parseStringParam(request.getParameter("country"), "");
String controlStatus = ParameterParserUtil.parseStringParam(request.getParameter("controlstatus"), "");
int NbMinutes = ParameterParserUtil.parseIntegerParam(request.getParameter("nbminuteshistory"), 0);
// Defining help message.
String helpMessage = "\nThis servlet return the number of execution performed on WORKING test cases that match the following criterias :\n" + "- nbminuteshistory [mandatory] : the number of minutes in the past from the moment the servlet is called. This parameter must be > 0. [" + NbMinutes + "]\n" + "- test : Executions done on the test. [" + test + "]\n" + "- environment : Environment where the execution happened. Default to PROD. [" + environment + "]\n" + "- country : Executions done on the country. [" + country + "]\n" + "- application : Executions done against that application. [" + application + "]\n" + "- controlstatus : execution that return the following status. [" + controlStatus + "]\n";
try {
// Checking the parameter validity. nbminuteshistory is a mandatory parameter.
boolean error = false;
if (NbMinutes == 0) {
out.println("Error - Parameter nbminuteshistory is mandatory. Please feed it in order to specify the elapsed time where the history should be considered.");
error = true;
}
// Checking the parameter validity. If application has been entered, does it exist ?
if (!application.equalsIgnoreCase("") && !myApplicationService.exist(application)) {
out.println("Error - Application does not exist : " + application);
error = true;
}
if (!country.equalsIgnoreCase("") && !myInvariantService.isInvariantExist("COUNTRY", country)) {
out.println("Warning - Country does not exist : " + country);
}
if (!environment.equalsIgnoreCase("") && !myInvariantService.isInvariantExist("ENVIRONMENT", environment)) {
out.println("Warning - Environment does not exist : " + environment);
}
if (!controlStatus.equalsIgnoreCase("") && !myInvariantService.isInvariantExist("TCESTATUS", controlStatus)) {
out.println("Warning - Control Status does not exist : " + controlStatus);
}
// Starting the request only if previous parameters exist.
if (!error) {
// Getting a timestamp to filter the executions based on the nb of minutes
String dateLimitFrom = DateUtil.getMySQLTimestampTodayDeltaMinutes(-NbMinutes);
ITestCaseExecutionService MyTestExecutionService = appContext.getBean(TestCaseExecutionService.class);
List<TestCaseExecution> myList;
// Getting the lists of test cases the follow the criterias.
try {
myList = MyTestExecutionService.findTCExecutionbyCriteria1(dateLimitFrom, test, "", application, country, environment, controlStatus, "WORKING");
out.println(myList.size());
} catch (CerberusException e) {
out.println("0");
}
} else {
// In case of errors, we displayu the help message.
out.println(helpMessage);
}
} catch (Exception e) {
LOG.warn(Infos.getInstance().getProjectNameAndVersion() + " - Exception catched.", e);
out.print("Error while Getting number of executions : ");
out.println(e.getMessage());
} finally {
out.close();
}
}
use of org.cerberus.crud.service.IApplicationService in project cerberus-source by cerberustesting.
the class NewRelease method processRequest.
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
String charset = request.getCharacterEncoding();
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
/**
* Adding Log entry.
*/
ILogEventService logEventService = appContext.getBean(LogEventService.class);
logEventService.createForPublicCalls("/NewRelease", "CALL", "NewRelease called : " + request.getRequestURL(), request);
IApplicationService MyApplicationService = appContext.getBean(ApplicationService.class);
IUserService MyUserService = appContext.getBean(UserService.class);
IProjectService MyProjectService = appContext.getBean(ProjectService.class);
IBuildRevisionParametersService buildRevisionParametersService = appContext.getBean(IBuildRevisionParametersService.class);
IFactoryBuildRevisionParameters factoryBuildRevisionParameters = appContext.getBean(IFactoryBuildRevisionParameters.class);
// Parsing all parameters.
String application = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("application"), "", charset);
String release = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("release"), "", charset);
String project = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("project"), "", charset);
String ticket = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("ticket"), "", charset);
String bug = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("bug"), "", charset);
String subject = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("subject"), "", charset);
String owner = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("owner"), "", charset);
String link = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("link"), "", charset);
// Those Parameters could be used later when Cerberus send the deploy request to Jenkins.
String jenkinsbuildid = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("jenkinsbuildid"), "", charset);
String mavengroupid = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("mavengroupid"), "", charset);
String mavenartifactid = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("mavenartifactid"), "", charset);
String mavenversion = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("mavenversion"), "", charset);
String repositoryurl = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("repositoryurl"), "", charset);
String helpMessage = "\nThis servlet is used to create or update a release entry in a 'NONE' build and 'NONE' revision.\n\nParameter list :\n" + "- application [mandatory] : the application that produced the release. This parameter must match the application list in Cerberus. [" + application + "]\n" + "- release : release number or svn number. This should be unique at the application level. 2 calls on the same application and release will update the other parameters on the same entry. [" + release + "]\n" + "- project : Project reference. [" + project + "]\n" + "- ticket : Ticket Reference. [" + ticket + "]\n" + "- bug : Bug reference. [" + bug + "]\n" + "- subject : A short description of the change. [" + subject + "]\n" + "- owner : User name of the developper/ person who did the commit. [" + owner + "]\n" + "- link : URL Link on detail documentation on the release. [" + link + "]\n\n" + "The following optional parameters could be used later when Cerberus send the deploy request to Jenkins.\n" + "- jenkinsbuildid : Jenkins Build ID. [" + jenkinsbuildid + "]\n" + "- mavengroupid : Maven Group ID. [" + mavengroupid + "]\n" + "- mavenartifactid : Maven Artifact ID. [" + mavenartifactid + "]\n" + "- repositoryurl : Repository URL. [" + repositoryurl + "]\n" + "- mavenversion : Maven Version. [" + mavenversion + "]\n";
DatabaseSpring database = appContext.getBean(DatabaseSpring.class);
Connection connection = database.connect();
try {
boolean error = false;
// Checking the parameter validity. If application has been entered, does it exist ?
if (!application.equalsIgnoreCase("") && !MyApplicationService.exist(application)) {
out.println("Error - Application does not exist : " + application);
error = true;
}
if (application.equalsIgnoreCase("")) {
out.println("Error - Parameter application is mandatory.");
error = true;
}
// Checking the parameter validity. If owner has been entered, does it exist ?
if (!owner.equalsIgnoreCase("")) {
if (MyUserService.isUserExist(owner)) {
// We get the exact name from Cerberus.
owner = MyUserService.findUserByKey(owner).getLogin();
} else {
out.println("Warning - User does not exist : " + owner);
}
}
// Checking the parameter validity. If project has been entered, does it exist ?
if (!project.equalsIgnoreCase("") && !MyProjectService.exist(project)) {
out.println("Warning - Project does not exist : " + project);
}
// Starting the database update only when no blocking error has been detected.
if (error == false) {
// In case the bugID is not defined, we try to guess it from the subject. should be between # and a space or CR.
if (StringUtil.isNullOrEmpty(bug)) {
String[] columns = subject.split("#");
if (columns.length >= 2) {
for (int i = 1; i < columns.length; i++) {
String[] columnsbis = columns[i].split(" ");
if (columnsbis.length >= 1) {
if (!columnsbis[0].contains(";")) {
// Bug number should not include ;
bug = columnsbis[0];
}
}
}
}
}
// Transaction and database update.
// Duplicate entry Verification. On the build/relivion not yet assigned (NONE/NONE),
// we verify that the application + release has not been submitted yet.
// if it exist, we update it in stead of inserting a new row.
// That correspond in the cases where the Jenkins pipe is executed several times
// on a single svn commit.
/**
* Verify if the entry already exists if already exists, update
* it else create it
*/
AnswerItem answer = buildRevisionParametersService.readByVarious2("NONE", "NONE", release, application);
BuildRevisionParameters buildRevisionParameters = (BuildRevisionParameters) answer.getItem();
if (answer.getResultMessage().getCode() == new MessageEvent(MessageEventEnum.DATA_OPERATION_OK).getCode() && buildRevisionParameters != null) {
out.println("Warning - Release entry already exist. Updating the existing entry : " + buildRevisionParameters.getId());
if (!project.isEmpty()) {
buildRevisionParameters.setProject(project);
}
if (!ticket.isEmpty()) {
buildRevisionParameters.setTicketIdFixed(ticket);
}
if (!bug.isEmpty()) {
buildRevisionParameters.setBugIdFixed(bug);
}
if (!subject.isEmpty()) {
buildRevisionParameters.setSubject(subject);
}
if (!owner.isEmpty()) {
buildRevisionParameters.setReleaseOwner(owner);
}
if (!link.isEmpty()) {
buildRevisionParameters.setLink(link);
}
if (!jenkinsbuildid.isEmpty()) {
buildRevisionParameters.setJenkinsBuildId(jenkinsbuildid);
}
if (!mavengroupid.isEmpty()) {
buildRevisionParameters.setMavenGroupId(mavengroupid);
}
if (!mavenartifactid.isEmpty()) {
buildRevisionParameters.setMavenArtifactId(mavenartifactid);
}
if (!mavenversion.isEmpty()) {
buildRevisionParameters.setMavenVersion(mavenversion);
}
if (!repositoryurl.isEmpty()) {
buildRevisionParameters.setRepositoryUrl(repositoryurl);
}
buildRevisionParametersService.update(buildRevisionParameters);
} else if (answer.getResultMessage().getCode() == new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND).getCode()) {
buildRevisionParametersService.create(factoryBuildRevisionParameters.create(0, "NONE", "NONE", release, application, project, ticket, bug, link, owner, subject, null, jenkinsbuildid, mavengroupid, mavenartifactid, mavenversion, repositoryurl));
out.println("Release Inserted : '" + release + "' on '" + application + "' for user '" + owner + "'");
} else {
out.println("A problem occured : '" + answer.getResultMessage().getDescription());
}
} else {
// In case of errors, we display the help message.
out.println(helpMessage);
}
} catch (Exception e) {
LOG.warn(Infos.getInstance().getProjectNameAndVersion() + " - Exception catched.", e);
out.print("Error while inserting the release : ");
out.println(e.toString());
} finally {
out.close();
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn(e.toString());
}
}
}
use of org.cerberus.crud.service.IApplicationService in project cerberus-source by cerberustesting.
the class Homepage method readApplicationList.
private AnswerItem readApplicationList(String system, ApplicationContext appContext) throws JSONException {
AnswerItem item = new AnswerItem();
JSONObject jsonResponse = new JSONObject();
IApplicationService applicationService = appContext.getBean(ApplicationService.class);
AnswerItem resp = applicationService.readTestCaseCountersBySystemByStatus(system);
JSONArray jsonArray = new JSONArray();
HashMap<String, HashMap<String, Integer>> totalMap = (HashMap<String, HashMap<String, Integer>>) resp.getItem();
if (resp.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && resp.getItem() != null) {
IInvariantService invariantService = appContext.getBean(InvariantService.class);
AnswerList<Invariant> answerList = invariantService.readByIdnameGp1("TCSTATUS", "Y");
List<Invariant> myInvariants = answerList.getDataList();
for (String application : totalMap.keySet()) {
JSONObject row = extractRow(application, totalMap, myInvariants);
jsonArray.put(row);
}
}
jsonResponse.put("aaData", jsonArray);
jsonResponse.put("iTotalRecords", totalMap.size());
jsonResponse.put("iTotalDisplayRecords", totalMap.size());
item.setItem(jsonResponse);
item.setResultMessage(resp.getResultMessage());
return item;
}
use of org.cerberus.crud.service.IApplicationService in project cerberus-source by cerberustesting.
the class UpdateApplication method processRequest.
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, CerberusException, JSONException {
JSONObject jsonResponse = new JSONObject();
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
Answer ans = new Answer();
MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
ans.setResultMessage(msg);
PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);
String charset = request.getCharacterEncoding();
ICountryEnvironmentParametersService ceaService = appContext.getBean(ICountryEnvironmentParametersService.class);
IFactoryCountryEnvironmentParameters cedFactory = appContext.getBean(IFactoryCountryEnvironmentParameters.class);
response.setContentType("application/json");
// Calling Servlet Transversal Util.
ServletUtil.servletStart(request);
/**
* Parsing and securing all required parameters.
*/
// Parameter that are already controled by GUI (no need to decode) --> We SECURE them
String system = policy.sanitize(request.getParameter("system"));
String type = policy.sanitize(request.getParameter("type"));
String deployType = policy.sanitize(request.getParameter("deploytype"));
// Parameter that needs to be secured --> We SECURE+DECODE them
String application = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("application"), null, charset);
String originalApplication = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("originalApplication"), null, charset);
String subSystem = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("subsystem"), "", charset);
String mavenGpID = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("mavengroupid"), "", charset);
String description = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("description"), "", charset);
// Parameter that we cannot secure as we need the html --> We DECODE them
String svnURL = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("svnurl"), "", charset);
String bugTrackerURL = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("bugtrackerurl"), "", charset);
String newBugURL = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("bugtrackernewurl"), "", charset);
Integer sort = 10;
boolean sort_error = false;
try {
if (request.getParameter("sort") != null && !request.getParameter("sort").equals("")) {
sort = Integer.valueOf(policy.sanitize(request.getParameter("sort")));
}
} catch (Exception ex) {
sort_error = true;
}
// Getting list of application from JSON Call
JSONArray objApplicationArray = new JSONArray(request.getParameter("environmentList"));
List<CountryEnvironmentParameters> ceaList = new ArrayList();
ceaList = getCountryEnvironmentApplicationFromParameter(request, appContext, system, application, objApplicationArray);
// Prepare the final answer.
MessageEvent msg1 = new MessageEvent(MessageEventEnum.GENERIC_OK);
Answer finalAnswer = new Answer(msg1);
/**
* Checking all constrains before calling the services.
*/
if (StringUtil.isNullOrEmpty(application)) {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
msg.setDescription(msg.getDescription().replace("%ITEM%", "Application").replace("%OPERATION%", "Update").replace("%REASON%", "Application ID (application) is missing."));
ans.setResultMessage(msg);
} else if (StringUtil.isNullOrEmpty(system)) {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
msg.setDescription(msg.getDescription().replace("%ITEM%", "Application").replace("%OPERATION%", "Update").replace("%REASON%", "System is missing!"));
ans.setResultMessage(msg);
} else if (sort_error) {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
msg.setDescription(msg.getDescription().replace("%ITEM%", "Application").replace("%OPERATION%", "Update").replace("%REASON%", "Could not manage to convert sort to an integer value."));
ans.setResultMessage(msg);
} else {
/**
* All data seems cleans so we can call the services.
*/
IApplicationService applicationService = appContext.getBean(IApplicationService.class);
AnswerItem resp = applicationService.readByKey(originalApplication);
if (!(resp.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && resp.getItem() != null)) {
/**
* Object could not be found. We stop here and report the error.
*/
finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) resp);
} else {
/**
* The service was able to perform the query and confirm the
* object exist, then we can update it.
*/
Application applicationData = (Application) resp.getItem();
applicationData.setApplication(application);
applicationData.setSystem(system);
applicationData.setSubsystem(subSystem);
applicationData.setType(type);
applicationData.setMavengroupid(mavenGpID);
applicationData.setDeploytype(deployType);
applicationData.setSvnurl(svnURL);
applicationData.setBugTrackerUrl(bugTrackerURL);
applicationData.setBugTrackerNewUrl(newBugURL);
applicationData.setDescription(description);
applicationData.setSort(sort);
applicationData.setUsrModif(request.getRemoteUser());
ans = applicationService.update(originalApplication, applicationData);
finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);
if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {
/**
* Update was successful. Adding Log entry.
*/
ILogEventService logEventService = appContext.getBean(LogEventService.class);
logEventService.createForPrivateCalls("/UpdateApplication", "UPDATE", "Updated Application : ['" + originalApplication + "']", request);
// Update the Database with the new list.
ans = ceaService.compareListAndUpdateInsertDeleteElements(system, application, ceaList);
finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);
}
}
}
/**
* Formating and returning the json result.
*/
jsonResponse.put("messageType", finalAnswer.getResultMessage().getMessage().getCodeString());
jsonResponse.put("message", finalAnswer.getResultMessage().getDescription());
response.getWriter().print(jsonResponse);
response.getWriter().flush();
}
use of org.cerberus.crud.service.IApplicationService in project cerberus-source by cerberustesting.
the class CalculatePropertyForTestCase method doGet.
@Override
protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.BLOCKS);
String type = policy.sanitize(httpServletRequest.getParameter("type"));
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
String result = null;
String description = null;
String system = "";
String property = httpServletRequest.getParameter("property");
String testName = policy.sanitize(httpServletRequest.getParameter("test"));
String testCaseName = policy.sanitize(httpServletRequest.getParameter("testCase"));
String country = policy.sanitize(httpServletRequest.getParameter("country"));
String environment = policy.sanitize(httpServletRequest.getParameter("environment"));
try {
if (type.equals("executeSoapFromLib")) {
IAppServiceService appServiceService = appContext.getBean(AppServiceService.class);
ISoapService soapService = appContext.getBean(ISoapService.class);
IXmlUnitService xmlUnitService = appContext.getBean(IXmlUnitService.class);
AppService appService = appServiceService.findAppServiceByKey(property);
if (appService != null) {
ExecutionUUID executionUUIDObject = appContext.getBean(ExecutionUUID.class);
UUID executionUUID = UUID.randomUUID();
executionUUIDObject.setExecutionUUID(executionUUID.toString(), null);
soapService.callSOAP(appService.getServiceRequest(), appService.getServicePath(), appService.getOperation(), appService.getAttachementURL(), null, null, 60000, system);
result = xmlUnitService.getFromXml(executionUUID.toString(), appService.getAttachementURL());
description = appService.getDescription();
executionUUIDObject.removeExecutionUUID(executionUUID.toString());
LOG.debug("Clean ExecutionUUID");
}
} else {
try {
ITestCaseService testCaseService = appContext.getBean(TestCaseService.class);
IApplicationService applicationService = appContext.getBean(ApplicationService.class);
TestCase testCase = testCaseService.findTestCaseByKey(testName, testCaseName);
if (testCase != null) {
system = applicationService.convert(applicationService.readByKey(testCase.getApplication())).getSystem();
} else {
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.NO_DATA_FOUND));
}
} catch (CerberusException ex) {
LOG.warn(ex);
}
if (system != null) {
String database = policy.sanitize(httpServletRequest.getParameter("database"));
ICountryEnvironmentDatabaseService countryEnvironmentDatabaseService = appContext.getBean(CountryEnvironmentDatabaseService.class);
CountryEnvironmentDatabase countryEnvironmentDatabase;
countryEnvironmentDatabase = countryEnvironmentDatabaseService.convert(countryEnvironmentDatabaseService.readByKey(system, country, environment, database));
String connectionName = countryEnvironmentDatabase.getConnectionPoolName();
if (type.equals("executeSqlFromLib")) {
ISqlLibraryService sqlLibraryService = appContext.getBean(SqlLibraryService.class);
SqlLibrary sl = sqlLibraryService.findSqlLibraryByKey(policy.sanitize(property));
property = sl.getScript();
if (!(StringUtil.isNullOrEmpty(connectionName)) && !(StringUtil.isNullOrEmpty(policy.sanitize(property)))) {
ISQLService sqlService = appContext.getBean(ISQLService.class);
IParameterService parameterService = appContext.getBean(IParameterService.class);
Integer sqlTimeout = parameterService.getParameterIntegerByKey("cerberus_propertyexternalsql_timeout", system, 60);
result = sqlService.queryDatabase(connectionName, policy.sanitize(property), 1, sqlTimeout).get(0);
description = sl.getDescription();
}
}
}
}
} catch (CerberusException ex) {
LOG.warn(ex);
result = ex.getMessageError().getDescription();
description = ex.getMessageError().getDescription();
} catch (CerberusEventException ex) {
LOG.warn(ex);
result = ex.getMessageError().getDescription();
description = ex.getMessageError().getDescription();
}
if (result != null) {
try {
JSONObject jsonObject = new JSONObject();
jsonObject.put("resultList", result);
jsonObject.put("description", description);
httpServletResponse.setContentType("application/json");
httpServletResponse.getWriter().print(jsonObject.toString());
} catch (JSONException exception) {
LOG.warn(exception.toString());
}
}
}
Aggregations