Skip to content

Commit

Permalink
Further fixes following tests
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed Aug 3, 2020
1 parent 38161bb commit fc72ce3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions cmd/reva/open-file-in-app-provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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] <path> <viewMode (view, read, write)>"
return "Usage: open-file-in-app-provider [-flags] [-viewMode view|read|write] <path>"
}
viewMode := cmd.String("viewMode", "view", "the view permissions, defaults to view")

Expand All @@ -43,7 +43,7 @@ func openFileInAppProviderCommand() *command {
}
path := cmd.Args()[0]

viewMode := getViewMode(*viewMode)
vm := getViewMode(*viewMode)

client, err := getClient()
if err != nil {
Expand All @@ -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 {
Expand Down
6 changes: 2 additions & 4 deletions internal/grpc/services/appprovider/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,13 @@ 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"),
}
return res, nil
}
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)),
}
Expand Down Expand Up @@ -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"),
}
Expand All @@ -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),
Expand Down
6 changes: 6 additions & 0 deletions internal/grpc/services/gateway/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ 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"
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
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"
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit fc72ce3

Please sign in to comment.