Search in sources :

Example 6 with Adapter

use of nl.nn.adapterframework.core.Adapter in project iaf by ibissource.

the class ShowConfigurationStatus method retrieveErrorStoreCounters.

private List<ErrorStoreCounter> retrieveErrorStoreCounters(List<Configuration> configurations, Configuration configurationSelected) {
    List<ErrorStoreCounter> errorStoreCounters = new ArrayList<ErrorStoreCounter>();
    if (SHOW_COUNT_ERRORSTORE) {
        errorStoreCounters = new ArrayList<ErrorStoreCounter>();
        if (configurationSelected != null) {
            String config = configurationSelected.getName();
            int counter = 0;
            for (Iterator adapterIt = configurationSelected.getRegisteredAdapters().iterator(); adapterIt.hasNext(); ) {
                Adapter adapter = (Adapter) adapterIt.next();
                counter += retrieveErrorStoragesMessageCount(adapter);
            }
            if (counter > 0) {
                errorStoreCounters.add(new ErrorStoreCounter(config, counter));
            }
        } else {
            for (Configuration configuration : configurations) {
                String config = configuration.getName();
                int counter = 0;
                for (Iterator adapterIt = configuration.getRegisteredAdapters().iterator(); adapterIt.hasNext(); ) {
                    Adapter adapter = (Adapter) adapterIt.next();
                    counter += retrieveErrorStoragesMessageCount(adapter);
                }
                if (counter > 0) {
                    errorStoreCounters.add(new ErrorStoreCounter(config, counter));
                }
            }
        }
    }
    return errorStoreCounters;
}
Also used : Configuration(nl.nn.adapterframework.configuration.Configuration) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter)

Example 7 with Adapter

use of nl.nn.adapterframework.core.Adapter in project iaf by ibissource.

the class SlotIdRecord method executeSub.

