Skip to content

OaiPmhNet is a .NET library implementing the OAI-PMH specification.

License

Notifications You must be signed in to change notification settings

niklr/OaiPmhNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OaiPmhNet

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.

https://www.openarchives.org/pmh/

Dependencies:

Implementation steps

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.

1. Implement IRecordRepository interface

public interface IRecordRepository
{
	Record GetRecord(string identifier, string metadataPrefix);
	RecordContainer GetRecords(ArgumentContainer arguments, IResumptionToken resumptionToken = null);
	RecordContainer GetIdentifiers(ArgumentContainer arguments, IResumptionToken resumptionToken = null);
}

2. Implement IMetadataFormatRepository interface

public interface IMetadataFormatRepository
{
	MetadataFormat GetMetadataFormat(string prefix);
	IEnumerable<MetadataFormat> GetMetadataFormats();
}

3. Implement ISetRepository interface

public interface ISetRepository
{
	SetContainer GetSets(ArgumentContainer arguments, IResumptionToken resumptionToken = null);
}

4. Override default configuration (example)

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");

5. Initialize the DataProvider class

DataProvider provider = new DataProvider(config, metadataFormatRepository, recordRepository, setRepository);

6. Pass ArgumentContainer to DataProvider

ArgumentContainer arguments = new ArgumentContainer(verb, metadataPrefix, resumptionToken, identifier, from, until, set);
XDocument document = provider.ToXDocument(DateTime.Now, arguments);

7. (Optional) Convert response to XHTML using XSLT

document?.Root?.AddBeforeSelf(new XProcessingInstruction("xml-stylesheet", "type='text/xsl' href='/Content/xsl/oai2.xsl'"));
return this.Content(provider.ToString(document), "application/xml");

About

OaiPmhNet is a .NET library implementing the OAI-PMH specification.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages