/** {@inheritDoc} */ @Override protected Fixture onExecute() throws Exception { Long fixtureId = getResult().getFixture().getId(); Fixture fixture = fixtureRepository.findFixtureById(fixtureId); TaskExecutionStatus taskExecutionStatus = (getResult().getStatus().equals(ExecutionStatus.SUCCESS)) ? TaskExecutionStatus.SUCCESS : TaskExecutionStatus.FAILURE; fixture.setTaskExecutionStatus(taskExecutionStatus); if (getResult().getStatus().equals(ExecutionStatus.FAILURE)) { if (StringUtils.isNotBlank(getResult().getExceptionMessage())) { fixture.setLastTaskMessage(getResult().getExceptionMessage()); } } recordEvent(fixture); handleResult(fixture, result); if (shouldSendDefaultNotification()) { FixtureTaskExecutionNotification notification = new FixtureTaskExecutionNotification(new FixtureModel(fixture)); notificationCenter.sendNotification(notification); } return fixture; }
private void recordEvent(Fixture fixture) { String message = null; if (fixture.getTaskExecutionStatus() == TaskExecutionStatus.SUCCESS) { message = "Successfully executed task " + result.getTaskType() + " for fixture " + fixture.getDisplayName(); } else { message = "Failure executing task " + result.getTaskType() + " for fixture " + fixture.getDisplayName() + ", message: " + ((result.getExceptionMessage() == null) ? result.getExceptionMessage() : "(no message)"); } eventLogService.logEvent( "Task Execution", fixture.getIpAddress(), ((fixture.getAsset() != null) ? fixture.getAsset().getMacAddress() : null), message); }