use of nl.nn.testtool.Checkpoint in project iaf by ibissource.
the class Debugger method rerun.
@Override
public String rerun(String correlationId, Report originalReport, SecurityContext securityContext, ReportRunner reportRunner) {
String errorMessage = null;
if (securityContext.isUserInRoles(rerunRoles)) {
int i = 0;
List<Checkpoint> checkpoints = originalReport.getCheckpoints();
Checkpoint checkpoint = checkpoints.get(i);
String checkpointName = checkpoint.getName();
if (checkpointName.startsWith("Pipeline ")) {
String pipelineName = checkpointName.substring("Pipeline ".length());
Message inputMessage = new Message(checkpoint.getMessageWithResolvedVariables(reportRunner));
IAdapter adapter = ibisManager.getRegisteredAdapter(pipelineName);
if (adapter != null) {
synchronized (inRerun) {
inRerun.add(correlationId);
}
try {
// are also closed and the generated report will not remain in progress
try (PipeLineSession pipeLineSession = new PipeLineSession()) {
while (checkpoints.size() > i + 1) {
i++;
checkpoint = checkpoints.get(i);
checkpointName = checkpoint.getName();
if (checkpointName.startsWith("SessionKey ")) {
String sessionKey = checkpointName.substring("SessionKey ".length());
if (!sessionKey.equals("messageId") && !sessionKey.equals("originalMessage")) {
pipeLineSession.put(sessionKey, checkpoint.getMessage());
}
} else {
i = checkpoints.size();
}
}
adapter.processMessage(correlationId, inputMessage, pipeLineSession);
}
} finally {
synchronized (inRerun) {
inRerun.remove(correlationId);
}
}
} else {
errorMessage = "Adapter '" + pipelineName + "' not found";
}
} else {
errorMessage = "First checkpoint isn't a pipeline";
}
} else {
errorMessage = "Not allowed";
}
return errorMessage;
}
use of nl.nn.testtool.Checkpoint in project iaf by ibissource.
the class Storage method delete.
@Override
public void delete(Report report) throws StorageException {
String errorMessage = null;
if ("Table EXCEPTIONLOG".equals(report.getName())) {
List checkpoints = report.getCheckpoints();
Checkpoint checkpoint = (Checkpoint) checkpoints.get(0);
Message message = Message.asMessage(checkpoint.getMessage());
IAdapter adapter = ibisManager.getRegisteredAdapter(DELETE_ADAPTER);
if (adapter != null) {
PipeLineSession pipeLineSession = new PipeLineSession();
if (securityContext.getUserPrincipal() != null)
pipeLineSession.put("principal", securityContext.getUserPrincipal().getName());
PipeLineResult processResult = adapter.processMessage(TestTool.getCorrelationId(), message, pipeLineSession);
if (!processResult.isSuccessful()) {
errorMessage = "Delete failed (see logging for more details)";
} else {
try {
String result = processResult.getResult().asString();
if (!result.equalsIgnoreCase("<ok/>")) {
errorMessage = "Delete failed: " + result;
}
} catch (IOException e) {
throw new StorageException("Delete failed", e);
}
}
} else {
errorMessage = "Adapter '" + DELETE_ADAPTER + "' not found";
}
} else {
errorMessage = "Delete method is not implemented for '" + report.getName() + "'";
}
if (errorMessage != null) {
throw new StorageException(errorMessage);
}
}
use of nl.nn.testtool.Checkpoint in project iaf by ibissource.
the class Storage method getReport.
@Override
public Report getReport(Integer storageId) throws StorageException {
final Report report = new Report();
report.setTestTool(testTool);
report.setStorage(this);
report.setStorageId(storageId);
report.setName("Table " + table);
report.setStubStrategy("Never");
final List<Checkpoint> checkpoints = new ArrayList<Checkpoint>();
report.setCheckpoints(checkpoints);
StringBuilder query = new StringBuilder("select " + reportColumnNames.get(0));
for (int i = 1; i < reportColumnNames.size(); i++) {
query.append(", " + reportColumnNames.get(i));
}
query.append(" from " + table + " where LOGID = ?");
try {
jdbcTemplate.query(query.toString(), new Object[] { storageId }, new RowMapper() {
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
for (int i = 0; i < reportColumnNames.size(); i++) {
String value = getValue(rs, i + 1);
Checkpoint checkpoint = new Checkpoint(report, Thread.currentThread().getName(), Storage.class.getName(), "Column " + reportColumnNames.get(i), Checkpoint.TYPE_INPUTPOINT, 0);
checkpoint.setMessage(value);
checkpoints.add(checkpoint);
}
return null;
}
});
} catch (DataAccessException e) {
throw new StorageException("Could not read report", e);
}
return report;
}
use of nl.nn.testtool.Checkpoint in project iaf by ibissource.
the class Debugger method rerun.
@Override
public String rerun(String correlationId, Report originalReport, SecurityContext securityContext, ReportRunner reportRunner) {
String errorMessage = null;
if ("Table EXCEPTIONLOG".equals(originalReport.getName())) {
List<Checkpoint> checkpoints = originalReport.getCheckpoints();
Checkpoint checkpoint = checkpoints.get(0);
String inputMessage = checkpoint.getMessageWithResolvedVariables(reportRunner);
IAdapter adapter = ibisManager.getRegisteredAdapter(RESEND_ADAPTER);
if (adapter != null) {
PipeLineSession pipeLineSession = new PipeLineSession();
synchronized (inRerun) {
inRerun.add(correlationId);
}
try {
if (securityContext.getUserPrincipal() != null)
pipeLineSession.put("principal", securityContext.getUserPrincipal().getName());
PipeLineResult processResult = adapter.processMessage(correlationId, new Message(inputMessage), pipeLineSession);
if (!(processResult.isSuccessful() && processResult.getResult().asString().equalsIgnoreCase("<ok/>"))) {
errorMessage = "Rerun failed. Result of adapter " + RESEND_ADAPTER + ": " + processResult.getResult().asString();
}
} catch (IOException e) {
errorMessage = "Rerun failed. Exception in adapter " + RESEND_ADAPTER + ": (" + e.getClass().getName() + ") " + e.getMessage();
} finally {
synchronized (inRerun) {
inRerun.remove(correlationId);
}
}
} else {
errorMessage = "Adapter '" + RESEND_ADAPTER + "' not found";
}
} else {
errorMessage = super.rerun(correlationId, originalReport, securityContext, reportRunner);
}
return errorMessage;
}
use of nl.nn.testtool.Checkpoint in project iaf by ibissource.
the class StatusExtractor method extractMetadata.
public Object extractMetadata(Report report) {
String status = "Success";
List checkpoints = report.getCheckpoints();
if (checkpoints.size() > 0) {
Checkpoint lastCheckpoint = (Checkpoint) checkpoints.get(checkpoints.size() - 1);
if (lastCheckpoint.getType() == Checkpoint.TYPE_ABORTPOINT) {
status = "Error";
}
}
return status;
}
Aggregations