@@ -45,10 +45,11 @@ public Response getShare(String share) {
4545 return wrapExceptions (
4646 () ->
4747 optionalToNotFound (shareService .getShare (share ),
48- s -> {
48+ foundShare ->
49+ shareToForbidden (foundShare , s -> {
4950 var resultShare = new Share ().name (s .name ()).id (s .id ());
5051 return Response .ok (resultShare ).build ();
51- }),
52+ })) ,
5253 exceptionToResponse );
5354 }
5455
@@ -73,24 +74,25 @@ public Response getTableMetadata(
7374 String startingTimestampStr ,
7475 String deltaSharingCapabilities ) {
7576 return wrapExceptions (
76- () -> {
77- var startingTimestamp = parseTimestamp (startingTimestampStr );
78- return optionalToNotFound (
79- deltaSharesService .getTableMetadata (share , schema , table , startingTimestamp ),
80- m -> optionalToNotFound (
81- deltaSharesService .getTableVersion (share , schema , table , startingTimestamp ),
82- v -> Response .ok (
83- tableResponseSerializer .serialize (
84- DeltaMappers .toTableResponseMetadata (m )),
85- ndjsonMediaType )
86- .status (Response .Status .OK .getStatusCode ())
87- .header (DELTA_TABLE_VERSION_HEADER , String .valueOf (v ))
88- .header (
89- DELTA_SHARE_CAPABILITIES_HEADER ,
90- getResponseFormatHeader (
91- DeltaMappers .toHeaderCapabilitiesMap (deltaSharingCapabilities )))
92- .build ()));
93- },
77+ () ->
78+ optionalToNotFound (shareService .getShare (share ), foundShare -> shareToForbidden (foundShare , s -> {
79+ var startingTimestamp = parseTimestamp (startingTimestampStr );
80+ return optionalToNotFound (
81+ deltaSharesService .getTableMetadata (share , schema , table , startingTimestamp ),
82+ m -> optionalToNotFound (
83+ deltaSharesService .getTableVersion (share , schema , table , startingTimestamp ),
84+ v -> Response .ok (
85+ tableResponseSerializer .serialize (
86+ DeltaMappers .toTableResponseMetadata (m )),
87+ ndjsonMediaType )
88+ .status (Response .Status .OK .getStatusCode ())
89+ .header (DELTA_TABLE_VERSION_HEADER , String .valueOf (v ))
90+ .header (
91+ DELTA_SHARE_CAPABILITIES_HEADER ,
92+ getResponseFormatHeader (
93+ DeltaMappers .toHeaderCapabilitiesMap (deltaSharingCapabilities )))
94+ .build ()));
95+ })),
9496 exceptionToResponse );
9597 }
9698
@@ -99,28 +101,31 @@ public Response getTableVersion(
99101 String share , String schema , String table , String startingTimestampStr ) {
100102
101103 return wrapExceptions (
102- () -> {
104+ () ->
105+ optionalToNotFound (shareService .getShare (share ), foundShare -> shareToForbidden (foundShare , s -> {
103106 var startingTimestamp = parseTimestamp (startingTimestampStr );
104107 return optionalToNotFound (
105108 deltaSharesService .getTableVersion (share , schema , table , startingTimestamp ),
106109 t -> Response .ok ().header (DELTA_TABLE_VERSION_HEADER , t ).build ());
107- },
110+ })) ,
108111 exceptionToResponse );
109112 }
110113
111114 @ Override
112115 public Response listALLTables (String share , Integer maxResults , String pageToken ) {
113116 return wrapExceptions (
114- () -> optionalToNotFound (
115- deltaSharesService .listTablesOfShare (
116- share , parseToken (pageToken ), Optional .ofNullable (maxResults )),
117- c -> Response .ok (c .getToken ()
118- .map (t -> new ListTablesResponse ()
119- .items (mapList (c .getContent (), DeltaMappers ::table2api ))
120- .nextPageToken (tokenEncoder .encodePageToken (t )))
121- .orElse (new ListTablesResponse ()
122- .items (mapList (c .getContent (), DeltaMappers ::table2api ))))
123- .build ()),
117+ () ->
118+ optionalToNotFound (shareService .getShare (share ), foundShare -> shareToForbidden (foundShare , s ->
119+ optionalToNotFound (
120+ deltaSharesService .listTablesOfShare (
121+ share , parseToken (pageToken ), Optional .ofNullable (maxResults )),
122+ c -> Response .ok (c .getToken ()
123+ .map (t -> new ListTablesResponse ()
124+ .items (mapList (c .getContent (), DeltaMappers ::table2api ))
125+ .nextPageToken (tokenEncoder .encodePageToken (t )))
126+ .orElse (new ListTablesResponse ()
127+ .items (mapList (c .getContent (), DeltaMappers ::table2api ))))
128+ .build ()))),
124129 exceptionToResponse );
125130 }
126131
0 commit comments