protocol

package
v0.0.0-...-d207067 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package protocol defines the golang objects for the OAI protocol It provides objects to harvest items from repository

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type About

type About struct {
	Body []byte `xml:",innerxml"`
}

About is an optional and repeatable container to hold data about the metadata part of the record.

The contents of an about container must conform to an XML Schema. Individual implementation communities may create XML Schema that define specific uses for the contents of about containers. Two common uses of about containers are: - rights statements: some repositories may find it desirable to attach terms of use to the metadata they make available through the OAI-PMH. No specific set of XML tags for rights expression is defined by OAI-PMH, but the about container is provided to allow for encapsulating community-defined rights tags. - provenance statements: One suggested use of the about container is to indicate the provenance of a metadata record, e.g. whether it has been harvested itself and if so from which repository, and when. An XML Schema for such a provenance container, as well as some supporting information is available from the accompanying Implementation Guidelines document.

http://www.openarchives.org/OAI/openarchivesprotocol.html#Record

func (About) String

func (ab About) String() string

String returns the string representation

type Description

type Description struct {
	Body []byte `xml:",innerxml"`
}

Description is an extensible mechanism for communities to describe their repositories.

For example, the description container could be used to include collection-level metadata in the response to the Identify request. Implementation Guidelines are available to give directions with this respect. Each description container must be accompanied by the URL of an XML schema describing the structure of the description container.

http://www.openarchives.org/OAI/openarchivesprotocol.html#Identify

func (Description) String

func (ab Description) String() string

String returns the string representation

type Error

type Error struct {
	Code    string `xml:"code,attr"`
	Message string `xml:",chardata"`
}

Error represents an OAI error

In event of an error or exception condition, repositories must indicate OAI-PMH errors, distinguished from HTTP Status-Codes, by including one or more error elements in the response. While one error element is sufficient to indicate the presence of the error or exception condition, repositories should report all errors or exceptions that arise from processing the request. Each error element must have a code attribute that must be from the following table; each error element may also have a free text string value to provide information about the error that is useful to a human reader. These strings are not defined by the OAI-PMH.

Error Codes - badArgument The request includes illegal arguments, is missing required arguments, includes a repeated argument, or values for arguments have an illegal syntax. - badResumptionToken The value of the resumptionToken argument is invalid or expired. - badVerb Value of the verb argument is not a legal OAI-PMH verb, the verb argument is missing, or the verb argument is repeated. - cannotDisseminateFormat The metadata format identified by the value given for the metadataPrefix argument is not supported by the item or by the repository.

  • idDoesNotExist The value of the identifier argument is unknown or illegal in this repository.
  • noRecordsMatch The combination of the values of the from, until, set and metadataPrefix arguments results in an empty list.
  • noMetadataFormats There are no metadata formats available for the specified item.
  • noSetHierarchy The repository does not support sets.

http://www.openarchives.org/OAI/openarchivesprotocol.html#ErrorConditions

type GetRecord

type GetRecord struct {
	Record Record `xml:"record"`
}

GetRecord is used to retrieve an individual metadata record from a repository.

Required arguments specify the identifier of the item from which the record is requested and the format of the metadata that should be included in the record. Depending on the level at which a repository tracks deletions, a header with a "deleted" value for the status attribute may be returned, in case the metadata format specified by the metadataPrefix is no longer available from the repository or from the specified item.

http://www.openarchives.org/OAI/openarchivesprotocol.html#GetRecord

type Header struct {
	Identifier string   `xml:"identifier"`
	DateStamp  string   `xml:"datestamp"`
	SetSpec    []string `xml:"setSpec"`
	Status     string   `xml:"status,attr"`
}

Header contains the unique identifier of the item and properties necessary for selective harvesting.

The header consists of the following parts: - the unique identifier -- the unique identifier of an item in a repository; - the datestamp -- the date of creation, modification or deletion of the record for the purpose of selective harvesting. - zero or more setSpec elements -- the set membership of the item for the purpose of selective harvesting. - an optional status attribute with a value of deleted indicates the withdrawal of availability of the specified metadata format for the item, dependent on the repository support for deletions.