public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    IniDynaActionForm showIbisstoreSummaryForm = (IniDynaActionForm) form;
    // Initialize action
    initAction(request);
    if (ibisManager == null)
        return (mapping.findForward("noIbisContext"));
    String jmsRealm = (String) showIbisstoreSummaryForm.get("jmsRealm");
    String cookieName = AppConstants.getInstance().getString(SHOWIBISSTORECOOKIE, SHOWIBISSTORECOOKIE);
    if (StringUtils.isEmpty(jmsRealm)) {
        // get jmsRealm value from cookie
        Cookie[] cookies = request.getCookies();
        if (null != cookies) {
            for (int i = 0; i < cookies.length; i++) {
                Cookie aCookie = cookies[i];
                if (aCookie.getName().equals(cookieName)) {
                    jmsRealm = aCookie.getValue();
                    log.debug("jmsRealm from cookie [" + jmsRealm + "]");
                }
            }
        }
    }
    for (IAdapter iAdapter : ibisManager.getRegisteredAdapters()) {
        Adapter adapter = (Adapter) iAdapter;
        for (Iterator receiverIt = adapter.getReceiverIterator(); receiverIt.hasNext(); ) {
            ReceiverBase receiver = (ReceiverBase) receiverIt.next();
            ITransactionalStorage errorStorage = receiver.getErrorStorage();
            if (errorStorage != null) {
                String slotId = errorStorage.getSlotId();
                if (StringUtils.isNotEmpty(slotId)) {
                    SlotIdRecord sir = new SlotIdRecord(adapter.getName(), receiver.getName(), null);
                    String type = errorStorage.getType();
                    slotmap.put(type + "/" + slotId, sir);
                }
            }
            ITransactionalStorage messageLog = receiver.getMessageLog();
            if (messageLog != null) {
                String slotId = messageLog.getSlotId();
                if (StringUtils.isNotEmpty(slotId)) {
                    SlotIdRecord sir = new SlotIdRecord(adapter.getName(), receiver.getName(), null);
                    String type = messageLog.getType();
                    slotmap.put(type + "/" + slotId, sir);
                }
            }
        }
        PipeLine pipeline = adapter.getPipeLine();
        if (pipeline != null) {
            for (int i = 0; i < pipeline.getPipeLineSize(); i++) {
                IPipe pipe = pipeline.getPipe(i);
                if (pipe instanceof MessageSendingPipe) {
                    MessageSendingPipe msp = (MessageSendingPipe) pipe;
                    ITransactionalStorage messageLog = msp.getMessageLog();
                    if (messageLog != null) {
                        String slotId = messageLog.getSlotId();
                        if (StringUtils.isNotEmpty(slotId)) {
                            SlotIdRecord sir = new SlotIdRecord(adapter.getName(), null, msp.getName());
                            String type = messageLog.getType();
                            slotmap.put(type + "/" + slotId, sir);
                            slotmap.put(slotId, sir);
                        }
                    }
                }
            }
        }
    }
    List jmsRealms = JmsRealmFactory.getInstance().getRegisteredRealmNamesAsList();
    if (jmsRealms.size() == 0) {
        jmsRealms.add("no realms defined");
    } else {
        if (StringUtils.isEmpty(jmsRealm)) {
            jmsRealm = (String) jmsRealms.get(0);
        }
    }
    showIbisstoreSummaryForm.set("jmsRealms", jmsRealms);
    if (StringUtils.isNotEmpty(jmsRealm)) {
        String result = "<none/>";
        try {
            IbisstoreSummaryQuerySender qs;
            qs = (IbisstoreSummaryQuerySender) ibisManager.getIbisContext().createBeanAutowireByName(IbisstoreSummaryQuerySender.class);
            qs.setSlotmap(slotmap);
            try {
                qs.setName("QuerySender");
                qs.setJmsRealm(jmsRealm);
                qs.setQueryType("select");
                qs.setBlobSmartGet(true);
                qs.configure(true);
                qs.open();
                result = qs.sendMessage("dummy", qs.getDbmsSupport().getIbisStoreSummaryQuery());
            } catch (Throwable t) {
                error("error occured on executing jdbc query", t);
            } finally {
                qs.close();
            }
        } catch (Exception e) {
            error("error occured on creating or closing connection", e);
        }
        if (log.isDebugEnabled())
            log.debug("result [" + result + "]");
        request.setAttribute("result", result);
    }
    if (!errors.isEmpty()) {
        saveErrors(request, errors);
        return (mapping.findForward("success"));
    }
    // Successfull: store cookie
    String cookieValue = jmsRealm;
    Cookie cookie = new Cookie(cookieName, cookieValue);
    cookie.setMaxAge(Integer.MAX_VALUE);
    log.debug("Store cookie for " + request.getServletPath() + " cookieName[" + cookieName + "] " + " cookieValue[" + cookieValue + "]");
    try {
        response.addCookie(cookie);
    } catch (Throwable t) {
        log.warn("unable to add cookie to request. cookie value [" + cookie.getValue() + "]", t);
    }
    log.debug("forward to success");
    return (mapping.findForward("success"));
}
Also used : Cookie(javax.servlet.http.Cookie) ReceiverBase(nl.nn.adapterframework.receivers.ReceiverBase) MessageSendingPipe(nl.nn.adapterframework.pipes.MessageSendingPipe) Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter) ServletException(javax.servlet.ServletException) JdbcException(nl.nn.adapterframework.jdbc.JdbcException) SQLException(java.sql.SQLException) IOException(java.io.IOException) ITransactionalStorage(nl.nn.adapterframework.core.ITransactionalStorage) Iterator(java.util.Iterator) List(java.util.List) IniDynaActionForm(nl.nn.adapterframework.webcontrol.IniDynaActionForm) PipeLine(nl.nn.adapterframework.core.PipeLine) IAdapter(nl.nn.adapterframework.core.IAdapter) IPipe(nl.nn.adapterframework.core.IPipe)

Example 8 with Adapter

use of nl.nn.adapterframework.core.Adapter in project iaf by ibissource.

the class ShowSecurityItems method addRegisteredAdapters.

