Skip to content

Commit

Permalink
Make ocm shares available via GetShare()
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed Nov 8, 2023
1 parent ad4544f commit fa11f89
Showing 1 changed file with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
"google.golang.org/grpc/metadata"
"google.golang.org/protobuf/types/known/fieldmaskpb"

ocm "github.com/cs3org/go-cs3apis/cs3/sharing/ocm/v1beta1"
ocmv1beta1 "github.com/cs3org/go-cs3apis/cs3/sharing/ocm/v1beta1"
"github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/config"
"github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/response"
Expand Down Expand Up @@ -629,6 +630,66 @@ func (h *Handler) GetShare(w http.ResponseWriter, r *http.Request) {
}
}

if share == nil {
// check if we have a federated share
req := &ocm.GetOCMShareRequest{
Ref: &ocm.ShareReference{
Spec: &ocm.ShareReference_Id{
Id: &ocm.ShareId{
OpaqueId: shareID,
},
},
},
}
ocmShareResponse, err := client.GetOCMShare(ctx, req)
if err != nil {
response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error sending a grpc get ocm share request", err)
return
}

ocmShare := ocmShareResponse.GetShare()
if ocmShare != nil {
resourceID = ocmShare.ResourceId
share, err = conversions.OCMShare2ShareData(ocmShare)
if err != nil {
response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error mapping share data", err)
return
}
}
}

if share == nil {
// check if we have an incoming federated share
req := &ocm.GetReceivedOCMShareRequest{
Ref: &ocm.ShareReference{
Spec: &ocm.ShareReference_Id{
Id: &ocm.ShareId{
OpaqueId: shareID,
},
},
},
}
ocmShareResponse, err := client.GetReceivedOCMShare(ctx, req)
if err != nil {
response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error sending a grpc get ocm share request", err)
return
}

ocmShare := ocmShareResponse.GetShare()
if ocmShare != nil {
resourceID = &provider.ResourceId{
StorageId: utils.OCMStorageProviderID,
SpaceId: ocmShare.Id.OpaqueId,
OpaqueId: ocmShare.Id.OpaqueId,
}
share, err = conversions.ReceivedOCMShare2ShareData(ocmShare, h.ocmLocalMount(ocmShare))
if err != nil {
response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error mapping share data", err)
return
}
}
}

if share == nil {
sublog.Debug().Msg("no share found with this id")
response.WriteOCSError(w, r, response.MetaNotFound.StatusCode, "share not found", nil)
Expand Down

0 comments on commit fa11f89

Please sign in to comment.