http://www.openarchives.org/OAI/openarchivesprotocol.html#Record

type Identify

type Identify struct {
	// must
	RepositoryName    string   `xml:"repositoryName"`
	BaseURL           string   `xml:"baseURL"`
	ProtocolVersion   string   `xml:"protocolVersion"`
	EarliestDatestamp string   `xml:"earliestDatestamp"`
	DeletedRecord     string   `xml:"deletedRecord"`
	Granularity       string   `xml:"granularity"`
	AdminEmail        []string `xml:"adminEmail"`
	// may
	Description []Description `xml:"description"`
}

Identify is a verb used to retrieve information about a repository.

Some of the information returned is required as part of the OAI-PMH. Repositories may also employ the Identify verb to return additional descriptive information. The response must include one instance of the following elements: - repositoryName : a human readable name for the repository; - baseURL : the base URL of the repository; - protocolVersion : the version of the OAI-PMH supported by the repository; - earliestDatestamp : a UTCdatetime that is the guaranteed lower limit of all datestamps recording changes, modifications, or deletions in the repository. A repository must not use datestamps lower than the one specified by the content of the earliestDatestamp element. earliestDatestamp must be expressed at the finest granularity supported by the repository. - deletedRecord : the manner in which the repository supports the notion of deleted records. Legitimate values are no ; transient ; persistent with meanings defined in the section on deletion. - granularity: the finest harvesting granularity supported by the repository. The legitimate values are YYYY-MM-DD and YYYY-MM-DDThh:mm:ssZ with meanings as defined in ISO8601.

The response must include one or more instances of the following element: - adminEmail : the e-mail address of an administrator of the repository.

The response may include multiple instances of the following optional elements:

- compression : a compression encoding supported by the repository. The recommended values are those defined for the Content-Encoding header in Section 14.11 of RFC 2616 describing HTTP 1.1. A compression element should not be included for the identity encoding, which is implied. - description : an extensible mechanism for communities to describe their repositories. For example, the description container could be used to include collection-level metadata in the response to the Identify request. Implementation Guidelines are available to give directions with this respect. Each description container must be accompanied by the URL of an XML schema describing the structure of the description container.

http://www.openarchives.org/OAI/openarchivesprotocol.html#Identify

type ListIdentifiers

type ListIdentifiers struct {
	Headers         []Header `xml:"header"`
	ResumptionToken string   `xml:"resumptionToken"`
}

ListIdentifiers is an abbreviated verb form of ListRecords, retrieving only headers rather than records.

Optional arguments permit selective harvesting of headers based on set membership and/or datestamp.

Depending on the repository's support for deletions, a returned header may have a status attribute of "deleted" if a record matching the arguments

specified in the request has been deleted.

http://www.openarchives.org/OAI/openarchivesprotocol.html#ListIdentifiers

type ListMetadataFormats

type ListMetadataFormats struct {
	MetadataFormat []MetadataFormat `xml:"metadataFormat"`
}

ListMetadataFormats holds the formats received from server

OAI-PMH supports the dissemination of records in multiple metadata formats from a repository. The ListMetadataFormats request returns the list of all metadata formats available from a repository

http://www.openarchives.org/OAI/openarchivesprotocol.html#MetadataNamespaces

type ListRecords

type ListRecords struct {
	Records         []Record `xml:"record"`
	ResumptionToken string   `xml:"resumptionToken"`
}

ListRecords is a verb used to harvest records from a repository.

Optional arguments permit selective harvesting of records based on set membership and/or datestamp. Depending on the repository's support for deletions, a returned header may have a status attribute of "deleted" if a record matching the arguments specified in the request has been deleted. No metadata will be present for records with deleted status.

http://www.openarchives.org/OAI/openarchivesprotocol.html#FlowControl

type ListSets

type ListSets struct {
	Set []Set `xml:"set"`
}

ListSets represents a list of Sets

