public void receive()

in modules/core/src/main/java/org/apache/savan/messagereceiver/PublishingMessageReceiver.java [30:78]


    public void receive(MessageContext messageCtx) throws AxisFault {
        try {
            String toAddress = messageCtx.getTo().getAddress();
            //Here we try to locate the topic. It can be either a query parameter of the input address or a header
            //in the SOAP evvelope
            URI topic = null;

            SOAPEnvelope requestEnvelope = messageCtx.getEnvelope();
            int querySeperatorIndex = toAddress.indexOf('?');
            if (querySeperatorIndex > 0) {
                String queryString = toAddress.substring(querySeperatorIndex + 1);
                HashMap map = new HashMap();
                StringTokenizer t = new StringTokenizer(queryString, "=&");
                while (t.hasMoreTokens()) {
                    map.put(t.nextToken(), t.nextToken());
                }
                if (map.containsKey(EventingConstants.ElementNames.Topic)) {
                    topic = new URI((String)map.get(EventingConstants.ElementNames.Topic));
                }
            } else {
                OMElement topicHeader = requestEnvelope.getHeader().getFirstChildWithName(
                        new QName(EventingConstants.EXTENDED_EVENTING_NAMESPACE,
                                  EventingConstants.ElementNames.Topic));
                if (topicHeader != null) {
                    topic = new URI(topicHeader.getText());
                }
            }

            //Here we locate the content of the Event. If this is APP we unwrap APP wrapping elements.
            OMElement eventData = requestEnvelope.getBody().getFirstElement();
            if (AtomConstants.ATOM_NAMESPACE.equals(eventData.getNamespace().getNamespaceURI()) &&
                AtomConstants.ElementNames.Entry.equals(eventData.getLocalName())) {
                OMElement content = eventData.getFirstChildWithName(new QName(
                        AtomConstants.ATOM_NAMESPACE, AtomConstants.ElementNames.Content));
                if (content != null && content.getFirstElement() != null) {
                    eventData.getFirstElement();
                }
            }
            //Use in memory API to publish the event
            ServiceContext serviceContext = messageCtx.getServiceContext();
            PublicationClient client =
                    new PublicationClient(serviceContext.getConfigurationContext());
            client.sendPublication(eventData, serviceContext.getAxisService(), topic);
        } catch (OMException e) {
            throw AxisFault.makeFault(e);
        } catch (URISyntaxException e) {
            throw AxisFault.makeFault(e);
        }
    }