Example #1
0
        private void UpdateIndexer(IndexerResource indexerResource)
        {
            var indexer = _indexerService.Get(indexerResource.Id);

            indexer.InjectFrom(indexerResource);
            indexer.Settings = SchemaDeserializer.DeserializeSchema(indexer.Settings, indexerResource.Fields);

            ValidateIndexer(indexer);

            _indexerService.Update(indexer);
        }
Example #2
0
        /// <summary>
        /// Creates a new Validator instance given a Schematron syntax schema and custom
        /// validator settings.
        /// </summary>
        /// <param name="xSchema">ISO Schematron complex syntax schema.
        /// Must not be null.</param>
        /// <param name="settings">Validator settings</param>
        /// <returns>A new Validator instance</returns>
        /// <exception cref="System.ArgumentException"/>
        /// <exception cref="System.ArgumentNullException"/>
        /// <exception cref="SyntaxException"/>
        public static Validator Create(XDocument xSchema, ValidatorSettings settings)
        {
            if (xSchema == null)
            {
                throw new ArgumentNullException("xSchema");
            }

            if (settings == null)
            {
                settings = new ValidatorSettings();
            }

            if (settings.InclusionsResolver == null)
            {
                settings.InclusionsResolver = new FileInclusionResolver();
            }

            if (xSchema.Root == null)
            {
                throw new ArgumentException("Schema must contain root node.");
            }

            Validator validator = null;

            // make a deep copy of the supplied XML
            XDocument xSchemaCopy = new XDocument(xSchema);

            // resolve ISO namespace
            XmlNamespaceManager nsManager = new XmlNamespaceManager(new NameTable());

            nsManager.AddNamespace("sch", Constants.ISONamespace);

            settings.Phase = DetermineSchemaPhase(xSchemaCopy.Root, settings.Phase, nsManager);

            // preprocessing - turn to minimal form
            Preprocess(xSchemaCopy, nsManager, settings);

            // deserialization
            Schema minimalizedSchema = SchemaDeserializer.Deserialize(xSchemaCopy, nsManager);

            // xpath preprocessing
            CompileXPathExpressions(minimalizedSchema);

            // create instance
            validator           = new Validator();
            validator.schema    = minimalizedSchema;
            validator.MinSyntax = xSchemaCopy;

            return(validator);
        }
Example #3
0
        private Notification ConvertToNotification(NotificationResource notificationResource)
        {
            var notification = _notificationService.Schema()
                               .SingleOrDefault(i =>
                                                i.Implementation.Equals(notificationResource.Implementation,
                                                                        StringComparison.InvariantCultureIgnoreCase));

            if (notification == null)
            {
                throw new BadRequestException("Invalid Notification Implementation");
            }

            notification.InjectFrom(notificationResource);
            notification.Settings = SchemaDeserializer.DeserializeSchema(notification.Settings, notificationResource.Fields);

            return(notification);
        }
Example #4
0
        private Indexer GetIndexer(IndexerResource indexerResource)
        {
            var indexer = _indexerService.Schema()
                          .SingleOrDefault(i =>
                                           i.Implementation.Equals(indexerResource.Implementation,
                                                                   StringComparison.InvariantCultureIgnoreCase));

            if (indexer == null)
            {
                throw new BadRequestException("Invalid Indexer Implementation");
            }

            indexer.InjectFrom(indexerResource);
            indexer.Settings = SchemaDeserializer.DeserializeSchema(indexer.Settings, indexerResource.Fields);

            ValidateIndexer(indexer);

            return(indexer);
        }