public void onNotify(RequestEvent event, ActivityContextInterface aci) {
		if (tracer.isFineEnabled())
			tracer.fine("Received Notify, on activity: " + aci.getActivity() + "\nRequest:\n" + event.getRequest());
		
		Request request = event.getRequest();
		SubscriptionData subscriptionData = getSubscriptionDataCMP();
		EventHeader eventHeader = (EventHeader) request.getHeader(EventHeader.NAME);
		if (eventHeader == null || !eventHeader.getEventType().equals(subscriptionData.getEventPackage())) {
			try {
				Response badEventResponse = this.messageFactory.createResponse(Response.BAD_EVENT, request);
				event.getServerTransaction().sendResponse(badEventResponse);
				// TODO: terminate dialog?
			} catch (Exception e) {
				if (tracer.isSevereEnabled()) {
					tracer.severe("Failed to create 489 answer to NOTIFY", e);
				}

			}
			return;
			
		} else {

			try {
				Response okResponse = this.messageFactory.createResponse(Response.OK, request);
				event.getServerTransaction().sendResponse(okResponse);				
			} catch (Exception e) {
				if (tracer.isSevereEnabled()) {
					tracer.severe("Failed to create 200 answer to NOTIFY", e);
				}
				return;
			}
		}
		// lets create Notify
		Notify notify = new Notify();
		notify.setSubscriber(subscriptionData.getSubscriberURI());

		ContentTypeHeader contentType = (ContentTypeHeader) request.getHeader(ContentTypeHeader.NAME);
		if (contentType != null) {
			// use CT Header?
			notify.setContentType(contentType.getContentType());
			notify.setContentSubType(contentType.getContentSubType());
			notify.setContent(new String(request.getRawContent()));
		}
		notify.setNotifier(subscriptionData.getNotifierURI());
		// check, whats in header.

		SubscriptionStateHeader subscriptionStateHeader = (SubscriptionStateHeader) request.getHeader(SubscriptionStateHeader.NAME);

		SubscriptionStatus state = SubscriptionStatus.fromString(subscriptionStateHeader.getState());
		notify.setStatus(state);
		
		// do magic
		switch (state) {
		case active:
		case pending:
			// check for exp
			if (subscriptionStateHeader.getExpires() != Notify.NO_TIMEOUT) {
				notify.setExpires(subscriptionStateHeader.getExpires());
				// set timer if needed
				SubscribeRequestType subscribeRequestType = getSubscribeRequestTypeCMP();
				if (subscribeRequestType == SubscribeRequestType.NEW || subscribeRequestType == SubscribeRequestType.REFRESH) {
					startExpiresTimer(aci,subscriptionStateHeader.getExpires());
					setSubscribeRequestTypeCMP(null);
				}								
			}

			break;
		case waiting:
			// nothing...
			break;
		case extension:
			notify.setStatusExtension(subscriptionStateHeader.getState());
		case terminated:
		 	// check reason
			String reasonString = subscriptionStateHeader.getReasonCode();
			TerminationReason reason = TerminationReason.fromString(reasonString);
			notify.setTerminationReason(reason);
			if (reason != null) {
				switch (reason) {
				case rejected:
				case noresource:
				case deactivated:
				case timeout:
					break;
				case probation:
				case giveup:
					if (subscriptionStateHeader.getRetryAfter() != Notify.NO_TIMEOUT) {
						notify.setRetryAfter(subscriptionStateHeader.getRetryAfter());
					}
					break;

				case extension:
					notify.setTerminationReasonExtension(reasonString);
					break;
				}
			}
			break;

		}
		// deliver to parent
		try {
			SbbLocalObjectExt sbbLocalObjectExt = sbbContext.getSbbLocalObject();
			if(state == SubscriptionStatus.terminated)
			{
				cancelExpiresTimer(aci);
				aci.detach(sbbLocalObjectExt);
				event.getDialog().delete();
			}
			((SubscriptionClientParentSbbLocalObject)sbbLocalObjectExt.getParent()).onNotify(notify, (SubscriptionClientChildSbbLocalObject) sbbLocalObjectExt);
		} catch (Exception e) {
			if (tracer.isSevereEnabled()) {
				tracer.severe("Received exception from parent on notify callback", e);
			}
		}

	}
