/// <summary>
        /// Create a node notification.
        /// </summary>
        public string CreateNotification(string transactionId, ComplexNotification notification)
        {
            string id         = IdProvider.Get();
            string notifyData = _serializationHelper.SerializeToBase64String(notification);

            DoInsert(TABLE_NAME,
                     "Id;TransactionId;NotifyData",
                     id, transactionId, notifyData);
            return(id);
        }
Ejemplo n.º 2
0
        public void ProcessNotify(string transactionId)
        {
            AppendAuditLogEvent("NCT ProcessNotify() enter");

            LazyInit();

            ComplexNotification notification = _transactionManager.GetNotifyTransactionByTransactionId(transactionId);

            if (notification != null)
            {
            }
            AppendAuditLogEvent("NCT ProcessNotify() exit");
        }
 /// <summary>
 /// Get a node notification.
 /// </summary>
 public ComplexNotification GetNotification(string id)
 {
     try
     {
         ComplexNotification notification =
             DoSimpleQueryForObjectDelegate <ComplexNotification>(
                 TABLE_NAME, "Id", id, "NotifyData",
                 delegate(IDataReader reader, int rowNum)
         {
             return(_serializationHelper.DeserializeFromBase64String <ComplexNotification>(reader.GetString(0), null));
         });
         return(notification);
     }
     catch (Spring.Dao.IncorrectResultSizeDataAccessException)
     {
         return(null); // Not found
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="securityToken"></param>
        /// <param name="nodeAddress"></param>
        /// <param name="dataflow"></param>
        /// <param name="documents"></param>
        /// <returns></returns>
        string INetworkNodeBinding.Notify(string securityToken, string nodeAddress, string dataflow, NodeDocument[] documents)
        {
            Init();
            LOG.Debug("Notify");

            #region Validate

            if (documents == null || documents.Length == 0)
            {
                throw _service11Provider.FaultProvider.GetFault(EndpointVersionType.EN11, ENExceptionCodeType.E_InvalidParameter,
                                                                "Document not provided");
            }

            if (documents.Length > 1)
            {
                throw _service11Provider.FaultProvider.GetFault(EndpointVersionType.EN11, ENExceptionCodeType.E_InvalidParameter,
                                                                "Only one document per notification allowed");
            }

            SoapContext context = HttpSoapContext.RequestContext;
            if (context.Attachments != null && context.Attachments.Count > 0)
            {
                // TODO: Mark, why is this check here?  Calling Notify() from the endpoint client NotifyEvent(), NotifyStatus(), etc. methods fail here
                throw _service11Provider.FaultProvider.GetFault(EndpointVersionType.EN11, ENExceptionCodeType.E_InvalidParameter,
                                                                "Notify does not use DIME. Put content in the message.");
            }

            if (string.IsNullOrEmpty(dataflow))
            {
                throw _service11Provider.FaultProvider.GetFault(EndpointVersionType.EN11, ENExceptionCodeType.E_InvalidParameter,
                                                                "NULL dataflow argument");
            }



            #endregion

            try
            {
                LOG.Debug("Getting visit");
                NamedEndpointVisit visit = _service11Provider.VisitProvider.GetVisit(securityToken);


                NotificationMessageCategoryType messageCategory = NotificationMessageCategoryType.None;

                switch (dataflow.Trim().ToLower())
                {
                case "http://www.exchangenetwork.net/node/event":
                    messageCategory = NotificationMessageCategoryType.Event;
                    break;

                case "http://www.exchangenetwork.net/node/status":
                    messageCategory = NotificationMessageCategoryType.Status;
                    break;

                case "other":
                    messageCategory = NotificationMessageCategoryType.Status;
                    break;

                default:
                    throw _service11Provider.FaultProvider.GetFault(EndpointVersionType.EN11, ENExceptionCodeType.E_InvalidParameter,
                                                                    "Invalid dataflow argument: " + dataflow);
                }

                ComplexNotification notif = new ComplexNotification();
                notif.FlowName      = dataflow;
                notif.Uri           = nodeAddress;
                notif.Notifications = new List <Notification>();


                LOG.Debug("Spooling documents");
                foreach (NodeDocument wsdlDoc in documents)
                {
                    Notification not = new Notification();

                    not.Category           = messageCategory;
                    not.Name               = wsdlDoc.name;
                    not.Status             = new TransactionStatus();
                    not.Status.Status      = CommonTransactionStatusCodeProvider.Convert(wsdlDoc.type);
                    not.Status.Description = Encoding.ASCII.GetString(wsdlDoc.content);

                    LOG.Debug("   Notification:" + not);

                    notif.Notifications.Add(not);
                }

                LOG.Debug("GetStatus using visit: " + visit);
                TransactionStatus tranStatus = _service11Provider.TransactionService.Notify(notif, visit);

                LOG.Debug("TransactionStatus: " + tranStatus);
                return(CommonTransactionStatusCodeProvider.ConvertTo11Enum(tranStatus.Status));
            }
            catch (Exception ex)
            {
                LOG.Error("Error while fotifying", ex);
                throw _service11Provider.FaultProvider.GetFault(EndpointVersionType.EN11, ex);
            }
        }
Ejemplo n.º 5
0
        public TransactionStatus Notify(ComplexNotification notification, NamedEndpointVisit visit)
        {
            Activity activity      = null;
            string   transactionId = null;

            try
            {
                NodeVisit nodeVisit;
                MakeEndpointActivity(visit, ActivityType.Audit, NodeMethod.Notify,
                                     out nodeVisit, out activity);
                if (notification == null)
                {
                    throw FaultProvider.GetFault(visit.Version, ENExceptionCodeType.E_InvalidParameter,
                                                 "Empty input notification");
                }
                if (string.IsNullOrEmpty(notification.FlowName))
                {
                    throw FaultProvider.GetFault(visit.Version, ENExceptionCodeType.E_InvalidDataflow,
                                                 "Empty dataflow name");
                }
                bool   isFlowProtected;
                string flowId = FlowManager.GetDataFlowIdByName(notification.FlowName, out isFlowProtected);
                if (flowId == null)
                {
                    throw FaultProvider.GetFault(visit.Version, ENExceptionCodeType.E_InvalidDataflow,
                                                 "Flow \"{0}\" was not found", notification.FlowName);
                }
                activity.FlowName = notification.FlowName;
                if (CollectionUtils.IsNullOrEmpty(notification.Notifications))
                {
                    throw FaultProvider.GetFault(visit.Version, ENExceptionCodeType.E_InvalidParameter,
                                                 "Notifications array is empty");
                }
                if (isFlowProtected)
                {
                    ValidateUserPermissions(nodeVisit, notification.FlowName, null, NodeMethod.Notify,
                                            activity);
                }

                activity.AppendFormat("Notify request from {0} by {1}.", visit.IP, nodeVisit.Account.NaasAccount);
                foreach (Notification notifyElement in notification.Notifications)
                {
                    activity.AppendFormat("Notify element name {0}, type {1}, status.", notifyElement.Name,
                                          notifyElement.Category.ToString(), notifyElement.Status.ToString());
                }

                transactionId = TransactionManager.CreateNotifyTransaction(flowId, string.Empty, nodeVisit.Account.Id,
                                                                           CommonTransactionStatusCode.Received,
                                                                           null, notification, visit.Version, true);
                activity.TransactionId = transactionId;

                TransactionStatus rtnTransactionStatus =
                    new TransactionStatus(transactionId, CommonTransactionStatusCode.Received);

                NotificationManager.DoNotifyNotifications(rtnTransactionStatus, flowId, notification.FlowName,
                                                          nodeVisit.Account.NaasAccount);

                NotifyProcessor.Wakeup();

                return(rtnTransactionStatus);
            }
            catch (Exception ex)
            {
                if (transactionId != null)
                {
                    TransactionManager.SetTransactionStatusNoThrow(transactionId,
                                                                   CommonTransactionStatusCode.Failed,
                                                                   ex.Message, false);
                }
                if (activity != null)
                {
                    activity.Append(ExceptionUtils.ToShortString(ex));
                    activity.Type = ActivityType.Error;
                }
                if (ex is SoapException)
                {
                    throw;      // Throw directly since already SoapException
                }
                else
                {
                    throw FaultProvider.GetFault(visit.Version, ex);
                }
            }
            finally
            {
                if (activity != null)
                {
                    ActivityManager.Log(activity);
                }
            }
        }