private static void read_oai_details(XmlReader readerXml, OAI_PMH_Configuration config)
        {
            bool baseSpecified = false;

            // Just step through the subtree of this
            while (readerXml.Read())
            {
                if (readerXml.NodeType == XmlNodeType.Element)
                {
                    switch (readerXml.Name.ToLower())
                    {
                        case "oai-pmh":
                            if (readerXml.Value.Trim().ToLower() == "false")
                                config.Enabled = false;
                            break;

                        case "repository":
                            if (readerXml.MoveToAttribute("IdentifierBase"))
                            {
                                baseSpecified = true;
                                config.Identifier_Base = readerXml.Value.Trim();
                            }
                            break;

                        case "identify":
                            read_oai_details_identify(readerXml.ReadSubtree(), config, baseSpecified );
                            break;

                        case "metadataprefixes":
                            read_oai_details_metadataPrefixes(readerXml.ReadSubtree(), config);
                            break;
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary> Constructor for a new instance of the Oai_MainWriter class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <param name="Query_String"> URL Query string to parse for OAI-PMH verbs and other values </param>
        public Oai_MainWriter(NameValueCollection Query_String, RequestCache RequestSpecificValues) : base(RequestSpecificValues)

        {
            // Build list of valid arguments
            validArgs = new List <string>
            {
                "from",
                "until",
                "metadataPrefix",
                "set",
                "resumptionToken",
                "identifier",
                "verb",
                "portal",
                "urlrelative"
            };

            // Load the list of OAI sets
            oaiSets     = SobekCM_Database.Get_OAI_Sets();
            queryString = Query_String;

            // Set the response type
            HttpContext.Current.Response.ContentType = "text/xml";

            // Determine some global settings
            if (UI_ApplicationCache_Gateway.Configuration.OAI_PMH != null)
            {
                config = UI_ApplicationCache_Gateway.Configuration.OAI_PMH;
                oai_resource_identifier_base = UI_ApplicationCache_Gateway.Configuration.OAI_PMH.Identifier_Base;
                oai_repository_name          = UI_ApplicationCache_Gateway.Configuration.OAI_PMH.Name;
                oai_repository_identifier    = UI_ApplicationCache_Gateway.Configuration.OAI_PMH.Identifier;
            }
            else
            {
                config = new OAI_PMH_Configuration();
                config.Set_Default();
                config.Enabled = true;
            }
            if (String.IsNullOrEmpty(oai_resource_identifier_base))
            {
                oai_resource_identifier_base = "oai:" + UI_ApplicationCache_Gateway.Settings.System.System_Abbreviation + ":";
            }
            if (String.IsNullOrEmpty(oai_repository_name))
            {
                oai_repository_name = UI_ApplicationCache_Gateway.Settings.System.System_Name;
            }
            if (String.IsNullOrEmpty(oai_repository_identifier))
            {
                oai_repository_identifier = UI_ApplicationCache_Gateway.Settings.System.System_Abbreviation;
            }

            // Get the list of metadata prefixes permissiable by the system
            metadataPrefixes = new List <string>();
            foreach (OAI_PMH_Metadata_Format thisConfig in config.Metadata_Prefixes)
            {
                metadataPrefixes.Add(thisConfig.Prefix);
            }
        }
        /// <summary> Static class is used to read the configuration file defining oai-pmh elements and metadata prefixes </summary>
        /// <param name="ConfigFile"> Path and name of the configuration XML file to read </param>
        /// <param name="SystemName"> System name from the system-wide settings, used as a default name for OAI-PMH </param>
        /// <param name="SystemAbbreviation"> System identifyer from the system-wide settings, used as a default identifier for OAI-PMH </param>
        /// <param name="SystemEmail"> System email(s) from the system-wide settings, used as default admin email(s) for OAI-PMH </param>
        /// <returns> Fully configured OAI-PMH configuration object </returns>
        public static OAI_PMH_Configuration Read_Config(string ConfigFile, string SystemName, string SystemAbbreviation, string SystemEmail )
        {
            // Create config value and set some default values
            OAI_PMH_Configuration returnValue = new OAI_PMH_Configuration
            {
                Identifier = SystemAbbreviation,
                Name = SystemName,
                Identifier_Base = "oai:" + SystemAbbreviation.ToLower() + ":"
            };
            returnValue.Add_Admin_Email(SystemEmail);

            // Streams used for reading
            Stream readerStream = null;
            XmlTextReader readerXml = null;

            try
            {
                // Open a link to the file
                readerStream = new FileStream(ConfigFile, FileMode.Open, FileAccess.Read);

                // Open a XML reader connected to the file
                readerXml = new XmlTextReader(readerStream);

                while (readerXml.Read())
                {
                    if (readerXml.NodeType == XmlNodeType.Element)
                    {
                        switch (readerXml.Name.ToLower())
                        {
                            case "oai-pmh":
                                read_oai_details(readerXml.ReadSubtree(), returnValue);
                                break;
                        }
                    }
                }
            }
            catch (Exception ee)
            {
                returnValue.Error = ee.Message;
            }
            finally
            {
                if (readerXml != null)
                {
                    readerXml.Close();
                }
                if (readerStream != null)
                {
                    readerStream.Close();
                }
            }

            return returnValue;
        }
        /// <summary> Constructor for a new instance of the Oai_MainWriter class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <param name="Query_String"> URL Query string to parse for OAI-PMH verbs and other values </param>
        public Oai_MainWriter(NameValueCollection Query_String, RequestCache RequestSpecificValues)
            : base(RequestSpecificValues)
        {
            // Build list of valid arguments
            validArgs = new List<string>
                            {
                                "from",
                                "until",
                                "metadataPrefix",
                                "set",
                                "resumptionToken",
                                "identifier",
                                "verb",
                                "portal",
                                "urlrelative"
                            };

            // Load the list of OAI sets
            oaiSets = SobekCM_Database.Get_OAI_Sets();
            queryString = Query_String;

            // Set the response type
            HttpContext.Current.Response.ContentType = "text/xml";

            // Determine some global settings
            if (UI_ApplicationCache_Gateway.Settings.OAI_PMH != null)
            {
                config = UI_ApplicationCache_Gateway.Settings.OAI_PMH;
                oai_resource_identifier_base = UI_ApplicationCache_Gateway.Settings.OAI_PMH.Identifier_Base;
                oai_repository_name = UI_ApplicationCache_Gateway.Settings.OAI_PMH.Name;
                oai_repository_identifier = UI_ApplicationCache_Gateway.Settings.OAI_PMH.Identifier;
            }
            else
            {
                config = new OAI_PMH_Configuration();
                config.Set_Default();
                config.Enabled = true;
            }
            if (String.IsNullOrEmpty(oai_resource_identifier_base)) oai_resource_identifier_base = "oai:" + UI_ApplicationCache_Gateway.Settings.System.System_Abbreviation + ":";
            if (String.IsNullOrEmpty(oai_repository_name)) oai_resource_identifier_base = UI_ApplicationCache_Gateway.Settings.System.System_Name;
            if (String.IsNullOrEmpty(oai_repository_identifier)) oai_resource_identifier_base = UI_ApplicationCache_Gateway.Settings.System.System_Abbreviation;

            // Get the list of metadata prefixes permissiable by the system
            metadataPrefixes = new List<string>();
            foreach (OAI_PMH_Metadata_Format thisConfig in config.Metadata_Prefixes)
            {
                metadataPrefixes.Add(thisConfig.Prefix);
            }
        }
Beispiel #5
0
        /// <summary> Constructor for a new instance of the InstanceWide_Configuration class </summary>
        public InstanceWide_Configuration()
        {
            // Create some of the configuration stuff
            Authentication     = new Authentication_Configuration();
            BriefItemMapping   = new BriefItemMapping_Configuration();
            ContactForm        = new ContactForm_Configuration();
            Engine             = new Engine_Server_Configuration();
            Extensions         = new Extension_Configuration();
            QualityControlTool = new QualityControl_Configuration();
            Metadata           = new Metadata_Configuration();
            OAI_PMH            = new OAI_PMH_Configuration();
            UI     = new InstanceWide_UI_Configuration();
            Source = new Configuration_Source_Info();

            // Set some defaults
            HasData = false;
        }
 private static void read_oai_details_metadataPrefixes(XmlReader readerXml, OAI_PMH_Configuration config)
 {
     while (readerXml.Read())
     {
         if (readerXml.NodeType == XmlNodeType.Element)
         {
             switch (readerXml.Name.ToLower())
             {
                 case "metadataformat":
                     OAI_PMH_Metadata_Format component = new OAI_PMH_Metadata_Format();
                     if (readerXml.MoveToAttribute("Prefix"))
                         component.Prefix = readerXml.Value.Trim();
                     if (readerXml.MoveToAttribute("Schema"))
                         component.Schema = readerXml.Value.Trim();
                     if (readerXml.MoveToAttribute("MetadataNamespace"))
                         component.MetadataNamespace = readerXml.Value.Trim();
                     if (readerXml.MoveToAttribute("Assembly"))
                         component.Assembly = readerXml.Value.Trim();
                     if (readerXml.MoveToAttribute("Namespace"))
                         component.Namespace = readerXml.Value.Trim();
                     if (readerXml.MoveToAttribute("Class"))
                         component.Class = readerXml.Value.Trim();
                     if ((readerXml.MoveToAttribute("Enabled")) && (readerXml.Value.Trim().ToLower() == "false"))
                         component.Enabled = false;
                     if ((!String.IsNullOrEmpty(component.Prefix)) && (!String.IsNullOrEmpty(component.Schema)) && (!String.IsNullOrEmpty(component.MetadataNamespace)) && (!String.IsNullOrEmpty(component.Class)))
                     {
                         config.Metadata_Prefixes.Add(component);
                     }
                     break;
             }
         }
     }
 }
        private static void read_oai_details_identify(XmlReader readerXml, OAI_PMH_Configuration config, bool baseSpecified )
        {
            bool emailFound = false;

            while (readerXml.Read())
            {
                if (readerXml.NodeType == XmlNodeType.Element)
                {
                    switch (readerXml.Name.ToLower())
                    {
                        case "name":
                            readerXml.Read();
                            config.Name = readerXml.Value.Trim();
                            break;

                        case "identifier":
                            readerXml.Read();
                            config.Identifier = readerXml.Value.Trim();
                            if (!baseSpecified)
                                config.Identifier_Base = "oai:" + config.Identifier.ToLower() + ":";
                            break;

                        case "adminemail":
                            if (!emailFound)
                            {
                                config.Admin_Emails.Clear();
                                emailFound = true;
                            }
                            readerXml.Read();
                            config.Add_Admin_Email(readerXml.Value.Trim());
                            break;

                        case "description":
                            readerXml.Read();
                            config.Add_Description(readerXml.Value.Trim());
                            break;

                    }
                }
            }
        }