public void notifySipSubscriber( Object content, ContentTypeHeader contentTypeHeader, Subscription subscription, EntityManager entityManager, ImplementedSubscriptionControlSbbLocalObject childSbb) { try { // get subscription dialog ActivityContextInterface dialogACI = sipSubscriptionHandler .sbb .getActivityContextNamingfacility() .lookup(subscription.getKey().toString()); if (dialogACI != null) { Dialog dialog = (Dialog) dialogACI.getActivity(); // create notify Request notify = createNotify(dialog, subscription); // add content if (content != null) { notify = setNotifyContent(subscription, notify, content, contentTypeHeader, childSbb); } // ....aayush added code here (with ref issue #567) notify.addHeader(addPChargingVectorHeader()); // send notify in dialog related with subscription dialog.sendRequest( sipSubscriptionHandler.sbb.getSipProvider().getNewClientTransaction(notify)); if (logger.isDebugEnabled()) { logger.debug( "NotifySubscribers: subscription " + subscription.getKey() + " sent request:\n" + notify.toString()); } } else { // clean up logger.warn( "Unable to find dialog aci to notify subscription " + subscription.getKey() + ". Removing subscription data"); sipSubscriptionHandler.sbb.removeSubscriptionData( entityManager, subscription, null, null, childSbb); } } catch (Exception e) { logger.error("failed to notify subscriber", e); } }
/** * Used by {@link ImplementedSubscriptionControlSbbLocalObject} to provide the authorization to a * new sip subscription request. * * @param event * @param subscriber * @param notifier * @param subscriptionKey * @param expires * @param responseCode * @param entityManager * @param childSbb */ public void newSipSubscriptionAuthorization( ServerTransaction serverTransaction, ActivityContextInterface serverTransactionACI, String subscriber, String subscriberDisplayName, Notifier notifier, SubscriptionKey key, int expires, int responseCode, boolean eventList, SubscriptionControlDataSource dataSource, ImplementedSubscriptionControlSbbLocalObject childSbb) { DialogActivity dialog = (DialogActivity) serverTransaction.getDialog(); ActivityContextInterface dialogAci = null; // send response try { Response response = sipSubscriptionHandler .sbb .getMessageFactory() .createResponse(responseCode, serverTransaction.getRequest()); if (responseCode == Response.ACCEPTED || responseCode == Response.OK) { // attach to dialog SbbLocalObject sbbLocalObject = sipSubscriptionHandler.sbb.getSbbContext().getSbbLocalObject(); dialogAci = sipSubscriptionHandler .sbb .getSipActivityContextInterfaceFactory() .getActivityContextInterface(dialog); dialogAci.attach(sbbLocalObject); if (serverTransactionACI != null) { serverTransactionACI.detach(sbbLocalObject); } // finish and send response response = sipSubscriptionHandler.addContactHeader(response); response.addHeader( sipSubscriptionHandler.sbb.getHeaderFactory().createExpiresHeader(expires)); serverTransaction.sendResponse(response); } else { response = sipSubscriptionHandler.addContactHeader(response); serverTransaction.sendResponse(response); if (tracer.isInfoEnabled()) { tracer.info( "Subscription: subscriber=" + subscriber + ",notifier=" + notifier + ",eventPackage=" + key.getEventPackage() + " not authorized (" + responseCode + ")"); } return; } } catch (Exception e) { tracer.severe("Can't send new subscription request's reponse", e); // cleanup try { Response response = sipSubscriptionHandler .sbb .getMessageFactory() .createResponse(Response.SERVER_INTERNAL_ERROR, serverTransaction.getRequest()); response = sipSubscriptionHandler.addContactHeader(response); serverTransaction.sendResponse(response); } catch (Exception f) { tracer.severe("Can't send RESPONSE", f); } return; } // create subscription, initial status depends on authorization Subscription.Status initialStatus = responseCode == Response.ACCEPTED ? Subscription.Status.pending : Subscription.Status.active; Subscription subscription = new Subscription( key, subscriber, notifier, initialStatus, subscriberDisplayName, expires, eventList, dataSource); if (!eventList || (responseCode == Response.ACCEPTED)) { // single resource or pending subscription (no notify content), notify subscriber try { sipSubscriptionHandler .getSipSubscriberNotificationHandler() .createAndSendNotify(dataSource, subscription, dialog, childSbb); } catch (Exception e) { tracer.severe("failed to notify subscriber", e); } } // notify winfo subscribers sipSubscriptionHandler .sbb .getWInfoSubscriptionHandler() .notifyWinfoSubscriptions(dataSource, subscription, childSbb); // bind name for dialog aci try { sipSubscriptionHandler.sbb.getActivityContextNamingfacility().bind(dialogAci, key.toString()); } catch (Exception e) { tracer.severe("failed to bind a name to dialog's aci", e); } // set new timer sipSubscriptionHandler.sbb.setSubscriptionTimerAndPersistSubscription( subscription, expires + 1, dialogAci); if (eventList && (responseCode == Response.OK)) { // it's a resource list and active subscription, delegate to the event list control for // further process of the new subscription if (!sipSubscriptionHandler .sbb .getEventListSubscriptionHandler() .createSubscription(subscription)) { // sip subscription sipSubscriptionHandler .getRemoveSipSubscriptionHandler() .removeSipSubscription(dialogAci, subscription, dataSource, childSbb); } } if (tracer.isInfoEnabled()) { tracer.info("Created " + subscription); } }