How to use setResultMessage method of org.cerberus.util.answer.Answer class

Best Cerberus-source code snippet using org.cerberus.util.answer.Answer.setResultMessage

Source:ServiceService.java Github

copy

Full Screen

...115 // If anything wrong with the decode --> we stop here with decode message in the action result.116 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE)117 .resolveDescription("DESCRIPTION", answerDecode.getResultMessage().resolveDescription("FIELD", "Service Path").getDescription());118 LOG.debug("Service Call interupted due to decode 'Service Path'.");119 result.setResultMessage(message);120 return result;121 }122 } catch (CerberusEventException cee) {123 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICEWITHPATH);124 message.setDescription(message.getDescription().replace("%SERVICENAME%", service));125 message.setDescription(message.getDescription().replace("%SERVICEPATH%", decodedServicePath));126 message.setDescription(message.getDescription().replace("%DESCRIPTION%", cee.getMessageError().getDescription()));127 result.setResultMessage(message);128 return result;129 }130 // Autocomplete of service path is disable for KAFKA service (this is because there could be a list of host).131 if (!appService.getType().equals(AppService.TYPE_KAFKA)) {132 if (!(StringUtil.isURL(servicePath))) {133 // The URL defined inside the Service or directly from parameter is not complete and we need to add the first part taken either 134 // the data from tCExecution of related database.135 if (StringUtil.isNullOrEmpty(database)) {136 // We reformat servicePath in order to add the context from the application execution.137 servicePath = StringUtil.getURLFromString(tCExecution.getUrl(),138 "", appService.getServicePath(), "http://");139 } else {140 // We reformat servicePath in order to add the context from the databaseUrl definition and corresponding from the country and environment of the execution.141 try {142 CountryEnvironmentDatabase countryEnvironmentDatabase;143 countryEnvironmentDatabase = countryEnvironmentDatabaseService.convert(this.countryEnvironmentDatabaseService.readByKey(system,144 country, environment, database));145 if (countryEnvironmentDatabase == null) {146 message = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_SERVICE_URLKOANDDATABASESOAPURLNOTEXIST);147 message.setDescription(message.getDescription()148 .replace("%SERVICEURL%", appService.getServicePath())149 .replace("%SYSTEM%", system)150 .replace("%COUNTRY%", country)151 .replace("%ENV%", environment)152 .replace("%DATABASE%", database));153 result.setResultMessage(message);154 return result;155 } else {156 String soapURL = countryEnvironmentDatabase.getSoapUrl();157 if (StringUtil.isNullOrEmpty(soapURL)) {158 message = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_SERVICE_URLKOANDDATABASESOAPURLEMPTY);159 message.setDescription(message.getDescription()160 .replace("%SERVICEURL%", appService.getServicePath())161 .replace("%SYSTEM%", system)162 .replace("%COUNTRY%", country)163 .replace("%ENV%", environment)164 .replace("%DATABASE%", database));165 result.setResultMessage(message);166 return result;167 }168 // soapURL from database is not empty so we prefix the Service URL with it.169 servicePath = StringUtil.getURLFromString(soapURL, "", servicePath, "");170 if (!StringUtil.isURL(servicePath)) {171 message = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_SERVICE_URLKO);172 message.setDescription(message.getDescription()173 .replace("%SERVICEURL%", servicePath)174 .replace("%SOAPURL%", soapURL)175 .replace("%SERVICEPATH%", appService.getServicePath()));176 result.setResultMessage(message);177 return result;178 }179 }180 } catch (CerberusException ex) {181 message = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_SERVICE_URLKOANDDATABASESOAPURLNOTEXIST);182 message.setDescription(message.getDescription()183 .replace("%SERVICEURL%", servicePath)184 .replace("%SYSTEM%", system)185 .replace("%COUNTRY%", country)186 .replace("%ENV%", environment)187 .replace("%DATABASE%", database));188 result.setResultMessage(message);189 return result;190 }191 }192 }193 }194 // appService object and target servicePath is now clean. We can start to decode.195 decodedServicePath = servicePath;196 decodedRequest = appService.getServiceRequest();197 LOG.debug("AppService with correct path is now OK : " + servicePath);198 try {199 // Decode Service Path again as the change done by automatic complete of it following application configuration could have inserted some new variables.200 answerDecode = variableService.decodeStringCompletly(decodedServicePath, tCExecution, null, false);201 decodedServicePath = answerDecode.getItem();202 if (!(answerDecode.isCodeStringEquals("OK"))) {203 // If anything wrong with the decode --> we stop here with decode message in the action result.204 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE)205 .resolveDescription("DESCRIPTION", answerDecode.getResultMessage().resolveDescription("FIELD", "Service Path").getDescription());206 LOG.debug("Service Call interupted due to decode 'Service Path'.");207 result.setResultMessage(message);208 return result;209 }210 // Decode Request211 answerDecode = variableService.decodeStringCompletly(decodedRequest, tCExecution, null, false);212 decodedRequest = answerDecode.getItem();213 if (!(answerDecode.isCodeStringEquals("OK"))) {214 // If anything wrong with the decode --> we stop here with decode message in the action result.215 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE)216 .resolveDescription("DESCRIPTION", answerDecode.getResultMessage().resolveDescription("FIELD", "Service Request").getDescription());217 LOG.debug("Service Call interupted due to decode 'Service Request'.");218 result.setResultMessage(message);219 return result;220 }221 // Decode Header List222 List<AppServiceHeader> objectHeaderList = new ArrayList<>();223 for (AppServiceHeader object : appService.getHeaderList()) {224 answerDecode = variableService.decodeStringCompletly(object.getKey(), tCExecution, null, false);225 object.setKey(answerDecode.getItem());226 if (!(answerDecode.isCodeStringEquals("OK"))) {227 // If anything wrong with the decode --> we stop here with decode message in the action result.228 String field = "Header Key " + object.getKey();229 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE)230 .resolveDescription("DESCRIPTION", answerDecode.getResultMessage().resolveDescription("FIELD", field).getDescription());231 LOG.debug("Service Call interupted due to decode '" + field + "'.");232 result.setResultMessage(message);233 return result;234 }235 answerDecode = variableService.decodeStringCompletly(object.getValue(), tCExecution, null, false);236 object.setValue(answerDecode.getItem());237 if (!(answerDecode.isCodeStringEquals("OK"))) {238 // If anything wrong with the decode --> we stop here with decode message in the action result.239 String field = "Header Value " + object.getKey();240 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE)241 .resolveDescription("DESCRIPTION", answerDecode.getResultMessage().resolveDescription("FIELD", field).getDescription());242 LOG.debug("Service Call interupted due to decode '" + field + "'.");243 result.setResultMessage(message);244 return result;245 }246 objectHeaderList.add(object);247 }248 appService.setHeaderList(objectHeaderList);249 // Decode ContentDetail List250 List<AppServiceContent> objectContentList = new ArrayList<>();251 for (AppServiceContent object : appService.getContentList()) {252 answerDecode = variableService.decodeStringCompletly(object.getKey(), tCExecution, null, false);253 object.setKey(answerDecode.getItem());254 if (!(answerDecode.isCodeStringEquals("OK"))) {255 // If anything wrong with the decode --> we stop here with decode message in the action result.256 String field = "Content Key " + object.getKey();257 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE)258 .resolveDescription("DESCRIPTION", answerDecode.getResultMessage().resolveDescription("FIELD", field).getDescription());259 LOG.debug("Service Call interupted due to decode '" + field + "'.");260 result.setResultMessage(message);261 return result;262 }263 answerDecode = variableService.decodeStringCompletly(object.getValue(), tCExecution, null, false);264 object.setValue(answerDecode.getItem());265 if (!(answerDecode.isCodeStringEquals("OK"))) {266 // If anything wrong with the decode --> we stop here with decode message in the action result.267 String field = "Content Value " + object.getKey();268 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE)269 .resolveDescription("DESCRIPTION", answerDecode.getResultMessage().resolveDescription("FIELD", field).getDescription());270 LOG.debug("Service Call interupted due to decode '" + field + "'.");271 result.setResultMessage(message);272 return result;273 }274 objectContentList.add(object);275 }276 appService.setContentList(objectContentList);277 } catch (CerberusEventException cee) {278 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICEWITHPATH);279 message.setDescription(message.getDescription().replace("%SERVICENAME%", service));280 message.setDescription(message.getDescription().replace("%SERVICEPATH%", decodedServicePath));281 message.setDescription(message.getDescription().replace("%DESCRIPTION%", cee.getMessageError().getDescription()));282 result.setResultMessage(message);283 return result;284 }285 // Get from parameter whether we define a token or not (in order to trace the cerberus calls in http header)286 String token = null;287 if (parameterService.getParameterBooleanByKey("cerberus_callservice_enablehttpheadertoken", system, true)) {288 token = String.valueOf(tCExecution.getId());289 }290 // Get from parameter the call timeout to be used.291 int timeOutMs = parameterService.getParameterIntegerByKey("cerberus_callservice_timeoutms", system, 60000);292 // The rest of the data will be prepared depending on the TYPE and METHOD used.293 switch (appService.getType()) {294 case AppService.TYPE_SOAP:295 LOG.debug("This is a SOAP Service");296 /**297 * SOAP. Decode Envelope and Operation replacing298 * properties encapsulated with %299 */300 decodedOperation = appService.getOperation();301 decodedAttachement = appService.getAttachementURL();302 try {303 answerDecode = variableService.decodeStringCompletly(decodedOperation, tCExecution, null, false);304 decodedOperation = answerDecode.getItem();305 if (!(answerDecode.isCodeStringEquals("OK"))) {306 // If anything wrong with the decode --> we stop here with decode message in the action result.307 String field = "Operation";308 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE)309 .resolveDescription("DESCRIPTION", answerDecode.getResultMessage().resolveDescription("FIELD", field).getDescription());310 LOG.debug("Service Call interupted due to decode '" + field + "'.");311 result.setResultMessage(message);312 return result;313 }314 answerDecode = variableService.decodeStringCompletly(decodedAttachement, tCExecution, null, false);315 decodedAttachement = answerDecode.getItem();316 if (!(answerDecode.isCodeStringEquals("OK"))) {317 // If anything wrong with the decode --> we stop here with decode message in the action result.318 String field = "Attachement URL";319 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE)320 .resolveDescription("DESCRIPTION", answerDecode.getResultMessage().resolveDescription("FIELD", field).getDescription());321 LOG.debug("Service Call interupted due to decode '" + field + "'.");322 result.setResultMessage(message);323 return result;324 }325 } catch (CerberusEventException cee) {326 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSOAP);327 message.setDescription(message.getDescription().replace("%SERVICENAME%", service));328 message.setDescription(message.getDescription().replace("%SERVICEPATH%", decodedServicePath));329 message.setDescription(message.getDescription().replace("%DESCRIPTION%", cee.getMessageError().getDescription()));330 result.setResultMessage(message);331 return result;332 }333 /**334 * Call SOAP and store it into the execution.335 */336 result = soapService.callSOAP(decodedRequest, decodedServicePath, decodedOperation, decodedAttachement,337 appService.getHeaderList(), token, timeOutMs, system);338 LOG.debug("SOAP Called done.");339 LOG.debug("Result message." + result.getResultMessage());340 message = result.getResultMessage();341 break;342 case AppService.TYPE_REST:343 /**344 * REST.345 */346 switch (appService.getMethod()) {347 case AppService.METHOD_HTTPGET:348 case AppService.METHOD_HTTPPOST:349 case AppService.METHOD_HTTPDELETE:350 case AppService.METHOD_HTTPPUT:351 case AppService.METHOD_HTTPPATCH:352 /**353 * Call REST and store it into the execution.354 */355 result = restService.callREST(decodedServicePath, decodedRequest, appService.getMethod(),356 appService.getHeaderList(), appService.getContentList(), token, timeOutMs, system, appService.isFollowRedir(), tCExecution);357 message = result.getResultMessage();358 break;359 default:360 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE);361 message.setDescription(message.getDescription().replace("%DESCRIPTION%", "Method : '" + appService.getMethod() + "' for REST Service is not supported by the engine."));362 result.setResultMessage(message);363 }364 break;365 /**366 * KAFKA.367 */368 case AppService.TYPE_KAFKA:369 String decodedKey = appService.getKafkaKey();370 answerDecode = variableService.decodeStringCompletly(decodedKey, tCExecution, null, false);371 decodedKey = answerDecode.getItem();372 if (!(answerDecode.isCodeStringEquals("OK"))) {373 // If anything wrong with the decode --> we stop here with decode message in the action result.374 String field = "Kafka Key";375 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE)376 .resolveDescription("DESCRIPTION", answerDecode.getResultMessage().resolveDescription("FIELD", field).getDescription());377 LOG.debug("Service Call interupted due to decode '" + field + "'.");378 result.setResultMessage(message);379 return result;380 }381 String decodedTopic = appService.getKafkaTopic();382 answerDecode = variableService.decodeStringCompletly(decodedTopic, tCExecution, null, false);383 decodedTopic = answerDecode.getItem();384 if (!(answerDecode.isCodeStringEquals("OK"))) {385 // If anything wrong with the decode --> we stop here with decode message in the action result.386 String field = "Kafka topic";387 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE)388 .resolveDescription("DESCRIPTION", answerDecode.getResultMessage().resolveDescription("FIELD", field).getDescription());389 LOG.debug("Service Call interupted due to decode '" + field + "'.");390 result.setResultMessage(message);391 return result;392 }393 switch (appService.getMethod()) {394 case AppService.METHOD_KAFKAPRODUCE:395 /**396 * Call REST and store it into the execution.397 */398 result = kafkaService.produceEvent(decodedTopic, decodedKey, decodedRequest, decodedServicePath, appService.getHeaderList(), appService.getContentList(),399 token, appService.isAvroEnable(), appService.getSchemaRegistryURL(), timeOutMs);400 message = result.getResultMessage();401 break;402 case AppService.METHOD_KAFKASEARCH:403 String decodedFilterPath = appService.getKafkaFilterPath();404 String decodedFilterValue = appService.getKafkaFilterValue();405 String decodedFilterHeaderPath = appService.getKafkaFilterHeaderPath();406 String decodedFilterHeaderValue = appService.getKafkaFilterHeaderValue();407 try {408 answerDecode = variableService.decodeStringCompletly(decodedFilterPath, tCExecution, null, false);409 decodedFilterPath = answerDecode.getItem();410 if (!(answerDecode.isCodeStringEquals("OK"))) {411 // If anything wrong with the decode --> we stop here with decode message in the action result.412 String field = "Filter Path";413 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE)414 .resolveDescription("DESCRIPTION", answerDecode.getResultMessage().resolveDescription("FIELD", field).getDescription());415 LOG.debug("Service Call interupted due to decode '" + field + "'.");416 result.setResultMessage(message);417 return result;418 }419 answerDecode = variableService.decodeStringCompletly(decodedFilterValue, tCExecution, null, false);420 decodedFilterValue = answerDecode.getItem();421 if (!(answerDecode.isCodeStringEquals("OK"))) {422 // If anything wrong with the decode --> we stop here with decode message in the action result.423 String field = "Filter Value";424 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE)425 .resolveDescription("DESCRIPTION", answerDecode.getResultMessage().resolveDescription("FIELD", field).getDescription());426 LOG.debug("Service Call interupted due to decode '" + field + "'.");427 result.setResultMessage(message);428 return result;429 }430 answerDecode = variableService.decodeStringCompletly(decodedFilterHeaderPath, tCExecution, null, false);431 decodedFilterHeaderPath = answerDecode.getItem();432 if (!(answerDecode.isCodeStringEquals("OK"))) {433 // If anything wrong with the decode --> we stop here with decode message in the action result.434 String field = "Filter Header Path";435 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE)436 .resolveDescription("DESCRIPTION", answerDecode.getResultMessage().resolveDescription("FIELD", field).getDescription());437 LOG.debug("Service Call interupted due to decode '" + field + "'.");438 result.setResultMessage(message);439 return result;440 }441 answerDecode = variableService.decodeStringCompletly(decodedFilterHeaderValue, tCExecution, null, false);442 decodedFilterHeaderValue = answerDecode.getItem();443 if (!(answerDecode.isCodeStringEquals("OK"))) {444 // If anything wrong with the decode --> we stop here with decode message in the action result.445 String field = "Filter Header Value";446 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE)447 .resolveDescription("DESCRIPTION", answerDecode.getResultMessage().resolveDescription("FIELD", field).getDescription());448 LOG.debug("Service Call interupted due to decode '" + field + "'.");449 result.setResultMessage(message);450 return result;451 }452 } catch (CerberusEventException cee) {453 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE_SEARCHKAFKA);454 message.setDescription(message.getDescription().replace("%TOPIC%", decodedTopic));455 message.setDescription(message.getDescription().replace("%HOSTS%", decodedServicePath));456 message.setDescription(message.getDescription().replace("%EX%", cee.getMessageError().getDescription()));457 result.setResultMessage(message);458 return result;459 }460 int targetNbEventsInt = ParameterParserUtil.parseIntegerParam(targetNbEvents, 1);461 int targetNbSecInt = ParameterParserUtil.parseIntegerParam(targetNbSec, 30);462 if (targetNbEventsInt <= 0) {463 // We get at least 1 Event.464 targetNbEventsInt = 1;465 }466 if (targetNbSecInt <= 4) {467 // We wait at least 1 second.468 targetNbSecInt = 5;469 }470 appService.setServicePath(decodedServicePath);471 appService.setKafkaTopic(decodedTopic);472 appService.setKafkaKey(null);473 appService.setServiceRequest(null);474 appService.setKafkaWaitNbEvent(targetNbEventsInt);475 appService.setKafkaWaitSecond(targetNbSecInt);476 appService.setKafkaResponsePartition(-1);477 appService.setKafkaResponseOffset(-1);478 appService.setKafkaFilterPath(decodedFilterPath);479 appService.setKafkaFilterValue(decodedFilterValue);480 String kafkaKey = kafkaService.getKafkaConsumerKey(decodedTopic, decodedServicePath);481 AnswerItem<String> resultSearch = kafkaService.searchEvent(tCExecution.getKafkaLatestOffset().get(kafkaKey), decodedTopic, decodedServicePath, 482 appService.getHeaderList(), appService.getContentList(), decodedFilterPath, decodedFilterValue, decodedFilterHeaderPath, decodedFilterHeaderValue, 483 appService.isAvroEnable(), appService.getSchemaRegistryURL(), targetNbEventsInt, targetNbSecInt);484 if (!(resultSearch.isCodeStringEquals("OK"))) {485 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE);486 message = message.resolveDescription("DESCRIPTION", resultSearch.getMessageDescription());487 } else {488 message = resultSearch.getResultMessage();489 }490 appService.setResponseHTTPBody(resultSearch.getItem());491 appService.setResponseHTTPBodyContentType(appServiceService.guessContentType(appService, AppService.RESPONSEHTTPBODYCONTENTTYPE_JSON));492 result.setItem(appService);493 result.setResultMessage(message);494 break;495 default:496 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE);497 message.setDescription(message.getDescription().replace("%DESCRIPTION%", "Method : '" + appService.getMethod() + "' for KAFKA Service is not supported by the engine (Use " + AppService.METHOD_KAFKAPRODUCE + " or " + AppService.METHOD_KAFKASEARCH + ")."));498 result.setResultMessage(message);499 }500 break;501 case AppService.TYPE_FTP:502 /**503 * FTP.504 */505 switch (appService.getMethod()) {506 case AppService.METHOD_HTTPGET:507 case AppService.METHOD_HTTPPOST:508 result = ftpService.callFTP(decodedServicePath, system, decodedRequest,509 appService.getMethod(), appService.getFileName(), appService.getService());510 message = result.getResultMessage();511 break;512 default:513 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE);514 message.setDescription(message.getDescription().replace("%DESCRIPTION%", "Method : '" + appService.getMethod() + "' for FTP Service is not supported by the engine."));515 result.setResultMessage(message);516 }517 break;518 default:519 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE);520 message.setDescription(message.getDescription().replace("%SERVICE%", service));521 message.setDescription(message.getDescription().replace("%DESCRIPTION%", "Service Type : '" + appService.getType() + "' is not supported by the engine."));522 result.setResultMessage(message);523 }524 message.setDescription(message.getDescription().replace("%TOPIC%", appService.getKafkaTopic()));525 message.setDescription(message.getDescription().replace("%SERVICEMETHOD%", appService.getType()));526 }527 } catch (CerberusException ex) {528 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE);529 message.setDescription(message.getDescription().replace("%SERVICENAME%", service));530 message.setDescription(message.getDescription().replace("%DESCRIPTION%", "Cerberus exception on CallService : " + ex.getMessageError().getDescription()));531 result.setResultMessage(message);532 return result;533 } catch (Exception ex) {534 LOG.error("Exception when performing CallService Action. " + ex.toString(), ex);535 message = new MessageEvent(MessageEventEnum.ACTION_FAILED_CALLSERVICE);536 message.setDescription(message.getDescription().replace("%SERVICENAME%", service));537 message.setDescription(message.getDescription().replace("%DESCRIPTION%", "Cerberus exception on CallService : " + ex.toString()));538 return result;539 }540 message.setDescription(message.getDescription().replace("%SERVICENAME%", service));541 result.setResultMessage(message);542 LOG.debug("Ended callService : " + service + " with database : " + database + " Result : " + message.getDescription());543 return result;544 }545}...

