jerryshao commented on code in PR #5948: URL: https://github.com/apache/gravitino/pull/5948#discussion_r1897154035
########## common/src/main/java/org/apache/gravitino/dto/requests/ModelVersionLinkRequest.java: ########## @@ -0,0 +1,67 @@ +/* + * 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.dto.requests; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Preconditions; +import java.util.Map; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.gravitino.rest.RESTRequest; + +/** Represents a request to link a model version. */ +@Getter +@ToString +@EqualsAndHashCode +@NoArgsConstructor +@AllArgsConstructor +public class ModelVersionLinkRequest implements RESTRequest { + + @JsonProperty("uri") + private String uri; + + @JsonProperty("aliases") + private String[] aliases; + + @JsonProperty("comment") + private String comment; + + @JsonProperty("properties") + private Map<String, String> properties; + + @Override + public void validate() throws IllegalArgumentException { + Preconditions.checkArgument( + StringUtils.isNotBlank(uri), "\"uri\" field is required and cannot be empty"); + + if (aliases != null && aliases.length > 0) { + for (String alias : aliases) { + Preconditions.checkArgument( + StringUtils.isNotBlank(alias), "alias must not be null or empty"); + Preconditions.checkArgument( + !NumberUtils.isCreatable(alias), "alias must not be a number or a number string"); Review Comment: It is because of the current implementation limitation, both the version and the alias will be treated as a part of NameIdentifier, if the name can be parsed as a number, then it will be treated as a version number, to avoid this ambiguity, I added this limitation. I can add the javadoc if needed. -- 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