Skip to content

Commit

Permalink
reduce changes to share api change
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed Oct 1, 2021
1 parent 5beb9b9 commit 536e416
Show file tree
Hide file tree
Showing 37 changed files with 1,638 additions and 3,150 deletions.
1 change: 0 additions & 1 deletion .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,6 @@ def ocisIntegrationTests(parallelRuns, skipExceptParts = []):
"/drone/src/cmd/revad/revad -c storage-home-ocis.toml &",
"/drone/src/cmd/revad/revad -c storage-oc-ocis.toml &",
"/drone/src/cmd/revad/revad -c storage-publiclink-ocis.toml &",
"/drone/src/cmd/revad/revad -c storage-shares-ocis.toml &",
"/drone/src/cmd/revad/revad -c ldap-users.toml",
],
},
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ This will require some PHP-related tools to run, for instance on Ubuntu you will
../../../cmd/revad/revad -c shares.toml &
../../../cmd/revad/revad -c storage-home.toml &
../../../cmd/revad/revad -c storage-users.toml &
../../../cmd/revad/revad -c storage-shares.toml &
../../../cmd/revad/revad -c storage-publiclink.toml &
../../../cmd/revad/revad -c ldap-users.toml
```
Expand All @@ -145,9 +144,7 @@ This will require some PHP-related tools to run, for instance on Ubuntu you will
TEST_WITH_LDAP='true' \
REVA_LDAP_HOSTNAME='localhost' \
TEST_REVA='true' \
BEHAT_FILTER_TAGS='~@notToImplementOnOCIS&&~@toImplementOnOCIS&&~comments-app-required&&~@federation-app-required&&~@notifications-app-required&&~systemtags-app-required&&~@provisioning_api-app-required&&~@preview-extension-required&&~@local_storage&&~@skipOnOcis-OCIS-Storage&&~@skipOnOcis' \
EXPECTECTED_FAILURES_FILE='../acceptance/expected-failures-on-OCIS-storage.md' \
DELETE_USER_DATA_CMD="rm -rf /var/tmp/reva/data/nodes/root/* /var/tmp/reva/data/nodes/*-*-*-* /var/tmp/reva/data/blobs/* /var/tmp/reva/data/spaces/*" \
BEHAT_FILTER_TAGS='~@skipOnOcis&&~@skipOnOcis-OCIS-Storage&&~@notToImplementOnOCIS' \
make test-acceptance-api
```
Expand Down
5 changes: 5 additions & 0 deletions changelog/unreleased/sharemanager-api-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Change: Sharemanager API change

This PR updates reva to reflect the share manager CS3 API changes.

https://github.com/cs3org/reva/pull/2121
6 changes: 0 additions & 6 deletions changelog/unreleased/tbd.md

This file was deleted.

10 changes: 10 additions & 0 deletions internal/grpc/services/gateway/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,17 @@ func (s *svc) OpenInApp(ctx context.Context, req *gateway.OpenInAppRequest) (*pr
}, nil
}

if s.isSharedFolder(ctx, p) {
return &providerpb.OpenInAppResponse{
Status: status.NewInvalid(ctx, "gateway: can't open shares folder"),
}, nil
}

resName, resChild := p, ""
if s.isShareChild(ctx, p) {
resName, resChild = s.splitShare(ctx, p)
}

statRes, err := s.stat(ctx, &storageprovider.StatRequest{
Ref: &storageprovider.Reference{Path: resName},
})
Expand Down
43 changes: 21 additions & 22 deletions internal/grpc/services/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,27 @@ func init() {
}

