use of nl.nn.adapterframework.util.MessageBrowsingFilter in project iaf by ibissource.
the class TransactionalStorage method browseReceiverMessages.
@GET
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/adapters/{adapterName}/receivers/{receiverName}/stores/{processState}")
@Produces(MediaType.APPLICATION_JSON)
public Response browseReceiverMessages(@PathParam("adapterName") String adapterName, @PathParam("receiverName") String receiverName, @PathParam("processState") String processState, @QueryParam("type") String type, @QueryParam("host") String host, @QueryParam("id") String id, @QueryParam("messageId") String messageId, @QueryParam("correlationId") String correlationId, @QueryParam("comment") String comment, @QueryParam("message") String message, @QueryParam("label") String label, @QueryParam("startDate") String startDateStr, @QueryParam("endDate") String endDateStr, @QueryParam("sort") String sort, @QueryParam("skip") int skipMessages, @QueryParam("max") int maxMessages) throws ApiException {
Adapter adapter = getIbisManager().getRegisteredAdapter(adapterName);
if (adapter == null) {
throw new ApiException("Adapter not found!");
}
Receiver<?> receiver = adapter.getReceiverByName(receiverName);
if (receiver == null) {
throw new ApiException("Receiver [" + receiverName + "] not found!");
}
// StorageType
ProcessState state = ProcessState.getProcessStateFromName(processState);
IMessageBrowser<?> storage = receiver.getMessageBrowser(state);
Map<ProcessState, Map<String, String>> targetPSInfo = getTargetProcessStateInfo(receiver.targetProcessStates().get(state));
if (storage == null) {
throw new ApiException("no IMessageBrowser found");
}
// Apply filters
MessageBrowsingFilter filter = new MessageBrowsingFilter(maxMessages, skipMessages);
filter.setTypeMask(type);
filter.setHostMask(host);
filter.setIdMask(id);
filter.setMessageIdMask(messageId);
filter.setCorrelationIdMask(correlationId);
filter.setCommentMask(comment);
filter.setMessageMask(message, storage, receiver.getListener());
filter.setLabelMask(label);
filter.setStartDateMask(startDateStr);
filter.setEndDateMask(endDateStr);
if ("desc".equalsIgnoreCase(sort))
filter.setSortOrder(SortOrder.DESC);
if ("asc".equalsIgnoreCase(sort))
filter.setSortOrder(SortOrder.ASC);
Map<String, Object> resultObj = getMessages(storage, filter);
if (targetPSInfo != null && targetPSInfo.size() > 0) {
resultObj.put("targetStates", targetPSInfo);
}
return Response.status(Response.Status.OK).entity(resultObj).build();
}
use of nl.nn.adapterframework.util.MessageBrowsingFilter in project iaf by ibissource.
the class TransactionalStorage method browsePipeMessages.
@GET
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/adapters/{adapterName}/pipes/{pipeName}/messages")
@Produces(MediaType.APPLICATION_JSON)
public Response browsePipeMessages(@PathParam("adapterName") String adapterName, @PathParam("pipeName") String pipeName, @QueryParam("type") String type, @QueryParam("host") String host, @QueryParam("id") String id, @QueryParam("messageId") String messageId, @QueryParam("correlationId") String correlationId, @QueryParam("comment") String comment, @QueryParam("message") String message, @QueryParam("label") String label, @QueryParam("startDate") String startDateStr, @QueryParam("endDate") String endDateStr, @QueryParam("sort") String sort, @QueryParam("skip") int skipMessages, @QueryParam("max") int maxMessages) throws ApiException {
Adapter adapter = getIbisManager().getRegisteredAdapter(adapterName);
if (adapter == null) {
throw new ApiException("Adapter not found!");
}
MessageSendingPipe pipe = (MessageSendingPipe) adapter.getPipeLine().getPipe(pipeName);
if (pipe == null) {
throw new ApiException("Pipe [" + pipeName + "] not found!");
}
IMessageBrowser<?> storage = pipe.getMessageLog();
// Apply filters
MessageBrowsingFilter filter = new MessageBrowsingFilter(maxMessages, skipMessages);
filter.setTypeMask(type);
filter.setHostMask(host);
filter.setIdMask(id);
filter.setMessageIdMask(messageId);
filter.setCorrelationIdMask(correlationId);
filter.setCommentMask(comment);
filter.setMessageMask(message, storage);
filter.setLabelMask(label);
filter.setStartDateMask(startDateStr);
filter.setEndDateMask(endDateStr);
if ("desc".equalsIgnoreCase(sort))
filter.setSortOrder(SortOrder.DESC);
if ("asc".equalsIgnoreCase(sort))
filter.setSortOrder(SortOrder.ASC);
return Response.status(Response.Status.OK).entity(getMessages(storage, filter)).build();
}
Aggregations