Skip to content

Commit

Permalink
Merge pull request #1 from ishank011/tx
Browse files Browse the repository at this point in the history
Cleanup datatx
  • Loading branch information
redblom authored May 25, 2021
2 parents 6ad0f87 + db765ec commit fb66ba3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 28 deletions.
4 changes: 2 additions & 2 deletions internal/grpc/services/gateway/ocmshareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
14 changes: 0 additions & 14 deletions internal/grpc/services/ocmshareprovider/ocmshareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions internal/http/services/ocmd/shares.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
},
},
},
},
Expand Down
5 changes: 2 additions & 3 deletions pkg/ocm/share/manager/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
)
Expand All @@ -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",
Expand Down

0 comments on commit fb66ba3

Please sign in to comment.