mchades commented on code in PR #7361: URL: https://github.com/apache/gravitino/pull/7361#discussion_r2189976363
########## core/src/main/java/org/apache/gravitino/policy/BasePolicy.java: ########## @@ -0,0 +1,285 @@ +/* + * 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.policy; + +import com.google.common.base.Preconditions; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import javax.annotation.Nullable; +import org.apache.commons.lang3.StringUtils; +import org.apache.gravitino.Audit; +import org.apache.gravitino.MetadataObject; +import org.apache.gravitino.exceptions.IllegalPolicyException; + +public class BasePolicy implements Policy { + protected String name; + + protected String type; + + @Nullable protected String comment; + + protected boolean enabled; + + protected boolean exclusive; + + protected boolean inheritable; + + protected Set<MetadataObject.Type> supportedObjectTypes; + + protected Content content; + + protected Audit auditInfo; + + public enum ContentType { + // Non-built-in types are all custom types. + CUSTOM("custom", CustomPolicy.CustomContent.class); + + private final String policyType; + private final Class<? extends Content> contentClass; + + ContentType(String policyType, Class<? extends Content> contentClass) { + this.policyType = policyType; + this.contentClass = contentClass; + } + + public static ContentType fromString(String policyType) { + Preconditions.checkArgument(StringUtils.isNotBlank(policyType), "policyType cannot be blank"); + for (ContentType contentType : ContentType.values()) { + if (contentType.policyType.equalsIgnoreCase(policyType)) { + return contentType; + } + } + return CUSTOM; + } + + public Class<? extends Content> contentClass() { Review Comment: It's used to deserialize content from the backend. -- 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