OaiPmhNet is a .NET library implementing the OAI-PMH specification. The Open Archives Initiative Protocol for Metadata Harvesting (OAI-PMH) is a low-barrier mechanism for repository interoperability. Data Providers are repositories that expose structured metadata via OAI-PMH. Service Providers then make OAI-PMH service requests to harvest that metadata. OAI-PMH is a set of six verbs or services that are invoked within HTTP.
http://www.openarchives.org/pmh/
The OaiPmhNet library can be customized to work with arbitrary data repositories by implementing 3 interfaces. A demonstration implementation can be found in the unit test project.
public interface IRecordRepository
{
Record GetRecord(string identifier, string metadataPrefix);
RecordContainer GetRecords(ArgumentContainer arguments, IResumptionToken resumptionToken = null);
RecordContainer GetIdentifiers(ArgumentContainer arguments, IResumptionToken resumptionToken = null);
}
public interface IMetadataFormatRepository
{
MetadataFormat GetMetadataFormat(string prefix);
IEnumerable<MetadataFormat> GetMetadataFormats();
}
public interface ISetRepository
{
SetContainer GetSets(ArgumentContainer arguments, IResumptionToken resumptionToken = null);
}
var config = OaiConfiguration.Instance;
config.RepositoryName = constants.APPLICATION_NAME;
config.BaseUrl = () =>
{
Uri baseUri = new Uri(UrlHelper.BaseSiteUri, "oai2");
return baseUri.AbsoluteUri;
};
config.DeletedRecord = "transient";
config.AdminEmails = new string[] { constants.SUPPORT_EMAIL };
config.ResumptionTokenCustomParameterNames.Add("offset");
DataProvider provider = new DataProvider(config, metadataFormatRepository, recordRepository, setRepository);
ArgumentContainer arguments = new ArgumentContainer(verb, metadataPrefix, resumptionToken, identifier, from, until, set);
XDocument document = provider.ToXDocument(DateTime.Now, arguments);
document?.Root?.AddBeforeSelf(new XProcessingInstruction("xml-stylesheet", "type='text/xsl' href='/Content/xsl/oai2.xsl'"));
return this.Content(provider.ToString(document), "application/xml");