/// <summary> /// Add the details to the subscription /// </summary> /// <param name="details">The details object</param> public void AddDetails(SubscriptionDetails details) { if (details != null) { if ((details.DirNodeID != null) && (details.DirNodeID.Length > 0)) { this.DirNodeID = details.DirNodeID; } if ((details.DirNodeName != null) && (details.DirNodeName.Length > 0)) { this.DirNodeName = details.DirNodeName; } } }
/// <summary> /// Handle when delivered /// </summary> /// <param name="poBox">POBox reference</param> /// <param name="subscription">subscription </param> /// <returns>True if successfull, else false</returns> private bool DoDelivered(POBox poBox, Subscription subscription) { bool result = false; POBoxService poService = new POBoxService(); log.Debug(" calling the PO Box server to get subscription state"); log.Debug(" domainID: " + subscription.DomainID); log.Debug(" fromID: " + subscription.FromIdentity); log.Debug(" SubID: " + subscription.MessageID); // Resolve the PO Box location for the inviter Uri poUri = DomainProvider.ResolvePOBoxLocation(subscription.DomainID, subscription.FromIdentity); if (poUri != null) { poService.Url = poUri.ToString() + poServiceLabel; log.Debug(" connecting to the Post Office Service : " + poService.Url); } else { log.Debug(" Could not resolve the PO Box location for: " + subscription.FromIdentity); return(result); } try { WebState webState = new WebState( subscription.DomainID, subscription.SubscriptionCollectionID, subscription.ToIdentity); webState.InitializeWebClient(poService, subscription.DomainID); } catch (NeedCredentialsException) { log.Debug(" no credentials - back to sleep"); return(result); } try { SubscriptionInformation subInfo = poService.GetSubscriptionInfo( subscription.DomainID, subscription.FromIdentity, subscription.MessageID, subscription.SubscriptionCollectionID); switch (subInfo.Status) { case POBoxStatus.Success: { log.Debug(" subInfo.FromName: " + subInfo.FromName); log.Debug(" subInfo.ToName: " + subInfo.ToName); log.Debug(" subInfo.State: " + subInfo.State.ToString()); log.Debug(" subInfo.Disposition: " + subInfo.Disposition.ToString()); if (subInfo.Disposition == ( int )SubscriptionDispositions.Accepted) { log.Debug(" creating collection..."); // Check to make sure the collection proxy doesn't already exist. if (poBox.StoreReference.GetCollectionByID(subscription.SubscriptionCollectionID) == null) { SubscriptionDetails details = new SubscriptionDetails(); details.DirNodeID = subInfo.DirNodeID; details.DirNodeName = subInfo.DirNodeName; subscription.SubscriptionRights = (Access.Rights)subInfo.AccessRights; subscription.AddDetails(details); poBox.Commit(subscription); // create slave stub subscription.ToMemberNodeID = subInfo.ToNodeID; subscription.CreateSlave(poBox.StoreReference); } // acknowledge the message which removes the originator's subscription. SubscriptionMsg subMsg = subscription.GenerateSubscriptionMessage(); POBoxStatus wsStatus = poService.AckSubscription(subMsg); if ((wsStatus == POBoxStatus.Success) || (wsStatus == POBoxStatus.AlreadyAccepted)) { // done with the subscription - move to local subscription to the ready state log.Debug(" moving subscription to ready state."); subscription.SubscriptionState = SubscriptionStates.Ready; poBox.Commit(subscription); result = true; } else { log.Debug(" failed acknowledging a subscription"); log.Debug(" status = {0}", wsStatus.ToString()); log.Debug(" deleting the local subscription"); poBox.Commit(poBox.Delete(subscription)); result = true; } } break; } case POBoxStatus.AlreadyAccepted: { log.Debug(" the subscription has already been accepted by another client."); result = CreateCollectionProxy(poBox, subscription); break; } case POBoxStatus.InvalidState: { log.Debug(" invalid state"); break; } default: { log.Debug(" server error = {0}. Deleting subscription.", subInfo.Status.ToString()); poBox.Commit(poBox.Delete(subscription)); result = true; break; } } } catch (Exception e) { log.Error(" DoDelivered failed with an exception"); log.Error(e.Message); log.Error(e.StackTrace); } return(result); }