Skip to content

Commit

Permalink
Try checking getty TGN URI
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Jul 23, 2024
1 parent 541cbdb commit 1b95bec
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion internal/handlers/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ func CheckMyWork(w http.ResponseWriter, r *http.Request) {

header := csvData[0]
doiPattern := regexp.MustCompile(`^10\.\d{4,9}\/[-._;()/:A-Za-z0-9]+$`)
gettyTgnPattern := regexp.MustCompile(`^http://vocab\.getty\.edu/page/tgn/\d+$`)

errors := map[string]string{}
requiredFields := []string{
"Title",
Expand Down Expand Up @@ -178,7 +180,28 @@ func CheckMyWork(w http.ResponseWriter, r *http.Request) {
errors[i] = "File does not exist in islandora_staging"
}
case "Subject Geographic (LCNAF)":
// TODO: check LCNAF API
if !gettyTgnPattern.MatchString(cell) {
errors[i] = "Invalid Getty TGN URI"
}
hierarchyURL := strings.Replace(cell, "page", "hierarchy", 1)

req, err := http.NewRequest("GET", hierarchyURL, nil)
if err != nil {
break
}
req.Header.Set("Accept", "application/json")

client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
errors[i] = "Unable to request hierarchical information"
break
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
errors[i] = "Unable to get hierarchical information"
}
}
}
}
Expand Down

0 comments on commit 1b95bec

Please sign in to comment.