Documentation
¶
Overview ¶
Package libgin provides functionality shared between the G-Node GIN services. These include: - GIN Web: The G-Node/GOGS fork (https://github.com/G-Node/gogs) - GIN DOI: The DOI registration service (https://github.com/G-Node/gin-doi) - GIN DEX: The indexing service for GIN (https://github.com/G-Node/gin-dex)
Index ¶
- Constants
- Variables
- func Decrypt(key, ciphertext []byte) ([]byte, error)
- func DecryptString(key []byte, encstring string) (string, error)
- func DecryptURLString(key []byte, encstring string) (string, error)
- func Encrypt(key, plaintext []byte) ([]byte, error)
- func EncryptString(key []byte, plaintext string) (string, error)
- func EncryptURLString(key []byte, plaintext string) (string, error)
- func GetArchiveSize(archiveURL string) (uint64, error)
- func IsRegisteredDOI(doi string) bool
- func PrettyDate(dt *time.Time) string
- func ReadConf(key string) string
- func ReadConfDefault(key, defval string) string
- func RepoPathToUUID(URI string) string
- type Author
- type BlobSResult
- type CommitSResult
- type Contributor
- type Creator
- type DOIRegInfo
- type DOIRequestData
- type DataCite
- func (dc *DataCite) AddAbstract(abstract string)
- func (dc *DataCite) AddAuthor(author *Author)
- func (dc *DataCite) AddFunding(fundstr string)
- func (dc *DataCite) AddReference(ref *Reference)
- func (dc *DataCite) AddURLs(repo, fork, archive string)
- func (dc *DataCite) FixSchemaAttrs()
- func (dc *DataCite) Marshal() (string, error)
- func (dc *DataCite) SetResourceType(resourceType string)
- type Date
- type Description
- type FunderIdentifier
- type FundingReference
- type GINUser
- type Identifier
- type IndexBlob
- type IndexCommit
- type IndexRequest
- type License
- type NameIdentifier
- type NamedIdentifier
- type Reference
- type RelatedIdentifier
- type RepositoryMetadata
- type RepositoryYAML
- type ResourceType
- type Rights
- type SearchRequest
- type SearchResults
Constants ¶
const ( Schema = "http://www.w3.org/2001/XMLSchema-instance" SchemaLocation = "http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4.3/metadata.xsd" Publisher = "G-Node" Language = "eng" Version = "1.0" )
const ( SEARCH_MATCH = iota SEARCH_FUZZY SEARCH_WILDCARD SEARCH_QUERY SEARCH_SUGGEST )
Variables ¶
var UUIDMap = map[string]string{
"INT/multielectrode_grasp": "f83565d148510fede8a277f660e1a419",
"ajkumaraswamy/HB-PAC_disinhibitory_network": "1090f803258557299d287c4d44a541b2",
"steffi/Kleineidam_et_al_2017": "f53069de4c4921a3cfa8f17d55ef98bb",
"Churan/Morris_et_al_Frontiers_2016": "97bc1456d3f4bca2d945357b3ec92029",
"fabee/efish_locking": "6953bbf0087ba444b2d549b759de4a06",
}
UUIDMap is a map between registered repositories and their UUIDs for datasets registered before the new UUID generation method was implemented. This map is required because the current method of computing UUIDs differs from the older method and this lookup is used to handle the old-method UUIDs.
Functions ¶
func DecryptString ¶
DecryptString decrypts an AES encrypted base64 string.
func DecryptURLString ¶
DecryptURLString decrypts an AES encrypted URL encoded base64 string.
func EncryptString ¶
EncryptString encrypts a string using AES and returns it in base64.
func EncryptURLString ¶
EncryptURLString encrypts a string using AES and returns it in URL encoded base64.
func GetArchiveSize ¶ added in v0.5.5
GetArchiveSize returns the size of the archive at the given URL. If the URL is invalid or unreachable, an error is returned.
func IsRegisteredDOI ¶
func PrettyDate ¶ added in v0.5.5
func ReadConf ¶
ReadConf returns the value of a configuration env variable. If the variable is not set, an empty string is returned (ignores any errors).
func ReadConfDefault ¶
ReadConfDefault returns the value of a configuration env variable. If the variable is not set, the default is returned.
func RepoPathToUUID ¶
RepoPathToUUID computes a UUID from a repository path.
Types ¶
type Author ¶
type Author struct {
FirstName string `yaml:"firstname"`
LastName string `yaml:"lastname"`
Affiliation string `yaml:"affiliation,omitempty"`
ID string `yaml:"id,omitempty"`
}
func (*Author) GetValidID ¶
func (c *Author) GetValidID() *NamedIdentifier
func (*Author) RenderAuthor ¶
type BlobSResult ¶
type CommitSResult ¶
type CommitSResult struct {
Source *IndexCommit `json:"_source"`
Score float64 `json:"_score"`
Highlight interface{} `json:"highlight"`
}
type Contributor ¶ added in v0.5.5
type Creator ¶ added in v0.5.5
type Creator struct {
Name string `xml:"creatorName"`
Identifier *NameIdentifier `xml:"nameIdentifier,omitempty"`
Affiliation string `xml:"affiliation,omitempty"`
}
type DOIRegInfo ¶
type DOIRegInfo struct {
Missing []string
DOI string
UUID string
FileName string
FileSize string
Title string
Authors []Author
Description string
Keywords []string
References []Reference
Funding []string
License *License
ResourceType string
DateTime time.Time
TemplateVersion string
}
DOIRegInfo holds all the metadata and information necessary for a DOI registration request. Deprecated and obsolete: Marked for removal
func (*DOIRegInfo) GetCitation ¶
func (c *DOIRegInfo) GetCitation() string
func (*DOIRegInfo) GetType ¶
func (c *DOIRegInfo) GetType() string
func (*DOIRegInfo) ISODate ¶ added in v0.3.2
func (c *DOIRegInfo) ISODate() string
func (*DOIRegInfo) Year ¶ added in v0.3.2
func (c *DOIRegInfo) Year() string
type DOIRequestData ¶
DOIRequestData is used to transmit data from GIN to DOI when a registration request is triggered.
type DataCite ¶ added in v0.5.5
type DataCite struct {
XMLName xml.Name `xml:"http://datacite.org/schema/kernel-4 resource"`
Schema string `xml:"xmlns:xsi,attr"`
SchemaLocation string `xml:"xsi:schemaLocation,attr"`
// Resource identifier (DOI)
Identifier Identifier `xml:"identifier"`
// Creators: Authors
Creators []Creator `xml:"creators>creator"`
Titles []string `xml:"titles>title"`
Descriptions []Description `xml:"descriptions>description"`
// RightsList: Licenses
RightsList []Rights `xml:"rightsList>rights"`
// Subjects: Keywords
Subjects *[]string `xml:"subjects>subject,omitempty"`
// RelatedIdentifiers: References
RelatedIdentifiers []RelatedIdentifier `xml:"relatedIdentifiers>relatedIdentifier"`
FundingReferences *[]FundingReference `xml:"fundingReferences>fundingReference,omitempty"`
// Contributors: Always German Neuroinformatics Node with type "HostingInstitution"
Contributors []Contributor `xml:"contributors>contributor"`
// Publisher: Always G-Node
Publisher string `xml:"publisher"`
// Publication Year
Year int `xml:"publicationYear"`
// Publication Date marked with type "Issued"
Dates []Date `xml:"dates>date"`
// Language: eng
Language string `xml:"language"`
ResourceType ResourceType `xml:"resourceType"`
// Size of the archive
Sizes *[]string `xml:"sizes>size,omitempty"`
// Version: 1.0
Version string `xml:"version"`
}
func NewDataCite ¶ added in v0.5.5
func NewDataCite() DataCite
Returns a DataCite struct populated with our defaults. The following values are set and generally shouldn't be changed: Schema, Namespace, SchemaLocation, Contributors, Publisher, Language, Version. Dates and Year are also pre-filled with the current date but should be changed when working with an existing publication.
func NewDataCiteFromYAML ¶ added in v0.5.5
func NewDataCiteFromYAML(info *RepositoryYAML) *DataCite
func UnmarshalFile ¶ added in v0.5.5
UnmarshalFile reads an XML file specified by the given path and returns a populated DataCite struct. Before returning, it adds the schema attributes for the top-level tag. See also FixSchemaAttrs.
func (*DataCite) AddAbstract ¶ added in v0.5.5
AddAbstract is a convenience function for adding a Description with type "Abstract".
func (*DataCite) AddFunding ¶ added in v0.5.5
AddFunding is a convenience function for appending a FundingReference in the format of the YAML data (<FUNDER>, <AWARDNUMBER>).
func (*DataCite) AddReference ¶ added in v0.5.5
AddReference is a convenience function for appending a RelatedIdentifier that describes a referenced work. The RelatedIdentifier includes the identifier, relation type, and identifier type. A full citation string is also added to the Descriptions list.
func (*DataCite) AddURLs ¶ added in v0.5.5
AddURLs is a convenience function for appending three reference URLs: 1. The source repository URL; 2. The DOI fork repository URL; 3. The Archive URL. If the archive URL is valid and reachable, the Size of the archive is added as well.
func (*DataCite) FixSchemaAttrs ¶ added in v0.5.5
func (dc *DataCite) FixSchemaAttrs()
FixSchemaAttrs adds the Schema and SchemaLocation attributes that can't be read from existing files when Unmarshaling. See https://github.com/golang/go/issues/9519 for the issue with attributes that have a namespace prefix.
func (*DataCite) Marshal ¶ added in v0.5.5
Marshal returns the marshalled version of the metadata structure, indented with tabs and with the appropriate XML header.
func (*DataCite) SetResourceType ¶ added in v0.5.5
SetResourceType is a convenience function for setting the ResourceType data and its resourceTypeGeneral to the same value.
type Description ¶ added in v0.5.5
type FunderIdentifier ¶ added in v0.5.5
type FundingReference ¶ added in v0.5.5
type FundingReference struct {
Funder string `xml:"funderName"`
AwardNumber string `xml:"awardNumber"`
Identifier *FunderIdentifier `xml:"funderIdentifier"`
}
type Identifier ¶ added in v0.5.5
type IndexCommit ¶
type IndexRequest ¶
type NameIdentifier ¶ added in v0.5.5
type NamedIdentifier ¶
type Reference ¶
type RelatedIdentifier ¶ added in v0.5.5
type RepositoryMetadata ¶ added in v0.5.5
type RepositoryMetadata struct {
// YAMLData is the original data coming from the repository
YAMLData *RepositoryYAML
// DataCite is the struct that produces the XML file
*DataCite
// The user that sent the request
RequestingUser *GINUser
// Should be full repository path (<user>/<reponame>)
SourceRepository string
// Should be full repository path of the snapshot fork (doi/<rpeoname>)
ForkRepository string
// UUID calculated from unique repository path or randomly assigned
UUID string
}
RepositoryMetadata can contain all known metadata for a registered (or to-be-registered) repository. To do this, it embeds the
type RepositoryYAML ¶ added in v0.5.5
type RepositoryYAML struct {
Authors []Author `yaml:"authors"`
Title string `yaml:"title"`
Description string `yaml:"description"`
Keywords []string `yaml:"keywords"`
License *License `yaml:"license,omitempty"`
Funding []string `yaml:"funding,omitempty"`
References []Reference `yaml:"references,omitempty"`
TemplateVersion string `yaml:"templateversion,omitempty"`
ResourceType string `yaml:"resourcetype"`
}
RepositoryYAML is used to read the information provided by a GIN user through the datacite.yml file. This data is usually used to populate the DataCite and RepositoryMetadata types.
type ResourceType ¶ added in v0.5.5
type SearchRequest ¶
type SearchResults ¶
type SearchResults struct {
Blobs []BlobSResult
Commits []CommitSResult
}