From fc72ce3a3d9064352fd4630b648a1011a8af3cae Mon Sep 17 00:00:00 2001 From: Giuseppe Lo Presti Date: Mon, 3 Aug 2020 15:02:15 +0200 Subject: [PATCH] Further fixes following tests --- cmd/reva/open-file-in-app-provider.go | 6 +++--- internal/grpc/services/appprovider/appprovider.go | 6 ++---- internal/grpc/services/gateway/appprovider.go | 6 ++++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cmd/reva/open-file-in-app-provider.go b/cmd/reva/open-file-in-app-provider.go index 9e5c8c1bd33..f7435628186 100644 --- a/cmd/reva/open-file-in-app-provider.go +++ b/cmd/reva/open-file-in-app-provider.go @@ -31,7 +31,7 @@ func openFileInAppProviderCommand() *command { cmd := newCommand("open-file-in-app-provider") cmd.Description = func() string { return "Open a file in an external app provider" } cmd.Usage = func() string { - return "Usage: open-file-in-app-provider [-flags] " + return "Usage: open-file-in-app-provider [-flags] [-viewMode view|read|write] " } viewMode := cmd.String("viewMode", "view", "the view permissions, defaults to view") @@ -43,7 +43,7 @@ func openFileInAppProviderCommand() *command { } path := cmd.Args()[0] - viewMode := getViewMode(*viewMode) + vm := getViewMode(*viewMode) client, err := getClient() if err != nil { @@ -54,7 +54,7 @@ func openFileInAppProviderCommand() *command { Spec: &provider.Reference_Path{Path: path}, } - openRequest := &gateway.OpenFileInAppProviderRequest{Ref: ref, ViewMode: viewMode} + openRequest := &gateway.OpenFileInAppProviderRequest{Ref: ref, ViewMode: vm} openRes, err := client.OpenFileInAppProvider(ctx, openRequest) if err != nil { diff --git a/internal/grpc/services/appprovider/appprovider.go b/internal/grpc/services/appprovider/appprovider.go index 6f1ce001bcf..5832bceb9c9 100644 --- a/internal/grpc/services/appprovider/appprovider.go +++ b/internal/grpc/services/appprovider/appprovider.go @@ -128,7 +128,6 @@ func (s *service) OpenFileInAppProvider(ctx context.Context, req *providerpb.Ope } appsRes, err := httpClient.Do(appsReq) if err != nil { - log.Error().Err(err).Msg("error performing http request") res := &providerpb.OpenFileInAppProviderResponse{ Status: status.NewInternal(ctx, err, "error performing http request"), } @@ -136,7 +135,6 @@ func (s *service) OpenFileInAppProvider(ctx context.Context, req *providerpb.Ope } defer appsRes.Body.Close() if appsRes.StatusCode != http.StatusOK { - log.Error().Err(err).Msg("error performing http request") res := &providerpb.OpenFileInAppProviderResponse{ Status: status.NewInternal(ctx, err, "error performing http request, status code: "+strconv.Itoa(appsRes.StatusCode)), } @@ -207,7 +205,6 @@ func (s *service) OpenFileInAppProvider(ctx context.Context, req *providerpb.Ope viewOptionsMap, ok := viewOptions.(map[string]interface{}) if !ok { - log.Error().Msg("error typecasting to map") res := &providerpb.OpenFileInAppProviderResponse{ Status: status.NewInternal(ctx, nil, "error typecasting to map"), } @@ -230,7 +227,8 @@ func (s *service) OpenFileInAppProvider(ctx context.Context, req *providerpb.Ope providerURL += "?" } - appProviderURL := fmt.Sprintf("%sWOPISrc=%s\n", providerURL, openResBody) + appProviderURL := fmt.Sprintf("%sWOPISrc=%s", providerURL, openResBody) + log.Info().Msg(fmt.Sprintf("Returning app provider URL %s", appProviderURL)) return &providerpb.OpenFileInAppProviderResponse{ Status: status.NewOK(ctx), diff --git a/internal/grpc/services/gateway/appprovider.go b/internal/grpc/services/gateway/appprovider.go index d8e73cf916e..aa4c0933a17 100644 --- a/internal/grpc/services/gateway/appprovider.go +++ b/internal/grpc/services/gateway/appprovider.go @@ -20,6 +20,7 @@ package gateway import ( "context" + "fmt" providerpb "github.com/cs3org/go-cs3apis/cs3/app/provider/v1beta1" registry "github.com/cs3org/go-cs3apis/cs3/app/registry/v1beta1" @@ -27,6 +28,7 @@ import ( rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" storageprovider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + "github.com/cs3org/reva/pkg/appctx" "github.com/cs3org/reva/pkg/errtypes" "github.com/cs3org/reva/pkg/rgrpc/status" "github.com/cs3org/reva/pkg/rgrpc/todo/pool" @@ -96,6 +98,10 @@ func (s *svc) OpenFileInAppProvider(ctx context.Context, req *gateway.OpenFileIn } // build the appProvider specific request with the required extra info that has been obtained + + log := appctx.GetLogger(ctx) + log.Debug().Msg(fmt.Sprintf("request: %s", req)) + appProviderReq := &providerpb.OpenFileInAppProviderRequest{ ResourceInfo: fileInfo, ViewMode: providerpb.OpenFileInAppProviderRequest_ViewMode(req.ViewMode),