-
Notifications
You must be signed in to change notification settings - Fork 0
/
handle.go
41 lines (35 loc) · 919 Bytes
/
handle.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package models
import "fmt"
/*
copy from handle-server-api
*/
type HandleData struct {
Url string `json:"url"`
Format string `json:"format"`
}
type HandleValue struct {
Timestamp string `json:"timestamp"`
Type string `json:"type"`
Index int `json:"index"`
Ttl int `json:"ttl"`
Data *HandleData `json:"data"`
}
type Handle struct {
Handle string `json:"handle"`
ResponseCode int `json:"responseCode"`
Values []*HandleValue `json:"values,omitempty"`
Message string `json:"message,omitempty"`
}
func (h *Handle) IsSuccess() bool {
return h.ResponseCode == 1
}
func (h *Handle) GetFullHandleURL() string {
if !h.IsSuccess() {
return ""
}
if h.Handle == "" {
return ""
}
//http://hdl.handle.net/<handle> where <handle> is <prefix>/LU-<localId>
return fmt.Sprintf("http://hdl.handle.net/%s", h.Handle)
}