@@ -75,13 +75,6 @@ func (shareMgr) RevaPlugin() reva.PluginInfo {
7575 }
7676}
7777
78- func (publicShareMgr ) RevaPlugin () reva.PluginInfo {
79- return reva.PluginInfo {
80- ID : "grpc.services.publicshareprovider.drivers.gorm" ,
81- New : NewPublicShareManager ,
82- }
83- }
84-
8578type config struct {
8679 Engine string `mapstructure:"engine"` // mysql | sqlite
8780 DBUsername string `mapstructure:"db_username"`
@@ -95,15 +88,6 @@ type config struct {
9588
9689// Aliased so we can export the right plugin ID
9790type shareMgr struct {
98- mgr
99- }
100-
101- // Aliased so we can export the right plugin ID
102- type publicShareMgr struct {
103- mgr
104- }
105-
106- type mgr struct {
10791 c * config
10892 db * gorm.DB
10993}
@@ -113,18 +97,6 @@ func (c *config) ApplyDefaults() {
11397}
11498
11599func NewShareManager (ctx context.Context , m map [string ]interface {}) (revashare.Manager , error ) {
116- shareMgr , err := New (ctx , m )
117- return shareMgr .(revashare.Manager ), err
118- }
119-
120- func NewPublicShareManager (ctx context.Context , m map [string ]interface {}) (publicshare.Manager , error ) {
121- shareMgr , err := New (ctx , m )
122- return shareMgr .(publicshare.Manager ), err
123-
124- }
125-
126- // New returns a new ShareAndPublicShareManager.
127- func New (ctx context.Context , m map [string ]interface {}) (ShareAndPublicShareManager , error ) {
128100 var c config
129101 if err := cfg .Decode (m , & c ); err != nil {
130102 return nil , err
@@ -147,19 +119,20 @@ func New(ctx context.Context, m map[string]interface{}) (ShareAndPublicShareMana
147119 }
148120
149121 // Migrate schemas
150- err = db .AutoMigrate (& model.Share {}, & model.PublicLink {}, & model. ShareState {})
122+ err = db .AutoMigrate (& model.Share {}, & model.ShareState {})
151123
152124 if err != nil {
153125 return nil , err
154126 }
155127
156- return & mgr {
128+ mgr := & shareMgr {
157129 c : & c ,
158130 db : db ,
159- }, nil
131+ }
132+ return mgr , nil
160133}
161134
162- func (m * mgr ) Share (ctx context.Context , md * provider.ResourceInfo , g * collaboration.ShareGrant ) (* collaboration.Share , error ) {
135+ func (m * shareMgr ) Share (ctx context.Context , md * provider.ResourceInfo , g * collaboration.ShareGrant ) (* collaboration.Share , error ) {
163136 user := appctx .ContextMustGetUser (ctx )
164137
165138 // do not allow share to myself or the owner if share is for a user
@@ -207,7 +180,7 @@ func (m *mgr) Share(ctx context.Context, md *provider.ResourceInfo, g *collabora
207180}
208181
209182// Get Share by ID. Does not return orphans.
210- func (m * mgr ) getShareByID (ctx context.Context , id * collaboration.ShareId ) (* model.Share , error ) {
183+ func (m * shareMgr ) getShareByID (ctx context.Context , id * collaboration.ShareId ) (* model.Share , error ) {
211184 var share model.Share
212185 res := m .db .First (& share , id .OpaqueId )
213186
@@ -219,7 +192,7 @@ func (m *mgr) getShareByID(ctx context.Context, id *collaboration.ShareId) (*mod
219192}
220193
221194// Get Share by Key. Does not return orphans.
222- func (m * mgr ) getShareByKey (ctx context.Context , key * collaboration.ShareKey , checkOwner bool ) (* model.Share , error ) {
195+ func (m * shareMgr ) getShareByKey (ctx context.Context , key * collaboration.ShareKey , checkOwner bool ) (* model.Share , error ) {
223196 owner := conversions .FormatUserID (key .Owner )
224197
225198 var share model.Share
@@ -248,7 +221,7 @@ func (m *mgr) getShareByKey(ctx context.Context, key *collaboration.ShareKey, ch
248221 return & share , nil
249222}
250223
251- func (m * mgr ) getShare (ctx context.Context , ref * collaboration.ShareReference ) (* model.Share , error ) {
224+ func (m * shareMgr ) getShare (ctx context.Context , ref * collaboration.ShareReference ) (* model.Share , error ) {
252225 var s * model.Share
253226 var err error
254227 switch {
@@ -283,7 +256,7 @@ func (m *mgr) getShare(ctx context.Context, ref *collaboration.ShareReference) (
283256 return nil , errtypes .NotFound (ref .String ())
284257}
285258
286- func (m * mgr ) GetShare (ctx context.Context , ref * collaboration.ShareReference ) (* collaboration.Share , error ) {
259+ func (m * shareMgr ) GetShare (ctx context.Context , ref * collaboration.ShareReference ) (* collaboration.Share , error ) {
287260 share , err := m .getShare (ctx , ref )
288261 if err != nil {
289262 return nil , err
@@ -295,7 +268,7 @@ func (m *mgr) GetShare(ctx context.Context, ref *collaboration.ShareReference) (
295268 return cs3share , nil
296269}
297270
298- func (m * mgr ) Unshare (ctx context.Context , ref * collaboration.ShareReference ) error {
271+ func (m * shareMgr ) Unshare (ctx context.Context , ref * collaboration.ShareReference ) error {
299272 var share * model.Share
300273 var err error
301274 if id := ref .GetId (); id != nil {
@@ -310,7 +283,7 @@ func (m *mgr) Unshare(ctx context.Context, ref *collaboration.ShareReference) er
310283 return res .Error
311284}
312285
313- func (m * mgr ) UpdateShare (ctx context.Context , ref * collaboration.ShareReference , p * collaboration.SharePermissions ) (* collaboration.Share , error ) {
286+ func (m * shareMgr ) UpdateShare (ctx context.Context , ref * collaboration.ShareReference , p * collaboration.SharePermissions ) (* collaboration.Share , error ) {
314287 var share * model.Share
315288 var err error
316289 if id := ref .GetId (); id != nil {
@@ -331,7 +304,7 @@ func (m *mgr) UpdateShare(ctx context.Context, ref *collaboration.ShareReference
331304 return m .GetShare (ctx , ref )
332305}
333306
334- func (m * mgr ) getPath (ctx context.Context , resID * provider.ResourceId ) (string , error ) {
307+ func (m * shareMgr ) getPath (ctx context.Context , resID * provider.ResourceId ) (string , error ) {
335308 client , err := pool .GetGatewayServiceClient (pool .Endpoint (m .c .GatewaySvc ))
336309 if err != nil {
337310 return "" , err
@@ -353,7 +326,7 @@ func (m *mgr) getPath(ctx context.Context, resID *provider.ResourceId) (string,
353326 return "" , errors .New (res .Status .Code .String () + ": " + res .Status .Message )
354327}
355328
356- func (m * mgr ) isProjectAdmin (u * userpb.User , path string ) bool {
329+ func (m * shareMgr ) isProjectAdmin (u * userpb.User , path string ) bool {
357330 if strings .HasPrefix (path , projectPathPrefix ) {
358331 // The path will look like /eos/project/c/cernbox, we need to extract the project name
359332 parts := strings .SplitN (path , "/" , 6 )
@@ -373,7 +346,7 @@ func (m *mgr) isProjectAdmin(u *userpb.User, path string) bool {
373346 return false
374347}
375348
376- func (m * mgr ) ListShares (ctx context.Context , filters []* collaboration.Filter ) ([]* collaboration.Share , error ) {
349+ func (m * shareMgr ) ListShares (ctx context.Context , filters []* collaboration.Filter ) ([]* collaboration.Share , error ) {
377350 uid := conversions .FormatUserID (appctx .ContextMustGetUser (ctx ).Id )
378351
379352 query := m .db .Model (& model.Share {}).
@@ -400,7 +373,7 @@ func (m *mgr) ListShares(ctx context.Context, filters []*collaboration.Filter) (
400373}
401374
402375// we list the shares that are targeted to the user in context or to the user groups.
403- func (m * mgr ) ListReceivedShares (ctx context.Context , filters []* collaboration.Filter ) ([]* collaboration.ReceivedShare , error ) {
376+ func (m * shareMgr ) ListReceivedShares (ctx context.Context , filters []* collaboration.Filter ) ([]* collaboration.ReceivedShare , error ) {
404377 user := appctx .ContextMustGetUser (ctx )
405378
406379 // We need to do this to parse the result
@@ -448,7 +421,7 @@ func (m *mgr) ListReceivedShares(ctx context.Context, filters []*collaboration.F
448421 return receivedShares , nil
449422}
450423
451- func (m * mgr ) getShareState (ctx context.Context , share * model.Share , user * userpb.User ) (* model.ShareState , error ) {
424+ func (m * shareMgr ) getShareState (ctx context.Context , share * model.Share , user * userpb.User ) (* model.ShareState , error ) {
452425 var shareState model.ShareState
453426 query := m .db .Model (& shareState ).
454427 Where ("share_id = ?" , share .ID ).
@@ -484,7 +457,7 @@ func emptyShareWithId(id string) (*model.Share, error) {
484457 return share , nil
485458}
486459
487- func (m * mgr ) getReceivedByID (ctx context.Context , id * collaboration.ShareId , gtype userpb.UserType ) (* collaboration.ReceivedShare , error ) {
460+ func (m * shareMgr ) getReceivedByID (ctx context.Context , id * collaboration.ShareId , gtype userpb.UserType ) (* collaboration.ReceivedShare , error ) {
488461 user := appctx .ContextMustGetUser (ctx )
489462 share , err := m .getShareByID (ctx , id )
490463 if err != nil {
@@ -500,7 +473,7 @@ func (m *mgr) getReceivedByID(ctx context.Context, id *collaboration.ShareId, gt
500473 return receivedShare , nil
501474}
502475
503- func (m * mgr ) getReceivedByKey (ctx context.Context , key * collaboration.ShareKey , gtype userpb.UserType ) (* collaboration.ReceivedShare , error ) {
476+ func (m * shareMgr ) getReceivedByKey (ctx context.Context , key * collaboration.ShareKey , gtype userpb.UserType ) (* collaboration.ReceivedShare , error ) {
504477 user := appctx .ContextMustGetUser (ctx )
505478 share , err := m .getShareByKey (ctx , key , false )
506479 if err != nil {
@@ -516,7 +489,7 @@ func (m *mgr) getReceivedByKey(ctx context.Context, key *collaboration.ShareKey,
516489 return receivedShare , nil
517490}
518491
519- func (m * mgr ) GetReceivedShare (ctx context.Context , ref * collaboration.ShareReference ) (* collaboration.ReceivedShare , error ) {
492+ func (m * shareMgr ) GetReceivedShare (ctx context.Context , ref * collaboration.ShareReference ) (* collaboration.ReceivedShare , error ) {
520493 var s * collaboration.ReceivedShare
521494 var err error
522495 switch {
@@ -540,7 +513,7 @@ func (m *mgr) GetReceivedShare(ctx context.Context, ref *collaboration.ShareRefe
540513 return s , nil
541514}
542515
543- func (m * mgr ) UpdateReceivedShare (ctx context.Context , recvShare * collaboration.ReceivedShare , fieldMask * field_mask.FieldMask ) (* collaboration.ReceivedShare , error ) {
516+ func (m * shareMgr ) UpdateReceivedShare (ctx context.Context , recvShare * collaboration.ReceivedShare , fieldMask * field_mask.FieldMask ) (* collaboration.ReceivedShare , error ) {
544517
545518 user := appctx .ContextMustGetUser (ctx )
546519
@@ -587,7 +560,7 @@ func (m *mgr) UpdateReceivedShare(ctx context.Context, recvShare *collaboration.
587560 return rs , nil
588561}
589562
590- func (m * mgr ) getUserType (ctx context.Context , username string ) (userpb.UserType , error ) {
563+ func (m * shareMgr ) getUserType (ctx context.Context , username string ) (userpb.UserType , error ) {
591564 client , err := pool .GetGatewayServiceClient (pool .Endpoint (m .c .GatewaySvc ))
592565 if err != nil {
593566 return userpb .UserType_USER_TYPE_PRIMARY , err
@@ -606,7 +579,7 @@ func (m *mgr) getUserType(ctx context.Context, username string) (userpb.UserType
606579 return userRes .GetUser ().Id .Type , nil
607580}
608581
609- func (m * mgr ) appendShareFiltersToQuery (query * gorm.DB , filters []* collaboration.Filter ) {
582+ func (m * shareMgr ) appendShareFiltersToQuery (query * gorm.DB , filters []* collaboration.Filter ) {
610583 // We want to chain filters of different types with AND
611584 // and filters of the same type with OR
612585 // Therefore, we group them by type
0 commit comments