From db765ecbe81ded384f85891dbe61f1d0b3c74458 Mon Sep 17 00:00:00 2001 From: Ishank Arora Date: Tue, 25 May 2021 13:54:04 +0200 Subject: [PATCH] Cleanup datatx --- internal/grpc/services/gateway/ocmshareprovider.go | 4 ++-- .../services/ocmshareprovider/ocmshareprovider.go | 14 -------------- internal/http/services/ocmd/shares.go | 9 --------- pkg/ocm/share/manager/json/json.go | 5 ++--- 4 files changed, 4 insertions(+), 28 deletions(-) diff --git a/internal/grpc/services/gateway/ocmshareprovider.go b/internal/grpc/services/gateway/ocmshareprovider.go index efa2f25a22..872009d9c1 100644 --- a/internal/grpc/services/gateway/ocmshareprovider.go +++ b/internal/grpc/services/gateway/ocmshareprovider.go @@ -260,7 +260,7 @@ func (s *svc) UpdateReceivedOCMShare(ctx context.Context, req *ocm.UpdateReceive panic("gateway: error updating a received share: the share is nil") } - createRefStatus, err := s.createWebdavReference(ctx, share.Share) + createRefStatus, err := s.createOCMReference(ctx, share.Share) return &ocm.UpdateReceivedOCMShareResponse{ Status: createRefStatus, }, err @@ -291,7 +291,7 @@ func (s *svc) GetReceivedOCMShare(ctx context.Context, req *ocm.GetReceivedOCMSh return res, nil } -func (s *svc) createWebdavReference(ctx context.Context, share *ocm.Share) (*rpc.Status, error) { +func (s *svc) createOCMReference(ctx context.Context, share *ocm.Share) (*rpc.Status, error) { log := appctx.GetLogger(ctx) diff --git a/internal/grpc/services/ocmshareprovider/ocmshareprovider.go b/internal/grpc/services/ocmshareprovider/ocmshareprovider.go index e48e828b69..1b4e8676db 100644 --- a/internal/grpc/services/ocmshareprovider/ocmshareprovider.go +++ b/internal/grpc/services/ocmshareprovider/ocmshareprovider.go @@ -20,7 +20,6 @@ package ocmshareprovider import ( "context" - "encoding/json" ocm "github.com/cs3org/go-cs3apis/cs3/sharing/ocm/v1beta1" "github.com/cs3org/reva/pkg/errtypes" @@ -47,11 +46,6 @@ type service struct { sm share.Manager } -type shareProtocol struct { - Name string `json:"name"` - Options map[string]interface{} `json:"options"` -} - func (c *config) init() { if c.Driver == "" { c.Driver = "json" @@ -155,14 +149,6 @@ func (s *service) CreateOCMShare(ctx context.Context, req *ocm.CreateOCMShareReq protocol, ok := req.Opaque.Map["protocol"] if ok { switch protocol.Decoder { - case "json": - var sp *shareProtocol - err := json.Unmarshal(protocol.Value, &sp) - if err != nil { - return &ocm.CreateOCMShareResponse{ - Status: status.NewInternal(ctx, err, "error decoding protocol"), - }, nil - } case "plain": if string(protocol.Value) == "datatx" { sharetype = ocm.Share_SHARE_TYPE_TRANSFER diff --git a/internal/http/services/ocmd/shares.go b/internal/http/services/ocmd/shares.go index 9fcf9a5057..6be1158068 100644 --- a/internal/http/services/ocmd/shares.go +++ b/internal/http/services/ocmd/shares.go @@ -155,11 +155,6 @@ func (h *sharesHandler) createShare(w http.ResponseWriter, r *http.Request) { return } - desiredProtocol, ok := options["protocol"].(string) - if !ok { - desiredProtocol = "" - } - ownerID := &userpb.UserId{ OpaqueId: owner, Idp: meshProvider, @@ -181,10 +176,6 @@ func (h *sharesHandler) createShare(w http.ResponseWriter, r *http.Request) { Decoder: "plain", Value: []byte(token), }, - "protocol": { - Decoder: "plain", - Value: []byte(desiredProtocol), - }, }, }, }, diff --git a/pkg/ocm/share/manager/json/json.go b/pkg/ocm/share/manager/json/json.go index 6746685f29..7a4e9d867a 100644 --- a/pkg/ocm/share/manager/json/json.go +++ b/pkg/ocm/share/manager/json/json.go @@ -274,14 +274,13 @@ func (m *mgr) Share(ctx context.Context, md *provider.ResourceId, g *ocm.ShareGr return nil, errors.New("Could not get token from context") } var protocol []byte - if st == ocm.Share_SHARE_TYPE_TRANSFER { // data transfer + if st == ocm.Share_SHARE_TYPE_TRANSFER { protocol, err = json.Marshal( map[string]interface{}{ "name": "datatx", "options": map[string]string{ "permissions": pm, "token": token, - "protocol": "datatx", }, }, ) @@ -290,7 +289,7 @@ func (m *mgr) Share(ctx context.Context, md *provider.ResourceId, g *ocm.ShareGr return nil, err } - } else { // 'regular' share + } else { protocol, err = json.Marshal( map[string]interface{}{ "name": "webdav",