private void addRegisteredAdapters(XmlBuilder securityItems) {
    XmlBuilder registeredAdapters = new XmlBuilder("registeredAdapters");
    securityItems.addSubElement(registeredAdapters);
    for (IAdapter iAdapter : ibisManager.getRegisteredAdapters()) {
        Adapter adapter = (Adapter) iAdapter;
        XmlBuilder adapterXML = new XmlBuilder("adapter");
        registeredAdapters.addSubElement(adapterXML);
        adapterXML.addAttribute("name", adapter.getName());
        Iterator recIt = adapter.getReceiverIterator();
        if (recIt.hasNext()) {
            XmlBuilder receiversXML = new XmlBuilder("receivers");
            while (recIt.hasNext()) {
                IReceiver receiver = (IReceiver) recIt.next();
                XmlBuilder receiverXML = new XmlBuilder("receiver");
                receiversXML.addSubElement(receiverXML);
                receiverXML.addAttribute("name", receiver.getName());
                if (receiver instanceof HasSender) {
                    ISender sender = ((HasSender) receiver).getSender();
                    if (sender != null) {
                        receiverXML.addAttribute("senderName", sender.getName());
                    }
                }
            }
            adapterXML.addSubElement(receiversXML);
        }
        // make list of pipes to be displayed in configuration status
        XmlBuilder pipesElem = new XmlBuilder("pipes");
        adapterXML.addSubElement(pipesElem);
        PipeLine pipeline = adapter.getPipeLine();
        for (int i = 0; i < pipeline.getPipes().size(); i++) {
            IPipe pipe = pipeline.getPipe(i);
            String pipename = pipe.getName();
            if (pipe instanceof MessageSendingPipe) {
                MessageSendingPipe msp = (MessageSendingPipe) pipe;
                XmlBuilder pipeElem = new XmlBuilder("pipe");
                pipeElem.addAttribute("name", pipename);
                ISender sender = msp.getSender();
                pipeElem.addAttribute("sender", ClassUtils.nameOf(sender));
                pipesElem.addSubElement(pipeElem);
                if (sender instanceof WebServiceSender) {
                    WebServiceSender s = (WebServiceSender) sender;
                    String certificate = s.getCertificate();
                    if (StringUtils.isNotEmpty(certificate)) {
                        XmlBuilder certElem = new XmlBuilder("certificate");
                        certElem.addAttribute("name", certificate);
                        String certificateAuthAlias = s.getCertificateAuthAlias();
                        certElem.addAttribute("authAlias", certificateAuthAlias);
                        URL certificateUrl = ClassUtils.getResourceURL(this, certificate);
                        if (certificateUrl == null) {
                            certElem.addAttribute("url", "");
                            pipeElem.addSubElement(certElem);
                            XmlBuilder infoElem = new XmlBuilder("info");
                            infoElem.setCdataValue("*** ERROR ***");
                            certElem.addSubElement(infoElem);
                        } else {
                            certElem.addAttribute("url", certificateUrl.toString());
                            pipeElem.addSubElement(certElem);
                            String certificatePassword = s.getCertificatePassword();
                            CredentialFactory certificateCf = new CredentialFactory(certificateAuthAlias, null, certificatePassword);
                            String keystoreType = s.getKeystoreType();
                            addCertificateInfo(certElem, certificateUrl, certificateCf.getPassword(), keystoreType, "Certificate chain");
                        }
                    }
                } else {
                    if (sender instanceof HttpSender) {
                        HttpSender s = (HttpSender) sender;
                        String certificate = s.getCertificate();
                        if (StringUtils.isNotEmpty(certificate)) {
                            XmlBuilder certElem = new XmlBuilder("certificate");
                            certElem.addAttribute("name", certificate);
                            String certificateAuthAlias = s.getCertificateAuthAlias();
                            certElem.addAttribute("authAlias", certificateAuthAlias);
                            URL certificateUrl = ClassUtils.getResourceURL(this, certificate);
                            if (certificateUrl == null) {
                                certElem.addAttribute("url", "");
                                pipeElem.addSubElement(certElem);
                                XmlBuilder infoElem = new XmlBuilder("info");
                                infoElem.setCdataValue("*** ERROR ***");
                                certElem.addSubElement(infoElem);
                            } else {
                                certElem.addAttribute("url", certificateUrl.toString());
                                pipeElem.addSubElement(certElem);
                                String certificatePassword = s.getCertificatePassword();
                                CredentialFactory certificateCf = new CredentialFactory(certificateAuthAlias, null, certificatePassword);
                                String keystoreType = s.getKeystoreType();
                                addCertificateInfo(certElem, certificateUrl, certificateCf.getPassword(), keystoreType, "Certificate chain");
                            }
                        }
                    } else {
                        if (sender instanceof FtpSender) {
                            FtpSender s = (FtpSender) sender;
                            String certificate = s.getCertificate();
                            if (StringUtils.isNotEmpty(certificate)) {
                                XmlBuilder certElem = new XmlBuilder("certificate");
                                certElem.addAttribute("name", certificate);
                                String certificateAuthAlias = s.getCertificateAuthAlias();
                                certElem.addAttribute("authAlias", certificateAuthAlias);
                                URL certificateUrl = ClassUtils.getResourceURL(this, certificate);
                                if (certificateUrl == null) {
                                    certElem.addAttribute("url", "");
                                    pipeElem.addSubElement(certElem);
                                    XmlBuilder infoElem = new XmlBuilder("info");
                                    infoElem.setCdataValue("*** ERROR ***");
                                    certElem.addSubElement(infoElem);
                                } else {
                                    certElem.addAttribute("url", certificateUrl.toString());
                                    pipeElem.addSubElement(certElem);
                                    String certificatePassword = s.getCertificatePassword();
                                    CredentialFactory certificateCf = new CredentialFactory(certificateAuthAlias, null, certificatePassword);
                                    String keystoreType = s.getCertificateType();
                                    addCertificateInfo(certElem, certificateUrl, certificateCf.getPassword(), keystoreType, "Certificate chain");
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : MessageSendingPipe(nl.nn.adapterframework.pipes.MessageSendingPipe) CredentialFactory(nl.nn.adapterframework.util.CredentialFactory) Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter) FtpSender(nl.nn.adapterframework.ftp.FtpSender) HttpSender(nl.nn.adapterframework.http.HttpSender) HasSender(nl.nn.adapterframework.core.HasSender) URL(java.net.URL) IReceiver(nl.nn.adapterframework.core.IReceiver) ISender(nl.nn.adapterframework.core.ISender) Iterator(java.util.Iterator) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) WebServiceSender(nl.nn.adapterframework.http.WebServiceSender) PipeLine(nl.nn.adapterframework.core.PipeLine) IAdapter(nl.nn.adapterframework.core.IAdapter) IPipe(nl.nn.adapterframework.core.IPipe)

Example 9 with Adapter

use of nl.nn.adapterframework.core.Adapter in project iaf by ibissource.

the class Browse method executeSub.

public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    // Initialize action
    initAction(request);
    DynaActionForm browseForm = getPersistentForm(mapping, form, request);
    String submit = request.getParameter("submit");
    log.debug("submit param [" + submit + "]");
    String maxMessagesStr = getAndSetProperty(request, browseForm, "maxMessages", getMaxMessages() + "");
    String skipMessagesStr = getAndSetProperty(request, browseForm, "skipMessages", "0");
    String action = getAndSetProperty(request, browseForm, "action");
    String storageType = getAndSetProperty(request, browseForm, "storageType");
    String adapterName = getAndSetProperty(request, browseForm, "adapterName");
    String receiverName = getAndSetProperty(request, browseForm, "receiverName");
    String pipeName = getAndSetProperty(request, browseForm, "pipeName");
    String messageId = getAndSetProperty(request, browseForm, "messageId");
    String typeMask = getAndSetProperty(request, browseForm, "typeMask");
    String hostMask = getAndSetProperty(request, browseForm, "hostMask");
    String currentIdMask = getAndSetProperty(request, browseForm, "currentIdMask");
    String messageIdMask = getAndSetProperty(request, browseForm, "messageIdMask");
    String correlationIdMask = getAndSetProperty(request, browseForm, "correlationIdMask");
    String commentMask = getAndSetProperty(request, browseForm, "commentMask");
    String messageTextMask = getAndSetProperty(request, browseForm, "messageTextMask");
    String labelMask = getAndSetProperty(request, browseForm, "labelMask");
    String startDateStr = getAndSetProperty(request, browseForm, "insertedAfter");
    String startDateClipStr = getAndSetProperty(request, browseForm, "insertedAfterClip");
    // not yet supported in actionForm
    String endDateStr = request.getParameter("insertedBefore");
    // not yet supported in actionForm
    String forceDescStr = request.getParameter("forceDescending");
    String viewAs = getAndSetProperty(request, browseForm, "viewAs", request.getParameter("type"));
    String[] selected = (String[]) browseForm.get("selected");
    boolean startDateClip = "on".equals(startDateClipStr);
    if (StringUtils.isNotEmpty(submit)) {
        action = submit;
    }
    Date startDate = null;
    Date endDate = null;
    String formattedStartDate = null;
    if (StringUtils.isNotEmpty(startDateStr)) {
        try {
            startDate = DateUtils.parseAnyDate(startDateStr);
            if (startDate != null) {
                formattedStartDate = DateUtils.formatOptimal(startDate);
                log.debug("parsed start date to [" + formattedStartDate + "]");
                browseForm.set("insertedAfter", formattedStartDate);
                if (startDateClip) {
                    endDate = DateUtils.nextHigherValue(startDate);
                }
            } else {
                warn("could not parse date from [" + startDateStr + "]");
            }
        } catch (CalendarParserException e) {
            warn("could not parse date from [" + startDateStr + "]", e);
        }
    }
    if (StringUtils.isNotEmpty(endDateStr)) {
        try {
            endDate = DateUtils.parseAnyDate(endDateStr);
            if (startDate == null) {
                warn("could not parse date from [" + endDateStr + "]");
            }
        } catch (CalendarParserException e) {
            warn("could not parse date from [" + startDateStr + "]", e);
        }
    }
    ArrayList viewAsList = new ArrayList();
    viewAsList.add("html");
    viewAsList.add("text");
    browseForm.set("viewAsList", viewAsList);
    log.debug("selected [" + browseForm.get("selected") + "]");
    // ArrayList selected=(ArrayList)browseForm.get("selected");
    // for (int i=0; i<selected.size(); i++) {
    // log.debug("selected "+i+" = ["+selected.get(i));
    // }
    maxMessages = Integer.parseInt(maxMessagesStr);
    skipMessages = Integer.parseInt(skipMessagesStr);
    // commandIssuedBy containes information about the location the
    // command is sent from
    String commandIssuedBy = HttpUtils.getCommandIssuedBy(request);
    log.debug("storageType [" + storageType + "] action [" + action + "] submit [" + submit + "] adapterName [" + adapterName + "] receiverName [" + receiverName + "] pipeName [" + pipeName + "] issued by [" + commandIssuedBy + "]");
    Adapter adapter = (Adapter) ibisManager.getRegisteredAdapter(adapterName);
    IMessageBrowser mb;
    IListener listener = null;
    String logCount;
    if ("messagelog".equals(storageType)) {
        if (StringUtils.isNotEmpty(pipeName)) {
            MessageSendingPipe pipe = (MessageSendingPipe) adapter.getPipeLine().getPipe(pipeName);
            mb = pipe.getMessageLog();
        } else {
            ReceiverBase receiver = (ReceiverBase) adapter.getReceiverByName(receiverName);
            mb = receiver.getMessageLog();
        }
        // actions 'deletemessage' and 'resendmessage' not allowed for messageLog
        if ("export selected".equalsIgnoreCase(action)) {
            performAction(adapter, null, action, mb, messageId, selected, request, response);
        }
    } else {
        ReceiverBase receiver = (ReceiverBase) adapter.getReceiverByName(receiverName);
        if (receiver == null) {
            error("cannot find Receiver [" + receiverName + "]", null);
            return null;
        }
        mb = receiver.getErrorStorage();
        if (performAction(adapter, receiver, action, mb, messageId, selected, request, response))
            return null;
        listener = receiver.getListener();
    }
    try {
        logCount = "(" + ((ITransactionalStorage) mb).getMessageCount() + ")";
    } catch (Exception e) {
        log.warn(e);
        logCount = "(?)";
    }
    try {
        if ("showmessage".equalsIgnoreCase(action)) {
            Object rawmsg = mb.browseMessage(messageId);
            String msg = null;
            if (listener != null) {
                msg = listener.getStringFromRawMessage(rawmsg, null);
            } else {
                msg = (String) rawmsg;
            }
            if (StringUtils.isEmpty(msg)) {
                msg = "<no message found>";
            }
            String type = request.getParameter("type");
            if (StringUtils.isEmpty(type)) {
                type = viewAs;
            }
            FileViewerServlet.showReaderContents(new StringReader(msg), "msg" + messageId, type, response, "message [" + messageId + "]");
            return null;
        } else {
            IMessageBrowsingIterator mbi = mb.getIterator(startDate, endDate, "true".equals(forceDescStr));
            try {
                XmlBuilder messages = new XmlBuilder("messages");
                messages.addAttribute("storageType", storageType);
                messages.addAttribute("action", action);
                messages.addAttribute("adapterName", XmlUtils.encodeChars(adapterName));
                if ("messagelog".equals(storageType) && StringUtils.isNotEmpty(pipeName)) {
                    messages.addAttribute("object", "pipe [" + XmlUtils.encodeChars(pipeName) + "] of adapter [" + XmlUtils.encodeChars(adapterName) + "] " + logCount);
                    messages.addAttribute("pipeName", XmlUtils.encodeChars(pipeName));
                } else {
                    messages.addAttribute("object", "receiver [" + XmlUtils.encodeChars(receiverName) + "] of adapter [" + XmlUtils.encodeChars(adapterName) + "] " + logCount);
                    messages.addAttribute("receiverName", XmlUtils.encodeChars(receiverName));
                }
                int messageCount;
                for (messageCount = 0; mbi.hasNext(); ) {
                    IMessageBrowsingIteratorItem iterItem = mbi.next();
                    try {
                        String cType = iterItem.getType();
                        String cHost = iterItem.getHost();
                        String cId = iterItem.getId();
                        String cMessageId = iterItem.getOriginalId();
                        String cCorrelationId = iterItem.getCorrelationId();
                        String comment = iterItem.getCommentString();
                        Date insertDate = iterItem.getInsertDate();
                        String cLabel = iterItem.getLabel();
                        if (StringUtils.isNotEmpty(typeMask) && !cType.startsWith(typeMask)) {
                            continue;
                        }
                        if (StringUtils.isNotEmpty(hostMask) && !cHost.startsWith(hostMask)) {
                            continue;
                        }
                        if (StringUtils.isNotEmpty(currentIdMask) && !cId.startsWith(currentIdMask)) {
                            continue;
                        }
                        if (StringUtils.isNotEmpty(messageIdMask) && !cMessageId.startsWith(messageIdMask)) {
                            continue;
                        }
                        if (StringUtils.isNotEmpty(correlationIdMask) && !cCorrelationId.startsWith(correlationIdMask)) {
                            continue;
                        }
                        if (startDate != null && insertDate != null) {
                            if (insertDate.before(startDate)) {
                                continue;
                            }
                            if (startDateClip) {
                                String formattedInsertDate = DateUtils.formatOptimal(insertDate);
                                if (!formattedInsertDate.startsWith(formattedStartDate)) {
                                    continue;
                                }
                            }
                        }
                        if (StringUtils.isNotEmpty(commentMask) && (StringUtils.isEmpty(comment) || comment.indexOf(commentMask) < 0)) {
                            continue;
                        }
                        if (StringUtils.isNotEmpty(messageTextMask)) {
                            Object rawmsg = mb.browseMessage(cId);
                            String msg = null;
                            if (listener != null) {
                                msg = listener.getStringFromRawMessage(rawmsg, new HashMap());
                            } else {
                                msg = (String) rawmsg;
                            }
                            if (msg == null || msg.indexOf(messageTextMask) < 0) {
                                continue;
                            }
                        }
                        if (StringUtils.isNotEmpty(labelMask) && (StringUtils.isEmpty(cLabel) || !cLabel.startsWith(labelMask))) {
                            continue;
                        }
                        messageCount++;
                        if (messageCount > skipMessages) {
                            XmlBuilder message = new XmlBuilder("message");
                            message.addAttribute("id", cId);
                            message.addAttribute("pos", Integer.toString(messageCount));
                            message.addAttribute("originalId", cMessageId);
                            message.addAttribute("correlationId", cCorrelationId);
                            message.addAttribute("type", cType);
                            message.addAttribute("host", cHost);
                            message.addAttribute("insertDate", DateUtils.format(insertDate, DateUtils.FORMAT_FULL_GENERIC));
                            if (iterItem.getExpiryDate() != null) {
                                message.addAttribute("expiryDate", DateUtils.format(iterItem.getExpiryDate(), DateUtils.FORMAT_FULL_GENERIC));
                            }
                            message.addAttribute("comment", XmlUtils.encodeChars(iterItem.getCommentString()));
                            message.addAttribute("label", cLabel);
                            messages.addSubElement(message);
                        }
                        if (getMaxMessages() > 0 && messageCount >= (getMaxMessages() + skipMessages)) {
                            log.warn("stopped iterating messages after [" + messageCount + "]: limit reached");
                            break;
                        }
                    } finally {
                        iterItem.release();
                    }
                }
                messages.addAttribute("messageCount", Integer.toString(messageCount - skipMessages));
                request.setAttribute("messages", messages.toXML());
            } finally {
                mbi.close();
            }
        }
    } catch (Throwable e) {
        error("Caught Exception", e);
        throw new ServletException(e);
    }
    if (!errors.isEmpty()) {
        saveErrors(request, errors);
    }
    log.debug("forward to success");
    return (mapping.findForward("success"));
}
Also used : ReceiverBase(nl.nn.adapterframework.receivers.ReceiverBase) DynaActionForm(org.apache.struts.action.DynaActionForm) MessageSendingPipe(nl.nn.adapterframework.pipes.MessageSendingPipe) HashMap(java.util.HashMap) IMessageBrowsingIteratorItem(nl.nn.adapterframework.core.IMessageBrowsingIteratorItem) IMessageBrowser(nl.nn.adapterframework.core.IMessageBrowser) IListener(nl.nn.adapterframework.core.IListener) ArrayList(java.util.ArrayList) Adapter(nl.nn.adapterframework.core.Adapter) IMessageBrowsingIterator(nl.nn.adapterframework.core.IMessageBrowsingIterator) Date(java.util.Date) ServletException(javax.servlet.ServletException) CalendarParserException(nl.nn.adapterframework.util.CalendarParserException) IOException(java.io.IOException) CalendarParserException(nl.nn.adapterframework.util.CalendarParserException) ServletException(javax.servlet.ServletException) StringReader(java.io.StringReader) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder)

Example 10 with Adapter

use of nl.nn.adapterframework.core.Adapter in project iaf by ibissource.

the class AbstractPipe method isRecoverAdapter.

protected boolean isRecoverAdapter() {
    boolean recover = false;
    IAdapter iAdapter = getAdapter();
    if (iAdapter == null) {
        recover = recoverAdapter;
    } else {
        if (iAdapter instanceof Adapter) {
            Adapter adapter = (Adapter) iAdapter;
            recover = adapter.isRecover();
        }
    }
    return recover;
}
Also used : Adapter(nl.nn.adapterframework.core.Adapter) IAdapter(nl.nn.adapterframework.core.IAdapter) IAdapter(nl.nn.adapterframework.core.IAdapter)

Aggregations

Adapter (nl.nn.adapterframework.core.Adapter)31 IAdapter (nl.nn.adapterframework.core.IAdapter)24 Iterator (java.util.Iterator)10 Path (javax.ws.rs.Path)10 Produces (javax.ws.rs.Produces)10 ReceiverBase (nl.nn.adapterframework.receivers.ReceiverBase)10 RolesAllowed (javax.annotation.security.RolesAllowed)9 IReceiver (nl.nn.adapterframework.core.IReceiver)9 GET (javax.ws.rs.GET)8 PipeLine (nl.nn.adapterframework.core.PipeLine)8 ArrayList (java.util.ArrayList)7 Configuration (nl.nn.adapterframework.configuration.Configuration)7 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)5 IListener (nl.nn.adapterframework.core.IListener)5 XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)5 ServletException (javax.servlet.ServletException)4 Response (javax.ws.rs.core.Response)4 IPipe (nl.nn.adapterframework.core.IPipe)4