public static void Validate(Subscription subscription)
        {
            EnsureDestinationIsValidURI(subscription);
            EnsureDestinationHasEndSlash(subscription);

            if (!(subscription.Schedule == null ^ string.IsNullOrEmpty(subscription.Trigger)))
            {
                throw new EpcisException(ExceptionType.SubscriptionControlsException, "Only one of the schedule and trigger must be provided");
            }
            if (!SubscriptionSchedule.IsValid(subscription))
            {
                throw new EpcisException(ExceptionType.SubscriptionControlsException, "Provided schedule parameters are invalid");
            }
        }
示例#2
0
            private void ValidateRequest(Subscription subscription)
            {
                var query = _queries.SingleOrDefault(q => q.Name == subscription.QueryName);

                if (query == null)
                {
                    throw new EpcisException(ExceptionType.NoSuchNameException, $"Query with name '{subscription.QueryName}' is not implemented");
                }
                else if (!query.AllowSubscription)
                {
                    throw new EpcisException(ExceptionType.SubscribeNotPermittedException, $"Query with name '{subscription.QueryName}' does not allow subscription");
                }
                else if (!(subscription.Schedule == null ^ string.IsNullOrEmpty(subscription.Trigger)))
                {
                    throw new EpcisException(ExceptionType.SubscriptionControlsException, "Only one of the schedule and trigger must be provided");
                }
                else if (!SubscriptionSchedule.IsValid(subscription))
                {
                    throw new EpcisException(ExceptionType.SubscriptionControlsException, "Provided schedule parameters are invalid");
                }

                EnsureDestinationIsValidURI(subscription);
                EnsureDestinationHasEndSlash(subscription);
            }