From 5c7c272a03c5ea466143a9725f2c6f9ef664e520 Mon Sep 17 00:00:00 2001 From: "Joseph G. Pawletko" Date: Tue, 3 Dec 2024 19:21:39 -0500 Subject: [PATCH 01/10] add error check to (a *ADClient)GetAgent() --- Agents.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Agents.go b/Agents.go index 60151a7..441f453 100644 --- a/Agents.go +++ b/Agents.go @@ -39,6 +39,9 @@ func (a *ASClient) GetAgent(agentType string, agentID int) (Agent, error) { } err = json.Unmarshal(body, &agent) + if err != nil { + return agent, err + } return agent, nil } From 1118e6c46132a703b985192f98d50fbe43c30643 Mon Sep 17 00:00:00 2001 From: "Joseph G. Pawletko" Date: Tue, 3 Dec 2024 19:28:50 -0500 Subject: [PATCH 02/10] comment out unused code --- ArchivalObjects.go | 42 ++++++++++++++++++++---------------------- Common.go | 18 +++++++++--------- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/ArchivalObjects.go b/ArchivalObjects.go index 2f9ce15..3903fab 100644 --- a/ArchivalObjects.go +++ b/ArchivalObjects.go @@ -4,8 +4,6 @@ import ( "encoding/json" "fmt" "io" - "regexp" - "strings" ) func (a *ASClient) GetArchivalObjectIDs(repositoryID int) ([]int, error) { @@ -91,14 +89,14 @@ func (a *ASClient) UpdateArchivalObject(repositoryId int, archivalObjectId int, return responseMessage, nil } -func getChildArchivalObjectURIs(children []ResourceTree, aos *[]string) { - for _, child := range children { - *aos = append(*aos, child.RecordURI) - if child.HasChildren { - getChildArchivalObjectURIs(child.Children, aos) - } - } -} +// func getChildArchivalObjectURIs(children []ResourceTree, aos *[]string) { +// for _, child := range children { +// *aos = append(*aos, child.RecordURI) +// if child.HasChildren { +// getChildArchivalObjectURIs(child.Children, aos) +// } +// } +// } func (a ASClient) DeleteArchivalObject(repositoryID int, archivalObjectID int) (string, error) { responseMessage := "" @@ -119,18 +117,18 @@ func (a ASClient) DeleteArchivalObject(repositoryID int, archivalObjectID int) ( return responseMessage, nil } -func getChildArchivalObjectURIsFiltered(children []ResourceTree, aos *[]string, filter string) { - matcher := regexp.MustCompile(filter) - for _, child := range children { - if matcher.MatchString(strings.Join(child.InstanceTypes, " ")) == true { - *aos = append(*aos, child.RecordURI) - } - - if child.HasChildren { - getChildArchivalObjectURIs(child.Children, aos) - } - } -} +// func getChildArchivalObjectURIsFiltered(children []ResourceTree, aos *[]string, filter string) { +// matcher := regexp.MustCompile(filter) +// for _, child := range children { +// if matcher.MatchString(strings.Join(child.InstanceTypes, " ")) == true { +// *aos = append(*aos, child.RecordURI) +// } + +// if child.HasChildren { +// getChildArchivalObjectURIs(child.Children, aos) +// } +// } +// } func (a *ASClient) GetRandomArchivalObject(repositoryID int, resourceID int) (int, int, error) { diff --git a/Common.go b/Common.go index c25bfc6..69a9676 100644 --- a/Common.go +++ b/Common.go @@ -105,15 +105,15 @@ func (a *ASClient) PostEndpoint(endpoint string, requestBody string, authenticat return response, nil } -// slice contains methods -func containsInt(list []int, id int) bool { - for _, i := range list { - if id == i { - return true - } - } - return false -} +// // slice contains methods +// func containsInt(list []int, id int) bool { +// for _, i := range list { +// if id == i { +// return true +// } +// } +// return false +// } type CreateOrUpdateResponse struct { Status string `json:"status"` From bd0648750f27c2c7e1c3f4312f0721b6ac47e8d5 Mon Sep 17 00:00:00 2001 From: "Joseph G. Pawletko" Date: Tue, 3 Dec 2024 19:29:43 -0500 Subject: [PATCH 03/10] add missing error check --- Repositories.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Repositories.go b/Repositories.go index 8031e56..850529a 100644 --- a/Repositories.go +++ b/Repositories.go @@ -22,6 +22,9 @@ func (a *ASClient) GetRepositories() ([]int, error) { reps := make([]map[string]interface{}, 1, 1) err = json.Unmarshal(body, &reps) + if err != nil { + return repIds, err + } for i := range reps { rep := fmt.Sprintf("%v", reps[i]["uri"]) From fb1e519fb64f11a7bd217dce9c0edb745143034a Mon Sep 17 00:00:00 2001 From: "Joseph G. Pawletko" Date: Tue, 3 Dec 2024 19:30:42 -0500 Subject: [PATCH 04/10] tweak range statement per linter recommendation --- Schema_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Schema_test.go b/Schema_test.go index 1d0a508..3422e28 100644 --- a/Schema_test.go +++ b/Schema_test.go @@ -2,8 +2,9 @@ package aspace import ( "flag" - goaspacetest "github.com/nyudlts/go-aspace/goaspace_testing" "testing" + + goaspacetest "github.com/nyudlts/go-aspace/goaspace_testing" ) func TestSchemas(t *testing.T) { @@ -27,7 +28,7 @@ func TestSchemas(t *testing.T) { t.Log("Successfully got a list of schemas") keys := make([]string, 0, len(schemas)) - for k, _ := range schemas { + for k := range schemas { keys = append(keys, k) } From d440c2a9c03fef935b592e7f3d0f1768df3fce13 Mon Sep 17 00:00:00 2001 From: "Joseph G. Pawletko" Date: Tue, 3 Dec 2024 19:58:06 -0500 Subject: [PATCH 05/10] update go mod files --- go.mod | 7 +------ go.sum | 4 ---- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/go.mod b/go.mod index c4a550c..38eaa1e 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,4 @@ module github.com/nyudlts/go-aspace go 1.21 -require ( - github.com/lestrrat-go/libxml2 v0.0.0-20231124114421-99c71026c2f5 - gopkg.in/yaml.v2 v2.3.0 -) - -require github.com/pkg/errors v0.9.1 // indirect +require gopkg.in/yaml.v2 v2.3.0 diff --git a/go.sum b/go.sum index 094222e..168980d 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,3 @@ -github.com/lestrrat-go/libxml2 v0.0.0-20231124114421-99c71026c2f5 h1:lR4DHv41vdkhNPNDlr56n8BuLINQeWNeQAaAzBEOcuw= -github.com/lestrrat-go/libxml2 v0.0.0-20231124114421-99c71026c2f5/go.mod h1:/0MMipmS+5SMXCSkulsvJwYmddKI4IL5tVy6AZMo9n0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= From 3e54c66633d45d902228ec0af32ca5b5a93ace24 Mon Sep 17 00:00:00 2001 From: "Joseph G. Pawletko" Date: Fri, 6 Dec 2024 14:00:07 -0500 Subject: [PATCH 06/10] remove debug print statement from ASClient --- ASClient.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/ASClient.go b/ASClient.go index 90962dc..5e89a58 100644 --- a/ASClient.go +++ b/ASClient.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "log" "net/http" "os" "time" @@ -49,8 +48,6 @@ func NewClientFromCreds(creds Creds, timeout int) (*ASClient, error) { var client *ASClient - log.Printf("[DEBUG] url: %s, username: %s, password: %s", creds.URL, creds.Username, creds.Password) - tr := &http.Transport{ MaxIdleConns: 10, IdleConnTimeout: time.Duration(timeout) * time.Second, From 5cc14a2dd3a2c2df37e4b7070c20406640a4a7b4 Mon Sep 17 00:00:00 2001 From: "Joseph G. Pawletko" Date: Mon, 16 Dec 2024 10:51:12 -0500 Subject: [PATCH 07/10] update CHANGELOG, bump to v0.7.1 --- CHANGELOG.md | 12 ++++++++---- Common.go | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 321d7c5..35237af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,17 @@ ## CHANGELOG + +#### v0.7.1 + - remove debug print from `NewClientFromCreds()` + #### v0.7.0 - - add `func (a *ASClient) FindArchivalObjectsByID(...)([]string, error)` + - add `func (a *ASClient) FindArchivalObjectsByID(...)([]string, error)` that allows you to look up archival objects by the `ref_id` or `component_id` fields - + #### v0.6.1 - bug fix: rewrite `func (wor WorkOrderRow) String()` to use `encoding/csv` to handle string escapes - + #### v0.6.0 - add `...FromURI()` functions: - add `GetArchivalObjectFromURI()` @@ -24,5 +28,5 @@ - force `bool` key/value pairs to always be sent in marshaled JSON for selected types - remove `omitempty` option from `DigitalObject` type `bool` JSON tags - remove `omitempty` option from `FileVersion` type `bool` JSON tags - + diff --git a/Common.go b/Common.go index 69a9676..07deffb 100644 --- a/Common.go +++ b/Common.go @@ -11,7 +11,7 @@ import ( "time" ) -var LibraryVersion = "v0.7.0" +var LibraryVersion = "v0.7.1" var seed = rand.NewSource(time.Now().UnixNano()) var rGen = rand.New(seed) From c3c9fc832b2e3e17b25e7992adad90fd03c8ee3e Mon Sep 17 00:00:00 2001 From: "Joseph G. Pawletko" Date: Mon, 16 Dec 2024 11:37:19 -0500 Subject: [PATCH 08/10] add detail to CHANGELOG v0.7.1 entry --- CHANGELOG.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35237af..31e504d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,14 @@ ## CHANGELOG - #### v0.7.1 - remove debug print from `NewClientFromCreds()` + - remove debug print statement from ASClient + - tidy go mod files (removed unused libxml2, yaml.v2 packages) + - tweak range statement per linter recommendation + - add missing error check + - comment out unused code + - add error check to (a *ADClient)GetAgent() + - update CHANGELOG, bump to v0.7.1 #### v0.7.0 - add `func (a *ASClient) FindArchivalObjectsByID(...)([]string, error)` @@ -28,5 +34,3 @@ - force `bool` key/value pairs to always be sent in marshaled JSON for selected types - remove `omitempty` option from `DigitalObject` type `bool` JSON tags - remove `omitempty` option from `FileVersion` type `bool` JSON tags - - From b933a09a904503b725661d5ae08f42ddaabe2c8c Mon Sep 17 00:00:00 2001 From: "Joseph G. Pawletko" Date: Mon, 16 Dec 2024 11:40:47 -0500 Subject: [PATCH 09/10] remove redundant line from CHANGELOG --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31e504d..40ec59e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,6 @@ #### v0.7.1 - remove debug print from `NewClientFromCreds()` - - remove debug print statement from ASClient - tidy go mod files (removed unused libxml2, yaml.v2 packages) - tweak range statement per linter recommendation - add missing error check From 6f6aa644673e1b477edadd76c2854abb2fd5d717 Mon Sep 17 00:00:00 2001 From: "Joseph G. Pawletko" Date: Mon, 16 Dec 2024 11:46:07 -0500 Subject: [PATCH 10/10] correct line in CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40ec59e..092d622 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ #### v0.7.1 - remove debug print from `NewClientFromCreds()` - - tidy go mod files (removed unused libxml2, yaml.v2 packages) + - tidy go mod files (removed unused libxml2 package) - tweak range statement per linter recommendation - add missing error check - comment out unused code