http://www.openarchives.org/OAI/openarchivesprotocol.html#Set

type Metadata

type Metadata struct {
	Body []byte `xml:",innerxml"`
}

Metadata is a single manifestation of the metadata from an item.

The OAI-PMH supports items with multiple manifestations (formats) of metadata. At a minimum, repositories must be able to return records with metadata expressed in the Dublin Core format, without any qualification. Optionally, a repository may also disseminate other formats of metadata. The specific metadata format of the record to be disseminated is specified by means of an argument -- the metadataPrefix -- in the GetRecord or ListRecords request that produces the record. The ListMetadataFormats request returns the list of all metadata formats available from a repository, or for a specific item (which can be specified as an argument to the ListMetadataFormats request).

http://www.openarchives.org/OAI/openarchivesprotocol.html#Record

func (Metadata) String

func (md Metadata) String() string

GoString returns the body as a string

type MetadataFormat

type MetadataFormat struct {
	MetadataPrefix    string `xml:"metadataPrefix"`
	Schema            string `xml:"schema"`
	MetadataNamespace string `xml:"metadataNamespace"`
}

MetadataFormat is a metadata format available from a repository

It contains: 1. The metadataPrefix - a string to specify the metadata format in OAI-PMH requests issued to the repository. metadataPrefix consists of any valid URI

unreserved characters. metadataPrefix arguments are used in ListRecords,
ListIdentifiers, and GetRecord requests to retrieve records, or the headers
 of records that include metadata in the format specified by the
  metadataPrefix;

