jerryshao commented on code in PR #14915: URL: https://github.com/apache/gravitino/pull/14915#discussion_r4583131557
########## api/src/main/java/org/apache/gravitino/glossary/GlossaryOperations.java: ########## @@ -0,0 +1,183 @@ +/* + * 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.glossary; + +import javax.annotation.Nullable; +import org.apache.gravitino.annotation.Evolving; +import org.apache.gravitino.exceptions.ForbiddenException; +import org.apache.gravitino.exceptions.NoSuchMetalakeException; +import org.apache.gravitino.exceptions.NoSuchTermException; +import org.apache.gravitino.exceptions.NotFoundException; +import org.apache.gravitino.exceptions.TermAlreadyExistsException; + +/** + * Interface for the glossary term operations of a metalake. + * + * <p>A term that the caller cannot see, for example a {@link GlossaryTerm.Status#DRAFT} term of + * another user, is left out of lists, and getting it throws {@link NoSuchTermException}. + * + * <p>In Step 1, {@code VIEW_DEFINITION} permits reading approved and deprecated terms. {@code + * CREATE_DEFINITION} includes view access and permits creating and maintaining terms owned by the + * caller. {@code MANAGE_DEFINITIONS} includes create and view access and permits managing all + * terms, including other owners' drafts. Ownership means the current owner, including group + * members; ownership alone does not replace effective create access. Expand allowed grant + * implications before applying explicit denies to each required capability. Every term read and + * write requires effective {@code VIEW_DEFINITION}; denying view hides terms from reads and blocks + * writes even for an owner with create access. Denying create prevents creation even with an allow + * on manage, but effective manage can still authorize edits. Denying manage removes the all-term + * path without removing effective create access to own terms. These privileges are granted on the + * metalake in Step 1. The metalake owner passes privilege checks, but remains subject to the Step 2 + * workflow and no-self-approval rule. + * + * <p>The write methods describe Step 1: changes take effect immediately, without review. Step 2 + * adds scoped management and review: new terms default to draft, and another authorized manage user + * must approve a submitted change. Neither management privileges nor a direct status update + * bypasses that workflow. Proposal and decision APIs are separate from these immediate-write + * operations. + */ +@Evolving +public interface GlossaryOperations { + + /** + * Lists the names of the terms in the metalake that are visible to the caller. + * + * @return The names of the terms. + * @throws NoSuchMetalakeException If the metalake does not exist. + */ + String[] listTerms() throws NoSuchMetalakeException; + + /** + * Lists the terms in the metalake that are visible to the caller, with details. + * + * @return The terms. + * @throws NoSuchMetalakeException If the metalake does not exist. + */ + GlossaryTerm[] listTermsInfo() throws NoSuchMetalakeException; + + /** + * Gets a term by its name. The name is compared by its normalized key, so case and extra spaces + * do not matter. + * + * @param name The name of the term. + * @return The term. + * @throws NoSuchTermException If the term does not exist or is not visible to the caller. + */ + GlossaryTerm getTerm(String name) throws NoSuchTermException; + + /** + * Creates a term in Step 1. The caller becomes its owner. Without a status, the server uses + * {@link GlossaryTerm.Status#APPROVED}; this does not mean that a human reviewed the term. + * + * <p>The caller needs effective {@code VIEW_DEFINITION}, effective {@code CREATE_DEFINITION}, and + * read access to each requested domain ({@code USE_DOMAIN}) and referenced broader or related + * term. Returned domains and relations follow the same visibility rules as reads. + * + * @param spec The content of the term. + * @return The created term. + * @throws TermAlreadyExistsException If a term with the same name or the same source reference + * already exists. + * @throws NoSuchTermException If a broader or related term does not exist or is not visible to + * the caller. + * @throws NotFoundException If a requested domain does not exist. + * @throws ForbiddenException If the caller lacks the required creation or domain privilege. + * @throws IllegalArgumentException If a synonym is the name of another term, or a relation is not + * allowed. + */ + GlossaryTerm createTerm(TermSpec spec) + throws TermAlreadyExistsException, NoSuchTermException, NotFoundException, ForbiddenException, + IllegalArgumentException; + + /** + * Alters a term in Step 1. All changes take effect immediately and together: if one fails, none + * is applied. The revision of the term increases by one. Use {@link + * TermChange#setStatus(GlossaryTerm.Status)} to change the status without an approval decision. + * + * <p>The caller needs effective {@code VIEW_DEFINITION}, plus effective {@code + * MANAGE_DEFINITIONS} or current ownership with effective {@code CREATE_DEFINITION}. Read access + * to referenced terms and domains is also required. Returned domains and relations follow the + * same visibility rules as reads. + * + * @param name The name of the term. + * @param changes The changes to apply. + * @return The altered term. + * @throws NoSuchTermException If the term, or a broader or related term in the changes, does not + * exist or is not visible to the caller. + * @throws TermAlreadyExistsException If the term is renamed to the name of another term, or its + * source reference is set to the one of another term. + * @throws NotFoundException If a domain to add does not exist. + * @throws ForbiddenException If the caller can see the term but lacks the required edit or domain + * privilege. + * @throws IllegalArgumentException If a change is not valid, for example a synonym that is the + * name of another term, or a broader term that would create a cycle or a chain longer than + * the depth limit. + */ + GlossaryTerm alterTerm(String name, TermChange... changes) + throws NoSuchTermException, TermAlreadyExistsException, NotFoundException, ForbiddenException, + IllegalArgumentException; + + /** + * Drops a term, with its synonyms, relations, domain links and bindings. An {@link + * GlossaryTerm.Status#APPROVED} term cannot be dropped; deprecate it first. Review Comment: [P1] A manager dropping an `APPROVED` term would get `IllegalArgumentException` under this contract, while T4.14 requires that same call to succeed. Please align the public Javadoc before downstream implementations consume it. Keep the hidden-or-missing result and permission check, and allow an authorized manager to drop the term in any status without a preliminary alter. ########## api/src/main/java/org/apache/gravitino/glossary/GlossaryTerm.java: ########## @@ -0,0 +1,208 @@ +/* + * 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.glossary; + +import java.util.Map; +import java.util.Optional; +import javax.annotation.Nullable; +import org.apache.gravitino.Auditable; +import org.apache.gravitino.annotation.Evolving; +import org.apache.gravitino.exceptions.NoSuchTermException; + +/** + * A glossary term defines a business word, such as "Active Customer", in a metalake. A term has a + * definition, synonyms, links to documentation, and an optional source reference. It can belong to + * zero or more domains, have several broader terms and any number of related terms, and be bound to + * the metadata objects and metrics behind it. + * + * <p>Names and synonyms are compared by a normalized key: spaces at both ends are removed, each run + * of whitespace becomes one space, and the text is lower-cased with {@code Locale.ROOT}. So {@code + * Churn}, {@code churn} and {@code " CHURN "} are the same name. A name is unique in a metalake, + * and a synonym cannot be the name of another term or of its own term. + * + * <p>A {@code GlossaryTerm} is a snapshot. The relation lists hold the names of the terms that are + * visible to the caller; hidden terms are left out. All projections, including mutation responses, + * omit domains the caller cannot read. Lookup results additionally omit non-approved relation + * names, as specified by {@link GlossaryOperations#matchTerms(String[], String)}. + */ +@Evolving +public interface GlossaryTerm extends Auditable { + + /** The status of a term. */ + enum Status { + /** + * The term is being written. In Step 1, reading requires effective {@code VIEW_DEFINITION}. The + * caller must also be the current owner with effective {@code CREATE_DEFINITION} (including + * group members), or have effective {@code MANAGE_DEFINITIONS}. The shared deny rules in {@link + * GlossaryOperations} apply; create access alone does not expose another owner's draft. + */ + DRAFT, + /** + * The term is available to authorized readers and agents. This is the Step 1 creation default, + * not evidence of human review. Step 2 defaults new terms to draft and requires approval. + */ + APPROVED, + /** The term is replaced. It stays readable, but lookups for agents leave it out. */ + DEPRECATED + } + + /** + * Returns the name of the term. The case is kept as the user typed it; spaces at both ends are + * removed. + * + * @return The name of the term. + */ + String name(); + + /** + * Returns the definition of the term. + * + * @return The definition of the term, or null if it is not set. + */ + @Nullable + String definition(); + + /** + * Returns the synonyms of the term. + * + * @return The synonyms of the term, or an empty array if it has none. + */ + String[] synonyms(); + + /** + * Returns the status of the term. + * + * @return The status of the term. + */ + Status status(); + + /** + * Returns the names of the domains the term belongs to that the caller can read. Hidden domain + * names, IDs and counts are not exposed. Filtering does not change stored membership or the + * revision, and a term can remain readable even if all its domains are hidden. + * + * @return The visible domain names, or an empty array if none are visible. + */ + String[] domains(); + + /** + * Returns the names of the direct broader terms. "A has broader term B" means "A is a kind of B". + * + * @return The names of the broader terms, or an empty array if the term is a top-level term. + */ + String[] broader(); + + /** + * Returns the names of the direct narrower terms, the terms that have this term as a broader + * term. Narrower terms are derived from broader terms and cannot be set. + * + * @return The names of the narrower terms, or an empty array if there are none. + */ + String[] narrower(); + + /** + * Returns the names of the related terms. A related link shows on both terms. + * + * @return The names of the related terms, or an empty array if there are none. + */ + String[] related(); + + /** + * Returns the documentation links of the term. + * + * @return The links of the term, or an empty array if there are none. + */ + TermLink[] links(); + + /** + * Returns where an imported term came from, in the form {@code <system>:<id>}, for example {@code + * datahub:urn:li:glossaryTerm:Customer}. It is unique in a metalake. + * + * @return The source reference, or empty if the term was created in Gravitino. + */ + Optional<String> sourceRef(); + + /** + * Returns the properties of the term. + * + * @return The properties of the term. + */ + Map<String, String> properties(); + + /** + * Returns the revision of the term. A new term has revision 1. Each successful alter call + * increases it by one, however many changes the call holds, and so does each bind or unbind call + * that changes the bindings of the term. Owner and tag changes do not increase it. A client can + * use it to see that a term changed after it read it. A revision is not an approved version. + * + * <p>Cleanup also increases the revision of each surviving term that loses a broader parent, + * related relation or binding, exactly once per cleanup transaction regardless of the number of + * losses. Unaffected terms, no-op cleanup and changes only to a derived narrower list do not + * increase it. In Step 2, pending changes do not alter the live revision or content; the previous + * approved state remains available to readers and agents until approval. + * + * @return The revision of the term. + */ + long version(); + + /** + * Returns the words that matched this term. It is set only on the terms returned by {@link + * GlossaryOperations#matchTerms(String[], String)}. + * + * @return The matches of this term, or an empty array if the term was not returned by a lookup. + */ + default TermMatch[] matchedBy() { + return new TermMatch[0]; + } + + /** + * Returns the bindings of the term. It is set only on the terms returned by {@link + * GlossaryOperations#matchTerms(String[], String)}. + * + * <p>The server first leaves out the objects and metrics that the caller cannot access, the same + * as {@link #listBindings(TermBinding.Kind)}. Then it keeps at most 20 of the remaining bindings; + * see {@link #bindingsTruncated()}. Use {@link #listBindings(TermBinding.Kind)} for all of them. + * + * @return The bindings of the term, or an empty array if the term was not returned by a lookup. + */ + default TermBinding[] bindings() { + return new TermBinding[0]; + } + + /** + * Returns whether {@link #bindings()} was cut to the limit. Only the bindings that the caller can + * access count, so a binding to a hidden object never sets this flag. + * + * @return True if the caller can access more bindings of the term than {@link #bindings()} + * returns. + */ + default boolean bindingsTruncated() { + return false; + } + + /** + * Lists the bindings of the term. Only the objects and metrics the caller can access are + * returned. + * + * @param kind The kind of bindings to list, or null to list both kinds. + * @return The bindings of the term. + * @throws NoSuchTermException If the term does not exist or is not visible to the caller. + */ + TermBinding[] listBindings(@Nullable TermBinding.Kind kind) throws NoSuchTermException; Review Comment: [P1] When the first 1,000 candidates are hidden and the next one is visible, an empty `TermBinding[]` cannot tell the caller how to continue. Please expose `listBindings(kind, pageSize, pageToken)` returning a `TermBindingPage` with the visible bindings and continuation. Have the first-page convenience method return the same page type, and cover an empty page with a continuation. ########## api/src/main/java/org/apache/gravitino/MetadataObjects.java: ########## @@ -49,7 +49,8 @@ public class MetadataObjects { MetadataObject.Type.JOB, MetadataObject.Type.JOB_TEMPLATE, MetadataObject.Type.POLICY, - MetadataObject.Type.DOMAIN); + MetadataObject.Type.DOMAIN, + MetadataObject.Type.GLOSSARY_TERM); Review Comment: [P2] The glossary naming test preserves `v1.2/Churn` as one name, but the same value sent through `MetadataObjectDTO` is split at the dot. Please preserve the entire full name for `GLOSSARY_TERM` in `MetadataObjectDTO.setFullName` and add a Jackson round-trip assertion for both `name()` and `parent()`. Checking `fullName()` alone would miss the split. ########## api/src/main/java/org/apache/gravitino/glossary/GlossaryOperations.java: ########## @@ -0,0 +1,183 @@ +/* + * 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.glossary; + +import javax.annotation.Nullable; +import org.apache.gravitino.annotation.Evolving; +import org.apache.gravitino.exceptions.ForbiddenException; +import org.apache.gravitino.exceptions.NoSuchMetalakeException; +import org.apache.gravitino.exceptions.NoSuchTermException; +import org.apache.gravitino.exceptions.NotFoundException; +import org.apache.gravitino.exceptions.TermAlreadyExistsException; + +/** + * Interface for the glossary term operations of a metalake. + * + * <p>A term that the caller cannot see, for example a {@link GlossaryTerm.Status#DRAFT} term of + * another user, is left out of lists, and getting it throws {@link NoSuchTermException}. + * + * <p>In Step 1, {@code VIEW_DEFINITION} permits reading approved and deprecated terms. {@code + * CREATE_DEFINITION} includes view access and permits creating and maintaining terms owned by the + * caller. {@code MANAGE_DEFINITIONS} includes create and view access and permits managing all + * terms, including other owners' drafts. Ownership means the current owner, including group + * members; ownership alone does not replace effective create access. Expand allowed grant + * implications before applying explicit denies to each required capability. Every term read and + * write requires effective {@code VIEW_DEFINITION}; denying view hides terms from reads and blocks + * writes even for an owner with create access. Denying create prevents creation even with an allow + * on manage, but effective manage can still authorize edits. Denying manage removes the all-term + * path without removing effective create access to own terms. These privileges are granted on the + * metalake in Step 1. The metalake owner passes privilege checks, but remains subject to the Step 2 + * workflow and no-self-approval rule. + * + * <p>The write methods describe Step 1: changes take effect immediately, without review. Step 2 + * adds scoped management and review: new terms default to draft, and another authorized manage user + * must approve a submitted change. Neither management privileges nor a direct status update + * bypasses that workflow. Proposal and decision APIs are separate from these immediate-write + * operations. + */ +@Evolving +public interface GlossaryOperations { + + /** + * Lists the names of the terms in the metalake that are visible to the caller. + * + * @return The names of the terms. + * @throws NoSuchMetalakeException If the metalake does not exist. + */ + String[] listTerms() throws NoSuchMetalakeException; + + /** + * Lists the terms in the metalake that are visible to the caller, with details. + * + * @return The terms. + * @throws NoSuchMetalakeException If the metalake does not exist. + */ + GlossaryTerm[] listTermsInfo() throws NoSuchMetalakeException; + + /** + * Gets a term by its name. The name is compared by its normalized key, so case and extra spaces + * do not matter. + * + * @param name The name of the term. + * @return The term. + * @throws NoSuchTermException If the term does not exist or is not visible to the caller. + */ + GlossaryTerm getTerm(String name) throws NoSuchTermException; + + /** + * Creates a term in Step 1. The caller becomes its owner. Without a status, the server uses + * {@link GlossaryTerm.Status#APPROVED}; this does not mean that a human reviewed the term. + * + * <p>The caller needs effective {@code VIEW_DEFINITION}, effective {@code CREATE_DEFINITION}, and + * read access to each requested domain ({@code USE_DOMAIN}) and referenced broader or related + * term. Returned domains and relations follow the same visibility rules as reads. + * + * @param spec The content of the term. + * @return The created term. + * @throws TermAlreadyExistsException If a term with the same name or the same source reference + * already exists. + * @throws NoSuchTermException If a broader or related term does not exist or is not visible to + * the caller. + * @throws NotFoundException If a requested domain does not exist. + * @throws ForbiddenException If the caller lacks the required creation or domain privilege. + * @throws IllegalArgumentException If a synonym is the name of another term, or a relation is not + * allowed. + */ + GlossaryTerm createTerm(TermSpec spec) + throws TermAlreadyExistsException, NoSuchTermException, NotFoundException, ForbiddenException, + IllegalArgumentException; + + /** + * Alters a term in Step 1. All changes take effect immediately and together: if one fails, none + * is applied. The revision of the term increases by one. Use {@link + * TermChange#setStatus(GlossaryTerm.Status)} to change the status without an approval decision. + * + * <p>The caller needs effective {@code VIEW_DEFINITION}, plus effective {@code + * MANAGE_DEFINITIONS} or current ownership with effective {@code CREATE_DEFINITION}. Read access + * to referenced terms and domains is also required. Returned domains and relations follow the + * same visibility rules as reads. + * + * @param name The name of the term. + * @param changes The changes to apply. + * @return The altered term. + * @throws NoSuchTermException If the term, or a broader or related term in the changes, does not + * exist or is not visible to the caller. + * @throws TermAlreadyExistsException If the term is renamed to the name of another term, or its + * source reference is set to the one of another term. + * @throws NotFoundException If a domain to add does not exist. + * @throws ForbiddenException If the caller can see the term but lacks the required edit or domain + * privilege. + * @throws IllegalArgumentException If a change is not valid, for example a synonym that is the + * name of another term, or a broader term that would create a cycle or a chain longer than + * the depth limit. + */ + GlossaryTerm alterTerm(String name, TermChange... changes) Review Comment: [P1] If `X` is dropped and recreated between load and save, this signature lets the stale edit apply to the replacement. Please expose the design's opaque `revisionToken` on `GlossaryTerm`, add an optional expected-token alter overload, and specify `TermVersionConflictException` for a mismatch before any write or no-op detection. Keep unconditional alter available and specify that a matching no-op preserves the revision and token. A same-name replacement at the same numeric version is the important regression case. ########## api/src/main/java/org/apache/gravitino/glossary/GlossaryOperations.java: ########## @@ -0,0 +1,183 @@ +/* + * 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.glossary; + +import javax.annotation.Nullable; +import org.apache.gravitino.annotation.Evolving; +import org.apache.gravitino.exceptions.ForbiddenException; +import org.apache.gravitino.exceptions.NoSuchMetalakeException; +import org.apache.gravitino.exceptions.NoSuchTermException; +import org.apache.gravitino.exceptions.NotFoundException; +import org.apache.gravitino.exceptions.TermAlreadyExistsException; + +/** + * Interface for the glossary term operations of a metalake. + * + * <p>A term that the caller cannot see, for example a {@link GlossaryTerm.Status#DRAFT} term of + * another user, is left out of lists, and getting it throws {@link NoSuchTermException}. + * + * <p>In Step 1, {@code VIEW_DEFINITION} permits reading approved and deprecated terms. {@code + * CREATE_DEFINITION} includes view access and permits creating and maintaining terms owned by the + * caller. {@code MANAGE_DEFINITIONS} includes create and view access and permits managing all + * terms, including other owners' drafts. Ownership means the current owner, including group + * members; ownership alone does not replace effective create access. Expand allowed grant + * implications before applying explicit denies to each required capability. Every term read and + * write requires effective {@code VIEW_DEFINITION}; denying view hides terms from reads and blocks + * writes even for an owner with create access. Denying create prevents creation even with an allow + * on manage, but effective manage can still authorize edits. Denying manage removes the all-term + * path without removing effective create access to own terms. These privileges are granted on the + * metalake in Step 1. The metalake owner passes privilege checks, but remains subject to the Step 2 + * workflow and no-self-approval rule. + * + * <p>The write methods describe Step 1: changes take effect immediately, without review. Step 2 + * adds scoped management and review: new terms default to draft, and another authorized manage user + * must approve a submitted change. Neither management privileges nor a direct status update + * bypasses that workflow. Proposal and decision APIs are separate from these immediate-write + * operations. + */ +@Evolving +public interface GlossaryOperations { + + /** + * Lists the names of the terms in the metalake that are visible to the caller. + * + * @return The names of the terms. + * @throws NoSuchMetalakeException If the metalake does not exist. + */ + String[] listTerms() throws NoSuchMetalakeException; + + /** + * Lists the terms in the metalake that are visible to the caller, with details. + * + * @return The terms. + * @throws NoSuchMetalakeException If the metalake does not exist. + */ + GlossaryTerm[] listTermsInfo() throws NoSuchMetalakeException; + + /** + * Gets a term by its name. The name is compared by its normalized key, so case and extra spaces + * do not matter. + * + * @param name The name of the term. + * @return The term. + * @throws NoSuchTermException If the term does not exist or is not visible to the caller. + */ + GlossaryTerm getTerm(String name) throws NoSuchTermException; + + /** + * Creates a term in Step 1. The caller becomes its owner. Without a status, the server uses + * {@link GlossaryTerm.Status#APPROVED}; this does not mean that a human reviewed the term. + * + * <p>The caller needs effective {@code VIEW_DEFINITION}, effective {@code CREATE_DEFINITION}, and + * read access to each requested domain ({@code USE_DOMAIN}) and referenced broader or related + * term. Returned domains and relations follow the same visibility rules as reads. + * + * @param spec The content of the term. + * @return The created term. + * @throws TermAlreadyExistsException If a term with the same name or the same source reference + * already exists. + * @throws NoSuchTermException If a broader or related term does not exist or is not visible to + * the caller. + * @throws NotFoundException If a requested domain does not exist. + * @throws ForbiddenException If the caller lacks the required creation or domain privilege. + * @throws IllegalArgumentException If a synonym is the name of another term, or a relation is not + * allowed. + */ + GlossaryTerm createTerm(TermSpec spec) + throws TermAlreadyExistsException, NoSuchTermException, NotFoundException, ForbiddenException, + IllegalArgumentException; + + /** + * Alters a term in Step 1. All changes take effect immediately and together: if one fails, none + * is applied. The revision of the term increases by one. Use {@link + * TermChange#setStatus(GlossaryTerm.Status)} to change the status without an approval decision. + * + * <p>The caller needs effective {@code VIEW_DEFINITION}, plus effective {@code + * MANAGE_DEFINITIONS} or current ownership with effective {@code CREATE_DEFINITION}. Read access + * to referenced terms and domains is also required. Returned domains and relations follow the + * same visibility rules as reads. + * + * @param name The name of the term. + * @param changes The changes to apply. + * @return The altered term. + * @throws NoSuchTermException If the term, or a broader or related term in the changes, does not + * exist or is not visible to the caller. + * @throws TermAlreadyExistsException If the term is renamed to the name of another term, or its + * source reference is set to the one of another term. + * @throws NotFoundException If a domain to add does not exist. + * @throws ForbiddenException If the caller can see the term but lacks the required edit or domain + * privilege. + * @throws IllegalArgumentException If a change is not valid, for example a synonym that is the + * name of another term, or a broader term that would create a cycle or a chain longer than + * the depth limit. + */ + GlossaryTerm alterTerm(String name, TermChange... changes) + throws NoSuchTermException, TermAlreadyExistsException, NotFoundException, ForbiddenException, + IllegalArgumentException; + + /** + * Drops a term, with its synonyms, relations, domain links and bindings. An {@link + * GlossaryTerm.Status#APPROVED} term cannot be dropped; deprecate it first. + * + * <p>The checks run in this order: + * + * <ol> + * <li>If the term does not exist, or the caller cannot see it, nothing is dropped and the + * result is false. Both cases give the same result, so a hidden term stays hidden. + * <li>If the caller can see the term but may not drop it, for example a {@link + * GlossaryTerm.Status#DEPRECATED} term dropped by its owner without the manage privilege, a + * {@link ForbiddenException} is thrown. + * <li>If the caller may drop terms but the term is {@link GlossaryTerm.Status#APPROVED}, an + * {@link IllegalArgumentException} is thrown. + * </ol> + * + * @param name The name of the term. + * @return True if the term was dropped, false if it does not exist or is not visible to the + * caller. + * @throws ForbiddenException If the caller can see the term but may not drop it. + * @throws IllegalArgumentException If the term is {@link GlossaryTerm.Status#APPROVED}. + */ + boolean dropTerm(String name) throws ForbiddenException, IllegalArgumentException; + + /** + * Looks up business words, such as the words of a question to an agent. Each word is looked up on + * its own, and its normalized key is compared with the names and synonyms of the terms. Only + * exact matches count, so {@code customers} does not find {@code Customer}. Only {@link + * GlossaryTerm.Status#APPROVED} terms are returned, with {@link GlossaryTerm#matchedBy()} and + * {@link GlossaryTerm#bindings()} set. The bindings only hold the objects and metrics that the + * caller can access, at most 20 per term; see {@link GlossaryTerm#bindings()}. A term is returned + * once, even when it matches several words. + * + * <p>The approved-only restriction applies to roots and all nested relation names, even for an + * owner or a caller with management access who can read drafts through ordinary operations. + * Hidden domains are omitted. Term status and returned content reflect one consistent read + * snapshot. No entry means no authorized approved exact match, not that the word has no business + * meaning. A binding identifies a candidate asset or metric and grants no data access. + * + * @param words The words to look up, at most 20. + * @param domain The name of a domain to limit the lookup to its terms and those of its + * subdomains, or null to look up all terms. + * @return The matched terms. A word that matches no term has no entry. + * @throws NotFoundException If the domain does not exist or is not visible to the caller. + * @throws IllegalArgumentException If no word is given, a word is blank, or there are more words + * than 20 words. + */ + GlossaryTerm[] matchTerms(String[] words, @Nullable String domain) Review Comment: [P1] If binding authorization exhausts the lookup budget for an approved match, the caller needs a way to recover the definition. Please add the `includeBindings` variant and `LookupTooBroadException` specified by T1. Preserve the existing default, and let a definition-only retry retain the same domain and approval filters while representing binding fields as unrequested. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