public void onNotify ( RequestEvent event , ActivityContextInterface aci ) { if ( tracer . isFineEnabled ( ) ) tracer . fine ( "Received Notify, on activity: " + aci . getActivity ( ) + "\nRequest:\n" + event . getRequest ( ) ) ; Request request = event . getRequest ( ) ; SubscriptionData subscriptionData = getSubscriptionDataCMP ( ) ; EventHeader eventHeader = ( EventHeader ) request . getHeader ( EventHeader . NAME ) ; if ( eventHeader == null || ! eventHeader . getEventType ( ) . equals ( subscriptionData . getEventPackage ( ) ) ) { try { Response badEventResponse = this . messageFactory . createResponse ( Response . BAD_EVENT , request ) ; event . getServerTransaction ( ) . sendResponse ( badEventResponse ) ; } catch ( Exception e ) { if ( tracer . isSevereEnabled ( ) ) { tracer . severe ( "Failed to create 489 answer to NOTIFY" , e ) ; } } return ; } else { try { Response okResponse = this . messageFactory . createResponse ( Response . OK , request ) ; event . getServerTransaction ( ) . sendResponse ( okResponse ) ; } catch ( Exception e ) { if ( tracer . isSevereEnabled ( ) ) { tracer . severe ( "Failed to create 200 answer to NOTIFY" , e ) ; } return ; } } Notify notify = new Notify ( ) ; notify . setSubscriber ( subscriptionData . getSubscriberURI ( ) ) ; ContentTypeHeader contentType = ( ContentTypeHeader ) request . getHeader ( ContentTypeHeader . NAME ) ; if ( contentType != null ) { notify . setContentType ( contentType . getContentType ( ) ) ; notify . setContentSubType ( contentType . getContentSubType ( ) ) ; notify . setContent ( new String ( request . getRawContent ( ) ) ) ; } notify . setNotifier ( subscriptionData . getNotifierURI ( ) ) ; SubscriptionStateHeader subscriptionStateHeader = ( SubscriptionStateHeader ) request . getHeader ( SubscriptionStateHeader . NAME ) ; SubscriptionStatus state = SubscriptionStatus . fromString ( subscriptionStateHeader . getState ( ) ) ; notify . setStatus ( state ) ; switch ( state ) { case active : case pending : if ( subscriptionStateHeader . getExpires ( ) != Notify . NO_TIMEOUT ) { notify . setExpires ( subscriptionStateHeader . getExpires ( ) ) ; SubscribeRequestType subscribeRequestType = getSubscribeRequestTypeCMP ( ) ; if ( subscribeRequestType == SubscribeRequestType . NEW || subscribeRequestType == SubscribeRequestType . REFRESH ) { startExpiresTimer ( aci , subscriptionStateHeader . getExpires ( ) ) ; setSubscribeRequestTypeCMP ( null ) ; } } break ; case waiting : break ; case extension : notify . setStatusExtension ( subscriptionStateHeader . getState ( ) ) ; case terminated : String reasonString = subscriptionStateHeader . getReasonCode ( ) ; TerminationReason reason = TerminationReason . fromString ( reasonString ) ; notify . setTerminationReason ( reason ) ; if ( reason != null ) { switch ( reason ) { case rejected : case noresource : case deactivated : case timeout : break ; case probation : case giveup : if ( subscriptionStateHeader . getRetryAfter ( ) != Notify . NO_TIMEOUT ) { notify . setRetryAfter ( subscriptionStateHeader . getRetryAfter ( ) ) ; } break ; case extension : notify . setTerminationReasonExtension ( reasonString ) ; break ; } } break ; } try { SbbLocalObjectExt sbbLocalObjectExt = sbbContext . getSbbLocalObject ( ) ; if ( state == SubscriptionStatus . terminated ) { cancelExpiresTimer ( aci ) ; aci . detach ( sbbLocalObjectExt ) ; event . getDialog ( ) . delete ( ) ; } ( ( SubscriptionClientParentSbbLocalObject ) sbbLocalObjectExt . getParent ( ) ) . onNotify ( notify , ( SubscriptionClientChildSbbLocalObject ) sbbLocalObjectExt ) ; } catch ( Exception e ) { if ( tracer . isSevereEnabled ( ) ) { tracer . severe ( "Received exception from parent on notify callback" , e ) ; } } }
//////////////////////////////