mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 04:09:40 -06:00
refine initialization logic again
Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
@@ -14,10 +14,19 @@ import (
|
||||
// ListBundles returns all bundles in the dataPath folder that match the given type.
|
||||
func (s *Store) ListBundles(bundleType settingsmsg.Bundle_Type, bundleIDs []string) ([]*settingsmsg.Bundle, error) {
|
||||
// TODO: this is needed for initialization - we need to find a better way to fix this
|
||||
if s.mdc == nil {
|
||||
if s.mdc == nil && len(bundleIDs) == 1 {
|
||||
return defaultBundle(bundleType, bundleIDs[0]), nil
|
||||
}
|
||||
//s.Init()
|
||||
s.Init()
|
||||
|
||||
if len(bundleIDs) == 0 {
|
||||
bIDs, err := s.mdc.ReadDir(nil, bundleFolderLocation)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bundleIDs = bIDs
|
||||
}
|
||||
var bundles []*settingsmsg.Bundle
|
||||
for _, id := range bundleIDs {
|
||||
b, err := s.mdc.SimpleDownload(nil, bundlePath(id))
|
||||
@@ -53,6 +62,7 @@ func (s *Store) ReadBundle(bundleID string) (*settingsmsg.Bundle, error) {
|
||||
|
||||
// ReadSetting tries to find a setting by the given id within the dataPath.
|
||||
func (s *Store) ReadSetting(settingID string) (*settingsmsg.Setting, error) {
|
||||
fmt.Println("ReadSetting not implemented")
|
||||
return nil, errors.New("not implemented")
|
||||
}
|
||||
|
||||
@@ -88,6 +98,7 @@ func (s *Store) AddSettingToBundle(bundleID string, setting *settingsmsg.Setting
|
||||
|
||||
// RemoveSettingFromBundle removes the setting from the bundle with the given ids.
|
||||
func (s *Store) RemoveSettingFromBundle(bundleID string, settingID string) error {
|
||||
fmt.Println("RemoveSettingFromBundle not implemented")
|
||||
return errors.New("not implemented")
|
||||
}
|
||||
|
||||
|
||||
@@ -3,13 +3,17 @@ package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"sync"
|
||||
|
||||
"github.com/cs3org/reva/pkg/storage/utils/metadata"
|
||||
"github.com/gofrs/uuid"
|
||||
olog "github.com/owncloud/ocis/ocis-pkg/log"
|
||||
settingsmsg "github.com/owncloud/ocis/protogen/gen/ocis/messages/settings/v0"
|
||||
"github.com/owncloud/ocis/settings/pkg/config"
|
||||
"github.com/owncloud/ocis/settings/pkg/settings"
|
||||
"github.com/owncloud/ocis/settings/pkg/store/defaults"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -116,10 +120,41 @@ func (s *Store) initMetadataClient(mdc MetadataClient) error {
|
||||
}
|
||||
}
|
||||
|
||||
s.mdc = mdc
|
||||
if s.initStore != nil {
|
||||
s.initStore(s)
|
||||
for _, p := range defaults.GenerateBundlesDefaultRoles() {
|
||||
b, err := json.Marshal(p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = mdc.SimpleUpload(nil, bundlePath(p.Id), b)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
for _, p := range defaults.DefaultRoleAssignments() {
|
||||
accountUUID := p.AccountUuid
|
||||
roleID := p.RoleId
|
||||
err = mdc.MakeDirIfNotExist(nil, accountPath(accountUUID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ass := &settingsmsg.UserRoleAssignment{
|
||||
Id: uuid.Must(uuid.NewV4()).String(),
|
||||
AccountUuid: accountUUID,
|
||||
RoleId: roleID,
|
||||
}
|
||||
b, err := json.Marshal(ass)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = mdc.SimpleUpload(nil, assignmentPath(accountUUID, ass.Id), b)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
s.mdc = mdc
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user