Initial commit: Open sourcing all of the Maple Open Technologies code.

This commit is contained in:
Bartlomiej Mika 2025-12-02 14:33:08 -05:00
commit 755d54a99d
2010 changed files with 448675 additions and 0 deletions

View file

@ -0,0 +1,36 @@
// monorepo/cloud/maplefile-backend/internal/maplefile/repo/collection/restore.go
package collection
import (
"context"
"fmt"
"time"
"github.com/gocql/gocql"
dom_collection "codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/internal/domain/collection"
)
func (impl *collectionRepositoryImpl) Restore(ctx context.Context, id gocql.UUID) error {
collection, err := impl.Get(ctx, id)
if err != nil {
return fmt.Errorf("failed to get collection for restore: %w", err)
}
if collection == nil {
return fmt.Errorf("collection not found")
}
// Validate state transition
if err := dom_collection.IsValidStateTransition(collection.State, dom_collection.CollectionStateActive); err != nil {
return fmt.Errorf("invalid state transition: %w", err)
}
// Update collection state
collection.State = dom_collection.CollectionStateActive
collection.ModifiedAt = time.Now()
collection.Version++
collection.TombstoneVersion = 0
collection.TombstoneExpiry = time.Time{}
return impl.Update(ctx, collection)
}