From 0d83885b9b5e8cd8c17367fc0b2acadfc554916d Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 21 Jan 2025 09:35:41 +0100 Subject: [PATCH] light modification --- models/resources/models.go | 4 ++++ models/utils/common.go | 1 - models/workspace/workspace.go | 5 ----- models/workspace/workspace_mongo_accessor.go | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/models/resources/models.go b/models/resources/models.go index 9d0b670..1781b16 100644 --- a/models/resources/models.go +++ b/models/resources/models.go @@ -1,6 +1,8 @@ package resources import ( + "fmt" + "cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/tools" ) @@ -28,6 +30,7 @@ func (r *ResourceSet) Clear() { } func (r *ResourceSet) Fill(request *tools.APIRequest) { + r.Clear() for k, v := range map[utils.DBObject][]string{ (&DataResource{}): r.Datas, (&ComputeResource{}): r.Computes, @@ -35,6 +38,7 @@ func (r *ResourceSet) Fill(request *tools.APIRequest) { (&ProcessingResource{}): r.Processings, (&WorkflowResource{}): r.Workflows, } { + fmt.Println(len(v), k) for _, id := range v { d, _, e := k.GetAccessor(request).LoadOne(id) if e == nil { diff --git a/models/utils/common.go b/models/utils/common.go index 1e86108..5639a18 100644 --- a/models/utils/common.go +++ b/models/utils/common.go @@ -144,7 +144,6 @@ func GenericSearch[T DBObject](filters *dbs.Filters, search string, defaultFilte if filters == nil && search != "" { filters = defaultFilters } - fmt.Println("filters", filters, wfa.GetType().String(), search) res_mongo, code, err := mongo.MONGOService.Search(filters, wfa.GetType().String()) return genericLoadAll[T](res_mongo, code, err, onlyDraft, f, wfa) } diff --git a/models/workspace/workspace.go b/models/workspace/workspace.go index 1086eb6..330bb3e 100644 --- a/models/workspace/workspace.go +++ b/models/workspace/workspace.go @@ -1,8 +1,6 @@ package workspace import ( - "fmt" - "cloud.o-forge.io/core/oc-lib/models/collaborative_area/shallow_collaborative_area" "cloud.o-forge.io/core/oc-lib/models/resources" "cloud.o-forge.io/core/oc-lib/models/utils" @@ -23,15 +21,12 @@ func (d *Workspace) GetAccessor(request *tools.APIRequest) utils.Accessor { } func (ao *Workspace) VerifyAuth(request *tools.APIRequest) bool { - fmt.Println("Workspace.VerifyAuth", ao.Shared) if ao.Shared != "" { shared, code, _ := shallow_collaborative_area.NewAccessor(request).LoadOne(ao.Shared) - fmt.Println("Workspace.VerifyAuth", shared, code) if code != 200 || shared == nil { return false } return shared.VerifyAuth(request) } - fmt.Println("Workspace.VerifyAuth", ao.AbstractObject.VerifyAuth(request)) return ao.AbstractObject.VerifyAuth(request) } diff --git a/models/workspace/workspace_mongo_accessor.go b/models/workspace/workspace_mongo_accessor.go index 6acfe18..4b6fcb5 100644 --- a/models/workspace/workspace_mongo_accessor.go +++ b/models/workspace/workspace_mongo_accessor.go @@ -78,7 +78,7 @@ func (a *workspaceMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, } res, _, err := a.Search(filters, "", true) // Search for the workspace if err == nil && len(res) > 0 { // If the workspace already exists, return an error - return nil, 409, errors.New("A workspace with the same name already exists") + return nil, 409, errors.New("a workspace with the same name already exists") } // reset the resources d := data.(*Workspace)