public void handleGetStatusRequest()

in modules/core/src/main/java/org/apache/savan/atom/AtomMessageReceiverDelegator.java [185:252]


    public void handleGetStatusRequest(SavanMessageContext getStatusMessage,
                                       MessageContext outMessage) throws SavanException {

        if (outMessage == null)
            throw new SavanException(
                    "Eventing protocol need to sent the SubscriptionResponseMessage. But the outMessage is null");

        MessageContext subscriptionMsgCtx = getStatusMessage.getMessageContext();

        String id = (String)getStatusMessage
                .getProperty(AtomConstants.TransferedProperties.SUBSCRIBER_UUID);
        if (id == null)
            throw new SavanException("Cannot fulfil request. AbstractSubscriber ID not found");

        //setting the action
        outMessage.getOptions().setAction(AtomConstants.Actions.UnsubscribeResponse);

        SOAPEnvelope outMessageEnvelope = outMessage.getEnvelope();
        SOAPFactory factory = null;

        if (outMessageEnvelope != null) {
            factory = (SOAPFactory)outMessageEnvelope.getOMFactory();
        } else {
            factory = (SOAPFactory)subscriptionMsgCtx.getEnvelope().getOMFactory();
            outMessageEnvelope = factory.getDefaultEnvelope();

            try {
                outMessage.setEnvelope(outMessageEnvelope);
            } catch (AxisFault e) {
                throw new SavanException(e);
            }
        }

        SubscriberStore store = CommonUtil
                .getSubscriberStore(getStatusMessage.getMessageContext().getAxisService());


        if (store == null) {
            throw new SavanException("AbstractSubscriber Store was not found");
        }

        AtomSubscriber subscriber = (AtomSubscriber)store.retrieve(id);
        if (subscriber == null) {
            throw new SavanException("AbstractSubscriber not found");
        }

        OMNamespace ens =
                factory.createOMNamespace(AtomConstants.ATOM_NAMESPACE, AtomConstants.ATOM_PREFIX);
        OMElement getStatusResponseElement =
                factory.createOMElement(AtomConstants.ElementNames.GetStatusResponse, ens);

        Date expires = subscriber.getSubscriptionEndingTime();
        if (expires != null) {
            OMElement expiresElement =
                    factory.createOMElement(AtomConstants.ElementNames.Expires, ens);
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(expires);
            String expirationString = ConverterUtil.convertToString(calendar);
            expiresElement.setText(expirationString);
            getStatusResponseElement.addChild(expiresElement);
        }

        outMessageEnvelope.getBody().addChild(getStatusResponseElement);

        //setting the message type
        outMessage.setProperty(SavanConstants.MESSAGE_TYPE, new Integer(
                SavanConstants.MessageTypes.GET_STATUS_RESPONSE_MESSAGE));
    }