2. The metadata schema URL - the URL of an XML schema to test validity of metadata expressed according to the format;

  1. The XML namespace URI that is a global identifier of the metadata format. (http://www.w3.org/TR/1999/REC-xml-names-19990114/Overview.html)

http://www.openarchives.org/OAI/openarchivesprotocol.html#MetadataNamespaces

type Record

type Record struct {
	Header   Header   `xml:"header"`
	Metadata Metadata `xml:"metadata"`
	About    About    `xml:"about"`
}

Record is metadata expressed in a single format.

A record is returned in an XML-encoded byte stream in response to an OAI-PMH request for metadata from an item. A record is identified unambiguously by the combination of the unique identifier of the item from which the record is available, the metadataPrefix identifying the metadata format of the record, and the datestamp of the record. The XML-encoding of records is organized into the following parts: header, metadata, about

http://www.openarchives.org/OAI/openarchivesprotocol.html#Record

type Request

type Request struct {
	BaseURL        string
	Set            string
	MetadataPrefix string

	Identifier      string
	ResumptionToken string
	From            string
	Until           string
	// contains filtered or unexported fields
}

Request encapsulates the information to get information using OAI-PMH protocol

func (*Request) Clear

func (request *Request) Clear()

Clear sets to default all the fields

func (*Request) GetFormats

func (request *Request) GetFormats() ([]byte, error)

GetFormats returns the content of the request for formats

func (*Request) GetIdentifiers

func (request *Request) GetIdentifiers(prefix string) ([]byte, error)

GetIdentifiers returns the content of the request to get all the identifiers for a particular metadata format

func (*Request) GetRecords

func (request *Request) GetRecords(prefix string) ([]byte, error)

GetRecords returns the content of the request to get all the records for a particular metadata format

func (*Request) GetSets

func (request *Request) GetSets() ([]byte, error)

GetSets returns the content of the request to get all the sets

func (*Request) Identify

func (request *Request) Identify() ([]byte, error)

Identify returns the identification details of the repository

func (*Request) IsValidResponse

func (request *Request) IsValidResponse(content []byte) error

IsValidResponse parses a content and returns the error

func (*Request) Parse

func (request *Request) Parse(content []byte) (*Response, error)

Parse returns the content of the remote repository

type RequestNode

type RequestNode struct {
	Verb           string `xml:"verb,attr"`
	Set            string `xml:"set,attr"`
	MetadataPrefix string `xml:"metadataPrefix,attr"`
}

RequestNode is indicating the protocol request that generated this response.

The rules for generating the request element are as follows: 1. The content of the request element must always be the base URL of the protocol request; 2. The only valid attributes for the request element are the keys of the key=value pairs of protocol request. The attribute values must be the corresponding values of those key=value pairs; 3. In cases where the request that generated this response did not result in an error or exception condition, the attributes and attribute values of the request element must match the key=value pairs of the protocol request; 4. In cases where the request that generated this response resulted in a badVerb or badArgument error condition, the repository must return the base URL of the protocol request only. Attributes must not be provided in these cases.

http://www.openarchives.org/OAI/openarchivesprotocol.html#XMLResponse

type Response

type Response struct {
	ResponseDate string      `xml:"responseDate"`
	Request      RequestNode `xml:"request"`
	Error        Error       `xml:"error"`

	Identify            Identify            `xml:"Identify"`
	ListMetadataFormats ListMetadataFormats `xml:"ListMetadataFormats"`
	ListSets            ListSets            `xml:"ListSets"`
	GetRecord           GetRecord           `xml:"GetRecord"`
	ListIdentifiers     ListIdentifiers     `xml:"ListIdentifiers"`
	ListRecords         ListRecords         `xml:"ListRecords"`
}

Response encapsulates the information from a harvest request

All responses to OAI-PMH requests must be well-formed XML instance documents. Encoding of the XML must use the UTF-8 representation of Unicode. Character references, rather than entity references, must be used. Character references allow XML responses to be treated as stand-alone documents that can be manipulated without dependency on entity declarations external to the document.

The XML data for all responses to OAI-PMH requests must validate against the XML Schema shown at the end of this section . As can be seen from that schema, responses to OAI-PMH requests have the following common markup:

(ignored) The first tag output is an XML declaration where the version is always 1.0 and the encoding is always UTF-8, eg: <?xml version="1.0" encoding="UTF-8" ?> (ignored) The remaining content is enclosed in a root element with the name OAI-PMH.

For all responses, the first two children of the root element are: - responseDate -- a UTCdatetime indicating the time and date that the response was sent. This must be expressed in UTC - request -- indicating the protocol request that generated this response.

The third child of the root element is either: - error -- an element that must be used in case of an error or exception condition; - (Identify, ListMetadataFormats, ListSets, GetRecord, ListIdentifiers, ListRecords) an element with the same name as the verb of the respective OAI-PMH request.

http://www.openarchives.org/OAI/openarchivesprotocol.html#XMLResponse

func (*Response) GetResumptionToken

func (response *Response) GetResumptionToken() string

GetResumptionToken returns the resumption token or an empty string if it does not have a token

func (*Response) HasResumptionToken

func (response *Response) HasResumptionToken() bool

HasResumptionToken determines if the request has or not a ResumptionToken

type Set

type Set struct {
	SetSpec        string      `xml:"setSpec"`
	SetName        string      `xml:"setName"`
	SetDescription Description `xml:"setDescription"`
}

Set is an optional construct for grouping items for the purpose of selective harvesting.

Repositories may organize items into sets. Set organization may be flat, i.e. a simple list, or hierarchical. Multiple hierarchies with distinct, independent top-level nodes are allowed. Hierarchical organization of sets is expressed in the syntax of the setSpec parameter as described below. When a repository defines a set organization it must include set membership information in the headers of items returned in response to the ListIdentifiers, ListRecords and GetRecord requests.

A Set has: - setSpec -- a colon [:] separated list indicating the path from the root of the set hierarchy to the respective node. Each element in the list is a string consisting of any valid URI unreserved characters, which must not contain any colons [:]. Since a setSpec forms a unique identifier for the set within the repository, it must be unique for each set. Flat set organizations have only sets with setSpec that do not contain any colons [:]. - setName -- a short human-readable string naming the set. - setDescription -- an optional and repeatable container that may hold community-specific XML-encoded data about the set; the accompanying Implementation Guidelines document provides suggestions regarding the usage of this container.

http://www.openarchives.org/OAI/openarchivesprotocol.html#Set

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL