4
4
*/
5
5
package com .datastrato .gravitino .authorization ;
6
6
7
+ import com .datastrato .gravitino .MetadataObject ;
7
8
import com .google .common .base .Splitter ;
8
9
import com .google .common .collect .ImmutableList ;
9
10
import com .google .common .collect .Lists ;
10
11
import java .util .List ;
11
12
import java .util .Objects ;
13
+ import java .util .stream .Collectors ;
12
14
import org .apache .commons .lang3 .StringUtils ;
13
15
14
16
/** The helper class for {@link SecurableObject}. */
@@ -139,7 +141,11 @@ public String name() {
139
141
140
142
@ Override
141
143
public String fullName () {
142
- return toString ();
144
+ if (parent != null ) {
145
+ return parent + "." + name ;
146
+ } else {
147
+ return name ;
148
+ }
143
149
}
144
150
145
151
@ Override
@@ -159,11 +165,18 @@ public int hashCode() {
159
165
160
166
@ Override
161
167
public String toString () {
162
- if (parent != null ) {
163
- return parent + "." + name ;
164
- } else {
165
- return name ;
166
- }
168
+ String privilegesStr =
169
+ privileges .stream ()
170
+ .map (p -> "[" + p .simpleString () + "]" )
171
+ .collect (Collectors .joining ("," ));
172
+
173
+ return "SecurableObject: [fullName="
174
+ + fullName ()
175
+ + "], [type="
176
+ + type
177
+ + "], [privileges="
178
+ + privilegesStr
179
+ + "]" ;
167
180
}
168
181
169
182
@ Override
@@ -189,9 +202,9 @@ public boolean equals(Object other) {
189
202
* @return The created {@link SecurableObject}
190
203
*/
191
204
public static SecurableObject parse (
192
- String fullName , SecurableObject .Type type , List <Privilege > privileges ) {
205
+ String fullName , MetadataObject .Type type , List <Privilege > privileges ) {
193
206
if ("*" .equals (fullName )) {
194
- if (type != SecurableObject .Type .METALAKE ) {
207
+ if (type != MetadataObject .Type .METALAKE ) {
195
208
throw new IllegalArgumentException ("If securable object isn't metalake, it can't be `*`" );
196
209
}
197
210
return SecurableObjects .ofAllMetalakes (privileges );
@@ -215,7 +228,7 @@ public static SecurableObject parse(
215
228
* @return The created {@link SecurableObject}
216
229
*/
217
230
static SecurableObject of (
218
- SecurableObject .Type type , List <String > names , List <Privilege > privileges ) {
231
+ MetadataObject .Type type , List <String > names , List <Privilege > privileges ) {
219
232
if (names == null ) {
220
233
throw new IllegalArgumentException ("Cannot create a securable object with null names" );
221
234
}
@@ -234,8 +247,8 @@ static SecurableObject of(
234
247
}
235
248
236
249
if (names .size () == 1
237
- && type != SecurableObject .Type .CATALOG
238
- && type != SecurableObject .Type .METALAKE ) {
250
+ && type != MetadataObject .Type .CATALOG
251
+ && type != MetadataObject .Type .METALAKE ) {
239
252
throw new IllegalArgumentException (
240
253
"If the length of names is 1, it must be the CATALOG or METALAKE type" );
241
254
}
@@ -245,9 +258,9 @@ static SecurableObject of(
245
258
}
246
259
247
260
if (names .size () == 3
248
- && type != SecurableObject .Type .FILESET
249
- && type != SecurableObject .Type .TABLE
250
- && type != SecurableObject .Type .TOPIC ) {
261
+ && type != MetadataObject .Type .FILESET
262
+ && type != MetadataObject .Type .TABLE
263
+ && type != MetadataObject .Type .TOPIC ) {
251
264
throw new IllegalArgumentException (
252
265
"If the length of names is 3, it must be FILESET, TABLE or TOPIC" );
253
266
}
0 commit comments