light modification

This commit is contained in:
mr 2025-01-21 09:35:41 +01:00
parent de585a7234
commit 0d83885b9b
4 changed files with 5 additions and 7 deletions

View File

@ -1,6 +1,8 @@
package resources package resources
import ( import (
"fmt"
"cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/models/utils"
"cloud.o-forge.io/core/oc-lib/tools" "cloud.o-forge.io/core/oc-lib/tools"
) )
@ -28,6 +30,7 @@ func (r *ResourceSet) Clear() {
} }
func (r *ResourceSet) Fill(request *tools.APIRequest) { func (r *ResourceSet) Fill(request *tools.APIRequest) {
r.Clear()
for k, v := range map[utils.DBObject][]string{ for k, v := range map[utils.DBObject][]string{
(&DataResource{}): r.Datas, (&DataResource{}): r.Datas,
(&ComputeResource{}): r.Computes, (&ComputeResource{}): r.Computes,
@ -35,6 +38,7 @@ func (r *ResourceSet) Fill(request *tools.APIRequest) {
(&ProcessingResource{}): r.Processings, (&ProcessingResource{}): r.Processings,
(&WorkflowResource{}): r.Workflows, (&WorkflowResource{}): r.Workflows,
} { } {
fmt.Println(len(v), k)
for _, id := range v { for _, id := range v {
d, _, e := k.GetAccessor(request).LoadOne(id) d, _, e := k.GetAccessor(request).LoadOne(id)
if e == nil { if e == nil {

View File

@ -144,7 +144,6 @@ func GenericSearch[T DBObject](filters *dbs.Filters, search string, defaultFilte
if filters == nil && search != "" { if filters == nil && search != "" {
filters = defaultFilters filters = defaultFilters
} }
fmt.Println("filters", filters, wfa.GetType().String(), search)
res_mongo, code, err := mongo.MONGOService.Search(filters, wfa.GetType().String()) res_mongo, code, err := mongo.MONGOService.Search(filters, wfa.GetType().String())
return genericLoadAll[T](res_mongo, code, err, onlyDraft, f, wfa) return genericLoadAll[T](res_mongo, code, err, onlyDraft, f, wfa)
} }

View File

@ -1,8 +1,6 @@
package workspace package workspace
import ( import (
"fmt"
"cloud.o-forge.io/core/oc-lib/models/collaborative_area/shallow_collaborative_area" "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/resources"
"cloud.o-forge.io/core/oc-lib/models/utils" "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 { func (ao *Workspace) VerifyAuth(request *tools.APIRequest) bool {
fmt.Println("Workspace.VerifyAuth", ao.Shared)
if ao.Shared != "" { if ao.Shared != "" {
shared, code, _ := shallow_collaborative_area.NewAccessor(request).LoadOne(ao.Shared) shared, code, _ := shallow_collaborative_area.NewAccessor(request).LoadOne(ao.Shared)
fmt.Println("Workspace.VerifyAuth", shared, code)
if code != 200 || shared == nil { if code != 200 || shared == nil {
return false return false
} }
return shared.VerifyAuth(request) return shared.VerifyAuth(request)
} }
fmt.Println("Workspace.VerifyAuth", ao.AbstractObject.VerifyAuth(request))
return ao.AbstractObject.VerifyAuth(request) return ao.AbstractObject.VerifyAuth(request)
} }

View File

@ -78,7 +78,7 @@ func (a *workspaceMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject,
} }
res, _, err := a.Search(filters, "", true) // Search for the workspace res, _, err := a.Search(filters, "", true) // Search for the workspace
if err == nil && len(res) > 0 { // If the workspace already exists, return an error 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 // reset the resources
d := data.(*Workspace) d := data.(*Workspace)