type config struct {
StorageRules map[string]map[string]interface{} `mapstructure:"storage_rules"`
AuthRegistryEndpoint string `mapstructure:"authregistrysvc"`
ApplicationAuthEndpoint string `mapstructure:"applicationauthsvc"`
StorageRegistryEndpoint string `mapstructure:"storageregistrysvc"`
AppRegistryEndpoint string `mapstructure:"appregistrysvc"`
PreferencesEndpoint string `mapstructure:"preferencessvc"`
UserShareProviderEndpoint string `mapstructure:"usershareprovidersvc"`
PublicShareProviderEndpoint string `mapstructure:"publicshareprovidersvc"`
OCMShareProviderEndpoint string `mapstructure:"ocmshareprovidersvc"`
OCMInviteManagerEndpoint string `mapstructure:"ocminvitemanagersvc"`
OCMProviderAuthorizerEndpoint string `mapstructure:"ocmproviderauthorizersvc"`
OCMCoreEndpoint string `mapstructure:"ocmcoresvc"`
UserProviderEndpoint string `mapstructure:"userprovidersvc"`
GroupProviderEndpoint string `mapstructure:"groupprovidersvc"`
DataTxEndpoint string `mapstructure:"datatx"`
DataGatewayEndpoint string `mapstructure:"datagateway"`
CommitShareToStorageGrant bool `mapstructure:"commit_share_to_storage_grant"`
CommitShareToStorageRef bool `mapstructure:"commit_share_to_storage_ref"`
DisableHomeCreationOnLogin bool `mapstructure:"disable_home_creation_on_login"`
TransferSharedSecret string `mapstructure:"transfer_shared_secret"`
TransferExpires int64 `mapstructure:"transfer_expires"`
TokenManager string `mapstructure:"token_manager"`
AuthRegistryEndpoint string `mapstructure:"authregistrysvc"`
ApplicationAuthEndpoint string `mapstructure:"applicationauthsvc"`
StorageRegistryEndpoint string `mapstructure:"storageregistrysvc"`
AppRegistryEndpoint string `mapstructure:"appregistrysvc"`
PreferencesEndpoint string `mapstructure:"preferencessvc"`
UserShareProviderEndpoint string `mapstructure:"usershareprovidersvc"`
PublicShareProviderEndpoint string `mapstructure:"publicshareprovidersvc"`
OCMShareProviderEndpoint string `mapstructure:"ocmshareprovidersvc"`
OCMInviteManagerEndpoint string `mapstructure:"ocminvitemanagersvc"`
OCMProviderAuthorizerEndpoint string `mapstructure:"ocmproviderauthorizersvc"`
OCMCoreEndpoint string `mapstructure:"ocmcoresvc"`
UserProviderEndpoint string `mapstructure:"userprovidersvc"`
GroupProviderEndpoint string `mapstructure:"groupprovidersvc"`
DataTxEndpoint string `mapstructure:"datatx"`
DataGatewayEndpoint string `mapstructure:"datagateway"`
CommitShareToStorageGrant bool `mapstructure:"commit_share_to_storage_grant"`
CommitShareToStorageRef bool `mapstructure:"commit_share_to_storage_ref"`
DisableHomeCreationOnLogin bool `mapstructure:"disable_home_creation_on_login"`
TransferSharedSecret string `mapstructure:"transfer_shared_secret"`
TransferExpires int64 `mapstructure:"transfer_expires"`
TokenManager string `mapstructure:"token_manager"`
// ShareFolder is the location where to create shares in the recipient's storage provider.
ShareFolder string `mapstructure:"share_folder"`
DataTransfersFolder string `mapstructure:"data_transfers_folder"`
Expand Down
100 changes: 52 additions & 48 deletions internal/grpc/services/gateway/ocmshareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,60 +224,64 @@ func (s *svc) UpdateReceivedOCMShare(ctx context.Context, req *ocm.UpdateReceive
return res, nil
}

// we don't commit received shares in state invalid
if req.Share.State == ocm.ShareState_SHARE_STATE_INVALID {
log.Error().Msg("the update field is invalid, aborting reference manipulation")
return res, nil

}

// TODO(labkode): if update field is displayName we need to do a rename on the storage to align
// share display name and storage filename.
if req.Share.State != ocm.ShareState_SHARE_STATE_INVALID {
if req.Share.State == ocm.ShareState_SHARE_STATE_ACCEPTED {
getShareReq := &ocm.GetReceivedOCMShareRequest{
Ref: &ocm.ShareReference{
Spec: &ocm.ShareReference_Id{
Id: req.Share.Share.Id,
// properties are updated in the order they appear in the field mask
// when an error occurs the request ends and no further fields are updated
for i := range req.UpdateMask.Paths {
switch req.UpdateMask.Paths[i] {
case "state":
switch req.GetShare().GetState() {
case ocm.ShareState_SHARE_STATE_ACCEPTED:
getShareReq := &ocm.GetReceivedOCMShareRequest{
Ref: &ocm.ShareReference{
Spec: &ocm.ShareReference_Id{
Id: req.Share.Share.Id,
},
},
},
}
getShareRes, err := s.GetReceivedOCMShare(ctx, getShareReq)
if err != nil {
log.Err(err).Msg("gateway: error calling GetReceivedShare")
return &ocm.UpdateReceivedOCMShareResponse{
Status: &rpc.Status{
Code: rpc.Code_CODE_INTERNAL,
},
}, nil
}

if getShareRes.Status.Code != rpc.Code_CODE_OK {
log.Error().Msg("gateway: error calling GetReceivedShare")
}
getShareRes, err := s.GetReceivedOCMShare(ctx, getShareReq)
if err != nil {
log.Err(err).Msg("gateway: error calling GetReceivedShare")
return &ocm.UpdateReceivedOCMShareResponse{
Status: &rpc.Status{
Code: rpc.Code_CODE_INTERNAL,
},
}, nil
}

if getShareRes.Status.Code != rpc.Code_CODE_OK {
log.Error().Msg("gateway: error calling GetReceivedShare")
return &ocm.UpdateReceivedOCMShareResponse{
Status: &rpc.Status{
Code: rpc.Code_CODE_INTERNAL,
},
}, nil
}

share := getShareRes.Share
if share == nil {
panic("gateway: error updating a received share: the share is nil")
}

createRefStatus, err := s.createOCMReference(ctx, share.Share)
return &ocm.UpdateReceivedOCMShareResponse{
Status: &rpc.Status{
Code: rpc.Code_CODE_INTERNAL,
},
}, nil
}

share := getShareRes.Share
if share == nil {
panic("gateway: error updating a received share: the share is nil")
Status: createRefStatus,
}, err
case ocm.ShareState_SHARE_STATE_REJECTED:
s.removeReference(ctx, req.GetShare().GetShare().ResourceId) // error is logged inside removeReference
// FIXME we are ignoring an error from removeReference here
return res, nil
}

createRefStatus, err := s.createOCMReference(ctx, share.Share)
case "mount_point":
// TODO(labkode): implementing updating mount point
err = errtypes.NotSupported("gateway: update of mount point is not yet implemented")
return &ocm.UpdateReceivedOCMShareResponse{
Status: createRefStatus,
}, err
Status: status.NewUnimplemented(ctx, err, "error updating received share"),
}, nil
default:
return nil, errtypes.NotSupported("updating " + req.UpdateMask.Paths[i] + " is not supported")
}
}

// TODO(labkode): implementing updating display name
err = errtypes.NotSupported("gateway: update of display name is not yet implemented")
return &ocm.UpdateReceivedOCMShareResponse{
Status: status.NewUnimplemented(ctx, err, "error updating received share"),
}, nil
return res, nil
}

func (s *svc) GetReceivedOCMShare(ctx context.Context, req *ocm.GetReceivedOCMShareRequest) (*ocm.GetReceivedOCMShareResponse, error) {
Expand Down
5 changes: 5 additions & 0 deletions internal/grpc/services/gateway/publicshareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ import (
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
link "github.com/cs3org/go-cs3apis/cs3/sharing/link/v1beta1"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/errtypes"
"github.com/cs3org/reva/pkg/rgrpc/todo/pool"
"github.com/pkg/errors"
)

func (s *svc) CreatePublicShare(ctx context.Context, req *link.CreatePublicShareRequest) (*link.CreatePublicShareResponse, error) {
if s.isSharedFolder(ctx, req.ResourceInfo.GetPath()) {
return nil, errtypes.AlreadyExists("gateway: can't create a public share of the share folder itself")
}

log := appctx.GetLogger(ctx)
log.Info().Msg("create public share")

Expand Down
Loading

0 comments on commit 536e416

Please sign in to comment.