xunliu commented on code in PR #5967: URL: https://github.com/apache/gravitino/pull/5967#discussion_r1897073070
########## core/src/main/java/org/apache/gravitino/authorization/PathBasedMetadataObject.java: ########## @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.gravitino.authorization; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import java.util.List; +import javax.annotation.Nullable; +import org.apache.gravitino.MetadataObject; + +public class PathBasedMetadataObject implements AuthorizationMetadataObject { + /** + * The type of object in the Ranger system. Every type will map one kind of the entity of the + * Gravitino type system. + */ + public enum Type implements AuthorizationMetadataObject.Type { + /** A path is mapped the path of storages like HDFS, S3 etc. */ + FILESET(MetadataObject.Type.FILESET), + TABLE(MetadataObject.Type.TABLE), + SCHEMA(MetadataObject.Type.SCHEMA), + CATALOG(MetadataObject.Type.CATALOG); + + private final MetadataObject.Type metadataType; + + Type(MetadataObject.Type type) { + this.metadataType = type; + } + + public MetadataObject.Type metadataObjectType() { + return metadataType; + } + + public static PathBasedMetadataObject.Type fromMetadataType(MetadataObject.Type metadataType) { + for (PathBasedMetadataObject.Type type : PathBasedMetadataObject.Type.values()) { + if (type.metadataObjectType() == metadataType) { + return type; + } + } + throw new IllegalArgumentException( + "No matching RangerMetadataObject.Type for " + metadataType); + } + } Review Comment: We only define one PathBased metadata object type `PATH` ``` public enum Type implements AuthorizationMetadataObject.Type { /** A path is mapped the path of storages like HDFS, S3 etc. */ PATH(MetadataObject.Type.FILESET, MetadataObject.Type.TABLE, MetadataObject.Type.SCHEMA, MetadataObject.Type. CATALOG); private final Set<MetadataObject.Type> validTypes; Type(MetadataObject.Type... types) { this.validTypes = EnumSet.copyOf(Arrays.asList(types)); } public boolean isValidType(MetadataObject.Type type) { return validTypes.contains(type); } } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@gravitino.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org