Search in sources :

Example 1 with MessageBrowsingFilter

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();
}
Also used : ProcessState(nl.nn.adapterframework.core.ProcessState) Adapter(nl.nn.adapterframework.core.Adapter) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) MessageBrowsingFilter(nl.nn.adapterframework.util.MessageBrowsingFilter) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with MessageBrowsingFilter

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();
}
Also used : MessageSendingPipe(nl.nn.adapterframework.pipes.MessageSendingPipe) Adapter(nl.nn.adapterframework.core.Adapter) MessageBrowsingFilter(nl.nn.adapterframework.util.MessageBrowsingFilter) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

RolesAllowed (javax.annotation.security.RolesAllowed)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Adapter (nl.nn.adapterframework.core.Adapter)2 MessageBrowsingFilter (nl.nn.adapterframework.util.MessageBrowsingFilter)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ProcessState (nl.nn.adapterframework.core.ProcessState)1 MessageSendingPipe (nl.nn.adapterframework.pipes.MessageSendingPipe)1