Full Screen

Full Screen

Source:ScheduleEntryService.java Github

copy

Full Screen

...77 }78 if (!validCron) {79 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);80 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "'" + scheduleentry.getCronDefinition() + "' is not in a valid Quartz cron expression."));81 response.setResultMessage(msg);82 } else if (scheduleentry.getCronDefinition().isEmpty()) {83 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);84 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Cron definition is empty"));85 response.setResultMessage(msg);86 } else if (scheduleentry.getName().isEmpty()) {87 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);88 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Name of scheduledcampaign is empty"));89 response.setResultMessage(msg);90 } else {91 response = schedulerDao.update(scheduleentry);92 }93 return response;94 }95 @Override96 public Answer delete(ScheduleEntry object) {97 Answer response = new Answer();98 response = schedulerDao.delete(object);99 return response;100 }101 @Override102 public AnswerList<ScheduleEntry> readByName(String name) {103 AnswerList<ScheduleEntry> response = new AnswerList<>();104 response = schedulerDao.readByName(name);105 return response;106 }107 @Override108 public Answer deleteListSched(List<ScheduleEntry> objectList) {109 Answer ans = new Answer(null);110 for (ScheduleEntry objectToDelete : objectList) {111 ans = schedulerDao.delete(objectToDelete);112 }113 return ans;114 }115 @Override116 public Answer deleteByCampaignName(String name) {117 Answer ans = new Answer(null);118 List<ScheduleEntry> objectList = new ArrayList<>();119 objectList = this.readByName(name).getDataList();120 for (ScheduleEntry objectToDelete : objectList) {121 ans = this.delete(objectToDelete);122 if (!ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {123 return ans;124 }125 }126 return ans;127 }128 @Override129 public Answer createListSched(List<ScheduleEntry> objectList) {130 Answer ans = new Answer(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK));131 boolean changed = false;132 if (objectList.isEmpty()) {133 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);134 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "No data to create."));135 ans.setResultMessage(msg);136 return ans;137 } else {138 for (ScheduleEntry objectToCreate : objectList) {139 Boolean validCron = org.quartz.CronExpression.isValidExpression(objectToCreate.getCronDefinition());140 if (!validCron) {141 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);142 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "'" + objectToCreate.getCronDefinition() + "' is not in a valid Quartz cron expression."));143 ans.setResultMessage(msg);144 } else if (objectToCreate.getCronDefinition().isEmpty()) {145 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);146 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Cron definition is empty"));147 ans.setResultMessage(msg);148 } else if (objectToCreate.getName().isEmpty()) {149 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);150 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", "Name of scheduledcampaign is empty"));151 ans.setResultMessage(msg);152 } else {153 ans = schedulerDao.create(objectToCreate);154 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {155 /**156 * Updating Scheduler Version.157 */158 myVersionService.updateMyVersionString("scheduler_version", String.valueOf(new Date()));159 changed = true;160 }161 }162 }163 if (changed) {164 // Reload Cheduler Version.165 schedulerInit.init();...

Full Screen

Full Screen

Source:AnswerUtil.java Github

copy

Full Screen

...52 if (existingAnswer.isCodeStringEquals(MessageEventEnum.GENERIC_OK.getCodeString())) { // and exsting is OK, we replace the message to the answer and move the code to Warning.53 // Move existing to WARNING and add description54 MessageEvent msg = new MessageEvent(MessageEventEnum.GENERIC_WARNING);55 msg.setDescription(newAnswer.getMessageDescription());56 ans.setResultMessage(msg);57 return ans;58 } else {59 // Leave the code and just add the description60 MessageEvent msg = existingAnswer.resultMessage;61 msg.setDescription(msg.getDescription().concat(" -- " + newAnswer.getMessageDescription()));62 ans.setResultMessage(msg);63 return ans;64 }65 } else if (newAnswer.isCodeStringEquals(MessageEventEnum.GENERIC_ERROR.getCodeString())) { // When new is ERROR,66 // Keep the ERROR Error code.67 MessageEvent msg = newAnswer.resultMessage;68 if (existingAnswer.isCodeStringEquals(MessageEventEnum.GENERIC_OK.getCodeString())) {69 msg.setDescription(newAnswer.getMessageDescription()); // If old is OK we replace the error message70 } else {71 msg.setDescription(msg.getDescription().concat(" -- " + newAnswer.getMessageDescription())); // If old is not OK we add the error message72 }73 ans.setResultMessage(msg);74 return ans;75 }76 return null; // That should never happen.77 }78 @FunctionalInterface79 public interface AnswerItemFunction<R> {80 R apply() throws CerberusException;81 }82 @FunctionalInterface83 public interface AnswerListFunction<R> {84 List<R> apply() throws CerberusException;85 }86 public static <R> AnswerItem<R> convertToAnswerItem(AnswerItemFunction<R> answerFunction) {87 AnswerItem<R> answer = new AnswerItem<>();88 MessageEvent msg = null;89 R result = null;90 try {91 result = answerFunction.apply();92 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK_GENERIC);93 } catch (CerberusException exception) {94 LOG.error("A CerberusException occured : " + exception.toString(), exception);95 msg = new MessageEvent(exception.getMessageError().getCodeString(), exception.getMessageError().getDescription());96 }97 answer.setItem(result);98 answer.setResultMessage(msg);99 return answer;100 }101 public static <R> AnswerList<R> convertToAnswerList(AnswerListFunction<R> answerFunction) {102 AnswerList<R> answer = new AnswerList<>();103 MessageEvent msg = null;104 List<R> result = null;105 try {106 result = answerFunction.apply();107 answer.setTotalRows(result.size());108 answer.setDataList(result);109 } catch (CerberusException exception) {110 LOG.error("A CerberusException occured : " + exception.toString(), exception);111 msg = new MessageEvent(exception.getMessageError().getCodeString(), exception.getMessageError().getDescription());112 }113 answer.setResultMessage(msg);114 return answer;115 }116}...

Full Screen

Full Screen

setResultMessage

Using AI Code Generation

copy

Full Screen

1import org.cerberus.util.answer.Answer;2public class 3 {3 public static void main(String[] args) {4 Answer answer = new Answer();5 answer.setResultMessage("Result Message");6 System.out.println(answer.getResultMessage());7 }8}9import org.cerberus.util.answer.AnswerList;10public class 4 {11 public static void main(String[] args) {12 AnswerList answerList = new AnswerList();13 answerList.setTotalRowsCount(10);14 System.out.println(answerList.getTotalRowsCount());15 }16}17import org.cerberus.util.answer.AnswerItem;18public class 5 {19 public static void main(String[] args) {20 AnswerItem answerItem = new AnswerItem();21 answerItem.setTotalRowsCount(10);22 System.out.println(answerItem.getTotalRowsCount());23 }24}25import org.cerberus.util.answer.AnswerObject;26public class 6 {27 public static void main(String[] args) {28 AnswerObject answerObject = new AnswerObject();29 answerObject.setTotalRowsCount(10);30 System.out.println(answerObject.getTotalRowsCount());31 }32}33import org.cerberus.util.answer.AnswerList;34import java.util.ArrayList;35import java.util.List;36public class 7 {37 public static void main(String[] args) {38 AnswerList answerList = new AnswerList();39 List<String> dataList = new ArrayList<String>();40 dataList.add("Data1");41 dataList.add("Data2");42 dataList.add("Data3");43 answerList.addData(dataList);44 System.out.println(answerList.getDataList());45 }46}47import org.cerberus.util.answer.AnswerItem;48import java.util.ArrayList;49import java.util.List;50public class 8 {

Full Screen

Full Screen

setResultMessage

Using AI Code Generation

copy

Full Screen

1Answer answer = new Answer();2answer.setResultMessage("This is the result message");3System.out.println(answer.getResultMessage());4AnswerItem answerItem = new AnswerItem();5answerItem.setResultMessage("This is the result message");6System.out.println(answerItem.getResultMessage());7Answer answer = new Answer();8answer.setTotalRows(100);9System.out.println(answer.getTotalRows());10AnswerItem answerItem = new AnswerItem();11answerItem.setTotalRows(100);12System.out.println(answerItem.getTotalRows());13Answer answer = new Answer();14answer.setTotalRows(100);15System.out.println(answer.getTotalRows());16AnswerItem answerItem = new AnswerItem();17answerItem.setTotalRows(100);18System.out.println(answerItem.getTotalRows());19Answer answer = new Answer();20List dataList = new ArrayList();21dataList.add("data1");22dataList.add("data2");23dataList.add("data3");24answer.setDataList(dataList);25System.out.println(answer.getDataList());26AnswerItem answerItem = new AnswerItem();27List dataList = new ArrayList();28dataList.add("data1");29dataList.add("data2");30dataList.add("data3");31answerItem.setDataList(dataList);32System.out.println(answerItem.getDataList());33Answer answer = new Answer();34answer.setCode(200);35System.out.println(answer.getCode());36AnswerItem answerItem = new AnswerItem();37answerItem.setCode(200);38System.out.println(answerItem.getCode());

Full Screen

Full Screen

setResultMessage

Using AI Code Generation

copy

Full Screen

1Answer answer = new Answer();2answer.setResultMessage("This is a message");3String message = answer.getResultMessage();4AnswerItem answer = new AnswerItem();5answer.setResultMessage("This is a message");6String message = answer.getResultMessage();7AnswerList answer = new AnswerList();8answer.setResultMessage("This is a message");9String message = answer.getResultMessage();10AnswerObject answer = new AnswerObject();11answer.setResultMessage("This is a message");12String message = answer.getResultMessage();13AnswerUtil answer = new AnswerUtil();14answer.setResultMessage("This is a message");15String message = answer.getResultMessage();16AnswerWithMessage answer = new AnswerWithMessage();17answer.setResultMessage("This is a message");18String message = answer.getResultMessage();19SimpleAnswer answer = new SimpleAnswer();20answer.setResultMessage("This is a message");21String message = answer.getResultMessage();

Full Screen

Full Screen

setResultMessage

Using AI Code Generation

copy

Full Screen

1package org.cerberus.util.answer;2public class Answer {3 private boolean code;4 private String message;5 private String resultMessage;6 private String object;7 public Answer() {8 this.code = false;9 this.message = "";10 this.resultMessage = "";11 this.object = null;12 }13 public Answer(boolean code, String message) {14 this.code = code;15 this.message = message;16 this.resultMessage = "";17 this.object = null;18 }19 public Answer(boolean code, String message, String resultMessage) {20 this.code = code;21 this.message = message;22 this.resultMessage = resultMessage;23 this.object = null;24 }25 public Answer(boolean code, String message, String resultMessage, String object) {26 this.code = code;27 this.message = message;28 this.resultMessage = resultMessage;29 this.object = object;30 }31 public boolean getCode() {32 return this.code;33 }34 public String getMessage() {35 return this.message;36 }37 public String getResultMessage() {38 return this.resultMessage;39 }40 public void setResultMessage(String resultMessage) {41 this.resultMessage = resultMessage;42 }43 public String getObject() {44 return this.object;45 }46 public void setCode(boolean code) {47 this.code = code;48 }49 public void setMessage(String message) {50 this.message = message;51 }52 public void setObject(String object) {53 this.object = object;54 }55 public String toString() {56 return "Answer{code=" + this.code + ", message=" + this.message + ", resultMessage=" + this.resultMessage + ", object=" + this.object + '}';57 }58}59package org.cerberus.util.answer;60public class AnswerUtil {61 public AnswerUtil() {62 }63 public static Answer createAnswer(boolean code, String message, String resultMessage, String object) {64 return new Answer(code, message, resultMessage, object);65 }66 public static Answer createAnswer(boolean code, String message, String resultMessage) {67 return new Answer(code, message, resultMessage);68 }69 public static Answer createAnswer(boolean code, String message) {70 return new Answer(code, message);71 }72 public static Answer createAnswer(boolean code

Full Screen

Full Screen

setResultMessage

Using AI Code Generation

copy

Full Screen

1import org.cerberus.util.answer.Answer;2public class 3 {3 public static void main(String[] args) {4 Answer answer = new Answer();5 answer.setResultMessage("The answer object has been created successfully");6 System.out.println(answer.getAnswer());7 System.out.println(answer.getResultMessage());8 }9}

Full Screen

Full Screen

setResultMessage

Using AI Code Generation

copy

Full Screen

1package com.cerberus.util.answer;2public class Answer {3 private String resultMessage;4 private String resultCode;5 public Answer() {6 this.resultMessage = "";7 this.resultCode = "";8 }9 public String getResultMessage() {10 return this.resultMessage;11 }12 public void setResultMessage(String resultMessage) {13 this.resultMessage = resultMessage;14 }15 public String getResultCode() {16 return this.resultCode;17 }18 public void setResultCode(String resultCode) {19 this.resultCode = resultCode;20 }21}22package com.cerberus.util.answer;23public class Answer {24 private String resultMessage;25 private String resultCode;26 public Answer() {27 this.resultMessage = "";28 this.resultCode = "";29 }30 public String getResultMessage() {31 return this.resultMessage;32 }33 public void setResultMessage(String resultMessage) {34 this.resultMessage = resultMessage;35 }36 public String getResultCode() {37 return this.resultCode;38 }39 public void setResultCode(String resultCode) {40 this.resultCode = resultCode;41 }42}43package com.cerberus.util.answer;44public class Answer {45 private String resultMessage;46 private String resultCode;47 public Answer() {48 this.resultMessage = "";49 this.resultCode = "";50 }51 public String getResultMessage() {52 return this.resultMessage;53 }54 public void setResultMessage(String resultMessage) {55 this.resultMessage = resultMessage;56 }57 public String getResultCode() {58 return this.resultCode;59 }60 public void setResultCode(String resultCode) {61 this.resultCode = resultCode;62 }63}64package com.cerberus.util.answer;65public class Answer {66 private String resultMessage;67 private String resultCode;68 public Answer() {69 this.resultMessage = "";

Full Screen

Full Screen

setResultMessage

Using AI Code Generation

copy

Full Screen

1import org.cerberus.util.answer.Answer;2import org.cerberus.util.answer.AnswerItem;3public class 3 implements ITestCase {4 public AnswerItem<String> execute(TestCaseExecution tCExecution) {5 AnswerItem<String> item = new AnswerItem<String>();6 Answer ans = new Answer(item);7 ans.setResultMessage("This is the message to be displayed when the test case is successfully run");8 return ans;9 }10}11import org.cerberus.util.answer.Answer;12import org.cerberus.util.answer.AnswerItem;13public class 4 implements ITestCase {14 public AnswerItem<String> execute(TestCaseExecution tCExecution) {15 AnswerItem<String> item = new AnswerItem<String>();16 Answer ans = new Answer(item);17 ans.setTotalNbRows(100);18 return ans;19 }20}21import org.cerberus.util.answer.Answer;22import org.cerberus.util.answer.AnswerItem;23public class 5 implements ITestCase {24 public AnswerItem<String> execute(TestCaseExecution tCExecution) {25 AnswerItem<String> item = new AnswerItem<String>();26 Answer ans = new Answer(item);27 ans.setTotalNbRows(100);28 return ans;29 }30}31import org.cerberus.util.answer.Answer;32import org.cerberus.util.answer.AnswerItem;33public class 6 implements ITestCase {34 public AnswerItem<String> execute(TestCaseExecution tCExecution) {

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Cerberus-source automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful