Skip to content

Commit

Permalink
Fixed error in the check for existing index entry.
Browse files Browse the repository at this point in the history
  • Loading branch information
mspalti committed Apr 30, 2022
1 parent fa5e452 commit 9fd72f4
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 185 deletions.
25 changes: 0 additions & 25 deletions .idea/codeStyles/Project.xml

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/solr_ocr_processor.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

119 changes: 0 additions & 119 deletions .idea/workspace.xml

This file was deleted.

7 changes: 7 additions & 0 deletions app/assets/build/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ ip_whitelist:
dspace_host:
# The DSpace api base url (no trailing slash)
"http://localhost:8080/server"
manifest_base:
# The base url for manifest ids in the solr index.
# This can be the same as the "dspace_host" above. But if
# you are running DSpace behind a proxy you need to
# set this to the proxy base url in order for
# manifest lookups to succeed. (no trailing slash)
"http://localhost:8080/server"
solr_url:
# The solr host (no trailing slash)
"http://localhost:8983/solr"
Expand Down
1 change: 1 addition & 0 deletions app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func config() (*Configuration, error) {
}
config := Configuration{
DSpaceHost: viper.GetString("dspace_host"),
ManifestBase: viper.GetString("manifest_base"),
Collections: viper.GetStringSlice("Collections"),
SolrUrl: viper.GetString("solr_url"),
SolrCore: viper.GetString("solr_core"),
Expand Down
1 change: 1 addition & 0 deletions app/model/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package model

type Configuration struct {
DSpaceHost string
ManifestBase string
Collections []string
SolrUrl string
SolrCore string
Expand Down
4 changes: 2 additions & 2 deletions app/model/solr.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ type SolrResponse struct {
}

type Docs struct {
ManifestUrl []string `json:"manifest_url,omitempty"`
OcrText string `json:"ocr_text,omitempty"`
ManifestUrl string `json:"manifest_url,omitempty"`
OcrText string `json:"ocr_text,omitempty"`
}

type SolrCreatePost struct {
Expand Down
5 changes: 2 additions & 3 deletions app/process/solr.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"strings"
)


// DeleteFromSolr removes all entries from the solr index for a uuid and (if lazy) removes ocr files from disk.
func DeleteFromSolr(settings model.Configuration, uuid string) error {
manifestUrl := getDSpaceApiEndpoint(settings.DSpaceHost, uuid, "manifest")
Expand Down Expand Up @@ -98,9 +97,9 @@ func deleteFiles(files []model.Docs) error {

// CheckSolr returns true if the index has entries for the uuid
func CheckSolr(settings model.Configuration, uuid string) (bool, error) {
manifestUrl := getDSpaceApiEndpoint(settings.DSpaceHost, uuid, "manifest")
manifestUrl := getDSpaceApiEndpoint(settings.ManifestBase, uuid, "manifest")
solrUrl := fmt.Sprintf("%s/%s/select?fl=manifest_url&q=manifest_url:%s",
settings.SolrUrl, settings.SolrCore, url.QueryEscape("\""+manifestUrl+"\""))
settings.SolrUrl, settings.SolrCore, "\""+manifestUrl+"\"")
payloadBuf := new(bytes.Buffer)
req, err := http.NewRequest("GET", solrUrl, payloadBuf)
req.Header.Set("Content-Type", "application/json")
Expand Down
2 changes: 1 addition & 1 deletion app/process/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ func fixResponse(input *string, settings model.Configuration) *string {
// getDSpaceApiEndpoint returns the URL for the DSpace IIIF endpoint
func getDSpaceApiEndpoint(host string, uuid string, iiiftype string) string {
return host + "/iiif/" + uuid + "/" + iiiftype
}
}

0 comments on commit 9fd72f4

Please sign in to comment.