Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#12841] refactor(core): Remove external_id and enabled from user and group metadata (#12842)

MaSai0dcc2ec16b62
diff --git a/api/src/main/java/org/apache/gravitino/authorization/Group.java b/api/src/main/java/org/apache/gravitino/authorization/Group.java
index f97ae948f0..355f2df2d1 100644
--- a/api/src/main/java/org/apache/gravitino/authorization/Group.java
+++ b/api/src/main/java/org/apache/gravitino/authorization/Group.java
@@ -19,7 +19,6 @@
package org.apache.gravitino.authorization;
import java.util.List;
-import javax.annotation.Nullable;
import org.apache.gravitino.Auditable;
import org.apache.gravitino.annotation.Evolving;
@@ -37,29 +36,10 @@ public interface Group extends Auditable {
/**
* The unique id assigned by Gravitino.
*
- * <p>This id is server-assigned and immutable. Upstream systems may also supply an optional
- * {@link #externalId()}.
- *
* @return The unique id of the group.
*/
Long id();
- /**
- * The stable identifier assigned by an upstream identity system (for example, SCIM, LDAP, or
- * IAM), or null if not set.
- *
- * <p>Gravitino {@link Group#name() group names} may differ from upstream ids or be unknown at
- * sync time. External id lets integrators look up and delete groups without relying on the
- * Gravitino group name. Mutable attributes such as {@code externalId} are updated via {@code
- * alterGroupById}.
- *
- * @return The upstream external identifier, or null if not set.
- */
- @Nullable
- default String externalId() {
- return null;
- }
-
/**
* The roles of the group.
*
diff --git a/api/src/main/java/org/apache/gravitino/authorization/GroupChange.java b/api/src/main/java/org/apache/gravitino/authorization/GroupChange.java
deleted file mode 100644
index af9f62e873..0000000000
--- a/api/src/main/java/org/apache/gravitino/authorization/GroupChange.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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 java.util.Objects;
-import javax.annotation.Nullable;
-import org.apache.gravitino.annotation.Evolving;
-
-/**
- * A group change is a change to a group. It can be used to update the optional external id.
- * Multiple changes may be applied in one {@code alterGroupById} call.
- */
-@Evolving
-public interface GroupChange {
-
- /**
- * Creates a group change to update the external identifier.
- *
- * @param newExternalId The new external identifier, or null to clear it.
- * @return The group change.
- */
- static GroupChange updateExternalId(@Nullable String newExternalId) {
- return new UpdateExternalId(newExternalId);
- }
-
- /** A group change to update the external identifier. */
- final class UpdateExternalId implements GroupChange {
- @Nullable private final String newExternalId;
-
- private UpdateExternalId(@Nullable String newExternalId) {
- this.newExternalId = newExternalId;
- }
-
- /**
- * Returns the new external identifier, or null to clear it.
- *
- * @return The new external identifier, or null.
- */
- @Nullable
- public String getNewExternalId() {
- return newExternalId;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof UpdateExternalId)) {
- return false;
- }
- UpdateExternalId that = (UpdateExternalId) o;
- return Objects.equals(newExternalId, that.newExternalId);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(newExternalId);
- }
-
- @Override
- public String toString() {
- return "UpdateExternalId " + newExternalId;
- }
- }
-}
diff --git a/api/src/main/java/org/apache/gravitino/authorization/User.java b/api/src/main/java/org/apache/gravitino/authorization/User.java
index 3e58c7d3a3..53014c908f 100644
--- a/api/src/main/java/org/apache/gravitino/authorization/User.java
+++ b/api/src/main/java/org/apache/gravitino/authorization/User.java
@@ -19,7 +19,6 @@
package org.apache.gravitino.authorization;
import java.util.List;
-import javax.annotation.Nullable;
import org.apache.gravitino.Auditable;
import org.apache.gravitino.annotation.Evolving;
@@ -38,38 +37,10 @@ public interface User extends Auditable {
/**
* The unique id assigned by Gravitino.
*
- * <p>This id is server-assigned and immutable. Upstream systems may also supply an optional
- * {@link #externalId()}.
- *
* @return The unique id of the user.
*/
Long id();
- /**
- * The stable identifier assigned by an upstream identity system (for example, SCIM, LDAP, or
- * IAM), or null if not set.
- *
- * <p>Gravitino {@link User#name() user names} may differ from upstream ids or be unknown at sync
- * time. External id lets integrators look up and correlate users without relying on the Gravitino
- * user name. Mutable attributes such as {@link #enabled()} and {@code externalId} are updated via
- * {@code alterUserById}.
- *
- * @return The upstream external identifier, or null if not set.
- */
- @Nullable
- default String externalId() {
- return null;
- }
-
- /**
- * Whether the user is enabled.
- *
- * @return True if the user is enabled, false otherwise.
- */
- default boolean enabled() {
- return true;
- }
-
/**
* The roles of the user. A user can have multiple roles. Every role binds several privileges.
*
diff --git a/api/src/main/java/org/apache/gravitino/authorization/UserChange.java b/api/src/main/java/org/apache/gravitino/authorization/UserChange.java
deleted file mode 100644
index f147784370..0000000000
--- a/api/src/main/java/org/apache/gravitino/authorization/UserChange.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * 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 java.util.Objects;
-import javax.annotation.Nullable;
-import org.apache.gravitino.annotation.Evolving;
-
-/**
- * A user change is a change to a user. It can be used to update the enabled flag or the optional
- * external id. Multiple changes may be applied in one {@code alterUserById} call.
- */
-@Evolving
-public interface UserChange {
-
- /**
- * Creates a user change to update whether the user is enabled.
- *
- * @param enabled Whether the user should be enabled.
- * @return The user change.
- */
- static UserChange updateEnabled(boolean enabled) {
- return new UpdateEnabled(enabled);
- }
-
- /**
- * Creates a user change to update the external identifier.
- *
- * @param newExternalId The new external identifier, or null to clear it.
- * @return The user change.
- */
- static UserChange updateExternalId(@Nullable String newExternalId) {
- return new UpdateExternalId(newExternalId);
- }
-
- /** A user change to update the enabled flag. */
- final class UpdateEnabled implements UserChange {
- private final boolean enabled;
-
- private UpdateEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- /**
- * Returns whether the user should be enabled.
- *
- * @return Whether the user should be enabled.
- */
- public boolean enabled() {
- return enabled;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof UpdateEnabled)) {
- return false;
- }
- UpdateEnabled that = (UpdateEnabled) o;
- return enabled == that.enabled;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(enabled);
- }
-
- @Override
- public String toString() {
- return "UpdateEnabled " + enabled;
- }
- }
-
- /** A user change to update the external identifier. */
- final class UpdateExternalId implements UserChange {
- @Nullable private final String newExternalId;
-
- private UpdateExternalId(@Nullable String newExternalId) {
- this.newExternalId = newExternalId;
- }
-
- /**
- * Returns the new external identifier, or null to clear it.
- *
- * @return The new external identifier, or null.
- */
- @Nullable
- public String getNewExternalId() {
- return newExternalId;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof UpdateExternalId)) {
- return false;
- }
- UpdateExternalId that = (UpdateExternalId) o;
- return Objects.equals(newExternalId, that.newExternalId);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(newExternalId);
- }
-
- @Override
- public String toString() {
- return "UpdateExternalId " + newExternalId;
- }
- }
-}
diff --git a/api/src/test/java/org/apache/gravitino/authorization/TestGroupChange.java b/api/src/test/java/org/apache/gravitino/authorization/TestGroupChange.java
deleted file mode 100644
index a029befe86..0000000000
--- a/api/src/test/java/org/apache/gravitino/authorization/TestGroupChange.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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 org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class TestGroupChange {
-
- @Test
- void testUpdateExternalId() {
- GroupChange.UpdateExternalId change =
- (GroupChange.UpdateExternalId) GroupChange.updateExternalId("ext-1");
- Assertions.assertEquals("ext-1", change.getNewExternalId());
- Assertions.assertEquals(GroupChange.updateExternalId("ext-1"), change);
- Assertions.assertEquals(GroupChange.updateExternalId(null), GroupChange.updateExternalId(null));
- Assertions.assertNotEquals(GroupChange.updateExternalId("ext-2"), change);
- }
-}
diff --git a/api/src/test/java/org/apache/gravitino/authorization/TestUserChange.java b/api/src/test/java/org/apache/gravitino/authorization/TestUserChange.java
deleted file mode 100644
index cfb051b5f4..0000000000
--- a/api/src/test/java/org/apache/gravitino/authorization/TestUserChange.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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 org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class TestUserChange {
-
- @Test
- void testUpdateEnabled() {
- UserChange.UpdateEnabled change = (UserChange.UpdateEnabled) UserChange.updateEnabled(false);
- Assertions.assertFalse(change.enabled());
- Assertions.assertEquals(UserChange.updateEnabled(false), change);
- Assertions.assertNotEquals(UserChange.updateEnabled(true), change);
- }
-
- @Test
- void testUpdateExternalId() {
- UserChange.UpdateExternalId change =
- (UserChange.UpdateExternalId) UserChange.updateExternalId("ext-1");
- Assertions.assertEquals("ext-1", change.getNewExternalId());
- Assertions.assertEquals(UserChange.updateExternalId("ext-1"), change);
- Assertions.assertEquals(UserChange.updateExternalId(null), UserChange.updateExternalId(null));
- Assertions.assertNotEquals(UserChange.updateExternalId("ext-2"), change);
- }
-}
diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListGroups.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListGroups.java
index 8d84614702..c33ae84303 100644
--- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListGroups.java
+++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListGroups.java
@@ -78,11 +78,6 @@ public class ListGroups extends Command {
return name;
}
- @Override
- public String externalId() {
- return null;
- }
-
@Override
public List<String> roles() {
return null;
diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListUsers.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListUsers.java
index 19382a0e93..d97449b62d 100644
--- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListUsers.java
+++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/ListUsers.java
@@ -78,16 +78,6 @@ public class ListUsers extends Command {
return user;
}
- @Override
- public String externalId() {
- return null;
- }
-
- @Override
- public boolean enabled() {
- return true;
- }
-
@Override
public List<String> roles() {
return null;
diff --git a/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoClient.java b/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoClient.java
index a1734ecb59..78aed2a690 100644
--- a/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoClient.java
+++ b/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoClient.java
@@ -203,22 +203,6 @@ public class GravitinoClient extends GravitinoClientBase
return getMetalake().addUser(user);
}
- /**
- * Adds a new User with an external identifier.
- *
- * @param user The name of the User.
- * @param externalId The external identifier of the User.
- * @param enabled Whether the User is enabled.
- * @return The added User instance.
- * @throws UserAlreadyExistsException If a User with the same name or external id already exists.
- * @throws NoSuchMetalakeException If the Metalake with the given name does not exist.
- * @throws RuntimeException If adding the User encounters storage issues.
- */
- public User addUser(String user, String externalId, boolean enabled)
- throws UserAlreadyExistsException, NoSuchMetalakeException {
- return getMetalake().addUser(user, externalId, enabled);
- }
-
/**
* Removes a User.
*
@@ -278,22 +262,6 @@ public class GravitinoClient extends GravitinoClientBase
return getMetalake().addGroup(group);
}
- /**
- * Adds a new Group with an external identifier.
- *
- * @param group The name of the Group.
- * @param externalId The external identifier of the Group.
- * @return The Added Group instance.
- * @throws GroupAlreadyExistsException If a Group with the same name or external id already
- * exists.
- * @throws NoSuchMetalakeException If the Metalake with the given name does not exist.
- * @throws RuntimeException If adding the Group encounters storage issues.
- */
- public Group addGroup(String group, String externalId)
- throws GroupAlreadyExistsException, NoSuchMetalakeException {
- return getMetalake().addGroup(group, externalId);
- }
-
/**
* Removes a Group.
*
diff --git a/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoMetalake.java b/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoMetalake.java
index b9724b1b3f..8eced5740e 100644
--- a/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoMetalake.java
+++ b/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoMetalake.java
@@ -891,35 +891,6 @@ public class GravitinoMetalake extends MetalakeDTO
return resp.getUser();
}
- /**
- * Adds a new User with an external identifier.
- *
- * @param user The name of the User.
- * @param externalId The external identifier of the User.
- * @param enabled Whether the User is enabled.
- * @return The added User instance.
- * @throws UserAlreadyExistsException If a User with the same name or external id already exists.
- * @throws NoSuchMetalakeException If the Metalake with the given name does not exist.
- * @throws RuntimeException If adding the User encounters storage issues.
- */
- public User addUser(String user, String externalId, boolean enabled)
- throws UserAlreadyExistsException, NoSuchMetalakeException {
- UserAddRequest req = new UserAddRequest(user, externalId, enabled);
- req.validate();
-
- UserResponse resp =
- restClient.post(
- String.format(
- API_METALAKES_USERS_PATH, RESTUtils.encodeString(this.name()), BLANK_PLACEHOLDER),
- req,
- UserResponse.class,
- Collections.emptyMap(),
- ErrorHandlers.userErrorHandler());
- resp.validate();
-
- return resp.getUser();
- }
-
/**
* Removes a User.
*
@@ -1036,35 +1007,6 @@ public class GravitinoMetalake extends MetalakeDTO
return resp.getGroup();
}
- /**
- * Adds a new Group with an external identifier.
- *
- * @param group The name of the Group.
- * @param externalId The external identifier of the Group.
- * @return The Added Group instance.
- * @throws GroupAlreadyExistsException If a Group with the same name or external id already
- * exists.
- * @throws NoSuchMetalakeException If the Metalake with the given name does not exist.
- * @throws RuntimeException If adding the Group encounters storage issues.
- */
- public Group addGroup(String group, String externalId)
- throws GroupAlreadyExistsException, NoSuchMetalakeException {
- GroupAddRequest req = new GroupAddRequest(group, externalId);
- req.validate();
-
- GroupResponse resp =
- restClient.post(
- String.format(
- API_METALAKES_GROUPS_PATH, RESTUtils.encodeString(this.name()), BLANK_PLACEHOLDER),
- req,
- GroupResponse.class,
- Collections.emptyMap(),
- ErrorHandlers.groupErrorHandler());
- resp.validate();
-
- return resp.getGroup();
- }
-
/**
* Removes a Group.
*
diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/TestUserGroup.java b/clients/client-java/src/test/java/org/apache/gravitino/client/TestUserGroup.java
index dbd7aab14e..e764f823bc 100644
--- a/clients/client-java/src/test/java/org/apache/gravitino/client/TestUserGroup.java
+++ b/clients/client-java/src/test/java/org/apache/gravitino/client/TestUserGroup.java
@@ -125,31 +125,6 @@ public class TestUserGroup extends TestBase {
RuntimeException.class, () -> gravitinoClient.addUser(username), "internal error");
}
- @Test
- public void testAddUserWithExternalId() throws Exception {
- String username = "user";
- String externalId = "ext-user-1";
- String userPath = withSlash(String.format(API_METALAKES_USERS_PATH, metalakeName, ""));
- UserAddRequest request = new UserAddRequest(username, externalId, false);
-
- UserDTO mockUser =
- UserDTO.builder()
- .withId(1L)
- .withName(username)
- .withExternalId(externalId)
- .withEnabled(false)
- .withAudit(
- AuditDTO.builder().withCreator("creator").withCreateTime(Instant.now()).build())
- .build();
- UserResponse userResponse = new UserResponse(mockUser);
- buildMockResource(Method.POST, userPath, request, userResponse, SC_OK);
-
- User addedUser = gravitinoClient.addUser(username, externalId, false);
- Assertions.assertNotNull(addedUser);
- Assertions.assertEquals(externalId, addedUser.externalId());
- Assertions.assertFalse(addedUser.enabled());
- }
-
@Test
public void testGetUsers() throws Exception {
String username = "user";
@@ -297,29 +272,6 @@ public class TestUserGroup extends TestBase {
RuntimeException.class, () -> gravitinoClient.addGroup(groupName), "internal error");
}
- @Test
- public void testAddGroupWithExternalId() throws Exception {
- String groupName = "group";
- String externalId = "ext-group-1";
- String groupPath = withSlash(String.format(API_METALAKES_GROUPS_PATH, metalakeName, ""));
- GroupAddRequest request = new GroupAddRequest(groupName, externalId);
-
- GroupDTO mockGroup =
- GroupDTO.builder()
- .withId(1L)
- .withName(groupName)
- .withExternalId(externalId)
- .withAudit(
- AuditDTO.builder().withCreator("creator").withCreateTime(Instant.now()).build())
- .build();
- GroupResponse groupResponse = new GroupResponse(mockGroup);
- buildMockResource(Method.POST, groupPath, request, groupResponse, SC_OK);
-
- Group addedGroup = gravitinoClient.addGroup(groupName, externalId);
- Assertions.assertNotNull(addedGroup);
- Assertions.assertEquals(externalId, addedGroup.externalId());
- }
-
@Test
public void testGetGroups() throws Exception {
String groupName = "group";
diff --git a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/AccessControlIT.java b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/AccessControlIT.java
index e5321c59c0..dfcb0f8516 100644
--- a/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/AccessControlIT.java
+++ b/clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/authorization/AccessControlIT.java
@@ -202,51 +202,6 @@ public class AccessControlIT extends BaseIT {
metalake.deleteRole("role2");
}
- @Test
- void testManageUsersAndGroupsWithExternalId() {
- String userExtId = "ext-user-it-1";
- String username = "ext_user_it";
- User user = metalake.addUser(username, userExtId, false);
- Assertions.assertEquals(userExtId, user.externalId());
- Assertions.assertFalse(user.enabled());
-
- user = metalake.getUser(username);
- Assertions.assertEquals(userExtId, user.externalId());
- Assertions.assertFalse(user.enabled());
-
- User listedUser =
- Arrays.stream(metalake.listUsers())
- .filter(u -> username.equals(u.name()))
- .findFirst()
- .orElseThrow();
- Assertions.assertEquals(userExtId, listedUser.externalId());
- Assertions.assertFalse(listedUser.enabled());
-
- Assertions.assertThrows(
- UserAlreadyExistsException.class, () -> metalake.addUser("dup_ext_user", userExtId, true));
-
- String groupExtId = "ext-group-it-1";
- String groupName = "ext_group_it";
- Group group = metalake.addGroup(groupName, groupExtId);
- Assertions.assertEquals(groupExtId, group.externalId());
-
- group = metalake.getGroup(groupName);
- Assertions.assertEquals(groupExtId, group.externalId());
-
- Group listedGroup =
- Arrays.stream(metalake.listGroups())
- .filter(g -> groupName.equals(g.name()))
- .findFirst()
- .orElseThrow();
- Assertions.assertEquals(groupExtId, listedGroup.externalId());
-
- Assertions.assertThrows(
- GroupAlreadyExistsException.class, () -> metalake.addGroup("dup_ext_group", groupExtId));
-
- Assertions.assertTrue(metalake.removeUser(username));
- Assertions.assertTrue(metalake.removeGroup(groupName));
- }
-
@Test
@SuppressWarnings("deprecation")
void testManageRoles() {
diff --git a/common/src/main/java/org/apache/gravitino/dto/authorization/GroupDTO.java b/common/src/main/java/org/apache/gravitino/dto/authorization/GroupDTO.java
index 7d34ee2c35..88c262ec35 100644
--- a/common/src/main/java/org/apache/gravitino/dto/authorization/GroupDTO.java
+++ b/common/src/main/java/org/apache/gravitino/dto/authorization/GroupDTO.java
@@ -22,7 +22,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Preconditions;
import java.util.Collections;
import java.util.List;
-import javax.annotation.Nullable;
import org.apache.commons.lang3.StringUtils;
import org.apache.gravitino.Audit;
import org.apache.gravitino.authorization.Group;
@@ -37,10 +36,6 @@ public class GroupDTO implements Group {
@JsonProperty("name")
private String name;
- @Nullable
- @JsonProperty("externalId")
- private String externalId;
-
@JsonProperty("audit")
private AuditDTO audit;
@@ -55,14 +50,12 @@ public class GroupDTO implements Group {
*
* @param id The id of the Group DTO.
* @param name The name of the Group DTO.
- * @param externalId The external id of the Group DTO.
* @param roles The roles of the Group DTO.
* @param audit The audit information of the Group DTO.
*/
- protected GroupDTO(Long id, String name, String externalId, List<String> roles, AuditDTO audit) {
+ protected GroupDTO(Long id, String name, List<String> roles, AuditDTO audit) {
this.id = id;
this.name = name;
- this.externalId = externalId;
this.audit = audit;
this.roles = roles;
}
@@ -83,11 +76,6 @@ public class GroupDTO implements Group {
return name;
}
- @Override
- public String externalId() {
- return externalId;
- }
-
/**
* The roles of the group. A group can have multiple roles. Every role binds several privileges.
*
@@ -128,9 +116,6 @@ public class GroupDTO implements Group {
/** The name of the group. */
protected String name;
- /** The external id of the group. */
- protected String externalId;
-
/** The roles of the group. */
protected List<String> roles = Collections.emptyList();
@@ -159,17 +144,6 @@ public class GroupDTO implements Group {
return (S) this;
}
- /**
- * Sets the external id of the group.
- *
- * @param externalId The external id of the group.
- * @return The builder instance.
- */
- public S withExternalId(String externalId) {
- this.externalId = externalId;
- return (S) this;
- }
-
/**
* Sets the roles of the group.
*
@@ -205,7 +179,7 @@ public class GroupDTO implements Group {
Preconditions.checkArgument(id != null, "id cannot be null");
Preconditions.checkArgument(StringUtils.isNotBlank(name), "name cannot be null or empty");
Preconditions.checkArgument(audit != null, "audit cannot be null");
- return new GroupDTO(id, name, externalId, roles, audit);
+ return new GroupDTO(id, name, roles, audit);
}
}
}
diff --git a/common/src/main/java/org/apache/gravitino/dto/authorization/UserDTO.java b/common/src/main/java/org/apache/gravitino/dto/authorization/UserDTO.java
index 2e741a8e01..b9b8456bd1 100644
--- a/common/src/main/java/org/apache/gravitino/dto/authorization/UserDTO.java
+++ b/common/src/main/java/org/apache/gravitino/dto/authorization/UserDTO.java
@@ -22,7 +22,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Preconditions;
import java.util.Collections;
import java.util.List;
-import javax.annotation.Nullable;
import org.apache.commons.lang3.StringUtils;
import org.apache.gravitino.Audit;
import org.apache.gravitino.authorization.User;
@@ -37,13 +36,6 @@ public class UserDTO implements User {
@JsonProperty("name")
private String name;
- @Nullable
- @JsonProperty("externalId")
- private String externalId;
-
- @JsonProperty("enabled")
- private boolean enabled = true;
-
@JsonProperty("audit")
private AuditDTO audit;
@@ -58,22 +50,12 @@ public class UserDTO implements User {
*
* @param id The id of the User DTO.
* @param name The name of the User DTO.
- * @param externalId The external id of the User DTO.
* @param roles The roles of the User DTO.
* @param audit The audit information of the User DTO.
- * @param enabled Whether the User DTO is enabled.
*/
- protected UserDTO(
- Long id,
- String name,
- String externalId,
- List<String> roles,
- AuditDTO audit,
- boolean enabled) {
+ protected UserDTO(Long id, String name, List<String> roles, AuditDTO audit) {
this.id = id;
this.name = name;
- this.externalId = externalId;
- this.enabled = enabled;
this.audit = audit;
this.roles = roles;
}
@@ -94,16 +76,6 @@ public class UserDTO implements User {
return name;
}
- @Override
- public String externalId() {
- return externalId;
- }
-
- @Override
- public boolean enabled() {
- return enabled;
- }
-
/**
* The roles of the user. A user can have multiple roles. Every role binds several privileges.
*
@@ -144,12 +116,6 @@ public class UserDTO implements User {
/** The name of the user. */
protected String name;
- /** The external id of the user. */
- protected String externalId;
-
- /** Whether the user is enabled. */
- protected boolean enabled = true;
-
/** The roles of the user. */
protected List<String> roles = Collections.emptyList();
@@ -178,28 +144,6 @@ public class UserDTO implements User {
return (S) this;
}
- /**
- * Sets the external id of the user.
- *
- * @param externalId The external id of the user.
- * @return The builder instance.
- */
- public S withExternalId(String externalId) {
- this.externalId = externalId;
- return (S) this;
- }
-
- /**
- * Sets whether the user is enabled.
- *
- * @param enabled Whether the user is enabled.
- * @return The builder instance.
- */
- public S withEnabled(boolean enabled) {
- this.enabled = enabled;
- return (S) this;
- }
-
/**
* Sets the roles of the user.
*
@@ -235,7 +179,7 @@ public class UserDTO implements User {
Preconditions.checkArgument(id != null, "id cannot be null");
Preconditions.checkArgument(StringUtils.isNotBlank(name), "name cannot be null or empty");
Preconditions.checkArgument(audit != null, "audit cannot be null");
- return new UserDTO(id, name, externalId, roles, audit, enabled);
+ return new UserDTO(id, name, roles, audit);
}
}
}
diff --git a/common/src/main/java/org/apache/gravitino/dto/requests/GroupAddRequest.java b/common/src/main/java/org/apache/gravitino/dto/requests/GroupAddRequest.java
index 892cacb6e3..3cfcb54e9c 100644
--- a/common/src/main/java/org/apache/gravitino/dto/requests/GroupAddRequest.java
+++ b/common/src/main/java/org/apache/gravitino/dto/requests/GroupAddRequest.java
@@ -20,7 +20,6 @@ package org.apache.gravitino.dto.requests;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Preconditions;
-import javax.annotation.Nullable;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@@ -40,13 +39,9 @@ public class GroupAddRequest implements RESTRequest {
@JsonProperty("name")
private final String name;
- @Nullable
- @JsonProperty("externalId")
- private final String externalId;
-
/** Default constructor for GroupAddRequest. (Used for Jackson deserialization.) */
public GroupAddRequest() {
- this(null, null);
+ this(null);
}
/**
@@ -55,19 +50,7 @@ public class GroupAddRequest implements RESTRequest {
* @param name The name of the group.
*/
public GroupAddRequest(String name) {
- this(name, null);
- }
-
- /**
- * Creates a new GroupAddRequest.
- *
- * @param name The name of the group.
- * @param externalId The external identifier of the group.
- */
- public GroupAddRequest(String name, String externalId) {
- super();
this.name = name;
- this.externalId = externalId;
}
/**
@@ -79,9 +62,5 @@ public class GroupAddRequest implements RESTRequest {
public void validate() throws IllegalArgumentException {
Preconditions.checkArgument(
StringUtils.isNotBlank(name), "\"name\" field is required and cannot be empty");
- if (externalId != null) {
- Preconditions.checkArgument(
- StringUtils.isNotBlank(externalId), "\"externalId\" field cannot be blank when provided");
- }
}
}
diff --git a/common/src/main/java/org/apache/gravitino/dto/requests/UserAddRequest.java b/common/src/main/java/org/apache/gravitino/dto/requests/UserAddRequest.java
index 688f2a00cb..1eba4aa9e4 100644
--- a/common/src/main/java/org/apache/gravitino/dto/requests/UserAddRequest.java
+++ b/common/src/main/java/org/apache/gravitino/dto/requests/UserAddRequest.java
@@ -20,7 +20,6 @@ package org.apache.gravitino.dto.requests;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Preconditions;
-import javax.annotation.Nullable;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@@ -40,17 +39,9 @@ public class UserAddRequest implements RESTRequest {
@JsonProperty("name")
private final String name;
- @Nullable
- @JsonProperty("externalId")
- private final String externalId;
-
- @Nullable
- @JsonProperty("enabled")
- private final Boolean enabled;
-
/** Default constructor for UserAddRequest. (Used for Jackson deserialization.) */
public UserAddRequest() {
- this(null, null, null);
+ this(null);
}
/**
@@ -59,21 +50,7 @@ public class UserAddRequest implements RESTRequest {
* @param name The name of the user.
*/
public UserAddRequest(String name) {
- this(name, null, null);
- }
-
- /**
- * Creates a new UserAddRequest.
- *
- * @param name The name of the user.
- * @param externalId The external identifier of the user.
- * @param enabled Whether the user is enabled.
- */
- public UserAddRequest(String name, String externalId, Boolean enabled) {
- super();
this.name = name;
- this.externalId = externalId;
- this.enabled = enabled;
}
/**
@@ -85,9 +62,5 @@ public class UserAddRequest implements RESTRequest {
public void validate() throws IllegalArgumentException {
Preconditions.checkArgument(
StringUtils.isNotBlank(name), "\"name\" field is required and cannot be empty");
- if (externalId != null) {
- Preconditions.checkArgument(
- StringUtils.isNotBlank(externalId), "\"externalId\" field cannot be blank when provided");
- }
}
}
diff --git a/common/src/main/java/org/apache/gravitino/dto/util/DTOConverters.java b/common/src/main/java/org/apache/gravitino/dto/util/DTOConverters.java
index 7ea792a255..717d955681 100644
--- a/common/src/main/java/org/apache/gravitino/dto/util/DTOConverters.java
+++ b/common/src/main/java/org/apache/gravitino/dto/util/DTOConverters.java
@@ -498,8 +498,6 @@ public class DTOConverters {
return UserDTO.builder()
.withId(user.id())
.withName(user.name())
- .withExternalId(user.externalId())
- .withEnabled(user.enabled())
.withRoles(user.roles())
.withAudit(toDTO(user.auditInfo()))
.build();
@@ -519,7 +517,6 @@ public class DTOConverters {
return GroupDTO.builder()
.withId(group.id())
.withName(group.name())
- .withExternalId(group.externalId())
.withRoles(group.roles())
.withAudit(toDTO(group.auditInfo()))
.build();
diff --git a/core/src/main/java/org/apache/gravitino/Entity.java b/core/src/main/java/org/apache/gravitino/Entity.java
index 43ee549581..f88fc9f11f 100644
--- a/core/src/main/java/org/apache/gravitino/Entity.java
+++ b/core/src/main/java/org/apache/gravitino/Entity.java
@@ -41,51 +41,9 @@ public interface Entity extends Serializable {
/** The user schema name in the system catalog. */
String USER_SCHEMA_NAME = "user";
- /**
- * A virtual schema name used only for {@link org.apache.gravitino.lock.TreeLockUtils} lock paths
- * when operating on users by Gravitino-assigned id (for example, get/alter/delete-by-id).
- *
- * <p>This is not a real metadata schema and does not store entities. It forms part of a synthetic
- * {@link org.apache.gravitino.NameIdentifier} such as {@code {metalake, system, user-id, <id>}}
- * so that concurrent operations on the same user id are serialized.
- */
- String USER_ID_SCHEMA_NAME = "user-id";
-
- /**
- * A virtual schema name used only for {@link org.apache.gravitino.lock.TreeLockUtils} lock paths
- * when operating on users by external id (for example, get/delete-by-external-id).
- *
- * <p>This is not a real metadata schema and does not store entities. It forms part of a synthetic
- * {@link org.apache.gravitino.NameIdentifier} such as {@code {metalake, system, user-external-id,
- * <externalId>}} so that concurrent operations on the same external id are serialized without
- * requiring the Gravitino user name.
- */
- String USER_EXTERNAL_ID_SCHEMA_NAME = "user-external-id";
-
/** The group schema name in the system catalog. */
String GROUP_SCHEMA_NAME = "group";
- /**
- * A virtual schema name used only for {@link org.apache.gravitino.lock.TreeLockUtils} lock paths
- * when operating on groups by Gravitino-assigned id (for example, get/alter/delete-by-id).
- *
- * <p>This is not a real metadata schema and does not store entities. It forms part of a synthetic
- * {@link org.apache.gravitino.NameIdentifier} such as {@code {metalake, system, group-id, <id>}}
- * so that concurrent operations on the same group id are serialized.
- */
- String GROUP_ID_SCHEMA_NAME = "group-id";
-
- /**
- * A virtual schema name used only for {@link org.apache.gravitino.lock.TreeLockUtils} lock paths
- * when operating on groups by external id (for example, get/delete-by-external-id).
- *
- * <p>This is not a real metadata schema and does not store entities. It forms part of a synthetic
- * {@link org.apache.gravitino.NameIdentifier} such as {@code {metalake, system,
- * group-external-id, <externalId>}} so that concurrent operations on the same external id are
- * serialized without requiring the Gravitino group name.
- */
- String GROUP_EXTERNAL_ID_SCHEMA_NAME = "group-external-id";
-
/** The role schema name in the system catalog. */
String ROLE_SCHEMA_NAME = "role";
diff --git a/core/src/main/java/org/apache/gravitino/EntityStore.java b/core/src/main/java/org/apache/gravitino/EntityStore.java
index c63458c720..62b12ab320 100644
--- a/core/src/main/java/org/apache/gravitino/EntityStore.java
+++ b/core/src/main/java/org/apache/gravitino/EntityStore.java
@@ -347,24 +347,4 @@ public interface EntityStore extends Closeable {
default SupportsRelationOperations relationOperations() {
throw new UnsupportedOperationException("relation operations are not supported");
}
-
- /**
- * Get the extra external id operations that are supported by the entity store.
- *
- * @return the external id operations that are supported by the entity store
- * @throws UnsupportedOperationException if the extra operations are not supported
- */
- default SupportsExternalIdOperations externalIdOperations() {
- throw new UnsupportedOperationException("external id operations are not supported");
- }
-
- /**
- * Get the extra id operations that are supported by the entity store.
- *
- * @return the id operations that are supported by the entity store
- * @throws UnsupportedOperationException if the extra operations are not supported
- */
- default SupportsIdOperations idOperations() {
- throw new UnsupportedOperationException("id operations are not supported");
- }
}
diff --git a/core/src/main/java/org/apache/gravitino/SupportsExternalIdOperations.java b/core/src/main/java/org/apache/gravitino/SupportsExternalIdOperations.java
deleted file mode 100644
index 520da24143..0000000000
--- a/core/src/main/java/org/apache/gravitino/SupportsExternalIdOperations.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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;
-
-import java.io.IOException;
-import java.util.function.Function;
-import org.apache.gravitino.exceptions.NoSuchEntityException;
-
-/**
- * Optional extension for entity stores that support lookup and mutation by external id within a
- * namespace.
- */
-public interface SupportsExternalIdOperations {
-
- /**
- * Get the entity from the underlying storage by external id.
- *
- * @param ident the external id name identifier
- * @param entityType the general type of the entity
- * @param type the detailed type of the entity
- * @param <E> the class of entity
- * @return the entity retrieved from the underlying storage
- * @throws NoSuchEntityException if the entity does not exist
- * @throws IOException if the retrieve operation fails
- */
- <E extends Entity & HasIdentifier> E getByExternalId(
- NameIdentifier ident, Entity.EntityType entityType, Class<E> type)
- throws NoSuchEntityException, IOException;
-
- /**
- * Update an entity by external id.
- *
- * @param ident the external id name identifier
- * @param entityType the general type of the entity
- * @param type the detailed type of the entity
- * @param updater the updater function to update the entity
- * @param <E> the class of entity
- * @return the updated entity
- * @throws NoSuchEntityException if the entity does not exist
- * @throws IOException if the update operation fails
- */
- <E extends Entity & HasIdentifier> E updateByExternalId(
- NameIdentifier ident, Entity.EntityType entityType, Class<E> type, Function<E, E> updater)
- throws NoSuchEntityException, IOException;
-
- /**
- * Delete an entity by external id.
- *
- * @param ident the external id name identifier
- * @param entityType the general type of the entity
- * @return true if the entity exists and is deleted successfully, false otherwise
- * @throws IOException if the delete operation fails
- */
- boolean deleteByExternalId(NameIdentifier ident, Entity.EntityType entityType) throws IOException;
-}
diff --git a/core/src/main/java/org/apache/gravitino/SupportsIdOperations.java b/core/src/main/java/org/apache/gravitino/SupportsIdOperations.java
deleted file mode 100644
index 36c4634955..0000000000
--- a/core/src/main/java/org/apache/gravitino/SupportsIdOperations.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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;
-
-import java.io.IOException;
-import java.util.function.Function;
-import org.apache.gravitino.exceptions.NoSuchEntityException;
-
-/**
- * Optional extension for entity stores that support lookup and mutation by Gravitino-assigned id
- * within a metalake.
- */
-public interface SupportsIdOperations {
-
- /**
- * Get the entity from the underlying storage by Gravitino-assigned id.
- *
- * @param ident the id name identifier
- * @param entityType the general type of the entity
- * @param type the detailed type of the entity
- * @param <E> the class of entity
- * @return the entity retrieved from the underlying storage
- * @throws NoSuchEntityException if the entity does not exist
- * @throws IOException if the retrieve operation fails
- */
- <E extends Entity & HasIdentifier> E getById(
- NameIdentifier ident, Entity.EntityType entityType, Class<E> type)
- throws NoSuchEntityException, IOException;
-
- /**
- * Update an entity by Gravitino-assigned id.
- *
- * @param ident the id name identifier
- * @param entityType the general type of the entity
- * @param type the detailed type of the entity
- * @param updater the updater function to update the entity
- * @param <E> the class of entity
- * @return the updated entity
- * @throws NoSuchEntityException if the entity does not exist
- * @throws IOException if the update operation fails
- */
- <E extends Entity & HasIdentifier> E updateById(
- NameIdentifier ident, Entity.EntityType entityType, Class<E> type, Function<E, E> updater)
- throws NoSuchEntityException, IOException;
-
- /**
- * Delete an entity by Gravitino-assigned id.
- *
- * @param ident the id name identifier
- * @param entityType the general type of the entity
- * @return true if the entity exists and is deleted successfully, false otherwise
- * @throws IOException if the delete operation fails
- */
- boolean deleteById(NameIdentifier ident, Entity.EntityType entityType) throws IOException;
-}
diff --git a/core/src/main/java/org/apache/gravitino/authorization/AccessControlDispatcher.java b/core/src/main/java/org/apache/gravitino/authorization/AccessControlDispatcher.java
index dfab6eddd5..f059744666 100644
--- a/core/src/main/java/org/apache/gravitino/authorization/AccessControlDispatcher.java
+++ b/core/src/main/java/org/apache/gravitino/authorization/AccessControlDispatcher.java
@@ -55,21 +55,6 @@ public interface AccessControlDispatcher {
User addUser(String metalake, String user)
throws UserAlreadyExistsException, NoSuchMetalakeException;
- /**
- * Adds a new User.
- *
- * @param metalake The Metalake of the User.
- * @param user The name of the User.
- * @param externalId The external identifier, or null if unset.
- * @param enabled Whether the User is enabled.
- * @return The added User instance.
- * @throws UserAlreadyExistsException If a User with the same name or external id already exists.
- * @throws NoSuchMetalakeException If the Metalake with the given name does not exist.
- * @throws RuntimeException If adding the User encounters storage issues.
- */
- User addUser(String metalake, String user, String externalId, boolean enabled)
- throws UserAlreadyExistsException, NoSuchMetalakeException;
-
/**
* Adds users in bulk.
*
@@ -108,19 +93,6 @@ public interface AccessControlDispatcher {
String metalake, List<String> users, Optional<Owner> metalakeOwner)
throws NoSuchMetalakeException;
- /**
- * Removes a User by external identifier.
- *
- * @param metalake The Metalake of the User.
- * @param externalId The external identifier of the User.
- * @return True if the User was successfully removed, false only when there's no such user,
- * otherwise it will throw an exception.
- * @throws IllegalArgumentException If externalId is null or blank.
- * @throws NoSuchMetalakeException If the Metalake with the given name does not exist.
- * @throws RuntimeException If removing the User encounters storage issues.
- */
- boolean removeUserByExternalId(String metalake, String externalId) throws NoSuchMetalakeException;
-
/**
* Gets a User.
*
@@ -133,64 +105,6 @@ public interface AccessControlDispatcher {
*/
User getUser(String metalake, String user) throws NoSuchUserException, NoSuchMetalakeException;
- /**
- * Gets a User by external identifier.
- *
- * @param metalake The Metalake of the User.
- * @param externalId The external identifier of the User.
- * @return The getting User instance.
- * @throws IllegalArgumentException If externalId is null or blank.
- * @throws NoSuchUserException If the User with the given external id does not exist.
- * @throws NoSuchMetalakeException If the Metalake with the given name does not exist.
- * @throws RuntimeException If getting the User encounters storage issues.
- */
- User getUserByExternalId(String metalake, String externalId)
- throws NoSuchUserException, NoSuchMetalakeException;
-
- /**
- * Gets a User by Gravitino-assigned id.
- *
- * @param metalake The Metalake of the User.
- * @param userId The Gravitino-assigned id of the User.
- * @return The getting User instance.
- * @throws NoSuchUserException If the User with the given id does not exist.
- * @throws NoSuchMetalakeException If the Metalake with the given name does not exist.
- * @throws RuntimeException If getting the User encounters storage issues.
- */
- User getUserById(String metalake, long userId)
- throws NoSuchUserException, NoSuchMetalakeException;
-
- /**
- * Removes a User by Gravitino-assigned id.
- *
- * @param metalake The Metalake of the User.
- * @param userId The Gravitino-assigned id of the User.
- * @return True if the User was successfully removed, false only when there's no such user,
- * otherwise it will throw an exception.
- * @throws NoSuchMetalakeException If the Metalake with the given name does not exist.
- * @throws RuntimeException If removing the User encounters storage issues.
- */
- boolean removeUserById(String metalake, long userId) throws NoSuchMetalakeException;
-
- /**
- * Alters a User by Gravitino-assigned id.
- *
- * <p>Supports updating {@code enabled} and/or {@code externalId} in one call via {@link
- * UserChange}. Role bindings are preserved.
- *
- * @param metalake The Metalake of the User.
- * @param userId The Gravitino-assigned id of the User.
- * @param changes The changes to apply. Must not be empty.
- * @return The updated User instance.
- * @throws IllegalArgumentException If changes is null or empty, or contains an unsupported
- * change.
- * @throws NoSuchUserException If the User with the given id does not exist.
- * @throws NoSuchMetalakeException If the Metalake with the given name does not exist.
- * @throws RuntimeException If updating the User encounters storage issues.
- */
- User alterUserById(String metalake, long userId, UserChange... changes)
- throws NoSuchUserException, NoSuchMetalakeException;
-
/**
* Lists the users.
*
@@ -243,21 +157,6 @@ public interface AccessControlDispatcher {
Group addGroup(String metalake, String group)
throws GroupAlreadyExistsException, NoSuchMetalakeException;
- /**
- * Adds a new Group.
- *
- * @param metalake The Metalake of the Group.
- * @param group The name of the Group.
- * @param externalId The external identifier, or null if unset.
- * @return The Added Group instance.
- * @throws GroupAlreadyExistsException If a Group with the same name or external id already
- * exists.
- * @throws NoSuchMetalakeException If the Metalake with the given name does not exist.
- * @throws RuntimeException If adding the Group encounters storage issues.
- */
- Group addGroup(String metalake, String group, String externalId)
- throws GroupAlreadyExistsException, NoSuchMetalakeException;
-
/**
* Adds groups in bulk.
*
@@ -296,20 +195,6 @@ public interface AccessControlDispatcher {
String metalake, List<String> groups, Optional<Owner> metalakeOwner)
throws NoSuchMetalakeException;
- /**
- * Removes a Group by external identifier.
- *
- * @param metalake The Metalake of the Group.
- * @param externalId The external identifier of the Group.
- * @return True if the Group was successfully removed, false only when there's no such group,
- * otherwise it will throw an exception.
- * @throws IllegalArgumentException If externalId is null or blank.
- * @throws NoSuchMetalakeException If the Metalake with the given name does not exist.
- * @throws RuntimeException If removing the Group encounters storage issues.
- */
- boolean removeGroupByExternalId(String metalake, String externalId)
- throws NoSuchMetalakeException;
-
/**
* Gets a Group.
*
@@ -323,63 +208,6 @@ public interface AccessControlDispatcher {
Group getGroup(String metalake, String group)
throws NoSuchGroupException, NoSuchMetalakeException;
- /**
- * Gets a Group by external identifier.
- *
- * @param metalake The Metalake of the Group.
- * @param externalId The external identifier of the Group.
- * @return The getting Group instance.
- * @throws IllegalArgumentException If externalId is null or blank.
- * @throws NoSuchGroupException If the Group with the given external id does not exist.
- * @throws NoSuchMetalakeException If the Metalake with the given name does not exist.
- * @throws RuntimeException If getting the Group encounters storage issues.
- */
- Group getGroupByExternalId(String metalake, String externalId)
- throws NoSuchGroupException, NoSuchMetalakeException;
-
- /**
- * Gets a Group by Gravitino-assigned id.
- *
- * @param metalake The Metalake of the Group.
- * @param groupId The Gravitino-assigned id of the Group.
- * @return The getting Group instance.
- * @throws NoSuchGroupException If the Group with the given id does not exist.
- * @throws NoSuchMetalakeException If the Metalake with the given name does not exist.
- * @throws RuntimeException If getting the Group encounters storage issues.
- */
- Group getGroupById(String metalake, long groupId)
- throws NoSuchGroupException, NoSuchMetalakeException;
-
- /**
- * Removes a Group by Gravitino-assigned id.
- *
- * @param metalake The Metalake of the Group.
- * @param groupId The Gravitino-assigned id of the Group.
- * @return True if the Group was successfully removed, false only when there's no such group,
- * otherwise it will throw an exception.
- * @throws NoSuchMetalakeException If the Metalake with the given name does not exist.
- * @throws RuntimeException If removing the Group encounters storage issues.
- */
- boolean removeGroupById(String metalake, long groupId) throws NoSuchMetalakeException;
-
- /**
- * Alters a Group by Gravitino-assigned id.
- *
- * <p>Supports updating {@code externalId} via {@link GroupChange}. Role bindings are preserved.
- *
- * @param metalake The Metalake of the Group.
- * @param groupId The Gravitino-assigned id of the Group.
- * @param changes The changes to apply. Must not be empty.
- * @return The updated Group instance.
- * @throws IllegalArgumentException If changes is null or empty, or contains an unsupported
- * change.
- * @throws NoSuchGroupException If the Group with the given id does not exist.
- * @throws NoSuchMetalakeException If the Metalake with the given name does not exist.
- * @throws RuntimeException If updating the Group encounters storage issues.
- */
- Group alterGroupById(String metalake, long groupId, GroupChange... changes)
- throws NoSuchGroupException, NoSuchMetalakeException;
-
/**
* List groups
*
diff --git a/core/src/main/java/org/apache/gravitino/authorization/AccessControlManager.java b/core/src/main/java/org/apache/gravitino/authorization/AccessControlManager.java
index 72f5022a6e..b0d39dc93b 100644
--- a/core/src/main/java/org/apache/gravitino/authorization/AccessControlManager.java
+++ b/core/src/main/java/org/apache/gravitino/authorization/AccessControlManager.java
@@ -52,8 +52,6 @@ import org.apache.gravitino.utils.MetadataObjectUtil;
public class AccessControlManager implements AccessControlDispatcher {
private final UserGroupManager userGroupManager;
- private final UserGroupExternalManager userGroupExternalManager;
- private final UserGroupIdManager userGroupIdManager;
private final RoleManager roleManager;
private final PermissionManager permissionManager;
private final List<String> serviceAdmins;
@@ -61,8 +59,6 @@ public class AccessControlManager implements AccessControlDispatcher {
public AccessControlManager(EntityStore store, IdGenerator idGenerator, Config config) {
this.roleManager = new RoleManager(store, idGenerator);
this.userGroupManager = new UserGroupManager(store, idGenerator);
- this.userGroupExternalManager = new UserGroupExternalManager(store, idGenerator);
- this.userGroupIdManager = new UserGroupIdManager(store, idGenerator);
this.permissionManager = new PermissionManager(store, roleManager);
this.serviceAdmins = config.get(Configs.SERVICE_ADMINS);
}
@@ -76,15 +72,6 @@ public class AccessControlManager implements AccessControlDispatcher {
() -> userGroupManager.addUser(metalake, user));
}
- @Override
- public User addUser(String metalake, String user, String externalId, boolean enabled)
- throws UserAlreadyExistsException, NoSuchMetalakeException {
- return TreeLockUtils.doWithTreeLock(
- NameIdentifier.of(AuthorizationUtils.ofUserNamespace(metalake).levels()),
- LockType.WRITE,
- () -> userGroupExternalManager.addUser(metalake, user, externalId, enabled));
- }
-
@Override
public List<BulkItemResult<User>> addUsers(String metalake, List<UserAdd> users)
throws NoSuchMetalakeException {
@@ -96,14 +83,7 @@ public class AccessControlManager implements AccessControlDispatcher {
for (int index = 0; index < users.size(); index++) {
UserAdd user = users.get(index);
try {
- User addedUser =
- user.hasExternalId()
- ? userGroupExternalManager.addUser(
- metalake,
- user.name(),
- user.externalId(),
- Optional.ofNullable(user.enabled()).orElse(true))
- : userGroupManager.addUser(metalake, user.name());
+ User addedUser = userGroupManager.addUser(metalake, user.name());
results.add(BulkItemResult.success(index, user.name(), addedUser));
} catch (Exception e) {
results.add(BulkItemResult.failure(index, user.name(), e));
@@ -150,15 +130,6 @@ public class AccessControlManager implements AccessControlDispatcher {
});
}
- @Override
- public boolean removeUserByExternalId(String metalake, String externalId)
- throws NoSuchMetalakeException {
- return TreeLockUtils.doWithTreeLock(
- AuthorizationUtils.ofUserExternalId(metalake, externalId),
- LockType.WRITE,
- () -> userGroupExternalManager.removeUserByExternalId(metalake, externalId));
- }
-
@Override
public User getUser(String metalake, String user)
throws NoSuchUserException, NoSuchMetalakeException {
@@ -168,41 +139,6 @@ public class AccessControlManager implements AccessControlDispatcher {
() -> userGroupManager.getUser(metalake, user));
}
- @Override
- public User getUserByExternalId(String metalake, String externalId)
- throws NoSuchUserException, NoSuchMetalakeException {
- return TreeLockUtils.doWithTreeLock(
- AuthorizationUtils.ofUserExternalId(metalake, externalId),
- LockType.READ,
- () -> userGroupExternalManager.getUserByExternalId(metalake, externalId));
- }
-
- @Override
- public User getUserById(String metalake, long userId)
- throws NoSuchUserException, NoSuchMetalakeException {
- return TreeLockUtils.doWithTreeLock(
- AuthorizationUtils.ofUserId(metalake, userId),
- LockType.READ,
- () -> userGroupIdManager.getUserById(metalake, userId));
- }
-
- @Override
- public boolean removeUserById(String metalake, long userId) throws NoSuchMetalakeException {
- return TreeLockUtils.doWithTreeLock(
- AuthorizationUtils.ofUserId(metalake, userId),
- LockType.WRITE,
- () -> userGroupIdManager.removeUserById(metalake, userId));
- }
-
- @Override
- public User alterUserById(String metalake, long userId, UserChange... changes)
- throws NoSuchUserException, NoSuchMetalakeException {
- return TreeLockUtils.doWithTreeLock(
- AuthorizationUtils.ofUserId(metalake, userId),
- LockType.WRITE,
- () -> userGroupIdManager.alterUserById(metalake, userId, changes));
- }
-
@Override
public String[] listUserNames(String metalake) throws NoSuchMetalakeException {
return TreeLockUtils.doWithTreeLock(
@@ -245,15 +181,6 @@ public class AccessControlManager implements AccessControlDispatcher {
() -> userGroupManager.addGroup(metalake, group));
}
- @Override
- public Group addGroup(String metalake, String group, String externalId)
- throws GroupAlreadyExistsException, NoSuchMetalakeException {
- return TreeLockUtils.doWithTreeLock(
- NameIdentifier.of(AuthorizationUtils.ofGroupNamespace(metalake).levels()),
- LockType.WRITE,
- () -> userGroupExternalManager.addGroup(metalake, group, externalId));
- }
-
@Override
public List<BulkItemResult<Group>> addGroups(String metalake, List<GroupAdd> groups)
throws NoSuchMetalakeException {
@@ -265,11 +192,7 @@ public class AccessControlManager implements AccessControlDispatcher {
for (int index = 0; index < groups.size(); index++) {
GroupAdd group = groups.get(index);
try {
- Group addedGroup =
- group.hasExternalId()
- ? userGroupExternalManager.addGroup(
- metalake, group.name(), group.externalId())
- : userGroupManager.addGroup(metalake, group.name());
+ Group addedGroup = userGroupManager.addGroup(metalake, group.name());
results.add(BulkItemResult.success(index, group.name(), addedGroup));
} catch (Exception e) {
results.add(BulkItemResult.failure(index, group.name(), e));
@@ -316,15 +239,6 @@ public class AccessControlManager implements AccessControlDispatcher {
});
}
- @Override
- public boolean removeGroupByExternalId(String metalake, String externalId)
- throws NoSuchMetalakeException {
- return TreeLockUtils.doWithTreeLock(
- AuthorizationUtils.ofGroupExternalId(metalake, externalId),
- LockType.WRITE,
- () -> userGroupExternalManager.removeGroupByExternalId(metalake, externalId));
- }
-
@Override
public Group getGroup(String metalake, String group)
throws NoSuchGroupException, NoSuchMetalakeException {
@@ -334,41 +248,6 @@ public class AccessControlManager implements AccessControlDispatcher {
() -> userGroupManager.getGroup(metalake, group));
}
- @Override
- public Group getGroupByExternalId(String metalake, String externalId)
- throws NoSuchGroupException, NoSuchMetalakeException {
- return TreeLockUtils.doWithTreeLock(
- AuthorizationUtils.ofGroupExternalId(metalake, externalId),
- LockType.READ,
- () -> userGroupExternalManager.getGroupByExternalId(metalake, externalId));
- }
-
- @Override
- public Group getGroupById(String metalake, long groupId)
- throws NoSuchGroupException, NoSuchMetalakeException {
- return TreeLockUtils.doWithTreeLock(
- AuthorizationUtils.ofGroupId(metalake, groupId),
- LockType.READ,
- () -> userGroupIdManager.getGroupById(metalake, groupId));
- }
-
- @Override
- public boolean removeGroupById(String metalake, long groupId) throws NoSuchMetalakeException {
- return TreeLockUtils.doWithTreeLock(
- AuthorizationUtils.ofGroupId(metalake, groupId),
- LockType.WRITE,
- () -> userGroupIdManager.removeGroupById(metalake, groupId));
- }
-
- @Override
- public Group alterGroupById(String metalake, long groupId, GroupChange... changes)
- throws NoSuchGroupException, NoSuchMetalakeException {
- return TreeLockUtils.doWithTreeLock(
- AuthorizationUtils.ofGroupId(metalake, groupId),
- LockType.WRITE,
- () -> userGroupIdManager.alterGroupById(metalake, groupId, changes));
- }
-
@Override
public Group[] listGroups(String metalake) throws NoSuchMetalakeException {
return TreeLockUtils.doWithTreeLock(
diff --git a/core/src/main/java/org/apache/gravitino/authorization/AuthorizationUtils.java b/core/src/main/java/org/apache/gravitino/authorization/AuthorizationUtils.java
index aee06ea128..5224a2d787 100644
--- a/core/src/main/java/org/apache/gravitino/authorization/AuthorizationUtils.java
+++ b/core/src/main/java/org/apache/gravitino/authorization/AuthorizationUtils.java
@@ -64,15 +64,7 @@ public class AuthorizationUtils {
private static final String FILESET_SCHEMA_LOCATION = "location";
private static final String HIVE_LOCATION = "location";
static final String USER_DOES_NOT_EXIST_MSG = "User %s does not exist in the metalake %s";
- static final String USER_WITH_EXTERNAL_ID_DOES_NOT_EXIST_MSG =
- "User with external id %s does not exist in the metalake %s";
- static final String USER_WITH_ID_DOES_NOT_EXIST_MSG =
- "User with id %s does not exist in the metalake %s";
static final String GROUP_DOES_NOT_EXIST_MSG = "Group %s does not exist in the metalake %s";
- static final String GROUP_WITH_EXTERNAL_ID_DOES_NOT_EXIST_MSG =
- "Group with external id %s does not exist in the metalake %s";
- static final String GROUP_WITH_ID_DOES_NOT_EXIST_MSG =
- "Group with id %s does not exist in the metalake %s";
static final String ROLE_DOES_NOT_EXIST_MSG = "Role %s does not exist in the metalake %s";
/**
@@ -156,74 +148,6 @@ public class AuthorizationUtils {
metalake, Entity.SYSTEM_CATALOG_RESERVED_NAME, Entity.USER_SCHEMA_NAME, user);
}
- /**
- * Creates a synthetic {@link NameIdentifier} used only as a {@link
- * org.apache.gravitino.lock.TreeLockUtils} lock path for user operations keyed by external id.
- *
- * @param metalake the metalake name
- * @param externalId the external id of the user
- * @return a synthetic name identifier for tree locking only
- */
- public static NameIdentifier ofUserExternalId(String metalake, String externalId) {
- return NameIdentifier.of(
- metalake,
- Entity.SYSTEM_CATALOG_RESERVED_NAME,
- Entity.USER_EXTERNAL_ID_SCHEMA_NAME,
- externalId);
- }
-
- /**
- * Creates a synthetic {@link NameIdentifier} used only as a tree-lock path for user operations
- * keyed by Gravitino-assigned id.
- *
- * @param metalake the metalake name
- * @param userId the Gravitino-assigned user id
- * @return a synthetic name identifier for tree locking only
- */
- public static NameIdentifier ofUserId(String metalake, long userId) {
- return NameIdentifier.of(
- metalake,
- Entity.SYSTEM_CATALOG_RESERVED_NAME,
- Entity.USER_ID_SCHEMA_NAME,
- String.valueOf(userId));
- }
-
- /**
- * Creates a synthetic {@link NameIdentifier} used only as a tree-lock path for group operations
- * keyed by Gravitino-assigned id.
- *
- * @param metalake the metalake name
- * @param groupId the Gravitino-assigned group id
- * @return a synthetic name identifier for tree locking only
- */
- public static NameIdentifier ofGroupId(String metalake, long groupId) {
- return NameIdentifier.of(
- metalake,
- Entity.SYSTEM_CATALOG_RESERVED_NAME,
- Entity.GROUP_ID_SCHEMA_NAME,
- String.valueOf(groupId));
- }
-
- /**
- * Creates a synthetic {@link NameIdentifier} used only as a {@link
- * org.apache.gravitino.lock.TreeLockUtils} lock path for group operations keyed by external id.
- *
- * <p>This is <strong>not</strong> the entity's storage identifier. Group entities are stored and
- * retrieved by Gravitino group name via {@link #ofGroup(String, String)}. At lock time the group
- * name may be unknown, so external-id operations need a dedicated lock path.
- *
- * @param metalake the metalake name
- * @param externalId the external id of the group
- * @return a synthetic name identifier for tree locking only
- */
- public static NameIdentifier ofGroupExternalId(String metalake, String externalId) {
- return NameIdentifier.of(
- metalake,
- Entity.SYSTEM_CATALOG_RESERVED_NAME,
- Entity.GROUP_EXTERNAL_ID_SCHEMA_NAME,
- externalId);
- }
-
public static Namespace ofRoleNamespace(String metalake) {
return Namespace.of(metalake, Entity.SYSTEM_CATALOG_RESERVED_NAME, Entity.ROLE_SCHEMA_NAME);
}
@@ -236,74 +160,16 @@ public class AuthorizationUtils {
return Namespace.of(metalake, Entity.SYSTEM_CATALOG_RESERVED_NAME, Entity.USER_SCHEMA_NAME);
}
- public static Namespace ofUserExternalIdNamespace(String metalake) {
- return Namespace.of(
- metalake, Entity.SYSTEM_CATALOG_RESERVED_NAME, Entity.USER_EXTERNAL_ID_SCHEMA_NAME);
- }
-
- public static Namespace ofUserIdNamespace(String metalake) {
- return Namespace.of(metalake, Entity.SYSTEM_CATALOG_RESERVED_NAME, Entity.USER_ID_SCHEMA_NAME);
- }
-
- public static Namespace ofGroupExternalIdNamespace(String metalake) {
- return Namespace.of(
- metalake, Entity.SYSTEM_CATALOG_RESERVED_NAME, Entity.GROUP_EXTERNAL_ID_SCHEMA_NAME);
- }
-
- public static Namespace ofGroupIdNamespace(String metalake) {
- return Namespace.of(metalake, Entity.SYSTEM_CATALOG_RESERVED_NAME, Entity.GROUP_ID_SCHEMA_NAME);
- }
-
public static void checkUser(NameIdentifier ident) {
NameIdentifier.check(ident != null, "User identifier must not be null");
checkUserNamespace(ident.namespace());
}
- /**
- * Validates that the name identifier refers to a user external id in a metalake.
- *
- * @param ident the external id name identifier to validate
- */
- public static void checkUserExternalId(NameIdentifier ident) {
- NameIdentifier.check(ident != null, "External id identifier must not be null");
- checkUserExternalIdNamespace(ident.namespace());
- }
-
- /**
- * Validates that the name identifier refers to a user id in a metalake.
- *
- * @param ident the user id name identifier to validate
- */
- public static void checkUserId(NameIdentifier ident) {
- NameIdentifier.check(ident != null, "User id identifier must not be null");
- checkUserIdNamespace(ident.namespace());
- }
-
public static void checkGroup(NameIdentifier ident) {
NameIdentifier.check(ident != null, "Group identifier must not be null");
checkGroupNamespace(ident.namespace());
}
- /**
- * Validates that the name identifier refers to a group external id in a metalake.
- *
- * @param ident the external id name identifier to validate
- */
- public static void checkGroupExternalId(NameIdentifier ident) {
- NameIdentifier.check(ident != null, "External id identifier must not be null");
- checkGroupExternalIdNamespace(ident.namespace());
- }
-
- /**
- * Validates that the name identifier refers to a group id in a metalake.
- *
- * @param ident the group id name identifier to validate
- */
- public static void checkGroupId(NameIdentifier ident) {
- NameIdentifier.check(ident != null, "Group id identifier must not be null");
- checkGroupIdNamespace(ident.namespace());
- }
-
public static void checkRole(NameIdentifier ident) {
NameIdentifier.check(ident != null, "Role identifier must not be null");
checkRoleNamespace(ident.namespace());
@@ -316,34 +182,6 @@ public class AuthorizationUtils {
namespace);
}
- public static void checkUserExternalIdNamespace(Namespace namespace) {
- Namespace.check(
- namespace != null && namespace.length() == 3,
- "User external id namespace must have 3 levels, the input namespace is %s",
- namespace);
- }
-
- public static void checkUserIdNamespace(Namespace namespace) {
- Namespace.check(
- namespace != null && namespace.length() == 3,
- "User id namespace must have 3 levels, the input namespace is %s",
- namespace);
- }
-
- public static void checkGroupExternalIdNamespace(Namespace namespace) {
- Namespace.check(
- namespace != null && namespace.length() == 3,
- "Group external id namespace must have 3 levels, the input namespace is %s",
- namespace);
- }
-
- public static void checkGroupIdNamespace(Namespace namespace) {
- Namespace.check(
- namespace != null && namespace.length() == 3,
- "Group id namespace must have 3 levels, the input namespace is %s",
- namespace);
- }
-
public static void checkGroupNamespace(Namespace namespace) {
Namespace.check(
namespace != null && namespace.length() == 3,
diff --git a/core/src/main/java/org/apache/gravitino/authorization/PermissionManager.java b/core/src/main/java/org/apache/gravitino/authorization/PermissionManager.java
index f732eff9f7..fadb3463bc 100644
--- a/core/src/main/java/org/apache/gravitino/authorization/PermissionManager.java
+++ b/core/src/main/java/org/apache/gravitino/authorization/PermissionManager.java
@@ -118,8 +118,6 @@ class PermissionManager {
.withNamespace(userEntity.namespace())
.withId(userEntity.id())
.withName(userEntity.name())
- .withExternalId(userEntity.externalId())
- .withEnabled(userEntity.enabled())
.withRoleNames(roleNames)
.withRoleIds(roleIds)
.withAuditInfo(auditInfo)
@@ -209,7 +207,6 @@ class PermissionManager {
.withId(groupEntity.id())
.withNamespace(groupEntity.namespace())
.withName(groupEntity.name())
- .withExternalId(groupEntity.externalId())
.withRoleNames(roleNames)
.withRoleIds(roleIds)
.withAuditInfo(auditInfo)
@@ -298,7 +295,6 @@ class PermissionManager {
.withNamespace(groupEntity.namespace())
.withId(groupEntity.id())
.withName(groupEntity.name())
- .withExternalId(groupEntity.externalId())
.withRoleNames(roleNames)
.withRoleIds(roleIds)
.withAuditInfo(auditInfo)
@@ -388,8 +384,6 @@ class PermissionManager {
.withId(userEntity.id())
.withNamespace(userEntity.namespace())
.withName(userEntity.name())
- .withExternalId(userEntity.externalId())
- .withEnabled(userEntity.enabled())
.withRoleNames(roleNames)
.withRoleIds(roleIds)
.withAuditInfo(auditInfo)
diff --git a/core/src/main/java/org/apache/gravitino/authorization/UserGroupExternalManager.java b/core/src/main/java/org/apache/gravitino/authorization/UserGroupExternalManager.java
deleted file mode 100644
index 7fb7bc62dd..0000000000
--- a/core/src/main/java/org/apache/gravitino/authorization/UserGroupExternalManager.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * 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.collect.Lists;
-import java.io.IOException;
-import java.time.Instant;
-import org.apache.gravitino.Entity;
-import org.apache.gravitino.EntityAlreadyExistsException;
-import org.apache.gravitino.EntityStore;
-import org.apache.gravitino.exceptions.GroupAlreadyExistsException;
-import org.apache.gravitino.exceptions.NoSuchEntityException;
-import org.apache.gravitino.exceptions.NoSuchGroupException;
-import org.apache.gravitino.exceptions.NoSuchUserException;
-import org.apache.gravitino.exceptions.UserAlreadyExistsException;
-import org.apache.gravitino.meta.AuditInfo;
-import org.apache.gravitino.meta.GroupEntity;
-import org.apache.gravitino.meta.UserEntity;
-import org.apache.gravitino.storage.IdGenerator;
-import org.apache.gravitino.utils.PrincipalUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** Manages user and group operations keyed by external id within a metalake. */
-class UserGroupExternalManager extends UserGroupManager {
-
- private static final Logger LOG = LoggerFactory.getLogger(UserGroupExternalManager.class);
-
- /**
- * Creates a {@link UserGroupExternalManager} instance.
- *
- * @param store the entity store
- * @param idGenerator the id generator
- */
- UserGroupExternalManager(EntityStore store, IdGenerator idGenerator) {
- super(store, idGenerator);
- }
-
- User addUser(String metalake, String name, String externalId, boolean enabled)
- throws UserAlreadyExistsException {
- try {
- UserEntity userEntity =
- UserEntity.builder()
- .withId(idGenerator.nextId())
- .withName(name)
- .withNamespace(AuthorizationUtils.ofUserNamespace(metalake))
- .withRoleNames(Lists.newArrayList())
- .withEnabled(enabled)
- .withExternalId(externalId)
- .withAuditInfo(
- AuditInfo.builder()
- .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
- .withCreateTime(Instant.now())
- .build())
- .build();
- store.put(userEntity, false /* overwritten */);
- return userEntity;
- } catch (EntityAlreadyExistsException e) {
- LOG.warn("User {} in the metalake {} already exists", name, metalake, e);
- throw new UserAlreadyExistsException(
- "User %s in the metalake %s already exists", name, metalake);
- } catch (IOException ioe) {
- LOG.error(
- "Adding user {} failed in the metalake {} due to storage issues", name, metalake, ioe);
- throw new RuntimeException(ioe);
- }
- }
-
- boolean removeUserByExternalId(String metalake, String externalId) {
- try {
- return store
- .externalIdOperations()
- .deleteByExternalId(
- AuthorizationUtils.ofUserExternalId(metalake, externalId), Entity.EntityType.USER);
- } catch (IOException ioe) {
- LOG.error(
- "Removing user with external id {} in the metalake {} failed due to storage issues",
- externalId,
- metalake,
- ioe);
- throw new RuntimeException(ioe);
- }
- }
-
- User getUserByExternalId(String metalake, String externalId) throws NoSuchUserException {
- try {
- return store
- .externalIdOperations()
- .getByExternalId(
- AuthorizationUtils.ofUserExternalId(metalake, externalId),
- Entity.EntityType.USER,
- UserEntity.class);
- } catch (NoSuchEntityException e) {
- LOG.warn(
- "User with external id {} does not exist in the metalake {}", externalId, metalake, e);
- throw new NoSuchUserException(
- AuthorizationUtils.USER_WITH_EXTERNAL_ID_DOES_NOT_EXIST_MSG, externalId, metalake);
- } catch (IOException ioe) {
- LOG.error("Getting user with external id {} failed due to storage issues", externalId, ioe);
- throw new RuntimeException(ioe);
- }
- }
-
- Group addGroup(String metalake, String group, String externalId)
- throws GroupAlreadyExistsException {
- try {
- GroupEntity groupEntity =
- GroupEntity.builder()
- .withId(idGenerator.nextId())
- .withName(group)
- .withNamespace(AuthorizationUtils.ofGroupNamespace(metalake))
- .withRoleNames(Lists.newArrayList())
- .withExternalId(externalId)
- .withAuditInfo(
- AuditInfo.builder()
- .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
- .withCreateTime(Instant.now())
- .build())
- .build();
- store.put(groupEntity, false /* overwritten */);
- return groupEntity;
- } catch (EntityAlreadyExistsException e) {
- LOG.warn("Group {} in the metalake {} already exists", group, metalake, e);
- throw new GroupAlreadyExistsException(
- "Group %s in the metalake %s already exists", group, metalake);
- } catch (IOException ioe) {
- LOG.error(
- "Adding group {} failed in the metalake {} due to storage issues", group, metalake, ioe);
- throw new RuntimeException(ioe);
- }
- }
-
- boolean removeGroupByExternalId(String metalake, String externalId) {
- try {
- return store
- .externalIdOperations()
- .deleteByExternalId(
- AuthorizationUtils.ofGroupExternalId(metalake, externalId), Entity.EntityType.GROUP);
- } catch (IOException ioe) {
- LOG.error(
- "Removing group with external id {} in the metalake {} failed due to storage issues",
- externalId,
- metalake,
- ioe);
- throw new RuntimeException(ioe);
- }
- }
-
- Group getGroupByExternalId(String metalake, String externalId) throws NoSuchGroupException {
- try {
- return store
- .externalIdOperations()
- .getByExternalId(
- AuthorizationUtils.ofGroupExternalId(metalake, externalId),
- Entity.EntityType.GROUP,
- GroupEntity.class);
- } catch (NoSuchEntityException e) {
- LOG.warn(
- "Group with external id {} does not exist in the metalake {}", externalId, metalake, e);
- throw new NoSuchGroupException(
- AuthorizationUtils.GROUP_WITH_EXTERNAL_ID_DOES_NOT_EXIST_MSG, externalId, metalake);
- } catch (IOException ioe) {
- LOG.error("Getting group with external id {} failed due to storage issues", externalId, ioe);
- throw new RuntimeException(ioe);
- }
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/authorization/UserGroupIdManager.java b/core/src/main/java/org/apache/gravitino/authorization/UserGroupIdManager.java
deleted file mode 100644
index 6583a73499..0000000000
--- a/core/src/main/java/org/apache/gravitino/authorization/UserGroupIdManager.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * 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 java.io.IOException;
-import java.time.Instant;
-import org.apache.gravitino.Entity;
-import org.apache.gravitino.EntityStore;
-import org.apache.gravitino.exceptions.NoSuchEntityException;
-import org.apache.gravitino.exceptions.NoSuchGroupException;
-import org.apache.gravitino.exceptions.NoSuchUserException;
-import org.apache.gravitino.meta.AuditInfo;
-import org.apache.gravitino.meta.GroupEntity;
-import org.apache.gravitino.meta.UserEntity;
-import org.apache.gravitino.storage.IdGenerator;
-import org.apache.gravitino.utils.PrincipalUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** Manages user and group operations keyed by Gravitino-assigned id within a metalake. */
-class UserGroupIdManager extends UserGroupManager {
-
- private static final Logger LOG = LoggerFactory.getLogger(UserGroupIdManager.class);
-
- /**
- * Creates a {@link UserGroupIdManager} instance.
- *
- * @param store the entity store
- * @param idGenerator the id generator
- */
- UserGroupIdManager(EntityStore store, IdGenerator idGenerator) {
- super(store, idGenerator);
- }
-
- boolean removeUserById(String metalake, long userId) {
- try {
- return store
- .idOperations()
- .deleteById(AuthorizationUtils.ofUserId(metalake, userId), Entity.EntityType.USER);
- } catch (IOException ioe) {
- LOG.error(
- "Removing user with id {} in the metalake {} failed due to storage issues",
- userId,
- metalake,
- ioe);
- throw new RuntimeException(ioe);
- }
- }
-
- User getUserById(String metalake, long userId) throws NoSuchUserException {
- try {
- return store
- .idOperations()
- .getById(
- AuthorizationUtils.ofUserId(metalake, userId),
- Entity.EntityType.USER,
- UserEntity.class);
- } catch (NoSuchEntityException e) {
- LOG.warn("User with id {} does not exist in the metalake {}", userId, metalake, e);
- throw new NoSuchUserException(
- AuthorizationUtils.USER_WITH_ID_DOES_NOT_EXIST_MSG, userId, metalake);
- } catch (IOException ioe) {
- LOG.error("Getting user with id {} failed due to storage issues", userId, ioe);
- throw new RuntimeException(ioe);
- }
- }
-
- User alterUserById(String metalake, long userId, UserChange... changes)
- throws NoSuchUserException {
- Preconditions.checkArgument(
- changes != null && changes.length > 0, "User changes cannot be empty");
- try {
- return store
- .idOperations()
- .updateById(
- AuthorizationUtils.ofUserId(metalake, userId),
- Entity.EntityType.USER,
- UserEntity.class,
- user -> applyChanges(user, changes));
- } catch (NoSuchEntityException e) {
- LOG.warn("User with id {} does not exist in the metalake {}", userId, metalake, e);
- throw new NoSuchUserException(
- AuthorizationUtils.USER_WITH_ID_DOES_NOT_EXIST_MSG, userId, metalake);
- } catch (IOException ioe) {
- LOG.error(
- "Altering user with id {} in the metalake {} failed due to storage issues",
- userId,
- metalake,
- ioe);
- throw new RuntimeException(ioe);
- }
- }
-
- private static UserEntity applyChanges(UserEntity user, UserChange... changes) {
- String externalId = user.externalId();
- boolean enabled = user.enabled();
- for (UserChange change : changes) {
- if (change instanceof UserChange.UpdateEnabled) {
- enabled = ((UserChange.UpdateEnabled) change).enabled();
- } else if (change instanceof UserChange.UpdateExternalId) {
- externalId = ((UserChange.UpdateExternalId) change).getNewExternalId();
- } else {
- throw new IllegalArgumentException("Unsupported user change: " + change);
- }
- }
- return UserEntity.builder()
- .withId(user.id())
- .withName(user.name())
- .withNamespace(user.namespace())
- .withExternalId(externalId)
- .withEnabled(enabled)
- .withRoleNames(user.roleNames())
- .withRoleIds(user.roleIds())
- .withAuditInfo(
- AuditInfo.builder()
- .withCreator(user.auditInfo().creator())
- .withCreateTime(user.auditInfo().createTime())
- .withLastModifier(PrincipalUtils.getCurrentPrincipal().getName())
- .withLastModifiedTime(Instant.now())
- .build())
- .build();
- }
-
- boolean removeGroupById(String metalake, long groupId) {
- try {
- return store
- .idOperations()
- .deleteById(AuthorizationUtils.ofGroupId(metalake, groupId), Entity.EntityType.GROUP);
- } catch (IOException ioe) {
- LOG.error(
- "Removing group with id {} in the metalake {} failed due to storage issues",
- groupId,
- metalake,
- ioe);
- throw new RuntimeException(ioe);
- }
- }
-
- Group getGroupById(String metalake, long groupId) throws NoSuchGroupException {
- try {
- return store
- .idOperations()
- .getById(
- AuthorizationUtils.ofGroupId(metalake, groupId),
- Entity.EntityType.GROUP,
- GroupEntity.class);
- } catch (NoSuchEntityException e) {
- LOG.warn("Group with id {} does not exist in the metalake {}", groupId, metalake, e);
- throw new NoSuchGroupException(
- AuthorizationUtils.GROUP_WITH_ID_DOES_NOT_EXIST_MSG, groupId, metalake);
- } catch (IOException ioe) {
- LOG.error("Getting group with id {} failed due to storage issues", groupId, ioe);
- throw new RuntimeException(ioe);
- }
- }
-
- Group alterGroupById(String metalake, long groupId, GroupChange... changes)
- throws NoSuchGroupException {
- Preconditions.checkArgument(
- changes != null && changes.length > 0, "Group changes cannot be empty");
- try {
- return store
- .idOperations()
- .updateById(
- AuthorizationUtils.ofGroupId(metalake, groupId),
- Entity.EntityType.GROUP,
- GroupEntity.class,
- group -> applyGroupChanges(group, changes));
- } catch (NoSuchEntityException e) {
- LOG.warn("Group with id {} does not exist in the metalake {}", groupId, metalake, e);
- throw new NoSuchGroupException(
- AuthorizationUtils.GROUP_WITH_ID_DOES_NOT_EXIST_MSG, groupId, metalake);
- } catch (IOException ioe) {
- LOG.error(
- "Altering group with id {} in the metalake {} failed due to storage issues",
- groupId,
- metalake,
- ioe);
- throw new RuntimeException(ioe);
- }
- }
-
- private static GroupEntity applyGroupChanges(GroupEntity group, GroupChange... changes) {
- String externalId = group.externalId();
- for (GroupChange change : changes) {
- if (change instanceof GroupChange.UpdateExternalId) {
- externalId = ((GroupChange.UpdateExternalId) change).getNewExternalId();
- } else {
- throw new IllegalArgumentException("Unsupported group change: " + change);
- }
- }
- return GroupEntity.builder()
- .withId(group.id())
- .withName(group.name())
- .withNamespace(group.namespace())
- .withExternalId(externalId)
- .withRoleNames(group.roleNames())
- .withRoleIds(group.roleIds())
- .withAuditInfo(
- AuditInfo.builder()
- .withCreator(group.auditInfo().creator())
- .withCreateTime(group.auditInfo().createTime())
- .withLastModifier(PrincipalUtils.getCurrentPrincipal().getName())
- .withLastModifiedTime(Instant.now())
- .build())
- .build();
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/bulk/GroupAdd.java b/core/src/main/java/org/apache/gravitino/bulk/GroupAdd.java
index d4e76a68d2..ad0962aceb 100644
--- a/core/src/main/java/org/apache/gravitino/bulk/GroupAdd.java
+++ b/core/src/main/java/org/apache/gravitino/bulk/GroupAdd.java
@@ -3,8 +3,8 @@
* 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
+ * 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
@@ -18,24 +18,18 @@
*/
package org.apache.gravitino.bulk;
-import javax.annotation.Nullable;
-import org.apache.commons.lang3.StringUtils;
-
/** Represents one group to add in a bulk operation. */
public final class GroupAdd {
private final String name;
- @Nullable private final String externalId;
/**
* Creates a group add item.
*
* @param name The group name.
- * @param externalId The external identifier, or null if unset.
*/
- public GroupAdd(String name, @Nullable String externalId) {
+ public GroupAdd(String name) {
this.name = name;
- this.externalId = externalId;
}
/**
@@ -46,23 +40,4 @@ public final class GroupAdd {
public String name() {
return name;
}
-
- /**
- * Returns the external identifier.
- *
- * @return The external identifier, or null if unset.
- */
- @Nullable
- public String externalId() {
- return externalId;
- }
-
- /**
- * Returns whether the group has an external identifier.
- *
- * @return True if the group has a non-blank external identifier, otherwise false.
- */
- public boolean hasExternalId() {
- return StringUtils.isNotBlank(externalId);
- }
}
diff --git a/core/src/main/java/org/apache/gravitino/bulk/UserAdd.java b/core/src/main/java/org/apache/gravitino/bulk/UserAdd.java
index 8c33b4abb7..f060defff1 100644
--- a/core/src/main/java/org/apache/gravitino/bulk/UserAdd.java
+++ b/core/src/main/java/org/apache/gravitino/bulk/UserAdd.java
@@ -18,27 +18,18 @@
*/
package org.apache.gravitino.bulk;
-import javax.annotation.Nullable;
-import org.apache.commons.lang3.StringUtils;
-
/** Represents one user to add in a bulk operation. */
public final class UserAdd {
private final String name;
- @Nullable private final String externalId;
- @Nullable private final Boolean enabled;
/**
* Creates a user add item.
*
* @param name The user name.
- * @param externalId The external identifier, or null if unset.
- * @param enabled Whether the user is enabled, or null to use the default value.
*/
- public UserAdd(String name, @Nullable String externalId, @Nullable Boolean enabled) {
+ public UserAdd(String name) {
this.name = name;
- this.externalId = externalId;
- this.enabled = enabled;
}
/**
@@ -49,33 +40,4 @@ public final class UserAdd {
public String name() {
return name;
}
-
- /**
- * Returns the external identifier.
- *
- * @return The external identifier, or null if unset.
- */
- @Nullable
- public String externalId() {
- return externalId;
- }
-
- /**
- * Returns whether the user has an external identifier.
- *
- * @return True if the user has an external identifier, otherwise false.
- */
- public boolean hasExternalId() {
- return StringUtils.isNotBlank(externalId);
- }
-
- /**
- * Returns whether the user is enabled.
- *
- * @return Whether the user is enabled, or null to use the default value.
- */
- @Nullable
- public Boolean enabled() {
- return enabled;
- }
}
diff --git a/core/src/main/java/org/apache/gravitino/hook/AccessControlHookDispatcher.java b/core/src/main/java/org/apache/gravitino/hook/AccessControlHookDispatcher.java
index 6dfa084e99..6958dd1a98 100644
--- a/core/src/main/java/org/apache/gravitino/hook/AccessControlHookDispatcher.java
+++ b/core/src/main/java/org/apache/gravitino/hook/AccessControlHookDispatcher.java
@@ -29,7 +29,6 @@ import org.apache.gravitino.authorization.AccessControlDispatcher;
import org.apache.gravitino.authorization.AuthorizationUtils;
import org.apache.gravitino.authorization.GravitinoAuthorizer;
import org.apache.gravitino.authorization.Group;
-import org.apache.gravitino.authorization.GroupChange;
import org.apache.gravitino.authorization.Owner;
import org.apache.gravitino.authorization.OwnerDispatcher;
import org.apache.gravitino.authorization.PagedResult;
@@ -37,7 +36,6 @@ import org.apache.gravitino.authorization.Privilege;
import org.apache.gravitino.authorization.Role;
import org.apache.gravitino.authorization.SecurableObject;
import org.apache.gravitino.authorization.User;
-import org.apache.gravitino.authorization.UserChange;
import org.apache.gravitino.bulk.BulkItemResult;
import org.apache.gravitino.bulk.GroupAdd;
import org.apache.gravitino.bulk.UserAdd;
@@ -76,12 +74,6 @@ public class AccessControlHookDispatcher implements AccessControlDispatcher {
return dispatcher.addUser(metalake, user);
}
- @Override
- public User addUser(String metalake, String user, String externalId, boolean enabled)
- throws UserAlreadyExistsException, NoSuchMetalakeException {
- return dispatcher.addUser(metalake, user, externalId, enabled);
- }
-
@Override
public List<BulkItemResult<User>> addUsers(String metalake, List<UserAdd> users)
throws NoSuchMetalakeException {
@@ -100,41 +92,12 @@ public class AccessControlHookDispatcher implements AccessControlDispatcher {
return dispatcher.removeUsers(metalake, users, metalakeOwner);
}
- @Override
- public boolean removeUserByExternalId(String metalake, String externalId)
- throws NoSuchMetalakeException {
- return dispatcher.removeUserByExternalId(metalake, externalId);
- }
-
@Override
public User getUser(String metalake, String user)
throws NoSuchUserException, NoSuchMetalakeException {
return dispatcher.getUser(metalake, user);
}
- @Override
- public User getUserByExternalId(String metalake, String externalId)
- throws NoSuchUserException, NoSuchMetalakeException {
- return dispatcher.getUserByExternalId(metalake, externalId);
- }
-
- @Override
- public User getUserById(String metalake, long userId)
- throws NoSuchUserException, NoSuchMetalakeException {
- return dispatcher.getUserById(metalake, userId);
- }
-
- @Override
- public boolean removeUserById(String metalake, long userId) throws NoSuchMetalakeException {
- return dispatcher.removeUserById(metalake, userId);
- }
-
- @Override
- public User alterUserById(String metalake, long userId, UserChange... changes)
- throws NoSuchUserException, NoSuchMetalakeException {
- return dispatcher.alterUserById(metalake, userId, changes);
- }
-
@Override
public User[] listUsers(String metalake) throws NoSuchMetalakeException {
return dispatcher.listUsers(metalake);
@@ -162,12 +125,6 @@ public class AccessControlHookDispatcher implements AccessControlDispatcher {
return dispatcher.addGroup(metalake, group);
}
- @Override
- public Group addGroup(String metalake, String group, String externalId)
- throws GroupAlreadyExistsException, NoSuchMetalakeException {
- return dispatcher.addGroup(metalake, group, externalId);
- }
-
@Override
public List<BulkItemResult<Group>> addGroups(String metalake, List<GroupAdd> groups)
throws NoSuchMetalakeException {
@@ -186,41 +143,12 @@ public class AccessControlHookDispatcher implements AccessControlDispatcher {
return dispatcher.removeGroups(metalake, groups, metalakeOwner);
}
- @Override
- public boolean removeGroupByExternalId(String metalake, String externalId)
- throws NoSuchMetalakeException {
- return dispatcher.removeGroupByExternalId(metalake, externalId);
- }
-
@Override
public Group getGroup(String metalake, String group)
throws NoSuchGroupException, NoSuchMetalakeException {
return dispatcher.getGroup(metalake, group);
}
- @Override
- public Group getGroupByExternalId(String metalake, String externalId)
- throws NoSuchGroupException, NoSuchMetalakeException {
- return dispatcher.getGroupByExternalId(metalake, externalId);
- }
-
- @Override
- public Group getGroupById(String metalake, long groupId)
- throws NoSuchGroupException, NoSuchMetalakeException {
- return dispatcher.getGroupById(metalake, groupId);
- }
-
- @Override
- public boolean removeGroupById(String metalake, long groupId) throws NoSuchMetalakeException {
- return dispatcher.removeGroupById(metalake, groupId);
- }
-
- @Override
- public Group alterGroupById(String metalake, long groupId, GroupChange... changes)
- throws NoSuchGroupException, NoSuchMetalakeException {
- return dispatcher.alterGroupById(metalake, groupId, changes);
- }
-
@Override
public Group[] listGroups(String metalake) throws NoSuchMetalakeException {
return dispatcher.listGroups(metalake);
diff --git a/core/src/main/java/org/apache/gravitino/listener/AccessControlEventDispatcher.java b/core/src/main/java/org/apache/gravitino/listener/AccessControlEventDispatcher.java
index 26bc9fc358..16a8b83378 100644
--- a/core/src/main/java/org/apache/gravitino/listener/AccessControlEventDispatcher.java
+++ b/core/src/main/java/org/apache/gravitino/listener/AccessControlEventDispatcher.java
@@ -26,14 +26,12 @@ import java.util.Set;
import org.apache.gravitino.MetadataObject;
import org.apache.gravitino.authorization.AccessControlDispatcher;
import org.apache.gravitino.authorization.Group;
-import org.apache.gravitino.authorization.GroupChange;
import org.apache.gravitino.authorization.Owner;
import org.apache.gravitino.authorization.PagedResult;
import org.apache.gravitino.authorization.Privilege;
import org.apache.gravitino.authorization.Role;
import org.apache.gravitino.authorization.SecurableObject;
import org.apache.gravitino.authorization.User;
-import org.apache.gravitino.authorization.UserChange;
import org.apache.gravitino.bulk.BulkItemResult;
import org.apache.gravitino.bulk.GroupAdd;
import org.apache.gravitino.bulk.UserAdd;
@@ -52,12 +50,6 @@ import org.apache.gravitino.listener.api.event.AddGroupPreEvent;
import org.apache.gravitino.listener.api.event.AddUserEvent;
import org.apache.gravitino.listener.api.event.AddUserFailureEvent;
import org.apache.gravitino.listener.api.event.AddUserPreEvent;
-import org.apache.gravitino.listener.api.event.AlterGroupEvent;
-import org.apache.gravitino.listener.api.event.AlterGroupFailureEvent;
-import org.apache.gravitino.listener.api.event.AlterGroupPreEvent;
-import org.apache.gravitino.listener.api.event.AlterUserEvent;
-import org.apache.gravitino.listener.api.event.AlterUserFailureEvent;
-import org.apache.gravitino.listener.api.event.AlterUserPreEvent;
import org.apache.gravitino.listener.api.event.CountGroupsEvent;
import org.apache.gravitino.listener.api.event.CountGroupsFailureEvent;
import org.apache.gravitino.listener.api.event.CountGroupsPreEvent;
@@ -70,24 +62,12 @@ import org.apache.gravitino.listener.api.event.CreateRolePreEvent;
import org.apache.gravitino.listener.api.event.DeleteRoleEvent;
import org.apache.gravitino.listener.api.event.DeleteRoleFailureEvent;
import org.apache.gravitino.listener.api.event.DeleteRolePreEvent;
-import org.apache.gravitino.listener.api.event.GetGroupByExternalIdEvent;
-import org.apache.gravitino.listener.api.event.GetGroupByExternalIdFailureEvent;
-import org.apache.gravitino.listener.api.event.GetGroupByExternalIdPreEvent;
-import org.apache.gravitino.listener.api.event.GetGroupByIdEvent;
-import org.apache.gravitino.listener.api.event.GetGroupByIdFailureEvent;
-import org.apache.gravitino.listener.api.event.GetGroupByIdPreEvent;
import org.apache.gravitino.listener.api.event.GetGroupEvent;
import org.apache.gravitino.listener.api.event.GetGroupFailureEvent;
import org.apache.gravitino.listener.api.event.GetGroupPreEvent;
import org.apache.gravitino.listener.api.event.GetRoleEvent;
import org.apache.gravitino.listener.api.event.GetRoleFailureEvent;
import org.apache.gravitino.listener.api.event.GetRolePreEvent;
-import org.apache.gravitino.listener.api.event.GetUserByExternalIdEvent;
-import org.apache.gravitino.listener.api.event.GetUserByExternalIdFailureEvent;
-import org.apache.gravitino.listener.api.event.GetUserByExternalIdPreEvent;
-import org.apache.gravitino.listener.api.event.GetUserByIdEvent;
-import org.apache.gravitino.listener.api.event.GetUserByIdFailureEvent;
-import org.apache.gravitino.listener.api.event.GetUserByIdPreEvent;
import org.apache.gravitino.listener.api.event.GetUserEvent;
import org.apache.gravitino.listener.api.event.GetUserFailureEvent;
import org.apache.gravitino.listener.api.event.GetUserPreEvent;
@@ -124,21 +104,9 @@ import org.apache.gravitino.listener.api.event.ListUsersPreEvent;
import org.apache.gravitino.listener.api.event.OverridePrivilegesEvent;
import org.apache.gravitino.listener.api.event.OverridePrivilegesFailureEvent;
import org.apache.gravitino.listener.api.event.OverridePrivilegesPreEvent;
-import org.apache.gravitino.listener.api.event.RemoveGroupByExternalIdEvent;
-import org.apache.gravitino.listener.api.event.RemoveGroupByExternalIdFailureEvent;
-import org.apache.gravitino.listener.api.event.RemoveGroupByExternalIdPreEvent;
-import org.apache.gravitino.listener.api.event.RemoveGroupByIdEvent;
-import org.apache.gravitino.listener.api.event.RemoveGroupByIdFailureEvent;
-import org.apache.gravitino.listener.api.event.RemoveGroupByIdPreEvent;
import org.apache.gravitino.listener.api.event.RemoveGroupEvent;
import org.apache.gravitino.listener.api.event.RemoveGroupFailureEvent;
import org.apache.gravitino.listener.api.event.RemoveGroupPreEvent;
-import org.apache.gravitino.listener.api.event.RemoveUserByExternalIdEvent;
-import org.apache.gravitino.listener.api.event.RemoveUserByExternalIdFailureEvent;
-import org.apache.gravitino.listener.api.event.RemoveUserByExternalIdPreEvent;
-import org.apache.gravitino.listener.api.event.RemoveUserByIdEvent;
-import org.apache.gravitino.listener.api.event.RemoveUserByIdFailureEvent;
-import org.apache.gravitino.listener.api.event.RemoveUserByIdPreEvent;
import org.apache.gravitino.listener.api.event.RemoveUserEvent;
import org.apache.gravitino.listener.api.event.RemoveUserFailureEvent;
import org.apache.gravitino.listener.api.event.RemoveUserPreEvent;
@@ -195,24 +163,6 @@ public class AccessControlEventDispatcher implements AccessControlDispatcher {
}
}
- /** {@inheritDoc} */
- @Override
- public User addUser(String metalake, String user, String externalId, boolean enabled)
- throws UserAlreadyExistsException, NoSuchMetalakeException {
- String initiator = PrincipalUtils.getCurrentUserName();
-
- eventBus.dispatchEvent(new AddUserPreEvent(initiator, metalake, user));
- try {
- User userObject = dispatcher.addUser(metalake, user, externalId, enabled);
- eventBus.dispatchEvent(new AddUserEvent(initiator, metalake, new UserInfo(userObject)));
-
- return userObject;
- } catch (Exception e) {
- eventBus.dispatchEvent(new AddUserFailureEvent(initiator, metalake, e, user));
- throw e;
- }
- }
-
/** {@inheritDoc} */
@Override
public List<BulkItemResult<User>> addUsers(String metalake, List<UserAdd> users)
@@ -270,26 +220,6 @@ public class AccessControlEventDispatcher implements AccessControlDispatcher {
}
}
- /** {@inheritDoc} */
- @Override
- public boolean removeUserByExternalId(String metalake, String externalId)
- throws NoSuchMetalakeException {
- String initiator = PrincipalUtils.getCurrentUserName();
-
- eventBus.dispatchEvent(new RemoveUserByExternalIdPreEvent(initiator, metalake, externalId));
- try {
- boolean isExists = dispatcher.removeUserByExternalId(metalake, externalId);
- eventBus.dispatchEvent(
- new RemoveUserByExternalIdEvent(initiator, metalake, externalId, isExists));
-
- return isExists;
- } catch (Exception e) {
- eventBus.dispatchEvent(
- new RemoveUserByExternalIdFailureEvent(initiator, metalake, e, externalId));
- throw e;
- }
- }
-
/** {@inheritDoc} */
@Override
public User getUser(String metalake, String user)
@@ -308,80 +238,6 @@ public class AccessControlEventDispatcher implements AccessControlDispatcher {
}
}
- /** {@inheritDoc} */
- @Override
- public User getUserByExternalId(String metalake, String externalId)
- throws NoSuchUserException, NoSuchMetalakeException {
- String initiator = PrincipalUtils.getCurrentUserName();
-
- eventBus.dispatchEvent(new GetUserByExternalIdPreEvent(initiator, metalake, externalId));
- try {
- User userObject = dispatcher.getUserByExternalId(metalake, externalId);
- eventBus.dispatchEvent(
- new GetUserByExternalIdEvent(initiator, metalake, new UserInfo(userObject)));
-
- return userObject;
- } catch (Exception e) {
- eventBus.dispatchEvent(
- new GetUserByExternalIdFailureEvent(initiator, metalake, e, externalId));
- throw e;
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public User getUserById(String metalake, long userId)
- throws NoSuchUserException, NoSuchMetalakeException {
- String initiator = PrincipalUtils.getCurrentUserName();
-
- eventBus.dispatchEvent(new GetUserByIdPreEvent(initiator, metalake, userId));
- try {
- User userObject = dispatcher.getUserById(metalake, userId);
- eventBus.dispatchEvent(new GetUserByIdEvent(initiator, metalake, new UserInfo(userObject)));
-
- return userObject;
- } catch (Exception e) {
- eventBus.dispatchEvent(new GetUserByIdFailureEvent(initiator, metalake, e, userId));
- throw e;
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean removeUserById(String metalake, long userId) throws NoSuchMetalakeException {
- String initiator = PrincipalUtils.getCurrentUserName();
-
- eventBus.dispatchEvent(new RemoveUserByIdPreEvent(initiator, metalake, userId));
- try {
- boolean isExists = dispatcher.removeUserById(metalake, userId);
- eventBus.dispatchEvent(new RemoveUserByIdEvent(initiator, metalake, userId, isExists));
-
- return isExists;
- } catch (Exception e) {
- eventBus.dispatchEvent(new RemoveUserByIdFailureEvent(initiator, metalake, e, userId));
- throw e;
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public User alterUserById(String metalake, long userId, UserChange... changes)
- throws NoSuchUserException, NoSuchMetalakeException {
- String initiator = PrincipalUtils.getCurrentUserName();
-
- eventBus.dispatchEvent(new AlterUserPreEvent(initiator, metalake, userId, changes));
- try {
- User userObject = dispatcher.alterUserById(metalake, userId, changes);
- eventBus.dispatchEvent(
- new AlterUserEvent(initiator, metalake, changes, new UserInfo(userObject)));
-
- return userObject;
- } catch (Exception e) {
- eventBus.dispatchEvent(new AlterUserFailureEvent(initiator, metalake, userId, changes, e));
- throw e;
- }
- }
-
/** {@inheritDoc} */
@Override
public User[] listUsers(String metalake) throws NoSuchMetalakeException {
@@ -473,24 +329,6 @@ public class AccessControlEventDispatcher implements AccessControlDispatcher {
}
}
- /** {@inheritDoc} */
- @Override
- public Group addGroup(String metalake, String group, String externalId)
- throws GroupAlreadyExistsException, NoSuchMetalakeException {
- String initiator = PrincipalUtils.getCurrentUserName();
-
- eventBus.dispatchEvent(new AddGroupPreEvent(initiator, metalake, group));
- try {
- Group groupObject = dispatcher.addGroup(metalake, group, externalId);
- eventBus.dispatchEvent(new AddGroupEvent(initiator, metalake, new GroupInfo(groupObject)));
-
- return groupObject;
- } catch (Exception e) {
- eventBus.dispatchEvent(new AddGroupFailureEvent(initiator, metalake, e, group));
- throw e;
- }
- }
-
/** {@inheritDoc} */
@Override
public List<BulkItemResult<Group>> addGroups(String metalake, List<GroupAdd> groups)
@@ -551,26 +389,6 @@ public class AccessControlEventDispatcher implements AccessControlDispatcher {
}
}
- /** {@inheritDoc} */
- @Override
- public boolean removeGroupByExternalId(String metalake, String externalId)
- throws NoSuchMetalakeException {
- String initiator = PrincipalUtils.getCurrentUserName();
-
- eventBus.dispatchEvent(new RemoveGroupByExternalIdPreEvent(initiator, metalake, externalId));
- try {
- boolean isExists = dispatcher.removeGroupByExternalId(metalake, externalId);
- eventBus.dispatchEvent(
- new RemoveGroupByExternalIdEvent(initiator, metalake, externalId, isExists));
-
- return isExists;
- } catch (Exception e) {
- eventBus.dispatchEvent(
- new RemoveGroupByExternalIdFailureEvent(initiator, metalake, e, externalId));
- throw e;
- }
- }
-
/** {@inheritDoc} */
@Override
public Group getGroup(String metalake, String group)
@@ -589,81 +407,6 @@ public class AccessControlEventDispatcher implements AccessControlDispatcher {
}
}
- /** {@inheritDoc} */
- @Override
- public Group getGroupByExternalId(String metalake, String externalId)
- throws NoSuchGroupException, NoSuchMetalakeException {
- String initiator = PrincipalUtils.getCurrentUserName();
-
- eventBus.dispatchEvent(new GetGroupByExternalIdPreEvent(initiator, metalake, externalId));
- try {
- Group groupObject = dispatcher.getGroupByExternalId(metalake, externalId);
- eventBus.dispatchEvent(
- new GetGroupByExternalIdEvent(initiator, metalake, new GroupInfo(groupObject)));
-
- return groupObject;
- } catch (Exception e) {
- eventBus.dispatchEvent(
- new GetGroupByExternalIdFailureEvent(initiator, metalake, e, externalId));
- throw e;
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public Group getGroupById(String metalake, long groupId)
- throws NoSuchGroupException, NoSuchMetalakeException {
- String initiator = PrincipalUtils.getCurrentUserName();
-
- eventBus.dispatchEvent(new GetGroupByIdPreEvent(initiator, metalake, groupId));
- try {
- Group groupObject = dispatcher.getGroupById(metalake, groupId);
- eventBus.dispatchEvent(
- new GetGroupByIdEvent(initiator, metalake, new GroupInfo(groupObject)));
-
- return groupObject;
- } catch (Exception e) {
- eventBus.dispatchEvent(new GetGroupByIdFailureEvent(initiator, metalake, e, groupId));
- throw e;
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean removeGroupById(String metalake, long groupId) throws NoSuchMetalakeException {
- String initiator = PrincipalUtils.getCurrentUserName();
-
- eventBus.dispatchEvent(new RemoveGroupByIdPreEvent(initiator, metalake, groupId));
- try {
- boolean isExists = dispatcher.removeGroupById(metalake, groupId);
- eventBus.dispatchEvent(new RemoveGroupByIdEvent(initiator, metalake, groupId, isExists));
-
- return isExists;
- } catch (Exception e) {
- eventBus.dispatchEvent(new RemoveGroupByIdFailureEvent(initiator, metalake, e, groupId));
- throw e;
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public Group alterGroupById(String metalake, long groupId, GroupChange... changes)
- throws NoSuchGroupException, NoSuchMetalakeException {
- String initiator = PrincipalUtils.getCurrentUserName();
-
- eventBus.dispatchEvent(new AlterGroupPreEvent(initiator, metalake, groupId, changes));
- try {
- Group groupObject = dispatcher.alterGroupById(metalake, groupId, changes);
- eventBus.dispatchEvent(
- new AlterGroupEvent(initiator, metalake, changes, new GroupInfo(groupObject)));
-
- return groupObject;
- } catch (Exception e) {
- eventBus.dispatchEvent(new AlterGroupFailureEvent(initiator, metalake, groupId, changes, e));
- throw e;
- }
- }
-
/** {@inheritDoc} */
@Override
public Group[] listGroups(String metalake) {
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/AlterGroupEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/AlterGroupEvent.java
deleted file mode 100644
index 7e9d4922e6..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/AlterGroupEvent.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import javax.annotation.Nullable;
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-import org.apache.gravitino.authorization.GroupChange;
-import org.apache.gravitino.listener.api.info.GroupInfo;
-
-/** Represents an event triggered upon the successful alteration of a group. */
-@DeveloperApi
-public final class AlterGroupEvent extends GroupEvent {
- private final GroupInfo updatedGroupInfo;
- private final GroupChange[] groupChanges;
-
- /**
- * Creates a new {@link AlterGroupEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param groupChanges The changes applied to the group.
- * @param updatedGroupInfo The post-alteration state of the group.
- */
- public AlterGroupEvent(
- String initiator, String metalake, GroupChange[] groupChanges, GroupInfo updatedGroupInfo) {
- super(initiator, AuthorizationUtils.ofGroupId(metalake, updatedGroupInfo.id()));
- this.groupChanges = groupChanges != null ? groupChanges.clone() : null;
- this.updatedGroupInfo = updatedGroupInfo;
- }
-
- /**
- * Returns the final state of the group after successful alteration.
- *
- * @return The updated group information.
- */
- public GroupInfo updatedGroupInfo() {
- return updatedGroupInfo;
- }
-
- /**
- * Returns the specific changes that were made to the group.
- *
- * @return An array of {@link GroupChange}, or null.
- */
- @Nullable
- public GroupChange[] changes() {
- return groupChanges;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.ALTER_GROUP;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/AlterGroupFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/AlterGroupFailureEvent.java
deleted file mode 100644
index 790bfc8746..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/AlterGroupFailureEvent.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-import org.apache.gravitino.authorization.GroupChange;
-
-/** Represents an event triggered when an attempt to alter a group fails due to an exception. */
-@DeveloperApi
-public class AlterGroupFailureEvent extends GroupFailureEvent {
- private final long groupId;
- private final GroupChange[] changes;
-
- /**
- * Creates a new {@link AlterGroupFailureEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param groupId The Gravitino-assigned id of the group.
- * @param changes The changes attempted to be made to the group.
- * @param exception The exception that caused the failure.
- */
- public AlterGroupFailureEvent(
- String initiator, String metalake, long groupId, GroupChange[] changes, Exception exception) {
- super(initiator, AuthorizationUtils.ofGroupId(metalake, groupId), exception);
- this.groupId = groupId;
- this.changes = changes;
- }
-
- /**
- * Returns the Gravitino-assigned id of the group.
- *
- * @return The group id.
- */
- public long groupId() {
- return groupId;
- }
-
- /**
- * Returns the changes attempted to be made to the group.
- *
- * @return An array of {@link GroupChange}.
- */
- public GroupChange[] changes() {
- return changes;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.ALTER_GROUP;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/AlterGroupPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/AlterGroupPreEvent.java
deleted file mode 100644
index 322c7422a6..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/AlterGroupPreEvent.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-import org.apache.gravitino.authorization.GroupChange;
-
-/** Represents an event triggered before altering a group by Gravitino-assigned id. */
-@DeveloperApi
-public class AlterGroupPreEvent extends GroupPreEvent {
- private final long groupId;
- private final GroupChange[] changes;
-
- /**
- * Creates a new {@link AlterGroupPreEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param groupId The Gravitino-assigned id of the group.
- * @param changes The changes being applied to the group.
- */
- public AlterGroupPreEvent(
- String initiator, String metalake, long groupId, GroupChange[] changes) {
- super(initiator, AuthorizationUtils.ofGroupId(metalake, groupId));
- this.groupId = groupId;
- this.changes = changes;
- }
-
- /**
- * Returns the Gravitino-assigned id of the group being altered.
- *
- * @return The group id.
- */
- public long groupId() {
- return groupId;
- }
-
- /**
- * Returns the changes being applied to the group.
- *
- * @return An array of {@link GroupChange}.
- */
- public GroupChange[] changes() {
- return changes;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.ALTER_GROUP;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/AlterUserEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/AlterUserEvent.java
deleted file mode 100644
index bfaa83d612..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/AlterUserEvent.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import javax.annotation.Nullable;
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-import org.apache.gravitino.authorization.UserChange;
-import org.apache.gravitino.listener.api.info.UserInfo;
-
-/** Represents an event triggered upon the successful alteration of a user. */
-@DeveloperApi
-public final class AlterUserEvent extends UserEvent {
- private final UserInfo updatedUserInfo;
- private final UserChange[] userChanges;
-
- /**
- * Creates a new {@link AlterUserEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param userChanges The changes applied to the user.
- * @param updatedUserInfo The post-alteration state of the user.
- */
- public AlterUserEvent(
- String initiator, String metalake, UserChange[] userChanges, UserInfo updatedUserInfo) {
- super(initiator, AuthorizationUtils.ofUserId(metalake, updatedUserInfo.id()));
- this.userChanges = userChanges != null ? userChanges.clone() : null;
- this.updatedUserInfo = updatedUserInfo;
- }
-
- /**
- * Returns the final state of the user after successful alteration.
- *
- * @return The updated user information.
- */
- public UserInfo updatedUserInfo() {
- return updatedUserInfo;
- }
-
- /**
- * Returns the specific changes that were made to the user.
- *
- * @return An array of {@link UserChange}, or null.
- */
- @Nullable
- public UserChange[] changes() {
- return userChanges;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.ALTER_USER;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/AlterUserFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/AlterUserFailureEvent.java
deleted file mode 100644
index a7ff8cc382..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/AlterUserFailureEvent.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-import org.apache.gravitino.authorization.UserChange;
-
-/** Represents an event triggered when an attempt to alter a user fails due to an exception. */
-@DeveloperApi
-public class AlterUserFailureEvent extends UserFailureEvent {
- private final long userId;
- private final UserChange[] changes;
-
- /**
- * Creates a new {@link AlterUserFailureEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param userId The Gravitino-assigned id of the user.
- * @param changes The changes attempted to be made to the user.
- * @param exception The exception that caused the failure.
- */
- public AlterUserFailureEvent(
- String initiator, String metalake, long userId, UserChange[] changes, Exception exception) {
- super(initiator, AuthorizationUtils.ofUserId(metalake, userId), exception);
- this.userId = userId;
- this.changes = changes;
- }
-
- /**
- * Returns the Gravitino-assigned id of the user.
- *
- * @return The user id.
- */
- public long userId() {
- return userId;
- }
-
- /**
- * Returns the changes attempted to be made to the user.
- *
- * @return An array of {@link UserChange}.
- */
- public UserChange[] changes() {
- return changes;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.ALTER_USER;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/AlterUserPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/AlterUserPreEvent.java
deleted file mode 100644
index 17cc51a2d2..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/AlterUserPreEvent.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-import org.apache.gravitino.authorization.UserChange;
-
-/** Represents an event triggered before altering a user by Gravitino-assigned id. */
-@DeveloperApi
-public class AlterUserPreEvent extends UserPreEvent {
- private final long userId;
- private final UserChange[] changes;
-
- /**
- * Creates a new {@link AlterUserPreEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param userId The Gravitino-assigned id of the user.
- * @param changes The changes being applied to the user.
- */
- public AlterUserPreEvent(String initiator, String metalake, long userId, UserChange[] changes) {
- super(initiator, AuthorizationUtils.ofUserId(metalake, userId));
- this.userId = userId;
- this.changes = changes;
- }
-
- /**
- * Returns the Gravitino-assigned id of the user being altered.
- *
- * @return The user id.
- */
- public long userId() {
- return userId;
- }
-
- /**
- * Returns the changes being applied to the user.
- *
- * @return An array of {@link UserChange}.
- */
- public UserChange[] changes() {
- return changes;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.ALTER_USER;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupByExternalIdEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupByExternalIdEvent.java
deleted file mode 100644
index 7a54d57207..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupByExternalIdEvent.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-import org.apache.gravitino.listener.api.info.GroupInfo;
-
-/** Represents an event triggered after successfully retrieving a group by external id. */
-@DeveloperApi
-public class GetGroupByExternalIdEvent extends GroupEvent {
- private final GroupInfo loadedGroupInfo;
-
- public GetGroupByExternalIdEvent(String initiator, String metalake, GroupInfo loadedGroupInfo) {
- super(
- initiator,
- AuthorizationUtils.ofGroupExternalId(
- metalake,
- loadedGroupInfo
- .externalId()
- .orElseThrow(
- () ->
- new IllegalStateException(
- "Group external id is required for GetGroupByExternalIdEvent"))));
- this.loadedGroupInfo = loadedGroupInfo;
- }
-
- /** Returns the retrieved group information. */
- public GroupInfo loadedGroupInfo() {
- return loadedGroupInfo;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.GET_GROUP_BY_EXTERNAL_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupByExternalIdFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupByExternalIdFailureEvent.java
deleted file mode 100644
index 38764265d9..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupByExternalIdFailureEvent.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered when retrieving a group by external id fails. */
-@DeveloperApi
-public class GetGroupByExternalIdFailureEvent extends GroupFailureEvent {
- private final String externalId;
-
- public GetGroupByExternalIdFailureEvent(
- String initiator, String metalake, Exception exception, String externalId) {
- super(initiator, AuthorizationUtils.ofGroupExternalId(metalake, externalId), exception);
- this.externalId = externalId;
- }
-
- /** Returns the external identifier of the group. */
- public String externalId() {
- return externalId;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.GET_GROUP_BY_EXTERNAL_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupByExternalIdPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupByExternalIdPreEvent.java
deleted file mode 100644
index ba93d71f39..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupByExternalIdPreEvent.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered before retrieving a group by external id. */
-@DeveloperApi
-public class GetGroupByExternalIdPreEvent extends GroupPreEvent {
- private final String externalId;
-
- public GetGroupByExternalIdPreEvent(String initiator, String metalake, String externalId) {
- super(initiator, AuthorizationUtils.ofGroupExternalId(metalake, externalId));
- this.externalId = externalId;
- }
-
- /** Returns the external identifier of the group being retrieved. */
- public String externalId() {
- return externalId;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.GET_GROUP_BY_EXTERNAL_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupByIdEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupByIdEvent.java
deleted file mode 100644
index 4e7087c04b..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupByIdEvent.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-import org.apache.gravitino.listener.api.info.GroupInfo;
-
-/** Represents an event triggered after successfully retrieving a group by Gravitino-assigned id. */
-@DeveloperApi
-public class GetGroupByIdEvent extends GroupEvent {
- private final GroupInfo loadedGroupInfo;
-
- /**
- * Creates a new {@link GetGroupByIdEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param loadedGroupInfo The retrieved group information.
- */
- public GetGroupByIdEvent(String initiator, String metalake, GroupInfo loadedGroupInfo) {
- super(initiator, AuthorizationUtils.ofGroupId(metalake, loadedGroupInfo.id()));
- this.loadedGroupInfo = loadedGroupInfo;
- }
-
- /**
- * Returns the retrieved group information.
- *
- * @return The group information.
- */
- public GroupInfo loadedGroupInfo() {
- return loadedGroupInfo;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.GET_GROUP_BY_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupByIdFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupByIdFailureEvent.java
deleted file mode 100644
index 35838405d9..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupByIdFailureEvent.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered when retrieving a group by Gravitino-assigned id fails. */
-@DeveloperApi
-public class GetGroupByIdFailureEvent extends GroupFailureEvent {
- private final long groupId;
-
- /**
- * Creates a new {@link GetGroupByIdFailureEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param exception The exception that caused the failure.
- * @param groupId The Gravitino-assigned id of the group.
- */
- public GetGroupByIdFailureEvent(
- String initiator, String metalake, Exception exception, long groupId) {
- super(initiator, AuthorizationUtils.ofGroupId(metalake, groupId), exception);
- this.groupId = groupId;
- }
-
- /**
- * Returns the Gravitino-assigned id of the group.
- *
- * @return The group id.
- */
- public long groupId() {
- return groupId;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.GET_GROUP_BY_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupByIdPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupByIdPreEvent.java
deleted file mode 100644
index b4c967900a..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupByIdPreEvent.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered before retrieving a group by Gravitino-assigned id. */
-@DeveloperApi
-public class GetGroupByIdPreEvent extends GroupPreEvent {
- private final long groupId;
-
- /**
- * Creates a new {@link GetGroupByIdPreEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param groupId The Gravitino-assigned id of the group.
- */
- public GetGroupByIdPreEvent(String initiator, String metalake, long groupId) {
- super(initiator, AuthorizationUtils.ofGroupId(metalake, groupId));
- this.groupId = groupId;
- }
-
- /**
- * Returns the Gravitino-assigned id of the group being retrieved.
- *
- * @return The group id.
- */
- public long groupId() {
- return groupId;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.GET_GROUP_BY_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetUserByExternalIdEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetUserByExternalIdEvent.java
deleted file mode 100644
index aa3b48fdd6..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/GetUserByExternalIdEvent.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-import org.apache.gravitino.listener.api.info.UserInfo;
-
-/** Represents an event triggered after successfully retrieving a user by external id. */
-@DeveloperApi
-public class GetUserByExternalIdEvent extends UserEvent {
- private final UserInfo loadedUserInfo;
-
- /**
- * Creates a new {@link GetUserByExternalIdEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param loadedUserInfo The retrieved user information.
- */
- public GetUserByExternalIdEvent(String initiator, String metalake, UserInfo loadedUserInfo) {
- super(
- initiator,
- AuthorizationUtils.ofUserExternalId(
- metalake,
- loadedUserInfo
- .externalId()
- .orElseThrow(
- () ->
- new IllegalStateException(
- "User external id is required for GetUserByExternalIdEvent"))));
- this.loadedUserInfo = loadedUserInfo;
- }
-
- /**
- * Returns the retrieved user information.
- *
- * @return The user information.
- */
- public UserInfo loadedUserInfo() {
- return loadedUserInfo;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.GET_USER_BY_EXTERNAL_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetUserByExternalIdFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetUserByExternalIdFailureEvent.java
deleted file mode 100644
index 9d374609e1..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/GetUserByExternalIdFailureEvent.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered when retrieving a user by external id fails. */
-@DeveloperApi
-public class GetUserByExternalIdFailureEvent extends UserFailureEvent {
- private final String externalId;
-
- /**
- * Creates a new {@link GetUserByExternalIdFailureEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param exception The exception that caused the failure.
- * @param externalId The external identifier of the user.
- */
- public GetUserByExternalIdFailureEvent(
- String initiator, String metalake, Exception exception, String externalId) {
- super(initiator, AuthorizationUtils.ofUserExternalId(metalake, externalId), exception);
- this.externalId = externalId;
- }
-
- /**
- * Returns the external identifier of the user.
- *
- * @return The external identifier.
- */
- public String externalId() {
- return externalId;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.GET_USER_BY_EXTERNAL_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetUserByExternalIdPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetUserByExternalIdPreEvent.java
deleted file mode 100644
index 73f75d71ee..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/GetUserByExternalIdPreEvent.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered before retrieving a user by external id. */
-@DeveloperApi
-public class GetUserByExternalIdPreEvent extends UserPreEvent {
- private final String externalId;
-
- /**
- * Creates a new {@link GetUserByExternalIdPreEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param externalId The external identifier of the user.
- */
- public GetUserByExternalIdPreEvent(String initiator, String metalake, String externalId) {
- super(initiator, AuthorizationUtils.ofUserExternalId(metalake, externalId));
- this.externalId = externalId;
- }
-
- /**
- * Returns the external identifier of the user being retrieved.
- *
- * @return The external identifier.
- */
- public String externalId() {
- return externalId;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.GET_USER_BY_EXTERNAL_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetUserByIdEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetUserByIdEvent.java
deleted file mode 100644
index 6f3f8e8b84..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/GetUserByIdEvent.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-import org.apache.gravitino.listener.api.info.UserInfo;
-
-/** Represents an event triggered after successfully retrieving a user by Gravitino-assigned id. */
-@DeveloperApi
-public class GetUserByIdEvent extends UserEvent {
- private final UserInfo loadedUserInfo;
-
- /**
- * Creates a new {@link GetUserByIdEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param loadedUserInfo The retrieved user information.
- */
- public GetUserByIdEvent(String initiator, String metalake, UserInfo loadedUserInfo) {
- super(initiator, AuthorizationUtils.ofUserId(metalake, loadedUserInfo.id()));
- this.loadedUserInfo = loadedUserInfo;
- }
-
- /**
- * Returns the retrieved user information.
- *
- * @return The user information.
- */
- public UserInfo loadedUserInfo() {
- return loadedUserInfo;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.GET_USER_BY_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetUserByIdFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetUserByIdFailureEvent.java
deleted file mode 100644
index 5080b61a46..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/GetUserByIdFailureEvent.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered when retrieving a user by Gravitino-assigned id fails. */
-@DeveloperApi
-public class GetUserByIdFailureEvent extends UserFailureEvent {
- private final long userId;
-
- /**
- * Creates a new {@link GetUserByIdFailureEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param exception The exception that caused the failure.
- * @param userId The Gravitino-assigned id of the user.
- */
- public GetUserByIdFailureEvent(
- String initiator, String metalake, Exception exception, long userId) {
- super(initiator, AuthorizationUtils.ofUserId(metalake, userId), exception);
- this.userId = userId;
- }
-
- /**
- * Returns the Gravitino-assigned id of the user.
- *
- * @return The user id.
- */
- public long userId() {
- return userId;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.GET_USER_BY_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetUserByIdPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetUserByIdPreEvent.java
deleted file mode 100644
index dc19ec144b..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/GetUserByIdPreEvent.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered before retrieving a user by Gravitino-assigned id. */
-@DeveloperApi
-public class GetUserByIdPreEvent extends UserPreEvent {
- private final long userId;
-
- /**
- * Creates a new {@link GetUserByIdPreEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param userId The Gravitino-assigned id of the user.
- */
- public GetUserByIdPreEvent(String initiator, String metalake, long userId) {
- super(initiator, AuthorizationUtils.ofUserId(metalake, userId));
- this.userId = userId;
- }
-
- /**
- * Returns the Gravitino-assigned id of the user being retrieved.
- *
- * @return The user id.
- */
- public long userId() {
- return userId;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.GET_USER_BY_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupByExternalIdEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupByExternalIdEvent.java
deleted file mode 100644
index 57fb82b49a..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupByExternalIdEvent.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered after removing a group by external id. */
-@DeveloperApi
-public class RemoveGroupByExternalIdEvent extends GroupEvent {
- private final String externalId;
- private final boolean isExists;
-
- public RemoveGroupByExternalIdEvent(
- String initiator, String metalake, String externalId, boolean isExists) {
- super(initiator, AuthorizationUtils.ofGroupExternalId(metalake, externalId));
- this.externalId = externalId;
- this.isExists = isExists;
- }
-
- /** Returns the external identifier of the removed group. */
- public String externalId() {
- return externalId;
- }
-
- /** Returns whether the group existed and was removed. */
- public boolean isExists() {
- return isExists;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.REMOVE_GROUP_BY_EXTERNAL_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupByExternalIdFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupByExternalIdFailureEvent.java
deleted file mode 100644
index 5a13de0101..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupByExternalIdFailureEvent.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered when removing a group by external id fails. */
-@DeveloperApi
-public class RemoveGroupByExternalIdFailureEvent extends GroupFailureEvent {
- private final String externalId;
-
- public RemoveGroupByExternalIdFailureEvent(
- String initiator, String metalake, Exception exception, String externalId) {
- super(initiator, AuthorizationUtils.ofGroupExternalId(metalake, externalId), exception);
- this.externalId = externalId;
- }
-
- /** Returns the external identifier of the group. */
- public String externalId() {
- return externalId;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.REMOVE_GROUP_BY_EXTERNAL_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupByExternalIdPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupByExternalIdPreEvent.java
deleted file mode 100644
index b0c3f897ff..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupByExternalIdPreEvent.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered before removing a group by external id. */
-@DeveloperApi
-public class RemoveGroupByExternalIdPreEvent extends GroupPreEvent {
- private final String externalId;
-
- public RemoveGroupByExternalIdPreEvent(String initiator, String metalake, String externalId) {
- super(initiator, AuthorizationUtils.ofGroupExternalId(metalake, externalId));
- this.externalId = externalId;
- }
-
- /** Returns the external identifier of the group being removed. */
- public String externalId() {
- return externalId;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.REMOVE_GROUP_BY_EXTERNAL_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupByIdEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupByIdEvent.java
deleted file mode 100644
index cdb9e71477..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupByIdEvent.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered after removing a group by Gravitino-assigned id. */
-@DeveloperApi
-public class RemoveGroupByIdEvent extends GroupEvent {
- private final long groupId;
- private final boolean isExists;
-
- /**
- * Creates a new {@link RemoveGroupByIdEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param groupId The Gravitino-assigned id of the group.
- * @param isExists Whether the group existed and was removed.
- */
- public RemoveGroupByIdEvent(String initiator, String metalake, long groupId, boolean isExists) {
- super(initiator, AuthorizationUtils.ofGroupId(metalake, groupId));
- this.groupId = groupId;
- this.isExists = isExists;
- }
-
- /**
- * Returns the Gravitino-assigned id of the removed group.
- *
- * @return The group id.
- */
- public long groupId() {
- return groupId;
- }
-
- /**
- * Returns whether the group existed and was removed.
- *
- * @return {@code true} if the group was removed.
- */
- public boolean isExists() {
- return isExists;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.REMOVE_GROUP_BY_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupByIdFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupByIdFailureEvent.java
deleted file mode 100644
index d3d562bc27..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupByIdFailureEvent.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered when removing a group by Gravitino-assigned id fails. */
-@DeveloperApi
-public class RemoveGroupByIdFailureEvent extends GroupFailureEvent {
- private final long groupId;
-
- /**
- * Creates a new {@link RemoveGroupByIdFailureEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param exception The exception that caused the failure.
- * @param groupId The Gravitino-assigned id of the group.
- */
- public RemoveGroupByIdFailureEvent(
- String initiator, String metalake, Exception exception, long groupId) {
- super(initiator, AuthorizationUtils.ofGroupId(metalake, groupId), exception);
- this.groupId = groupId;
- }
-
- /**
- * Returns the Gravitino-assigned id of the group.
- *
- * @return The group id.
- */
- public long groupId() {
- return groupId;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.REMOVE_GROUP_BY_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupByIdPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupByIdPreEvent.java
deleted file mode 100644
index e689a23283..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupByIdPreEvent.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered before removing a group by Gravitino-assigned id. */
-@DeveloperApi
-public class RemoveGroupByIdPreEvent extends GroupPreEvent {
- private final long groupId;
-
- /**
- * Creates a new {@link RemoveGroupByIdPreEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param groupId The Gravitino-assigned id of the group.
- */
- public RemoveGroupByIdPreEvent(String initiator, String metalake, long groupId) {
- super(initiator, AuthorizationUtils.ofGroupId(metalake, groupId));
- this.groupId = groupId;
- }
-
- /**
- * Returns the Gravitino-assigned id of the group being removed.
- *
- * @return The group id.
- */
- public long groupId() {
- return groupId;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.REMOVE_GROUP_BY_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserByExternalIdEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserByExternalIdEvent.java
deleted file mode 100644
index 5bd7095615..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserByExternalIdEvent.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered after removing a user by external id. */
-@DeveloperApi
-public class RemoveUserByExternalIdEvent extends UserEvent {
- private final String externalId;
- private final boolean isExists;
-
- /**
- * Creates a new {@link RemoveUserByExternalIdEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param externalId The external identifier of the user.
- * @param isExists Whether the user existed and was removed.
- */
- public RemoveUserByExternalIdEvent(
- String initiator, String metalake, String externalId, boolean isExists) {
- super(initiator, AuthorizationUtils.ofUserExternalId(metalake, externalId));
- this.externalId = externalId;
- this.isExists = isExists;
- }
-
- /**
- * Returns the external identifier of the removed user.
- *
- * @return The external identifier.
- */
- public String externalId() {
- return externalId;
- }
-
- /**
- * Returns whether the user existed and was removed.
- *
- * @return {@code true} if the user was removed.
- */
- public boolean isExists() {
- return isExists;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.REMOVE_USER_BY_EXTERNAL_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserByExternalIdFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserByExternalIdFailureEvent.java
deleted file mode 100644
index 89f0fccdef..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserByExternalIdFailureEvent.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered when removing a user by external id fails. */
-@DeveloperApi
-public class RemoveUserByExternalIdFailureEvent extends UserFailureEvent {
- private final String externalId;
-
- /**
- * Creates a new {@link RemoveUserByExternalIdFailureEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param exception The exception that caused the failure.
- * @param externalId The external identifier of the user.
- */
- public RemoveUserByExternalIdFailureEvent(
- String initiator, String metalake, Exception exception, String externalId) {
- super(initiator, AuthorizationUtils.ofUserExternalId(metalake, externalId), exception);
- this.externalId = externalId;
- }
-
- /**
- * Returns the external identifier of the user.
- *
- * @return The external identifier.
- */
- public String externalId() {
- return externalId;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.REMOVE_USER_BY_EXTERNAL_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserByExternalIdPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserByExternalIdPreEvent.java
deleted file mode 100644
index 9d908df42b..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserByExternalIdPreEvent.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered before removing a user by external id. */
-@DeveloperApi
-public class RemoveUserByExternalIdPreEvent extends UserPreEvent {
- private final String externalId;
-
- /**
- * Creates a new {@link RemoveUserByExternalIdPreEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param externalId The external identifier of the user.
- */
- public RemoveUserByExternalIdPreEvent(String initiator, String metalake, String externalId) {
- super(initiator, AuthorizationUtils.ofUserExternalId(metalake, externalId));
- this.externalId = externalId;
- }
-
- /**
- * Returns the external identifier of the user being removed.
- *
- * @return The external identifier.
- */
- public String externalId() {
- return externalId;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.REMOVE_USER_BY_EXTERNAL_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserByIdEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserByIdEvent.java
deleted file mode 100644
index 404e63f904..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserByIdEvent.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered after removing a user by Gravitino-assigned id. */
-@DeveloperApi
-public class RemoveUserByIdEvent extends UserEvent {
- private final long userId;
- private final boolean isExists;
-
- /**
- * Creates a new {@link RemoveUserByIdEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param userId The Gravitino-assigned id of the user.
- * @param isExists Whether the user existed and was removed.
- */
- public RemoveUserByIdEvent(String initiator, String metalake, long userId, boolean isExists) {
- super(initiator, AuthorizationUtils.ofUserId(metalake, userId));
- this.userId = userId;
- this.isExists = isExists;
- }
-
- /**
- * Returns the Gravitino-assigned id of the removed user.
- *
- * @return The user id.
- */
- public long userId() {
- return userId;
- }
-
- /**
- * Returns whether the user existed and was removed.
- *
- * @return {@code true} if the user was removed.
- */
- public boolean isExists() {
- return isExists;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.REMOVE_USER_BY_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserByIdFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserByIdFailureEvent.java
deleted file mode 100644
index 5f86700c32..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserByIdFailureEvent.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered when removing a user by Gravitino-assigned id fails. */
-@DeveloperApi
-public class RemoveUserByIdFailureEvent extends UserFailureEvent {
- private final long userId;
-
- /**
- * Creates a new {@link RemoveUserByIdFailureEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param exception The exception that caused the failure.
- * @param userId The Gravitino-assigned id of the user.
- */
- public RemoveUserByIdFailureEvent(
- String initiator, String metalake, Exception exception, long userId) {
- super(initiator, AuthorizationUtils.ofUserId(metalake, userId), exception);
- this.userId = userId;
- }
-
- /**
- * Returns the Gravitino-assigned id of the user.
- *
- * @return The user id.
- */
- public long userId() {
- return userId;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.REMOVE_USER_BY_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserByIdPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserByIdPreEvent.java
deleted file mode 100644
index 4696e555d5..0000000000
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserByIdPreEvent.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.listener.api.event;
-
-import org.apache.gravitino.annotation.DeveloperApi;
-import org.apache.gravitino.authorization.AuthorizationUtils;
-
-/** Represents an event triggered before removing a user by Gravitino-assigned id. */
-@DeveloperApi
-public class RemoveUserByIdPreEvent extends UserPreEvent {
- private final long userId;
-
- /**
- * Creates a new {@link RemoveUserByIdPreEvent}.
- *
- * @param initiator The user who initiated the request.
- * @param metalake The metalake name.
- * @param userId The Gravitino-assigned id of the user.
- */
- public RemoveUserByIdPreEvent(String initiator, String metalake, long userId) {
- super(initiator, AuthorizationUtils.ofUserId(metalake, userId));
- this.userId = userId;
- }
-
- /**
- * Returns the Gravitino-assigned id of the user being removed.
- *
- * @return The user id.
- */
- public long userId() {
- return userId;
- }
-
- @Override
- public OperationType operationType() {
- return OperationType.REMOVE_USER_BY_ID;
- }
-}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/info/GroupInfo.java b/core/src/main/java/org/apache/gravitino/listener/api/info/GroupInfo.java
index 4f5f8c65ea..a462758545 100644
--- a/core/src/main/java/org/apache/gravitino/listener/api/info/GroupInfo.java
+++ b/core/src/main/java/org/apache/gravitino/listener/api/info/GroupInfo.java
@@ -21,7 +21,6 @@ package org.apache.gravitino.listener.api.info;
import com.google.common.base.Preconditions;
import java.util.List;
-import java.util.Optional;
import org.apache.gravitino.annotation.DeveloperApi;
import org.apache.gravitino.authorization.Group;
@@ -30,7 +29,6 @@ import org.apache.gravitino.authorization.Group;
public class GroupInfo {
private final Long id;
private final String name;
- private final Optional<String> externalId;
private List<String> roles;
/**
@@ -41,7 +39,6 @@ public class GroupInfo {
public GroupInfo(Group group) {
this.id = Preconditions.checkNotNull(group.id(), "group id");
this.name = group.name();
- this.externalId = Optional.ofNullable(group.externalId());
this.roles = group.roles();
}
@@ -63,15 +60,6 @@ public class GroupInfo {
return name;
}
- /**
- * Returns the external identifier of the group.
- *
- * @return The external identifier of the group, or empty if not set.
- */
- public Optional<String> externalId() {
- return externalId;
- }
-
/**
* Returns the roles of the group.
*
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/info/UserInfo.java b/core/src/main/java/org/apache/gravitino/listener/api/info/UserInfo.java
index c2a0614ad2..473b7faef0 100644
--- a/core/src/main/java/org/apache/gravitino/listener/api/info/UserInfo.java
+++ b/core/src/main/java/org/apache/gravitino/listener/api/info/UserInfo.java
@@ -21,7 +21,6 @@ package org.apache.gravitino.listener.api.info;
import com.google.common.base.Preconditions;
import java.util.List;
-import java.util.Optional;
import org.apache.gravitino.annotation.DeveloperApi;
import org.apache.gravitino.authorization.User;
@@ -30,8 +29,6 @@ import org.apache.gravitino.authorization.User;
public class UserInfo {
private final Long id;
private final String name;
- private final Optional<String> externalId;
- private final boolean enabled;
private List<String> roles;
/**
@@ -42,8 +39,6 @@ public class UserInfo {
public UserInfo(User user) {
this.id = Preconditions.checkNotNull(user.id(), "user id");
this.name = user.name();
- this.externalId = Optional.ofNullable(user.externalId());
- this.enabled = user.enabled();
this.roles = user.roles();
}
@@ -65,24 +60,6 @@ public class UserInfo {
return name;
}
- /**
- * Returns the external identifier of the user.
- *
- * @return the external identifier of the user, or empty if not set
- */
- public Optional<String> externalId() {
- return externalId;
- }
-
- /**
- * Returns whether the user is enabled.
- *
- * @return whether the user is enabled
- */
- public boolean enabled() {
- return enabled;
- }
-
/**
* Returns the roles of the user.
*
diff --git a/core/src/main/java/org/apache/gravitino/meta/GroupEntity.java b/core/src/main/java/org/apache/gravitino/meta/GroupEntity.java
index 6dcf7c2f11..b8cac5ba4c 100644
--- a/core/src/main/java/org/apache/gravitino/meta/GroupEntity.java
+++ b/core/src/main/java/org/apache/gravitino/meta/GroupEntity.java
@@ -39,9 +39,6 @@ public class GroupEntity implements Group, Entity, Auditable, HasIdentifier {
public static final Field NAME =
Field.required("name", String.class, "The name of the group entity.");
- public static final Field EXTERNAL_ID =
- Field.optional("external_id", String.class, "The external id of the group entity.");
-
public static final Field ROLE_NAMES =
Field.optional("role_names", List.class, "The role names of the group entity.");
@@ -53,7 +50,6 @@ public class GroupEntity implements Group, Entity, Auditable, HasIdentifier {
private Long id;
private String name;
- private String externalId;
private AuditInfo auditInfo;
private List<String> roleNames;
private List<Long> roleIds;
@@ -71,7 +67,6 @@ public class GroupEntity implements Group, Entity, Auditable, HasIdentifier {
Map<Field, Object> fields = Maps.newHashMap();
fields.put(ID, id);
fields.put(NAME, name);
- fields.put(EXTERNAL_ID, externalId);
fields.put(AUDIT_INFO, auditInfo);
fields.put(ROLE_NAMES, roleNames);
fields.put(ROLE_IDS, roleIds);
@@ -89,11 +84,6 @@ public class GroupEntity implements Group, Entity, Auditable, HasIdentifier {
return name;
}
- @Override
- public String externalId() {
- return externalId;
- }
-
/**
* Returns the unique id of the group.
*
@@ -172,14 +162,13 @@ public class GroupEntity implements Group, Entity, Auditable, HasIdentifier {
&& Objects.equals(name, that.name)
&& Objects.equals(namespace, that.namespace)
&& Objects.equals(auditInfo, that.auditInfo)
- && Objects.equals(externalId, that.externalId)
&& CollectionUtils.isEqualCollection(roleNames, that.roleNames)
&& CollectionUtils.isEqualCollection(roleIds, that.roleIds);
}
@Override
public int hashCode() {
- return Objects.hash(id, name, auditInfo, externalId, roleNames, roleIds);
+ return Objects.hash(id, name, auditInfo, roleNames, roleIds);
}
public static Builder builder() {
@@ -215,17 +204,6 @@ public class GroupEntity implements Group, Entity, Auditable, HasIdentifier {
return this;
}
- /**
- * Sets the external id of the group entity.
- *
- * @param externalId The external id of the group entity.
- * @return The builder instance.
- */
- public Builder withExternalId(String externalId) {
- groupEntity.externalId = externalId;
- return this;
- }
-
/**
* Sets the audit details of the group entity.
*
diff --git a/core/src/main/java/org/apache/gravitino/meta/UserEntity.java b/core/src/main/java/org/apache/gravitino/meta/UserEntity.java
index 579cbd2ee7..c9d7089f85 100644
--- a/core/src/main/java/org/apache/gravitino/meta/UserEntity.java
+++ b/core/src/main/java/org/apache/gravitino/meta/UserEntity.java
@@ -42,12 +42,6 @@ public class UserEntity implements User, Entity, Auditable, HasIdentifier {
public static final Field NAME =
Field.required("name", String.class, "The name of the user entity.");
- public static final Field EXTERNAL_ID =
- Field.optional("external_id", String.class, "The external id of the user entity.");
-
- public static final Field ENABLED =
- Field.required("enabled", Boolean.class, "Whether the user entity is enabled.");
-
public static final Field AUDIT_INFO =
Field.required("audit_info", AuditInfo.class, "The audit details of the user entity.");
@@ -59,8 +53,6 @@ public class UserEntity implements User, Entity, Auditable, HasIdentifier {
private Long id;
private String name;
- private String externalId;
- private boolean enabled = true;
private AuditInfo auditInfo;
private List<String> roleNames;
private List<Long> roleIds;
@@ -78,8 +70,6 @@ public class UserEntity implements User, Entity, Auditable, HasIdentifier {
Map<Field, Object> fields = Maps.newHashMap();
fields.put(ID, id);
fields.put(NAME, name);
- fields.put(EXTERNAL_ID, externalId);
- fields.put(ENABLED, enabled);
fields.put(AUDIT_INFO, auditInfo);
fields.put(ROLE_NAMES, roleNames);
fields.put(ROLE_IDS, roleIds);
@@ -97,16 +87,6 @@ public class UserEntity implements User, Entity, Auditable, HasIdentifier {
return name;
}
- @Override
- public String externalId() {
- return externalId;
- }
-
- @Override
- public boolean enabled() {
- return enabled;
- }
-
/**
* Returns the unique id of the user.
*
@@ -185,15 +165,13 @@ public class UserEntity implements User, Entity, Auditable, HasIdentifier {
&& Objects.equals(name, that.name)
&& Objects.equals(namespace, that.namespace)
&& Objects.equals(auditInfo, that.auditInfo)
- && Objects.equals(externalId, that.externalId)
- && enabled == that.enabled
&& CollectionUtils.isEqualCollection(roleNames, that.roleNames)
&& CollectionUtils.isEqualCollection(roleIds, that.roleIds);
}
@Override
public int hashCode() {
- return Objects.hash(id, name, auditInfo, externalId, enabled, roleNames, roleIds);
+ return Objects.hash(id, name, auditInfo, roleNames, roleIds);
}
public static Builder builder() {
@@ -229,28 +207,6 @@ public class UserEntity implements User, Entity, Auditable, HasIdentifier {
return this;
}
- /**
- * Sets the external id of the user entity.
- *
- * @param externalId The external id of the user entity.
- * @return The builder instance.
- */
- public Builder withExternalId(String externalId) {
- userEntity.externalId = externalId;
- return this;
- }
-
- /**
- * Sets whether the user entity is enabled.
- *
- * @param enabled Whether the user entity is enabled.
- * @return The builder instance.
- */
- public Builder withEnabled(boolean enabled) {
- userEntity.enabled = enabled;
- return this;
- }
-
/**
* Sets the audit details of the user entity.
*
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/JDBCBackend.java b/core/src/main/java/org/apache/gravitino/storage/relational/JDBCBackend.java
index 2555396448..e3165cd16d 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/JDBCBackend.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/JDBCBackend.java
@@ -48,7 +48,6 @@ import org.apache.gravitino.RelationUpdate;
import org.apache.gravitino.RelationalEntity;
import org.apache.gravitino.SupportsRelationOperations;
import org.apache.gravitino.UnsupportedEntityTypeException;
-import org.apache.gravitino.authorization.AuthorizationUtils;
import org.apache.gravitino.cache.BaseEntityCache;
import org.apache.gravitino.exceptions.NoSuchEntityException;
import org.apache.gravitino.meta.BaseMetalake;
@@ -288,76 +287,6 @@ public class JDBCBackend implements RelationalBackend, SupportsOrphanedRelationC
}
}
- @Override
- public <E extends Entity & HasIdentifier> E getByExternalId(
- NameIdentifier ident, Entity.EntityType entityType)
- throws NoSuchEntityException, IOException {
- switch (entityType) {
- case USER:
- return (E) UserMetaService.getInstance().getUserByExternalId(ident);
- case GROUP:
- return (E) GroupMetaService.getInstance().getGroupByExternalId(ident);
- default:
- throw new UnsupportedEntityTypeException(
- "Unsupported entity type: %s for get by external id operation", entityType);
- }
- }
-
- @Override
- public <E extends Entity & HasIdentifier> E updateByExternalId(
- NameIdentifier ident, Entity.EntityType entityType, Function<E, E> updater)
- throws NoSuchEntityException, IOException {
- switch (entityType) {
- case USER:
- return (E) UserMetaService.getInstance().updateUserByExternalId(ident, updater);
- default:
- throw new UnsupportedEntityTypeException(
- "Unsupported entity type: %s for update enabled by external id operation", entityType);
- }
- }
-
- @Override
- public <E extends Entity & HasIdentifier> E getById(
- NameIdentifier ident, Entity.EntityType entityType)
- throws NoSuchEntityException, IOException {
- switch (entityType) {
- case USER:
- AuthorizationUtils.checkUserId(ident);
- return (E)
- UserMetaService.getInstance()
- .getUserById(ident.namespace().level(0), Long.parseLong(ident.name()));
- case GROUP:
- AuthorizationUtils.checkGroupId(ident);
- return (E)
- GroupMetaService.getInstance()
- .getGroupById(ident.namespace().level(0), Long.parseLong(ident.name()));
- default:
- throw new UnsupportedEntityTypeException(
- "Unsupported entity type: %s for get by id operation", entityType);
- }
- }
-
- @Override
- public <E extends Entity & HasIdentifier> E updateById(
- NameIdentifier ident, Entity.EntityType entityType, Function<E, E> updater)
- throws NoSuchEntityException, IOException {
- switch (entityType) {
- case USER:
- AuthorizationUtils.checkUserId(ident);
- return (E)
- UserMetaService.getInstance()
- .updateUserById(ident.namespace().level(0), Long.parseLong(ident.name()), updater);
- case GROUP:
- AuthorizationUtils.checkGroupId(ident);
- return (E)
- GroupMetaService.getInstance()
- .updateGroupById(ident.namespace().level(0), Long.parseLong(ident.name()), updater);
- default:
- throw new UnsupportedEntityTypeException(
- "Unsupported entity type: %s for update by id operation", entityType);
- }
- }
-
@Override
public <E extends Entity & HasIdentifier> List<E> batchGet(
List<NameIdentifier> identifiers, Entity.EntityType entityType) {
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/RelationalBackend.java b/core/src/main/java/org/apache/gravitino/storage/relational/RelationalBackend.java
index ea5a8aa46c..664dd17ec9 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/RelationalBackend.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/RelationalBackend.java
@@ -116,64 +116,6 @@ public interface RelationalBackend extends Closeable, SupportsRelationOperations
<E extends Entity & HasIdentifier> E get(NameIdentifier ident, Entity.EntityType entityType)
throws IOException;
- /**
- * Retrieves the entity associated with the external id name identifier.
- *
- * @param <E> The type of the entity returned.
- * @param ident The external id name identifier.
- * @param entityType The type of the entity.
- * @return The entity associated with the external id name identifier.
- * @throws NoSuchEntityException If the entity does not exist.
- * @throws IOException If an I/O exception occurs during retrieval.
- */
- <E extends Entity & HasIdentifier> E getByExternalId(
- NameIdentifier ident, Entity.EntityType entityType) throws NoSuchEntityException, IOException;
-
- /**
- * Updates an entity by external id.
- *
- * @param <E> the type of the entity returned
- * @param ident the external id name identifier
- * @param entityType the type of the entity
- * @param updater a {@link Function} that takes the current entity instance and returns the
- * updated instance
- * @return the updated entity
- * @throws NoSuchEntityException if the entity does not exist
- * @throws IOException if the update operation fails
- */
- <E extends Entity & HasIdentifier> E updateByExternalId(
- NameIdentifier ident, Entity.EntityType entityType, Function<E, E> updater)
- throws NoSuchEntityException, IOException;
-
- /**
- * Retrieves an entity by Gravitino-assigned id.
- *
- * @param <E> The type of the entity returned.
- * @param ident The id name identifier.
- * @param entityType The type of the entity.
- * @return The entity associated with the id name identifier.
- * @throws NoSuchEntityException If the entity does not exist.
- * @throws IOException If an I/O exception occurs during retrieval.
- */
- <E extends Entity & HasIdentifier> E getById(NameIdentifier ident, Entity.EntityType entityType)
- throws NoSuchEntityException, IOException;
-
- /**
- * Updates an entity by Gravitino-assigned id.
- *
- * @param <E> the type of the entity returned
- * @param ident the id name identifier
- * @param entityType the type of the entity
- * @param updater a {@link Function} that takes the current entity instance and returns the
- * updated instance
- * @return the updated entity
- * @throws NoSuchEntityException if the entity does not exist
- * @throws IOException if the update operation fails
- */
- <E extends Entity & HasIdentifier> E updateById(
- NameIdentifier ident, Entity.EntityType entityType, Function<E, E> updater)
- throws NoSuchEntityException, IOException;
-
/**
* Batch retrieves the entities associated with the identifiers and the entity type.
*
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/RelationalEntityStore.java b/core/src/main/java/org/apache/gravitino/storage/relational/RelationalEntityStore.java
index 0d643dfba8..4892cca90c 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/RelationalEntityStore.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/RelationalEntityStore.java
@@ -45,8 +45,6 @@ import org.apache.gravitino.RelationEdgeTarget;
import org.apache.gravitino.RelationQuery;
import org.apache.gravitino.RelationUpdate;
import org.apache.gravitino.RelationalEntity;
-import org.apache.gravitino.SupportsExternalIdOperations;
-import org.apache.gravitino.SupportsIdOperations;
import org.apache.gravitino.SupportsRelationOperations;
import org.apache.gravitino.cache.CacheFactory;
import org.apache.gravitino.cache.CachedEntityIdResolver;
@@ -66,11 +64,7 @@ import org.slf4j.LoggerFactory;
* RelationalBackend} interface. The default JDBC backend is {@link JDBCBackend}.
*/
public class RelationalEntityStore
- implements EntityStore,
- SupportsRelationOperations,
- SupportsExternalIdOperations,
- SupportsIdOperations,
- SupportsEntityChangeLog {
+ implements EntityStore, SupportsRelationOperations, SupportsEntityChangeLog {
private static final Logger LOGGER = LoggerFactory.getLogger(RelationalEntityStore.class);
public static final ImmutableMap<String, String> RELATIONAL_BACKENDS =
ImmutableMap.of(
@@ -216,84 +210,6 @@ public class RelationalEntityStore
});
}
- @Override
- public SupportsExternalIdOperations externalIdOperations() {
- return this;
- }
-
- @Override
- public SupportsIdOperations idOperations() {
- return this;
- }
-
- @Override
- public <E extends Entity & HasIdentifier> E getByExternalId(
- NameIdentifier ident, Entity.EntityType entityType, Class<E> type)
- throws NoSuchEntityException, IOException {
- return backend.getByExternalId(ident, entityType);
- }
-
- @Override
- public <E extends Entity & HasIdentifier> E updateByExternalId(
- NameIdentifier ident, Entity.EntityType entityType, Class<E> type, Function<E, E> updater)
- throws NoSuchEntityException, IOException {
- E updatedEntity = backend.updateByExternalId(ident, entityType, updater);
- cache.invalidate(updatedEntity.nameIdentifier(), entityType);
- return updatedEntity;
- }
-
- @Override
- public boolean deleteByExternalId(NameIdentifier ident, Entity.EntityType entityType)
- throws IOException {
- NameIdentifier nameIdent = null;
- try {
- HasIdentifier entity = backend.getByExternalId(ident, entityType);
- nameIdent = entity.nameIdentifier();
- return backend.delete(nameIdent, entityType, false);
- } catch (NoSuchEntityException e) {
- LOGGER.warn(
- "The entity to be deleted by external id does not exist in the store: {}", ident, e);
- return false;
- } finally {
- if (nameIdent != null) {
- cache.invalidate(nameIdent, entityType);
- }
- }
- }
-
- @Override
- public <E extends Entity & HasIdentifier> E getById(
- NameIdentifier ident, Entity.EntityType entityType, Class<E> type)
- throws NoSuchEntityException, IOException {
- return backend.getById(ident, entityType);
- }
-
- @Override
- public <E extends Entity & HasIdentifier> E updateById(
- NameIdentifier ident, Entity.EntityType entityType, Class<E> type, Function<E, E> updater)
- throws NoSuchEntityException, IOException {
- E updatedEntity = backend.updateById(ident, entityType, updater);
- cache.invalidate(updatedEntity.nameIdentifier(), entityType);
- return updatedEntity;
- }
-
- @Override
- public boolean deleteById(NameIdentifier ident, Entity.EntityType entityType) throws IOException {
- NameIdentifier nameIdent = null;
- try {
- HasIdentifier entity = backend.getById(ident, entityType);
- nameIdent = entity.nameIdentifier();
- return backend.delete(nameIdent, entityType, false);
- } catch (NoSuchEntityException e) {
- LOGGER.warn("The entity to be deleted by id does not exist in the store: {}", ident, e);
- return false;
- } finally {
- if (nameIdent != null) {
- cache.invalidate(nameIdent, entityType);
- }
- }
- }
-
@Override
public <E extends Entity & HasIdentifier> List<E> batchGet(
List<NameIdentifier> idents, Entity.EntityType entityType, Class<E> clazz) {
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/GroupMetaMapper.java b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/GroupMetaMapper.java
index 16bec4d7d2..a5bd65d5c3 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/GroupMetaMapper.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/GroupMetaMapper.java
@@ -125,16 +125,4 @@ public interface GroupMetaMapper {
@SelectProvider(type = GroupMetaSQLProviderFactory.class, method = "getGroupUpdatedAt")
GroupUpdatedAt getGroupUpdatedAt(
@Param("metalakeName") String metalakeName, @Param("groupName") String groupName);
-
- @SelectProvider(
- type = GroupMetaSQLProviderFactory.class,
- method = "selectGroupMetaByMetalakeNameAndExternalId")
- GroupPO selectGroupMetaByMetalakeNameAndExternalId(
- @Param("metalakeName") String metalakeName, @Param("externalId") String externalId);
-
- @SelectProvider(
- type = GroupMetaSQLProviderFactory.class,
- method = "selectGroupMetaByMetalakeNameAndId")
- GroupPO selectGroupMetaByMetalakeNameAndId(
- @Param("metalakeName") String metalakeName, @Param("groupId") Long groupId);
}
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/GroupMetaSQLProviderFactory.java b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/GroupMetaSQLProviderFactory.java
index a938a5e5ed..14c6ab732e 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/GroupMetaSQLProviderFactory.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/GroupMetaSQLProviderFactory.java
@@ -127,14 +127,4 @@ public class GroupMetaSQLProviderFactory {
@Param("metalakeName") String metalakeName, @Param("groupName") String groupName) {
return getProvider().getGroupUpdatedAt(metalakeName, groupName);
}
-
- public static String selectGroupMetaByMetalakeNameAndExternalId(
- @Param("metalakeName") String metalakeName, @Param("externalId") String externalId) {
- return getProvider().selectGroupMetaByMetalakeNameAndExternalId(metalakeName, externalId);
- }
-
- public static String selectGroupMetaByMetalakeNameAndId(
- @Param("metalakeName") String metalakeName, @Param("groupId") Long groupId) {
- return getProvider().selectGroupMetaByMetalakeNameAndId(metalakeName, groupId);
- }
}
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/UserMetaMapper.java b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/UserMetaMapper.java
index dcf0800e26..ba79e5dca0 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/UserMetaMapper.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/UserMetaMapper.java
@@ -119,22 +119,6 @@ public interface UserMetaMapper {
UserUpdatedAt getUserUpdatedAt(
@Param("metalakeName") String metalakeName, @Param("userName") String userName);
- @SelectProvider(
- type = UserMetaSQLProviderFactory.class,
- method = "selectUserMetaByMetalakeNameAndExternalId")
- UserPO selectUserMetaByMetalakeNameAndExternalId(
- @Param("metalakeName") String metalakeName, @Param("externalId") String externalId);
-
- @SelectProvider(
- type = UserMetaSQLProviderFactory.class,
- method = "selectUserMetaByMetalakeNameAndId")
- UserPO selectUserMetaByMetalakeNameAndId(
- @Param("metalakeName") String metalakeName, @Param("userId") Long userId);
-
- @UpdateProvider(type = UserMetaSQLProviderFactory.class, method = "updateUserMetaByExternalId")
- Integer updateUserMetaByExternalId(
- @Param("newUserMeta") UserPO newUserPO, @Param("oldUserMeta") UserPO oldUserPO);
-
/**
* Single-round-trip auth prefetch for the JCasbin authorize hot path. Returns every version
* sentinel the request needs:
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/UserMetaSQLProviderFactory.java b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/UserMetaSQLProviderFactory.java
index ff40d94dfa..0779d9920f 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/UserMetaSQLProviderFactory.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/UserMetaSQLProviderFactory.java
@@ -131,19 +131,4 @@ public class UserMetaSQLProviderFactory {
@Param("groupNames") List<String> groupNames) {
return getProvider().batchGetAuthSubjectsForUser(metalakeName, userName, groupNames);
}
-
- public static String selectUserMetaByMetalakeNameAndExternalId(
- @Param("metalakeName") String metalakeName, @Param("externalId") String externalId) {
- return getProvider().selectUserMetaByMetalakeNameAndExternalId(metalakeName, externalId);
- }
-
- public static String selectUserMetaByMetalakeNameAndId(
- @Param("metalakeName") String metalakeName, @Param("userId") Long userId) {
- return getProvider().selectUserMetaByMetalakeNameAndId(metalakeName, userId);
- }
-
- public static String updateUserMetaByExternalId(
- @Param("newUserMeta") UserPO newUserPO, @Param("oldUserMeta") UserPO oldUserPO) {
- return getProvider().updateUserMetaByExternalId(newUserPO, oldUserPO);
- }
}
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/GroupMetaBaseSQLProvider.java b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/GroupMetaBaseSQLProvider.java
index 964c237106..002d68d2b5 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/GroupMetaBaseSQLProvider.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/GroupMetaBaseSQLProvider.java
@@ -40,7 +40,7 @@ public class GroupMetaBaseSQLProvider {
public String listGroupPOsByMetalake(@Param("metalakeName") String metalakeName) {
return "SELECT gt.group_id as groupId, gt.group_name as groupName, gt.metalake_id as metalakeId,"
- + " gt.external_id as externalId,"
+ + ""
+ " gt.audit_info as auditInfo, gt.current_version as currentVersion, gt.last_version as lastVersion,"
+ " gt.deleted_at as deletedAt FROM "
+ GROUP_TABLE_NAME
@@ -53,7 +53,7 @@ public class GroupMetaBaseSQLProvider {
public String listExtendedGroupPOsByMetalakeId(@Param("metalakeId") Long metalakeId) {
return "SELECT gt.group_id as groupId, gt.group_name as groupName,"
+ " gt.metalake_id as metalakeId,"
- + " gt.external_id as externalId,"
+ + ""
+ " gt.audit_info as auditInfo,"
+ " gt.current_version as currentVersion, gt.last_version as lastVersion,"
+ " gt.deleted_at as deletedAt,"
@@ -93,7 +93,7 @@ public class GroupMetaBaseSQLProvider {
@Param("limit") int limit) {
return "SELECT gt.group_id as groupId, gt.group_name as groupName,"
+ " gt.metalake_id as metalakeId,"
- + " gt.external_id as externalId,"
+ + ""
+ " gt.audit_info as auditInfo,"
+ " gt.current_version as currentVersion, gt.last_version as lastVersion,"
+ " gt.deleted_at as deletedAt,"
@@ -130,7 +130,7 @@ public class GroupMetaBaseSQLProvider {
@Param("metalakeId") Long metalakeId, @Param("groupName") String name) {
return "SELECT group_id as groupId, group_name as groupName,"
+ " metalake_id as metalakeId,"
- + " external_id as externalId,"
+ + ""
+ " audit_info as auditInfo, current_version as currentVersion,"
+ " last_version as lastVersion, deleted_at as deletedAt"
+ " FROM "
@@ -142,7 +142,7 @@ public class GroupMetaBaseSQLProvider {
/** Returns SQL that selects and locks an active group by ID. */
public String selectGroupMetaByIdForUpdate(@Param("groupId") Long groupId) {
return "SELECT group_id as groupId, group_name as groupName,"
- + " metalake_id as metalakeId, external_id as externalId, audit_info as auditInfo,"
+ + " metalake_id as metalakeId, audit_info as auditInfo,"
+ " current_version as currentVersion, last_version as lastVersion,"
+ " deleted_at as deletedAt"
+ " FROM "
@@ -150,46 +150,12 @@ public class GroupMetaBaseSQLProvider {
+ " WHERE group_id = #{groupId} AND deleted_at = 0 FOR UPDATE";
}
- public String selectGroupMetaByMetalakeNameAndExternalId(
- @Param("metalakeName") String metalakeName, @Param("externalId") String externalId) {
- return "SELECT gt.group_id as groupId, gt.group_name as groupName,"
- + " gt.metalake_id as metalakeId,"
- + " gt.external_id as externalId,"
- + " gt.audit_info as auditInfo, gt.current_version as currentVersion,"
- + " gt.last_version as lastVersion, gt.deleted_at as deletedAt"
- + " FROM "
- + GROUP_TABLE_NAME
- + " gt JOIN "
- + MetalakeMetaMapper.TABLE_NAME
- + " mt ON gt.metalake_id = mt.metalake_id"
- + " WHERE mt.metalake_name = #{metalakeName}"
- + " AND gt.external_id = #{externalId}"
- + " AND gt.deleted_at = 0 AND mt.deleted_at = 0";
- }
-
- public String selectGroupMetaByMetalakeNameAndId(
- @Param("metalakeName") String metalakeName, @Param("groupId") Long groupId) {
- return "SELECT gt.group_id as groupId, gt.group_name as groupName,"
- + " gt.metalake_id as metalakeId,"
- + " gt.external_id as externalId,"
- + " gt.audit_info as auditInfo, gt.current_version as currentVersion,"
- + " gt.last_version as lastVersion, gt.deleted_at as deletedAt"
- + " FROM "
- + GROUP_TABLE_NAME
- + " gt JOIN "
- + MetalakeMetaMapper.TABLE_NAME
- + " mt ON gt.metalake_id = mt.metalake_id"
- + " WHERE mt.metalake_name = #{metalakeName}"
- + " AND gt.group_id = #{groupId}"
- + " AND gt.deleted_at = 0 AND mt.deleted_at = 0";
- }
-
public String listExtendedGroupPOsByMetalakeIdAndNames(
@Param("metalakeId") Long metalakeId, @Param("groupNames") List<String> groupNames) {
return "<script>"
+ "SELECT gt.group_id as groupId, gt.group_name as groupName,"
+ " gt.metalake_id as metalakeId,"
- + " gt.external_id as externalId,"
+ + ""
+ " gt.audit_info as auditInfo,"
+ " gt.current_version as currentVersion, gt.last_version as lastVersion,"
+ " gt.deleted_at as deletedAt,"
@@ -215,7 +181,7 @@ public class GroupMetaBaseSQLProvider {
+ "#{groupName}"
+ "</foreach>"
+ " )"
- + " GROUP BY gt.group_id, gt.group_name, gt.metalake_id, gt.external_id, gt.audit_info,"
+ + " GROUP BY gt.group_id, gt.group_name, gt.metalake_id, gt.audit_info,"
+ " gt.current_version, gt.last_version, gt.deleted_at"
+ "</script>";
}
@@ -223,13 +189,13 @@ public class GroupMetaBaseSQLProvider {
public String insertGroupMeta(@Param("groupMeta") GroupPO groupPO) {
return "INSERT INTO "
+ GROUP_TABLE_NAME
- + " (group_id, group_name, metalake_id, external_id,"
+ + " (group_id, group_name, metalake_id,"
+ " audit_info, current_version, last_version, deleted_at)"
+ " VALUES ("
+ " #{groupMeta.groupId},"
+ " #{groupMeta.groupName},"
+ " #{groupMeta.metalakeId},"
- + " #{groupMeta.externalId},"
+ + ""
+ " #{groupMeta.auditInfo},"
+ " #{groupMeta.currentVersion},"
+ " #{groupMeta.lastVersion},"
@@ -240,13 +206,13 @@ public class GroupMetaBaseSQLProvider {
public String insertGroupMetaOnDuplicateKeyUpdate(@Param("groupMeta") GroupPO groupPO) {
return "INSERT INTO "
+ GROUP_TABLE_NAME
- + " (group_id, group_name, metalake_id, external_id,"
+ + " (group_id, group_name, metalake_id,"
+ " audit_info, current_version, last_version, deleted_at)"
+ " VALUES ("
+ " #{groupMeta.groupId},"
+ " #{groupMeta.groupName},"
+ " #{groupMeta.metalakeId},"
- + " #{groupMeta.externalId},"
+ + ""
+ " #{groupMeta.auditInfo},"
+ " #{groupMeta.currentVersion},"
+ " #{groupMeta.lastVersion},"
@@ -256,7 +222,7 @@ public class GroupMetaBaseSQLProvider {
+ " group_name = #{groupMeta.groupName},"
+ " metalake_id = #{groupMeta.metalakeId},"
+ " audit_info = #{groupMeta.auditInfo},"
- + " external_id = #{groupMeta.externalId},"
+ + ""
// Advance rather than reset the OCC token so a writer holding a pre-overwrite snapshot
// cannot pass a later compare-and-set (an ABA conflict).
+ " last_version = current_version + 1,"
@@ -289,7 +255,7 @@ public class GroupMetaBaseSQLProvider {
+ " SET group_name = #{newGroupMeta.groupName},"
+ " metalake_id = #{newGroupMeta.metalakeId},"
+ " audit_info = #{newGroupMeta.auditInfo},"
- + " external_id = #{newGroupMeta.externalId},"
+ + ""
+ " current_version = #{newGroupMeta.currentVersion},"
+ " last_version = #{newGroupMeta.lastVersion},"
+ " deleted_at = #{newGroupMeta.deletedAt}"
@@ -301,7 +267,7 @@ public class GroupMetaBaseSQLProvider {
public String listGroupsByRoleId(@Param("roleId") Long roleId) {
return "SELECT gr.group_id as groupId, gr.group_name as groupName,"
+ " gr.metalake_id as metalakeId,"
- + " gr.external_id as externalId,"
+ + ""
+ " gr.audit_info as auditInfo, gr.current_version as currentVersion,"
+ " gr.last_version as lastVersion, gr.deleted_at as deletedAt"
+ " FROM "
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/OwnerMetaBaseSQLProvider.java b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/OwnerMetaBaseSQLProvider.java
index d84bf596ae..46806b59e3 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/OwnerMetaBaseSQLProvider.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/OwnerMetaBaseSQLProvider.java
@@ -47,8 +47,6 @@ public class OwnerMetaBaseSQLProvider {
return "SELECT ut.user_id as userId,"
+ " ut.user_name as userName,"
+ " ut.metalake_id as metalakeId,"
- + " ut.external_id as externalId,"
- + " ut.enabled as enabled,"
+ " ut.audit_info as auditInfo,"
+ " ut.current_version as currentVersion,"
+ " ut.last_version as lastVersion,"
@@ -72,8 +70,6 @@ public class OwnerMetaBaseSQLProvider {
+ "ut.user_id as userId, "
+ "ut.user_name as userName, "
+ "ut.metalake_id as metalakeId, "
- + "ut.external_id as externalId, "
- + "ut.enabled as enabled, "
+ "ut.audit_info as auditInfo, "
+ "ut.current_version as currentVersion, "
+ "ut.last_version as lastVersion, "
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/UserMetaBaseSQLProvider.java b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/UserMetaBaseSQLProvider.java
index 046c8a7e94..98e8931f1d 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/UserMetaBaseSQLProvider.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/UserMetaBaseSQLProvider.java
@@ -45,7 +45,6 @@ public class UserMetaBaseSQLProvider {
@Param("metalakeId") Long metalakeId, @Param("userName") String name) {
return "SELECT user_id as userId, user_name as userName,"
+ " metalake_id as metalakeId,"
- + " external_id as externalId, enabled as enabled,"
+ " audit_info as auditInfo, current_version as currentVersion,"
+ " last_version as lastVersion, deleted_at as deletedAt"
+ " FROM "
@@ -57,7 +56,7 @@ public class UserMetaBaseSQLProvider {
/** Returns SQL that selects and locks an active user by ID. */
public String selectUserMetaByIdForUpdate(@Param("userId") Long userId) {
return "SELECT user_id as userId, user_name as userName,"
- + " metalake_id as metalakeId, external_id as externalId, enabled as enabled,"
+ + " metalake_id as metalakeId,"
+ " audit_info as auditInfo, current_version as currentVersion,"
+ " last_version as lastVersion, deleted_at as deletedAt"
+ " FROM "
@@ -65,68 +64,15 @@ public class UserMetaBaseSQLProvider {
+ " WHERE user_id = #{userId} AND deleted_at = 0 FOR UPDATE";
}
- public String selectUserMetaByMetalakeNameAndExternalId(
- @Param("metalakeName") String metalakeName, @Param("externalId") String externalId) {
- return "SELECT ut.user_id as userId, ut.user_name as userName,"
- + " ut.metalake_id as metalakeId,"
- + " ut.external_id as externalId, ut.enabled as enabled,"
- + " ut.audit_info as auditInfo, ut.current_version as currentVersion,"
- + " ut.last_version as lastVersion, ut.deleted_at as deletedAt"
- + " FROM "
- + USER_TABLE_NAME
- + " ut JOIN "
- + MetalakeMetaMapper.TABLE_NAME
- + " mt ON ut.metalake_id = mt.metalake_id"
- + " WHERE mt.metalake_name = #{metalakeName}"
- + " AND ut.external_id = #{externalId}"
- + " AND ut.deleted_at = 0 AND mt.deleted_at = 0";
- }
-
- public String selectUserMetaByMetalakeNameAndId(
- @Param("metalakeName") String metalakeName, @Param("userId") Long userId) {
- return "SELECT ut.user_id as userId, ut.user_name as userName,"
- + " ut.metalake_id as metalakeId,"
- + " ut.external_id as externalId, ut.enabled as enabled,"
- + " ut.audit_info as auditInfo, ut.current_version as currentVersion,"
- + " ut.last_version as lastVersion, ut.deleted_at as deletedAt"
- + " FROM "
- + USER_TABLE_NAME
- + " ut JOIN "
- + MetalakeMetaMapper.TABLE_NAME
- + " mt ON ut.metalake_id = mt.metalake_id"
- + " WHERE mt.metalake_name = #{metalakeName}"
- + " AND ut.user_id = #{userId}"
- + " AND ut.deleted_at = 0 AND mt.deleted_at = 0";
- }
-
- public String updateUserMetaByExternalId(
- @Param("newUserMeta") UserPO newUserPO, @Param("oldUserMeta") UserPO oldUserPO) {
- return "UPDATE "
- + USER_TABLE_NAME
- + " SET user_name = #{newUserMeta.userName},"
- + " metalake_id = #{newUserMeta.metalakeId},"
- + " audit_info = #{newUserMeta.auditInfo},"
- + " external_id = #{newUserMeta.externalId},"
- + " enabled = #{newUserMeta.enabled},"
- + " current_version = #{newUserMeta.currentVersion},"
- + " last_version = #{newUserMeta.lastVersion},"
- + " deleted_at = #{newUserMeta.deletedAt}"
- + " WHERE user_id = #{oldUserMeta.userId}"
- + " AND current_version = #{oldUserMeta.currentVersion}"
- + " AND deleted_at = 0";
- }
-
public String insertUserMeta(@Param("userMeta") UserPO userPO) {
return "INSERT INTO "
+ USER_TABLE_NAME
- + " (user_id, user_name, metalake_id, external_id, enabled,"
+ + " (user_id, user_name, metalake_id,"
+ " audit_info, current_version, last_version, deleted_at)"
+ " VALUES ("
+ " #{userMeta.userId},"
+ " #{userMeta.userName},"
+ " #{userMeta.metalakeId},"
- + " #{userMeta.externalId},"
- + " #{userMeta.enabled},"
+ " #{userMeta.auditInfo},"
+ " #{userMeta.currentVersion},"
+ " #{userMeta.lastVersion},"
@@ -137,14 +83,12 @@ public class UserMetaBaseSQLProvider {
public String insertUserMetaOnDuplicateKeyUpdate(@Param("userMeta") UserPO userPO) {
return "INSERT INTO "
+ USER_TABLE_NAME
- + " (user_id, user_name, metalake_id, external_id, enabled,"
+ + " (user_id, user_name, metalake_id,"
+ " audit_info, current_version, last_version, deleted_at)"
+ " VALUES ("
+ " #{userMeta.userId},"
+ " #{userMeta.userName},"
+ " #{userMeta.metalakeId},"
- + " #{userMeta.externalId},"
- + " #{userMeta.enabled},"
+ " #{userMeta.auditInfo},"
+ " #{userMeta.currentVersion},"
+ " #{userMeta.lastVersion},"
@@ -154,8 +98,6 @@ public class UserMetaBaseSQLProvider {
+ " user_name = #{userMeta.userName},"
+ " metalake_id = #{userMeta.metalakeId},"
+ " audit_info = #{userMeta.auditInfo},"
- + " external_id = #{userMeta.externalId},"
- + " enabled = #{userMeta.enabled},"
// Advance rather than reset the OCC token so a writer holding a pre-overwrite snapshot
// cannot pass a later compare-and-set (an ABA conflict).
+ " last_version = current_version + 1,"
@@ -188,8 +130,6 @@ public class UserMetaBaseSQLProvider {
+ " SET user_name = #{newUserMeta.userName},"
+ " metalake_id = #{newUserMeta.metalakeId},"
+ " audit_info = #{newUserMeta.auditInfo},"
- + " external_id = #{newUserMeta.externalId},"
- + " enabled = #{newUserMeta.enabled},"
+ " current_version = #{newUserMeta.currentVersion},"
+ " last_version = #{newUserMeta.lastVersion},"
+ " deleted_at = #{newUserMeta.deletedAt}"
@@ -201,7 +141,6 @@ public class UserMetaBaseSQLProvider {
public String listUsersByRoleId(@Param("roleId") Long roleId) {
return "SELECT us.user_id as userId, us.user_name as userName,"
+ " us.metalake_id as metalakeId,"
- + " us.external_id as externalId, us.enabled as enabled,"
+ " us.audit_info as auditInfo, us.current_version as currentVersion,"
+ " us.last_version as lastVersion, us.deleted_at as deletedAt"
+ " FROM "
@@ -216,7 +155,6 @@ public class UserMetaBaseSQLProvider {
public String listUserPOsByMetalake(@Param("metalakeName") String metalakeName) {
return "SELECT ut.user_id as userId, ut.user_name as userName,"
+ " ut.metalake_id as metalakeId,"
- + " ut.external_id as externalId, ut.enabled as enabled,"
+ " ut.audit_info as auditInfo,"
+ " ut.current_version as currentVersion, ut.last_version as lastVersion,"
+ " ut.deleted_at as deletedAt"
@@ -232,7 +170,6 @@ public class UserMetaBaseSQLProvider {
public String listExtendedUserPOsByMetalakeId(@Param("metalakeId") Long metalakeId) {
return "SELECT ut.user_id as userId, ut.user_name as userName,"
+ " ut.metalake_id as metalakeId,"
- + " ut.external_id as externalId, ut.enabled as enabled,"
+ " ut.audit_info as auditInfo,"
+ " ut.current_version as currentVersion, ut.last_version as lastVersion,"
+ " ut.deleted_at as deletedAt,"
@@ -272,7 +209,6 @@ public class UserMetaBaseSQLProvider {
@Param("limit") int limit) {
return "SELECT ut.user_id as userId, ut.user_name as userName,"
+ " ut.metalake_id as metalakeId,"
- + " ut.external_id as externalId, ut.enabled as enabled,"
+ " ut.audit_info as auditInfo,"
+ " ut.current_version as currentVersion, ut.last_version as lastVersion,"
+ " ut.deleted_at as deletedAt,"
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/h2/GroupMetaH2Provider.java b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/h2/GroupMetaH2Provider.java
index 950a8a0125..2d542428cd 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/h2/GroupMetaH2Provider.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/h2/GroupMetaH2Provider.java
@@ -32,7 +32,7 @@ public class GroupMetaH2Provider extends GroupMetaBaseSQLProvider {
public String listExtendedGroupPOsByMetalakeId(@Param("metalakeId") Long metalakeId) {
return "SELECT gt.group_id as groupId, gt.group_name as groupName,"
+ " gt.metalake_id as metalakeId,"
- + " gt.external_id as externalId,"
+ + ""
+ " gt.audit_info as auditInfo,"
+ " gt.current_version as currentVersion, gt.last_version as lastVersion,"
+ " gt.deleted_at as deletedAt,"
@@ -63,7 +63,7 @@ public class GroupMetaH2Provider extends GroupMetaBaseSQLProvider {
@Param("limit") int limit) {
return "SELECT gt.group_id as groupId, gt.group_name as groupName,"
+ " gt.metalake_id as metalakeId,"
- + " gt.external_id as externalId,"
+ + ""
+ " gt.audit_info as auditInfo,"
+ " gt.current_version as currentVersion, gt.last_version as lastVersion,"
+ " gt.deleted_at as deletedAt,"
@@ -102,7 +102,7 @@ public class GroupMetaH2Provider extends GroupMetaBaseSQLProvider {
return "<script>"
+ "SELECT gt.group_id as groupId, gt.group_name as groupName,"
+ " gt.metalake_id as metalakeId,"
- + " gt.external_id as externalId,"
+ + ""
+ " gt.audit_info as auditInfo,"
+ " gt.current_version as currentVersion, gt.last_version as lastVersion,"
+ " gt.deleted_at as deletedAt,"
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/h2/UserMetaH2Provider.java b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/h2/UserMetaH2Provider.java
index 4f85335ab4..83fe6774b5 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/h2/UserMetaH2Provider.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/h2/UserMetaH2Provider.java
@@ -31,7 +31,6 @@ public class UserMetaH2Provider extends UserMetaBaseSQLProvider {
public String listExtendedUserPOsByMetalakeId(@Param("metalakeId") Long metalakeId) {
return "SELECT ut.user_id as userId, ut.user_name as userName,"
+ " ut.metalake_id as metalakeId,"
- + " ut.external_id as externalId, ut.enabled as enabled,"
+ " ut.audit_info as auditInfo,"
+ " ut.current_version as currentVersion, ut.last_version as lastVersion,"
+ " ut.deleted_at as deletedAt,"
@@ -62,7 +61,6 @@ public class UserMetaH2Provider extends UserMetaBaseSQLProvider {
@Param("limit") int limit) {
return "SELECT ut.user_id as userId, ut.user_name as userName,"
+ " ut.metalake_id as metalakeId,"
- + " ut.external_id as externalId, ut.enabled as enabled,"
+ " ut.audit_info as auditInfo,"
+ " ut.current_version as currentVersion, ut.last_version as lastVersion,"
+ " ut.deleted_at as deletedAt,"
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/postgresql/GroupMetaPostgreSQLProvider.java b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/postgresql/GroupMetaPostgreSQLProvider.java
index 586ee48e03..1a24acec0f 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/postgresql/GroupMetaPostgreSQLProvider.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/postgresql/GroupMetaPostgreSQLProvider.java
@@ -53,14 +53,14 @@ public class GroupMetaPostgreSQLProvider extends GroupMetaBaseSQLProvider {
public String insertGroupMetaOnDuplicateKeyUpdate(GroupPO groupPO) {
return "INSERT INTO "
+ GROUP_TABLE_NAME
- + " (group_id, group_name, metalake_id, external_id,"
+ + " (group_id, group_name, metalake_id,"
+ " audit_info,"
+ " current_version, last_version, deleted_at)"
+ " VALUES ("
+ " #{groupMeta.groupId},"
+ " #{groupMeta.groupName},"
+ " #{groupMeta.metalakeId},"
- + " #{groupMeta.externalId},"
+ + ""
+ " #{groupMeta.auditInfo},"
+ " #{groupMeta.currentVersion},"
+ " #{groupMeta.lastVersion},"
@@ -69,7 +69,7 @@ public class GroupMetaPostgreSQLProvider extends GroupMetaBaseSQLProvider {
+ " ON CONFLICT(group_id) DO UPDATE SET"
+ " group_name = #{groupMeta.groupName},"
+ " metalake_id = #{groupMeta.metalakeId},"
- + " external_id = #{groupMeta.externalId},"
+ + ""
+ " audit_info = #{groupMeta.auditInfo},"
// PostgreSQL requires the stored-row column to be qualified in ON CONFLICT assignments.
+ " current_version = "
@@ -85,7 +85,7 @@ public class GroupMetaPostgreSQLProvider extends GroupMetaBaseSQLProvider {
public String listExtendedGroupPOsByMetalakeId(@Param("metalakeId") Long metalakeId) {
return "SELECT gt.group_id as groupId, gt.group_name as groupName,"
+ " gt.metalake_id as metalakeId,"
- + " gt.external_id as externalId,"
+ + ""
+ " gt.audit_info as auditInfo,"
+ " gt.current_version as currentVersion, gt.last_version as lastVersion,"
+ " gt.deleted_at as deletedAt,"
@@ -116,7 +116,7 @@ public class GroupMetaPostgreSQLProvider extends GroupMetaBaseSQLProvider {
@Param("limit") int limit) {
return "SELECT gt.group_id as groupId, gt.group_name as groupName,"
+ " gt.metalake_id as metalakeId,"
- + " gt.external_id as externalId,"
+ + ""
+ " gt.audit_info as auditInfo,"
+ " gt.current_version as currentVersion, gt.last_version as lastVersion,"
+ " gt.deleted_at as deletedAt,"
@@ -155,7 +155,7 @@ public class GroupMetaPostgreSQLProvider extends GroupMetaBaseSQLProvider {
return "<script>"
+ "SELECT gt.group_id as groupId, gt.group_name as groupName,"
+ " gt.metalake_id as metalakeId,"
- + " gt.external_id as externalId,"
+ + ""
+ " gt.audit_info as auditInfo,"
+ " gt.current_version as currentVersion, gt.last_version as lastVersion,"
+ " gt.deleted_at as deletedAt,"
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/postgresql/UserMetaPostgreSQLProvider.java b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/postgresql/UserMetaPostgreSQLProvider.java
index c1c6dd1469..4562901e8b 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/postgresql/UserMetaPostgreSQLProvider.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/postgresql/UserMetaPostgreSQLProvider.java
@@ -52,15 +52,13 @@ public class UserMetaPostgreSQLProvider extends UserMetaBaseSQLProvider {
public String insertUserMetaOnDuplicateKeyUpdate(UserPO userPO) {
return "INSERT INTO "
+ USER_TABLE_NAME
- + " (user_id, user_name, metalake_id, external_id, enabled,"
+ + " (user_id, user_name, metalake_id,"
+ " audit_info,"
+ " current_version, last_version, deleted_at)"
+ " VALUES ("
+ " #{userMeta.userId},"
+ " #{userMeta.userName},"
+ " #{userMeta.metalakeId},"
- + " #{userMeta.externalId},"
- + " #{userMeta.enabled},"
+ " #{userMeta.auditInfo},"
+ " #{userMeta.currentVersion},"
+ " #{userMeta.lastVersion},"
@@ -69,8 +67,6 @@ public class UserMetaPostgreSQLProvider extends UserMetaBaseSQLProvider {
+ " ON CONFLICT(user_id) DO UPDATE SET"
+ " user_name = #{userMeta.userName},"
+ " metalake_id = #{userMeta.metalakeId},"
- + " external_id = #{userMeta.externalId},"
- + " enabled = #{userMeta.enabled},"
+ " audit_info = #{userMeta.auditInfo},"
// PostgreSQL requires the stored-row column to be qualified in ON CONFLICT assignments.
+ " current_version = "
@@ -86,7 +82,6 @@ public class UserMetaPostgreSQLProvider extends UserMetaBaseSQLProvider {
public String listExtendedUserPOsByMetalakeId(Long metalakeId) {
return "SELECT ut.user_id as userId, ut.user_name as userName,"
+ " ut.metalake_id as metalakeId,"
- + " ut.external_id as externalId, ut.enabled as enabled,"
+ " ut.audit_info as auditInfo,"
+ " ut.current_version as currentVersion, ut.last_version as lastVersion,"
+ " ut.deleted_at as deletedAt,"
@@ -117,7 +112,6 @@ public class UserMetaPostgreSQLProvider extends UserMetaBaseSQLProvider {
@Param("limit") int limit) {
return "SELECT ut.user_id as userId, ut.user_name as userName,"
+ " ut.metalake_id as metalakeId,"
- + " ut.external_id as externalId, ut.enabled as enabled,"
+ " ut.audit_info as auditInfo,"
+ " ut.current_version as currentVersion, ut.last_version as lastVersion,"
+ " ut.deleted_at as deletedAt,"
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/po/GroupPO.java b/core/src/main/java/org/apache/gravitino/storage/relational/po/GroupPO.java
index 6e01137164..478e9e774c 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/po/GroupPO.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/po/GroupPO.java
@@ -25,7 +25,6 @@ public class GroupPO {
private Long groupId;
private String groupName;
private Long metalakeId;
- private String externalId;
private String auditInfo;
private Long currentVersion;
private Long lastVersion;
@@ -43,10 +42,6 @@ public class GroupPO {
return metalakeId;
}
- public String getExternalId() {
- return externalId;
- }
-
public String getAuditInfo() {
return auditInfo;
}
@@ -75,7 +70,6 @@ public class GroupPO {
return Objects.equal(getGroupId(), tablePO.getGroupId())
&& Objects.equal(getGroupName(), tablePO.getGroupName())
&& Objects.equal(getMetalakeId(), tablePO.getMetalakeId())
- && Objects.equal(getExternalId(), tablePO.getExternalId())
&& Objects.equal(getAuditInfo(), tablePO.getAuditInfo())
&& Objects.equal(getCurrentVersion(), tablePO.getCurrentVersion())
&& Objects.equal(getLastVersion(), tablePO.getLastVersion())
@@ -88,7 +82,6 @@ public class GroupPO {
getGroupId(),
getGroupName(),
getMetalakeId(),
- getExternalId(),
getAuditInfo(),
getCurrentVersion(),
getLastVersion(),
@@ -117,11 +110,6 @@ public class GroupPO {
return this;
}
- public Builder withExternalId(String externalId) {
- groupPO.externalId = externalId;
- return this;
- }
-
public Builder withAuditInfo(String auditInfo) {
groupPO.auditInfo = auditInfo;
return this;
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/po/UserPO.java b/core/src/main/java/org/apache/gravitino/storage/relational/po/UserPO.java
index 0bf3cd9dfe..2a9079bc53 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/po/UserPO.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/po/UserPO.java
@@ -25,8 +25,6 @@ public class UserPO {
private Long userId;
private String userName;
private Long metalakeId;
- private String externalId;
- private Boolean enabled;
private String auditInfo;
private Long currentVersion;
private Long lastVersion;
@@ -44,14 +42,6 @@ public class UserPO {
return metalakeId;
}
- public String getExternalId() {
- return externalId;
- }
-
- public Boolean getEnabled() {
- return enabled;
- }
-
public String getAuditInfo() {
return auditInfo;
}
@@ -80,8 +70,6 @@ public class UserPO {
return Objects.equal(getUserId(), tablePO.getUserId())
&& Objects.equal(getUserName(), tablePO.getUserName())
&& Objects.equal(getMetalakeId(), tablePO.getMetalakeId())
- && Objects.equal(getExternalId(), tablePO.getExternalId())
- && Objects.equal(getEnabled(), tablePO.getEnabled())
&& Objects.equal(getAuditInfo(), tablePO.getAuditInfo())
&& Objects.equal(getCurrentVersion(), tablePO.getCurrentVersion())
&& Objects.equal(getLastVersion(), tablePO.getLastVersion())
@@ -94,8 +82,6 @@ public class UserPO {
getUserId(),
getUserName(),
getMetalakeId(),
- getExternalId(),
- getEnabled(),
getAuditInfo(),
getCurrentVersion(),
getLastVersion(),
@@ -124,16 +110,6 @@ public class UserPO {
return this;
}
- public Builder withExternalId(String externalId) {
- userPO.externalId = externalId;
- return this;
- }
-
- public Builder withEnabled(Boolean enabled) {
- userPO.enabled = enabled;
- return this;
- }
-
public Builder withAuditInfo(String auditInfo) {
userPO.auditInfo = auditInfo;
return this;
@@ -165,9 +141,6 @@ public class UserPO {
}
public UserPO build() {
- if (userPO.enabled == null) {
- userPO.enabled = true;
- }
validate();
return userPO;
}
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/service/GroupMetaService.java b/core/src/main/java/org/apache/gravitino/storage/relational/service/GroupMetaService.java
index b431cccf6f..028fe024cf 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/service/GroupMetaService.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/service/GroupMetaService.java
@@ -29,7 +29,6 @@ import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.gravitino.Entity;
@@ -406,150 +405,6 @@ public class GroupMetaService {
return groupDeletedCount[0] + groupRoleRelDeletedCount[0];
}
- private GroupPO getGroupPOByMetalakeNameAndExternalId(String metalakeName, String externalId) {
- GroupPO groupPO =
- SessionUtils.getWithoutCommit(
- GroupMetaMapper.class,
- mapper -> mapper.selectGroupMetaByMetalakeNameAndExternalId(metalakeName, externalId));
-
- if (groupPO == null) {
- throw new NoSuchEntityException(
- NoSuchEntityException.NO_SUCH_ENTITY_MESSAGE,
- Entity.EntityType.GROUP.name().toLowerCase(),
- externalId);
- }
- return groupPO;
- }
-
- @Monitored(
- metricsSource = GRAVITINO_RELATIONAL_STORE_METRIC_NAME,
- baseMetricName = "getGroupByExternalId")
- public GroupEntity getGroupByExternalId(NameIdentifier ident) {
- AuthorizationUtils.checkGroupExternalId(ident);
- String metalake = ident.namespace().level(0);
- String externalId = ident.name();
- GroupPO groupPO = getGroupPOByMetalakeNameAndExternalId(metalake, externalId);
- List<RolePO> rolePOs = RoleMetaService.getInstance().listRolesByGroupId(groupPO.getGroupId());
- return POConverters.fromGroupPO(
- groupPO, rolePOs, AuthorizationUtils.ofGroupNamespace(metalake));
- }
-
- private GroupPO getGroupPOByMetalakeNameAndId(String metalakeName, Long groupId) {
- GroupPO groupPO =
- SessionUtils.getWithoutCommit(
- GroupMetaMapper.class,
- mapper -> mapper.selectGroupMetaByMetalakeNameAndId(metalakeName, groupId));
-
- if (groupPO == null) {
- throw new NoSuchEntityException(
- NoSuchEntityException.NO_SUCH_ENTITY_MESSAGE,
- Entity.EntityType.GROUP.name().toLowerCase(),
- String.valueOf(groupId));
- }
- return groupPO;
- }
-
- @Monitored(
- metricsSource = GRAVITINO_RELATIONAL_STORE_METRIC_NAME,
- baseMetricName = "getGroupById")
- public GroupEntity getGroupById(String metalake, long groupId) {
- GroupPO groupPO = getGroupPOByMetalakeNameAndId(metalake, groupId);
- List<RolePO> rolePOs = RoleMetaService.getInstance().listRolesByGroupId(groupPO.getGroupId());
- return POConverters.fromGroupPO(
- groupPO, rolePOs, AuthorizationUtils.ofGroupNamespace(metalake));
- }
-
- @Monitored(
- metricsSource = GRAVITINO_RELATIONAL_STORE_METRIC_NAME,
- baseMetricName = "updateGroupById")
- public <E extends Entity & HasIdentifier> GroupEntity updateGroupById(
- String metalake, long groupId, Function<E, E> updater) throws IOException {
- GroupPO oldGroupPO = getGroupPOByMetalakeNameAndId(metalake, groupId);
- List<RolePO> rolePOs =
- RoleMetaService.getInstance().listRolesByGroupId(oldGroupPO.getGroupId());
- GroupEntity oldEntity =
- POConverters.fromGroupPO(
- oldGroupPO, rolePOs, AuthorizationUtils.ofGroupNamespace(metalake));
- GroupEntity newEntity = (GroupEntity) updater.apply((E) oldEntity);
- Preconditions.checkArgument(
- Objects.equals(oldEntity.id(), newEntity.id()),
- "The updated group entity id: %s should be same with the group entity id before: %s",
- newEntity.id(),
- oldEntity.id());
-
- try {
- SessionUtils.doMultipleWithCommit(
- () -> {
- int updated =
- SessionUtils.getWithoutCommit(
- GroupMetaMapper.class,
- mapper ->
- mapper.updateGroupMeta(
- POConverters.updateGroupPOWithVersion(oldGroupPO, newEntity),
- oldGroupPO));
- if (updated == 0) {
- NameIdentifier groupIdIdentifier =
- AuthorizationUtils.ofGroup(metalake, String.valueOf(groupId));
- throw groupWriteFailure(groupIdIdentifier, oldGroupPO, GroupLookup.ID);
- }
- },
- () ->
- SessionUtils.doWithoutCommit(
- GroupMetaMapper.class,
- mapper -> mapper.touchGroupUpdatedAt(oldGroupPO.getGroupId())));
- } catch (RuntimeException re) {
- ExceptionUtils.checkSQLException(
- re, Entity.EntityType.GROUP, newEntity.nameIdentifier().toString());
- throw re;
- }
- return newEntity;
- }
-
- @Monitored(
- metricsSource = GRAVITINO_RELATIONAL_STORE_METRIC_NAME,
- baseMetricName = "deleteGroupById")
- public boolean deleteGroupById(String metalake, long groupId) {
- GroupPO groupPO;
- try {
- groupPO = getGroupPOByMetalakeNameAndId(metalake, groupId);
- } catch (NoSuchEntityException e) {
- return false;
- }
-
- NameIdentifier identifier = AuthorizationUtils.ofGroup(metalake, groupPO.getGroupName());
-
- // Starts false so that any path that does not reach the child cleanup reports "nothing was
- // deleted here" rather than claiming a delete it did not perform.
- AtomicBoolean deletedGroup = new AtomicBoolean(false);
- SessionUtils.doMultipleWithCommit(
- () -> {
- int deleted =
- SessionUtils.getWithoutCommit(
- GroupMetaMapper.class,
- mapper ->
- mapper.softDeleteGroupMetaByGroupId(groupId, groupPO.getCurrentVersion()));
- if (deleted == 0) {
- // The compare-and-set matched no row for one of two reasons. Either the row is already
- // gone, and a delete that has nothing left to delete is a no-op rather than an error,
- // or the row is still there under a newer version, which is a genuine conflict.
- if (getGroupPOByIdForUpdate(groupId) == null) {
- return;
- }
- throw ExceptionUtils.concurrentModification(Entity.EntityType.GROUP, identifier);
- }
-
- deletedGroup.set(true);
- SessionUtils.doWithoutCommit(
- GroupRoleRelMapper.class, mapper -> mapper.softDeleteGroupRoleRelByGroupId(groupId));
- SessionUtils.doWithoutCommit(
- OwnerMetaMapper.class,
- mapper ->
- mapper.softDeleteOwnerRelByOwnerIdAndType(
- groupId, Entity.EntityType.GROUP.name()));
- });
- return deletedGroup.get();
- }
-
@Monitored(
metricsSource = GRAVITINO_RELATIONAL_STORE_METRIC_NAME,
baseMetricName = "countGroupsByMetalake")
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/service/UserMetaService.java b/core/src/main/java/org/apache/gravitino/storage/relational/service/UserMetaService.java
index a4b088b4da..b4fce90d25 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/service/UserMetaService.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/service/UserMetaService.java
@@ -29,7 +29,6 @@ import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.gravitino.Entity;
@@ -361,186 +360,6 @@ public class UserMetaService {
return userDeletedCount[0] + userRoleRelDeletedCount[0];
}
- private UserPO getUserPOByMetalakeNameAndExternalId(String metalakeName, String externalId) {
- UserPO userPO =
- SessionUtils.getWithoutCommit(
- UserMetaMapper.class,
- mapper -> mapper.selectUserMetaByMetalakeNameAndExternalId(metalakeName, externalId));
-
- if (userPO == null) {
- throw new NoSuchEntityException(
- NoSuchEntityException.NO_SUCH_ENTITY_MESSAGE,
- Entity.EntityType.USER.name().toLowerCase(),
- externalId);
- }
- return userPO;
- }
-
- @Monitored(
- metricsSource = GRAVITINO_RELATIONAL_STORE_METRIC_NAME,
- baseMetricName = "getUserByExternalId")
- public UserEntity getUserByExternalId(NameIdentifier ident) {
- AuthorizationUtils.checkUserExternalId(ident);
- String metalake = ident.namespace().level(0);
- String externalId = ident.name();
- Namespace userNamespace = AuthorizationUtils.ofUserNamespace(metalake);
- UserPO userPO = getUserPOByMetalakeNameAndExternalId(metalake, externalId);
- List<RolePO> rolePOs = RoleMetaService.getInstance().listRolesByUserId(userPO.getUserId());
- return POConverters.fromUserPO(userPO, rolePOs, userNamespace);
- }
-
- @Monitored(
- metricsSource = GRAVITINO_RELATIONAL_STORE_METRIC_NAME,
- baseMetricName = "updateUserByExternalId")
- public <E extends Entity & HasIdentifier> UserEntity updateUserByExternalId(
- NameIdentifier ident, Function<E, E> updater) throws IOException {
- AuthorizationUtils.checkUserExternalId(ident);
- String metalake = ident.namespace().level(0);
- String externalId = ident.name();
- Namespace userNamespace = AuthorizationUtils.ofUserNamespace(metalake);
- UserPO oldUserPO = getUserPOByMetalakeNameAndExternalId(metalake, externalId);
- List<RolePO> rolePOs = RoleMetaService.getInstance().listRolesByUserId(oldUserPO.getUserId());
- UserEntity oldEntity = POConverters.fromUserPO(oldUserPO, rolePOs, userNamespace);
- UserEntity newEntity = (UserEntity) updater.apply((E) oldEntity);
- Preconditions.checkArgument(
- Objects.equals(oldEntity.id(), newEntity.id()),
- "The updated user entity id: %s should be same with the user entity id before: %s",
- newEntity.id(),
- oldEntity.id());
-
- try {
- SessionUtils.doMultipleWithCommit(
- () -> {
- int updated =
- SessionUtils.getWithoutCommit(
- UserMetaMapper.class,
- mapper ->
- mapper.updateUserMetaByExternalId(
- POConverters.updateUserPOWithVersion(oldUserPO, newEntity), oldUserPO));
- if (updated == 0) {
- throw userWriteFailure(ident, oldUserPO, UserLookup.EXTERNAL_ID);
- }
- },
- () ->
- SessionUtils.doWithoutCommit(
- UserMetaMapper.class,
- mapper -> mapper.touchUserUpdatedAt(oldUserPO.getUserId())));
- } catch (RuntimeException re) {
- ExceptionUtils.checkSQLException(
- re, Entity.EntityType.USER, newEntity.nameIdentifier().toString());
- throw re;
- }
- return newEntity;
- }
-
- private UserPO getUserPOByMetalakeNameAndId(String metalakeName, Long userId) {
- UserPO userPO =
- SessionUtils.getWithoutCommit(
- UserMetaMapper.class,
- mapper -> mapper.selectUserMetaByMetalakeNameAndId(metalakeName, userId));
-
- if (userPO == null) {
- throw new NoSuchEntityException(
- NoSuchEntityException.NO_SUCH_ENTITY_MESSAGE,
- Entity.EntityType.USER.name().toLowerCase(),
- String.valueOf(userId));
- }
- return userPO;
- }
-
- @Monitored(metricsSource = GRAVITINO_RELATIONAL_STORE_METRIC_NAME, baseMetricName = "getUserById")
- public UserEntity getUserById(String metalake, long userId) {
- Namespace userNamespace = AuthorizationUtils.ofUserNamespace(metalake);
- UserPO userPO = getUserPOByMetalakeNameAndId(metalake, userId);
- List<RolePO> rolePOs = RoleMetaService.getInstance().listRolesByUserId(userPO.getUserId());
- return POConverters.fromUserPO(userPO, rolePOs, userNamespace);
- }
-
- @Monitored(
- metricsSource = GRAVITINO_RELATIONAL_STORE_METRIC_NAME,
- baseMetricName = "updateUserById")
- public <E extends Entity & HasIdentifier> UserEntity updateUserById(
- String metalake, long userId, Function<E, E> updater) throws IOException {
- Namespace userNamespace = AuthorizationUtils.ofUserNamespace(metalake);
- UserPO oldUserPO = getUserPOByMetalakeNameAndId(metalake, userId);
- List<RolePO> rolePOs = RoleMetaService.getInstance().listRolesByUserId(oldUserPO.getUserId());
- UserEntity oldEntity = POConverters.fromUserPO(oldUserPO, rolePOs, userNamespace);
- UserEntity newEntity = (UserEntity) updater.apply((E) oldEntity);
- Preconditions.checkArgument(
- Objects.equals(oldEntity.id(), newEntity.id()),
- "The updated user entity id: %s should be same with the user entity id before: %s",
- newEntity.id(),
- oldEntity.id());
-
- try {
- SessionUtils.doMultipleWithCommit(
- () -> {
- int updated =
- SessionUtils.getWithoutCommit(
- UserMetaMapper.class,
- mapper ->
- mapper.updateUserMeta(
- POConverters.updateUserPOWithVersion(oldUserPO, newEntity), oldUserPO));
- if (updated == 0) {
- NameIdentifier userIdIdentifier =
- AuthorizationUtils.ofUser(metalake, String.valueOf(userId));
- throw userWriteFailure(userIdIdentifier, oldUserPO, UserLookup.ID);
- }
- },
- () ->
- SessionUtils.doWithoutCommit(
- UserMetaMapper.class,
- mapper -> mapper.touchUserUpdatedAt(oldUserPO.getUserId())));
- } catch (RuntimeException re) {
- ExceptionUtils.checkSQLException(
- re, Entity.EntityType.USER, newEntity.nameIdentifier().toString());
- throw re;
- }
- return newEntity;
- }
-
- @Monitored(
- metricsSource = GRAVITINO_RELATIONAL_STORE_METRIC_NAME,
- baseMetricName = "deleteUserById")
- public boolean deleteUserById(String metalake, long userId) {
- UserPO userPO;
- try {
- userPO = getUserPOByMetalakeNameAndId(metalake, userId);
- } catch (NoSuchEntityException e) {
- return false;
- }
- NameIdentifier identifier = AuthorizationUtils.ofUser(metalake, userPO.getUserName());
-
- // Starts false so that any path that does not reach the child cleanup reports "nothing was
- // deleted here" rather than claiming a delete it did not perform.
- AtomicBoolean deletedUser = new AtomicBoolean(false);
- SessionUtils.doMultipleWithCommit(
- () -> {
- int deleted =
- SessionUtils.getWithoutCommit(
- UserMetaMapper.class,
- mapper -> mapper.softDeleteUserMetaByUserId(userId, userPO.getCurrentVersion()));
- if (deleted == 0) {
- // The compare-and-set matched no row for one of two reasons. Either the row is already
- // gone, and a delete that has nothing left to delete is a no-op rather than an error,
- // or the row is still there under a newer version, which is a genuine conflict.
- if (getUserPOByIdForUpdate(userId) == null) {
- return;
- }
- throw ExceptionUtils.concurrentModification(Entity.EntityType.USER, identifier);
- }
-
- deletedUser.set(true);
- SessionUtils.doWithoutCommit(
- UserRoleRelMapper.class, mapper -> mapper.softDeleteUserRoleRelByUserId(userId));
- SessionUtils.doWithoutCommit(
- OwnerMetaMapper.class,
- mapper ->
- mapper.softDeleteOwnerRelByOwnerIdAndType(userId, Entity.EntityType.USER.name()));
- });
- return deletedUser.get();
- }
-
@Monitored(
metricsSource = GRAVITINO_RELATIONAL_STORE_METRIC_NAME,
baseMetricName = "countUsersByMetalake")
@@ -625,8 +444,7 @@ public class UserMetaService {
Objects.equals(current.getMetalakeId(), observedUserPO.getMetalakeId())
&& (lookup != UserLookup.NAME
|| Objects.equals(current.getUserName(), observedUserPO.getUserName()))
- && (lookup != UserLookup.EXTERNAL_ID
- || Objects.equals(current.getExternalId(), observedUserPO.getExternalId())));
+ && (lookup != UserLookup.EXTERNAL_ID));
}
private UserPO getUserPOByIdForUpdate(long userId) {
diff --git a/core/src/main/java/org/apache/gravitino/storage/relational/utils/POConverters.java b/core/src/main/java/org/apache/gravitino/storage/relational/utils/POConverters.java
index 1fec61c1d7..51f21421cf 100644
--- a/core/src/main/java/org/apache/gravitino/storage/relational/utils/POConverters.java
+++ b/core/src/main/java/org/apache/gravitino/storage/relational/utils/POConverters.java
@@ -944,8 +944,6 @@ public class POConverters {
return builder
.withUserId(userEntity.id())
.withUserName(userEntity.name())
- .withExternalId(userEntity.externalId())
- .withEnabled(userEntity.enabled())
.withAuditInfo(JsonUtils.anyFieldMapper().writeValueAsString(userEntity.auditInfo()))
.withCurrentVersion(INIT_VERSION)
.withLastVersion(INIT_VERSION)
@@ -970,8 +968,6 @@ public class POConverters {
.withUserId(oldUserPO.getUserId())
.withUserName(newUser.name())
.withMetalakeId(oldUserPO.getMetalakeId())
- .withExternalId(newUser.externalId())
- .withEnabled(newUser.enabled())
.withAuditInfo(JsonUtils.anyFieldMapper().writeValueAsString(newUser.auditInfo()))
.withCurrentVersion(nextVersion)
.withLastVersion(nextVersion)
@@ -1001,8 +997,6 @@ public class POConverters {
.withId(userPO.getUserId())
.withName(userPO.getUserName())
.withNamespace(namespace)
- .withExternalId(userPO.getExternalId())
- .withEnabled(userPO.getEnabled())
.withAuditInfo(
JsonUtils.anyFieldMapper().readValue(userPO.getAuditInfo(), AuditInfo.class));
if (!roleNames.isEmpty()) {
@@ -1031,8 +1025,6 @@ public class POConverters {
.withId(userPO.getUserId())
.withName(userPO.getUserName())
.withNamespace(namespace)
- .withExternalId(userPO.getExternalId())
- .withEnabled(userPO.getEnabled())
.withAuditInfo(
JsonUtils.anyFieldMapper().readValue(userPO.getAuditInfo(), AuditInfo.class));
if (StringUtils.isNotBlank(userPO.getRoleNames())) {
@@ -1089,7 +1081,6 @@ public class POConverters {
.withId(groupPO.getGroupId())
.withName(groupPO.getGroupName())
.withNamespace(namespace)
- .withExternalId(groupPO.getExternalId())
.withAuditInfo(
JsonUtils.anyFieldMapper().readValue(groupPO.getAuditInfo(), AuditInfo.class));
if (!roleNames.isEmpty()) {
@@ -1118,7 +1109,6 @@ public class POConverters {
.withId(groupPO.getGroupId())
.withName(groupPO.getGroupName())
.withNamespace(namespace)
- .withExternalId(groupPO.getExternalId())
.withAuditInfo(
JsonUtils.anyFieldMapper().readValue(groupPO.getAuditInfo(), AuditInfo.class));
@@ -1224,7 +1214,6 @@ public class POConverters {
return builder
.withGroupId(groupEntity.id())
.withGroupName(groupEntity.name())
- .withExternalId(groupEntity.externalId())
.withAuditInfo(JsonUtils.anyFieldMapper().writeValueAsString(groupEntity.auditInfo()))
.withCurrentVersion(INIT_VERSION)
.withLastVersion(INIT_VERSION)
@@ -1248,7 +1237,6 @@ public class POConverters {
return GroupPO.builder()
.withGroupId(oldGroupPO.getGroupId())
.withGroupName(newGroup.name())
- .withExternalId(newGroup.externalId())
.withMetalakeId(oldGroupPO.getMetalakeId())
.withAuditInfo(JsonUtils.anyFieldMapper().writeValueAsString(newGroup.auditInfo()))
.withCurrentVersion(nextVersion)
diff --git a/core/src/test/java/org/apache/gravitino/authorization/TestAccessControlManager.java b/core/src/test/java/org/apache/gravitino/authorization/TestAccessControlManager.java
index 14e14565ef..aeb49a5ad3 100644
--- a/core/src/test/java/org/apache/gravitino/authorization/TestAccessControlManager.java
+++ b/core/src/test/java/org/apache/gravitino/authorization/TestAccessControlManager.java
@@ -257,15 +257,13 @@ public class TestAccessControlManager {
accessControlManager.addUsers(
METALAKE,
Lists.newArrayList(
- new UserAdd("bulk_user_1", "bulk-user-ext-1", false),
- new UserAdd("bulk_user_2", null, null),
- new UserAdd("bulk_user_1", null, null)));
+ new UserAdd("bulk_user_1"),
+ new UserAdd("bulk_user_2"),
+ new UserAdd("bulk_user_1")));
Assertions.assertEquals(3, results.size());
Assertions.assertTrue(results.get(0).succeeded());
Assertions.assertEquals("bulk_user_1", results.get(0).value().get().name());
- Assertions.assertEquals("bulk-user-ext-1", results.get(0).value().get().externalId());
- Assertions.assertFalse(results.get(0).value().get().enabled());
Assertions.assertTrue(results.get(1).succeeded());
Assertions.assertFalse(results.get(2).succeeded());
Assertions.assertTrue(results.get(2).error().get() instanceof UserAlreadyExistsException);
@@ -307,14 +305,13 @@ public class TestAccessControlManager {
accessControlManager.addGroups(
METALAKE,
Lists.newArrayList(
- new GroupAdd("bulk_group_1", "bulk-group-ext-1"),
- new GroupAdd("bulk_group_2", null),
- new GroupAdd("bulk_group_1", null)));
+ new GroupAdd("bulk_group_1"),
+ new GroupAdd("bulk_group_2"),
+ new GroupAdd("bulk_group_1")));
Assertions.assertEquals(3, results.size());
Assertions.assertTrue(results.get(0).succeeded());
Assertions.assertEquals("bulk_group_1", results.get(0).value().get().name());
- Assertions.assertEquals("bulk-group-ext-1", results.get(0).value().get().externalId());
Assertions.assertTrue(results.get(1).succeeded());
Assertions.assertFalse(results.get(2).succeeded());
Assertions.assertTrue(results.get(2).error().get() instanceof GroupAlreadyExistsException);
@@ -562,167 +559,6 @@ public class TestAccessControlManager {
accessControlManager.deleteRole("metalake_list", "testList2");
}
- @Test
- public void testUserExtId() {
- accessControlManager.addUser(METALAKE, "disabled_user", "ext-disabled-user", false);
- accessControlManager.removeUser(METALAKE, "disabled_user");
-
- String user = "ext_user";
- String extId = "ext-user-1";
- User added = accessControlManager.addUser(METALAKE, user, extId, true);
- Assertions.assertEquals(extId, added.externalId());
- Assertions.assertTrue(added.enabled());
- long userId = added.id();
-
- createCatalogRole("ext_role");
- accessControlManager.grantRolesToUser(METALAKE, Lists.newArrayList("ext_role"), user);
- User disabled =
- accessControlManager.alterUserById(METALAKE, userId, UserChange.updateEnabled(false));
- Assertions.assertFalse(disabled.enabled());
- assertSortedRoles(disabled, "ext_role");
-
- createCatalogRole("ext_role2");
- accessControlManager.grantRolesToUser(METALAKE, Lists.newArrayList("ext_role2"), user);
- assertSortedRoles(accessControlManager.getUser(METALAKE, user), "ext_role", "ext_role2");
- Assertions.assertFalse(accessControlManager.getUserByExternalId(METALAKE, extId).enabled());
-
- User enabled =
- accessControlManager.alterUserById(METALAKE, userId, UserChange.updateEnabled(true));
- Assertions.assertTrue(enabled.enabled());
- assertSortedRoles(enabled, "ext_role", "ext_role2");
-
- accessControlManager.revokeRolesFromUser(
- METALAKE, Lists.newArrayList("ext_role", "ext_role2"), user);
- accessControlManager.deleteRole(METALAKE, "ext_role2");
- accessControlManager.deleteRole(METALAKE, "ext_role");
- accessControlManager.removeUser(METALAKE, user);
- }
-
- @Test
- public void testMissingExt() {
- assertInvalidExt(() -> accessControlManager.getUserByExternalId(METALAKE, null));
- assertInvalidExt(() -> accessControlManager.getUserByExternalId(METALAKE, ""));
- assertInvalidExt(() -> accessControlManager.getGroupByExternalId(METALAKE, null));
- assertInvalidExt(() -> accessControlManager.getGroupByExternalId(METALAKE, ""));
- assertMissingExt(
- NoSuchUserException.class,
- () -> accessControlManager.getUserByExternalId(METALAKE, "missing-ext-id"));
- assertMissingExt(
- NoSuchGroupException.class,
- () -> accessControlManager.getGroupByExternalId(METALAKE, "missing-ext-id"));
- Assertions.assertThrows(
- NoSuchUserException.class,
- () -> accessControlManager.alterUserById(METALAKE, -1L, UserChange.updateEnabled(false)));
- }
-
- @Test
- public void testExtDup() {
- accessControlManager.addUser(METALAKE, "u1", "dup-ext", true);
- assertThrowsExt(
- UserAlreadyExistsException.class,
- () -> accessControlManager.addUser(METALAKE, "u2", "dup-ext", true));
- accessControlManager.removeUser(METALAKE, "u1");
-
- accessControlManager.addGroup(METALAKE, "g1", "dup-ext");
- assertThrowsExt(
- GroupAlreadyExistsException.class,
- () -> accessControlManager.addGroup(METALAKE, "g2", "dup-ext"));
- accessControlManager.removeGroup(METALAKE, "g1");
- }
-
- @Test
- public void testUserExtDel() {
- String extId = "ext-remove-user";
- accessControlManager.addUser(METALAKE, "remove_user", extId, true);
- Assertions.assertTrue(accessControlManager.removeUserByExternalId(METALAKE, extId));
- assertMissingExt(
- NoSuchUserException.class, () -> accessControlManager.getUserByExternalId(METALAKE, extId));
- Assertions.assertThrows(
- NoSuchUserException.class, () -> accessControlManager.getUser(METALAKE, "remove_user"));
- Assertions.assertFalse(accessControlManager.removeUserByExternalId(METALAKE, "missing-ext-id"));
- }
-
- @Test
- public void testGroupExtDel() {
- String extId = "ext-remove-group";
- accessControlManager.addGroup(METALAKE, "remove_group", extId);
- Assertions.assertTrue(accessControlManager.removeGroupByExternalId(METALAKE, extId));
- assertMissingExt(
- NoSuchGroupException.class,
- () -> accessControlManager.getGroupByExternalId(METALAKE, extId));
- Assertions.assertThrows(
- NoSuchGroupException.class, () -> accessControlManager.getGroup(METALAKE, "remove_group"));
- Assertions.assertFalse(
- accessControlManager.removeGroupByExternalId(METALAKE, "missing-ext-id"));
- }
-
- @Test
- public void testUserById() {
- User added = accessControlManager.addUser(METALAKE, "id_user", "ext-id-user", true);
- long userId = added.id();
- Assertions.assertNotNull(userId);
-
- User loaded = accessControlManager.getUserById(METALAKE, userId);
- Assertions.assertEquals(userId, loaded.id());
- Assertions.assertEquals("id_user", loaded.name());
- Assertions.assertEquals("ext-id-user", loaded.externalId());
- Assertions.assertTrue(loaded.enabled());
-
- User disabled =
- accessControlManager.alterUserById(METALAKE, userId, UserChange.updateEnabled(false));
- Assertions.assertFalse(disabled.enabled());
- Assertions.assertEquals(userId, disabled.id());
- Assertions.assertEquals("ext-id-user", disabled.externalId());
- Assertions.assertEquals(added.auditInfo().creator(), disabled.auditInfo().creator());
- Assertions.assertEquals(added.auditInfo().createTime(), disabled.auditInfo().createTime());
- Assertions.assertNotNull(disabled.auditInfo().lastModifier());
- Assertions.assertNotNull(disabled.auditInfo().lastModifiedTime());
- Assertions.assertTrue(
- !disabled.auditInfo().lastModifiedTime().isBefore(added.auditInfo().createTime()));
-
- User enabledAndExt =
- accessControlManager.alterUserById(
- METALAKE,
- userId,
- UserChange.updateEnabled(true),
- UserChange.updateExternalId("ext-id-user-2"));
- Assertions.assertTrue(enabledAndExt.enabled());
- Assertions.assertEquals(userId, enabledAndExt.id());
- Assertions.assertEquals("ext-id-user-2", enabledAndExt.externalId());
- User byNewExt = accessControlManager.getUserByExternalId(METALAKE, "ext-id-user-2");
- Assertions.assertEquals("id_user", byNewExt.name());
- Assertions.assertEquals(userId, byNewExt.id());
-
- Assertions.assertTrue(accessControlManager.removeUserById(METALAKE, userId));
- Assertions.assertThrows(
- NoSuchUserException.class, () -> accessControlManager.getUserById(METALAKE, userId));
- Assertions.assertFalse(accessControlManager.removeUserById(METALAKE, userId));
- Assertions.assertThrows(
- NoSuchUserException.class,
- () -> accessControlManager.alterUserById(METALAKE, userId, UserChange.updateEnabled(true)));
- }
-
- @Test
- public void testExtCache() {
- String extId = "ext-cache-user";
- User added = accessControlManager.addUser(METALAKE, "cache_user", extId, true);
- accessControlManager.getUser(METALAKE, "cache_user");
- accessControlManager.alterUserById(METALAKE, added.id(), UserChange.updateEnabled(false));
- Assertions.assertFalse(accessControlManager.getUser(METALAKE, "cache_user").enabled());
- accessControlManager.removeUser(METALAKE, "cache_user");
- }
-
- @Test
- public void testGroupExtId() {
- String group = "ext_group";
- String extId = "ext-group-1";
- Group added = accessControlManager.addGroup(METALAKE, group, extId);
- Assertions.assertEquals(extId, added.externalId());
- Assertions.assertEquals(
- group, accessControlManager.getGroupByExternalId(METALAKE, extId).name());
- accessControlManager.removeGroup(METALAKE, group);
- }
-
@Test
public void testUserPagination() {
long beforeCount = accessControlManager.countUsers(METALAKE);
@@ -823,39 +659,4 @@ public class TestAccessControlManager {
!testProps.containsKey(StringIdentifier.ID_KEY)
|| HiddenPropertyMaskUtils.MASKED_VALUE.equals(testProps.get(StringIdentifier.ID_KEY)));
}
-
- @Test
- public void testGroupById() {
- Group added = accessControlManager.addGroup(METALAKE, "id_group", "ext-id-group");
- long groupId = added.id();
- Assertions.assertNotNull(groupId);
-
- Group loaded = accessControlManager.getGroupById(METALAKE, groupId);
- Assertions.assertEquals(groupId, loaded.id());
- Assertions.assertEquals("id_group", loaded.name());
- Assertions.assertEquals("ext-id-group", loaded.externalId());
-
- Group updated =
- accessControlManager.alterGroupById(
- METALAKE, groupId, GroupChange.updateExternalId("ext-id-group-2"));
- Assertions.assertEquals(groupId, updated.id());
- Assertions.assertEquals("ext-id-group-2", updated.externalId());
- Assertions.assertEquals(
- "id_group", accessControlManager.getGroupByExternalId(METALAKE, "ext-id-group-2").name());
-
- Assertions.assertThrows(
- NoSuchGroupException.class,
- () ->
- accessControlManager.alterGroupById(METALAKE, -1L, GroupChange.updateExternalId("x")));
-
- Assertions.assertTrue(accessControlManager.removeGroupById(METALAKE, groupId));
- Assertions.assertThrows(
- NoSuchGroupException.class, () -> accessControlManager.getGroupById(METALAKE, groupId));
- Assertions.assertFalse(accessControlManager.removeGroupById(METALAKE, groupId));
- Assertions.assertThrows(
- NoSuchGroupException.class,
- () ->
- accessControlManager.alterGroupById(
- METALAKE, groupId, GroupChange.updateExternalId("x")));
- }
}
diff --git a/core/src/test/java/org/apache/gravitino/authorization/TestAuthorizationUtils.java b/core/src/test/java/org/apache/gravitino/authorization/TestAuthorizationUtils.java
index 31d0368490..e568d6f825 100644
--- a/core/src/test/java/org/apache/gravitino/authorization/TestAuthorizationUtils.java
+++ b/core/src/test/java/org/apache/gravitino/authorization/TestAuthorizationUtils.java
@@ -58,8 +58,6 @@ class TestAuthorizationUtils {
NameIdentifier user = AuthorizationUtils.ofUser(metalake, "user");
NameIdentifier group = AuthorizationUtils.ofGroup(metalake, "group");
NameIdentifier role = AuthorizationUtils.ofRole(metalake, "role");
- NameIdentifier userExt = AuthorizationUtils.ofUserExternalId(metalake, "ext-1");
- NameIdentifier groupExt = AuthorizationUtils.ofGroupExternalId(metalake, "ext-1");
Assertions.assertEquals(AuthorizationUtils.ofUserNamespace(metalake), user.namespace());
Assertions.assertEquals("user", user.name());
@@ -67,23 +65,6 @@ class TestAuthorizationUtils {
Assertions.assertEquals("group", group.name());
Assertions.assertEquals(AuthorizationUtils.ofRoleNamespace(metalake), role.namespace());
Assertions.assertEquals("role", role.name());
- Assertions.assertEquals(
- AuthorizationUtils.ofUserExternalIdNamespace(metalake), userExt.namespace());
- Assertions.assertEquals("ext-1", userExt.name());
- Assertions.assertEquals(
- AuthorizationUtils.ofGroupExternalIdNamespace(metalake), groupExt.namespace());
- Assertions.assertEquals("ext-1", groupExt.name());
- Assertions.assertNotEquals(user, userExt);
- Assertions.assertNotEquals(group, groupExt);
- Assertions.assertNotEquals(AuthorizationUtils.ofUser(metalake, "ext-1"), userExt);
- assertInvalidExternalId(() -> AuthorizationUtils.ofUserExternalId(metalake, null));
- assertInvalidExternalId(() -> AuthorizationUtils.ofUserExternalId(metalake, ""));
- assertInvalidExternalId(() -> AuthorizationUtils.ofGroupExternalId(metalake, null));
- assertInvalidExternalId(() -> AuthorizationUtils.ofGroupExternalId(metalake, ""));
- }
-
- private void assertInvalidExternalId(org.junit.jupiter.api.function.Executable executable) {
- Assertions.assertThrows(IllegalNameIdentifierException.class, executable);
}
@Test
@@ -142,39 +123,25 @@ class TestAuthorizationUtils {
@Test
void testCheckNameIdentifier() {
NameIdentifier user = AuthorizationUtils.ofUser(metalake, "user");
- NameIdentifier userExternalId = AuthorizationUtils.ofUserExternalId(metalake, "ext-1");
NameIdentifier group = AuthorizationUtils.ofGroup(metalake, "group");
- NameIdentifier groupExternalId = AuthorizationUtils.ofGroupExternalId(metalake, "ext-1");
NameIdentifier role = AuthorizationUtils.ofRole(metalake, "role");
Assertions.assertDoesNotThrow(() -> AuthorizationUtils.checkUser(user));
- Assertions.assertDoesNotThrow(() -> AuthorizationUtils.checkUserExternalId(userExternalId));
Assertions.assertDoesNotThrow(() -> AuthorizationUtils.checkGroup(group));
- Assertions.assertDoesNotThrow(() -> AuthorizationUtils.checkGroupExternalId(groupExternalId));
Assertions.assertDoesNotThrow(() -> AuthorizationUtils.checkRole(role));
Assertions.assertThrows(
IllegalNameIdentifierException.class, () -> AuthorizationUtils.checkUser(null));
- Assertions.assertThrows(
- IllegalNameIdentifierException.class, () -> AuthorizationUtils.checkUserExternalId(null));
Assertions.assertThrows(
IllegalNameIdentifierException.class, () -> AuthorizationUtils.checkGroup(null));
- Assertions.assertThrows(
- IllegalNameIdentifierException.class, () -> AuthorizationUtils.checkGroupExternalId(null));
Assertions.assertThrows(
IllegalNameIdentifierException.class, () -> AuthorizationUtils.checkRole(null));
Assertions.assertThrows(
IllegalNameIdentifierException.class,
() -> AuthorizationUtils.checkUser(NameIdentifier.of("")));
- Assertions.assertThrows(
- IllegalNameIdentifierException.class,
- () -> AuthorizationUtils.checkUserExternalId(NameIdentifier.of("")));
Assertions.assertThrows(
IllegalNameIdentifierException.class,
() -> AuthorizationUtils.checkGroup(NameIdentifier.of("")));
- Assertions.assertThrows(
- IllegalNameIdentifierException.class,
- () -> AuthorizationUtils.checkGroupExternalId(NameIdentifier.of("")));
Assertions.assertThrows(
IllegalNameIdentifierException.class,
() -> AuthorizationUtils.checkRole(NameIdentifier.of("")));
@@ -183,43 +150,25 @@ class TestAuthorizationUtils {
@Test
void testCheckNamespace() {
Namespace userNamespace = AuthorizationUtils.ofUserNamespace(metalake);
- Namespace userExternalIdNamespace = AuthorizationUtils.ofUserExternalIdNamespace(metalake);
Namespace groupNamespace = AuthorizationUtils.ofGroupNamespace(metalake);
- Namespace groupExternalIdNamespace = AuthorizationUtils.ofGroupExternalIdNamespace(metalake);
Namespace roleNamespace = AuthorizationUtils.ofRoleNamespace(metalake);
Assertions.assertDoesNotThrow(() -> AuthorizationUtils.checkUserNamespace(userNamespace));
- Assertions.assertDoesNotThrow(
- () -> AuthorizationUtils.checkUserExternalIdNamespace(userExternalIdNamespace));
Assertions.assertDoesNotThrow(() -> AuthorizationUtils.checkGroupNamespace(groupNamespace));
- Assertions.assertDoesNotThrow(
- () -> AuthorizationUtils.checkGroupExternalIdNamespace(groupExternalIdNamespace));
Assertions.assertDoesNotThrow(() -> AuthorizationUtils.checkRoleNamespace(roleNamespace));
Assertions.assertThrows(
IllegalNamespaceException.class, () -> AuthorizationUtils.checkUserNamespace(null));
- Assertions.assertThrows(
- IllegalNamespaceException.class,
- () -> AuthorizationUtils.checkUserExternalIdNamespace(null));
Assertions.assertThrows(
IllegalNamespaceException.class, () -> AuthorizationUtils.checkGroupNamespace(null));
- Assertions.assertThrows(
- IllegalNamespaceException.class,
- () -> AuthorizationUtils.checkGroupExternalIdNamespace(null));
Assertions.assertThrows(
IllegalNamespaceException.class, () -> AuthorizationUtils.checkRoleNamespace(null));
Assertions.assertThrows(
IllegalNamespaceException.class,
() -> AuthorizationUtils.checkUserNamespace(Namespace.of("a", "b")));
- Assertions.assertThrows(
- IllegalNamespaceException.class,
- () -> AuthorizationUtils.checkUserExternalIdNamespace(Namespace.of("a", "b")));
Assertions.assertThrows(
IllegalNamespaceException.class,
() -> AuthorizationUtils.checkGroupNamespace(Namespace.of("a")));
- Assertions.assertThrows(
- IllegalNamespaceException.class,
- () -> AuthorizationUtils.checkGroupExternalIdNamespace(Namespace.of("a", "b")));
Assertions.assertThrows(
IllegalNamespaceException.class,
() -> AuthorizationUtils.checkRoleNamespace(Namespace.of("a", "b", "c", "d")));
diff --git a/core/src/test/java/org/apache/gravitino/listener/api/event/TestGroupEvent.java b/core/src/test/java/org/apache/gravitino/listener/api/event/TestGroupEvent.java
index 601928a94f..819eaf96c6 100644
--- a/core/src/test/java/org/apache/gravitino/listener/api/event/TestGroupEvent.java
+++ b/core/src/test/java/org/apache/gravitino/listener/api/event/TestGroupEvent.java
@@ -32,9 +32,7 @@ import java.util.Map;
import java.util.Optional;
import org.apache.gravitino.NameIdentifier;
import org.apache.gravitino.authorization.AccessControlDispatcher;
-import org.apache.gravitino.authorization.AuthorizationUtils;
import org.apache.gravitino.authorization.Group;
-import org.apache.gravitino.authorization.GroupChange;
import org.apache.gravitino.authorization.PagedResult;
import org.apache.gravitino.bulk.BulkItemResult;
import org.apache.gravitino.bulk.GroupAdd;
@@ -57,7 +55,6 @@ public class TestGroupEvent {
private static final String METALAKE = "demo_metalake";
private static final String INEXIST_METALAKE = "inexist_metalake";
- private static final String GROUP_EXT_ID = "ext-group-1";
private static final long GROUP_ID = 1L;
private AccessControlEventDispatcher dispatcher;
private AccessControlEventDispatcher failureDispatcher;
@@ -66,7 +63,6 @@ public class TestGroupEvent {
private String otherGroupName;
private String inExistGroupName;
private Group group;
- private Group externalIdGroup;
private Group otherGroup;
private NameIdentifier identifier;
private List<String> grantedRoles;
@@ -78,7 +74,6 @@ public class TestGroupEvent {
this.otherGroupName = "group_admin";
this.inExistGroupName = "group_not_exist";
this.group = getMockGroup(groupName, ImmutableList.of("test", "engineer"));
- this.externalIdGroup = getMockGroupWithExtId(groupName, GROUP_EXT_ID, group.roles());
this.otherGroup = getMockGroup(otherGroupName, null);
this.identifier = NameIdentifier.of(METALAKE);
this.grantedRoles = ImmutableList.of("test", "engineer");
@@ -631,26 +626,12 @@ public class TestGroupEvent {
Assertions.assertEquals(revokedRoles, revokeGroupRolesFailureEvent.roles());
}
- @Test
- void testAddGroupWithExternalIdEvent() {
- dispatcher.addGroup(METALAKE, groupName, GROUP_EXT_ID);
-
- PreEvent preEvent = dummyEventListener.popPreEvent();
- Assertions.assertEquals(AddGroupPreEvent.class, preEvent.getClass());
- Assertions.assertEquals(OperationType.ADD_GROUP, preEvent.operationType());
-
- Event event = dummyEventListener.popPostEvent();
- Assertions.assertEquals(AddGroupEvent.class, event.getClass());
- Assertions.assertEquals(OperationType.ADD_GROUP, event.operationType());
- }
-
@Test
void testBulkAddGroupsDispatchesPerGroupEvents() {
dummyEventListener.clear();
dispatcher.addGroups(
- METALAKE,
- Arrays.asList(new GroupAdd(groupName, GROUP_EXT_ID), new GroupAdd(otherGroupName, null)));
+ METALAKE, Arrays.asList(new GroupAdd(groupName), new GroupAdd(otherGroupName)));
Assertions.assertEquals(2, dummyEventListener.getPreEvents().size());
PreEvent firstPreEvent = dummyEventListener.getPreEvents().get(0);
@@ -677,33 +658,6 @@ public class TestGroupEvent {
Assertions.assertEquals(otherGroupName, ((AddGroupFailureEvent) secondEvent).groupName());
}
- @Test
- void testGetGroupByExternalIdEvent() {
- dispatcher.getGroupByExternalId(METALAKE, GROUP_EXT_ID);
-
- PreEvent preEvent = dummyEventListener.popPreEvent();
- Assertions.assertEquals(GetGroupByExternalIdPreEvent.class, preEvent.getClass());
- Assertions.assertEquals(
- AuthorizationUtils.ofGroupExternalId(METALAKE, GROUP_EXT_ID), preEvent.identifier());
-
- Event event = dummyEventListener.popPostEvent();
- Assertions.assertEquals(GetGroupByExternalIdEvent.class, event.getClass());
- Assertions.assertEquals(OperationType.GET_GROUP_BY_EXTERNAL_ID, event.operationType());
- }
-
- @Test
- void testRemoveGroupByExternalIdEvent() {
- dispatcher.removeGroupByExternalId(METALAKE, GROUP_EXT_ID);
-
- PreEvent preEvent = dummyEventListener.popPreEvent();
- Assertions.assertEquals(RemoveGroupByExternalIdPreEvent.class, preEvent.getClass());
- Assertions.assertEquals(OperationType.REMOVE_GROUP_BY_EXTERNAL_ID, preEvent.operationType());
-
- Event event = dummyEventListener.popPostEvent();
- Assertions.assertEquals(RemoveGroupByExternalIdEvent.class, event.getClass());
- Assertions.assertEquals(OperationType.REMOVE_GROUP_BY_EXTERNAL_ID, event.operationType());
- }
-
@Test
void testBulkRemoveGroupsDispatchesPerGroupEvents() {
dummyEventListener.clear();
@@ -736,83 +690,6 @@ public class TestGroupEvent {
Assertions.assertEquals(inExistGroupName, ((RemoveGroupFailureEvent) secondEvent).groupName());
}
- @Test
- void testGetGroupByExternalIdFailureEvent() {
- Assertions.assertThrowsExactly(
- GravitinoRuntimeException.class,
- () -> failureDispatcher.getGroupByExternalId(METALAKE, GROUP_EXT_ID));
-
- dummyEventListener.popPreEvent();
- Event event = dummyEventListener.popPostEvent();
- Assertions.assertEquals(GetGroupByExternalIdFailureEvent.class, event.getClass());
- Assertions.assertEquals(OperationType.GET_GROUP_BY_EXTERNAL_ID, event.operationType());
- }
-
- @Test
- void testGetGroupByIdEvent() {
- dispatcher.getGroupById(METALAKE, GROUP_ID);
-
- PreEvent preEvent = dummyEventListener.popPreEvent();
- Assertions.assertEquals(GetGroupByIdPreEvent.class, preEvent.getClass());
- Assertions.assertEquals(OperationType.GET_GROUP_BY_ID, preEvent.operationType());
- Assertions.assertEquals(GROUP_ID, ((GetGroupByIdPreEvent) preEvent).groupId());
-
- Event event = dummyEventListener.popPostEvent();
- Assertions.assertEquals(GetGroupByIdEvent.class, event.getClass());
- Assertions.assertEquals(OperationType.GET_GROUP_BY_ID, event.operationType());
- validateGroup(((GetGroupByIdEvent) event).loadedGroupInfo(), group);
- }
-
- @Test
- void testRemoveGroupByIdEvent() {
- dispatcher.removeGroupById(METALAKE, GROUP_ID);
-
- PreEvent preEvent = dummyEventListener.popPreEvent();
- Assertions.assertEquals(RemoveGroupByIdPreEvent.class, preEvent.getClass());
- Assertions.assertEquals(OperationType.REMOVE_GROUP_BY_ID, preEvent.operationType());
-
- Event event = dummyEventListener.popPostEvent();
- Assertions.assertEquals(RemoveGroupByIdEvent.class, event.getClass());
- Assertions.assertEquals(OperationType.REMOVE_GROUP_BY_ID, event.operationType());
- Assertions.assertTrue(((RemoveGroupByIdEvent) event).isExists());
- }
-
- @Test
- void testAlterGroupEvent() {
- GroupChange change = GroupChange.updateExternalId("ext-group-2");
- dispatcher.alterGroupById(METALAKE, GROUP_ID, change);
-
- PreEvent preEvent = dummyEventListener.popPreEvent();
- Assertions.assertEquals(AlterGroupPreEvent.class, preEvent.getClass());
- Assertions.assertEquals(OperationType.ALTER_GROUP, preEvent.operationType());
- AlterGroupPreEvent alterPreEvent = (AlterGroupPreEvent) preEvent;
- Assertions.assertEquals(GROUP_ID, alterPreEvent.groupId());
- Assertions.assertArrayEquals(new GroupChange[] {change}, alterPreEvent.changes());
-
- Event event = dummyEventListener.popPostEvent();
- Assertions.assertEquals(AlterGroupEvent.class, event.getClass());
- Assertions.assertEquals(OperationType.ALTER_GROUP, event.operationType());
- AlterGroupEvent alterEvent = (AlterGroupEvent) event;
- Assertions.assertArrayEquals(new GroupChange[] {change}, alterEvent.changes());
- validateGroup(alterEvent.updatedGroupInfo(), group);
- }
-
- @Test
- void testAlterGroupFailureEvent() {
- GroupChange change = GroupChange.updateExternalId("ext-group-2");
- Assertions.assertThrowsExactly(
- GravitinoRuntimeException.class,
- () -> failureDispatcher.alterGroupById(METALAKE, GROUP_ID, change));
-
- dummyEventListener.popPreEvent();
- Event event = dummyEventListener.popPostEvent();
- Assertions.assertEquals(AlterGroupFailureEvent.class, event.getClass());
- Assertions.assertEquals(OperationType.ALTER_GROUP, event.operationType());
- AlterGroupFailureEvent failureEvent = (AlterGroupFailureEvent) event;
- Assertions.assertEquals(GROUP_ID, failureEvent.groupId());
- Assertions.assertArrayEquals(new GroupChange[] {change}, failureEvent.changes());
- }
-
private Group getMockGroup(String name, List<String> roles) {
Group mockGroup = mock(Group.class);
when(mockGroup.id()).thenReturn(GROUP_ID);
@@ -822,21 +699,10 @@ public class TestGroupEvent {
return mockGroup;
}
- private Group getMockGroupWithExtId(String name, String externalId, List<String> roles) {
- Group mockGroup = mock(Group.class);
- when(mockGroup.id()).thenReturn(GROUP_ID);
- when(mockGroup.name()).thenReturn(name);
- when(mockGroup.externalId()).thenReturn(externalId);
- when(mockGroup.roles()).thenReturn(roles);
-
- return mockGroup;
- }
-
private AccessControlEventDispatcher mockGroupDispatcher() {
AccessControlEventDispatcher dispatcher = mock(AccessControlEventDispatcher.class);
when(dispatcher.addGroup(METALAKE, groupName)).thenReturn(group);
when(dispatcher.addGroup(METALAKE, otherGroupName)).thenReturn(otherGroup);
- when(dispatcher.addGroup(METALAKE, groupName, GROUP_EXT_ID)).thenReturn(externalIdGroup);
when(dispatcher.addGroups(eq(METALAKE), any()))
.thenReturn(
Arrays.asList(
@@ -852,8 +718,6 @@ public class TestGroupEvent {
BulkItemResult.success(0, groupName),
BulkItemResult.failure(
1, inExistGroupName, new NoSuchGroupException("group not found"))));
- when(dispatcher.removeGroupByExternalId(METALAKE, GROUP_EXT_ID)).thenReturn(true);
- when(dispatcher.removeGroupById(METALAKE, GROUP_ID)).thenReturn(true);
when(dispatcher.listGroups(METALAKE)).thenReturn(new Group[] {group, otherGroup});
when(dispatcher.listGroups(eq(METALAKE), eq(0), eq(10)))
@@ -862,10 +726,6 @@ public class TestGroupEvent {
when(dispatcher.listGroupNames(METALAKE)).thenReturn(new String[] {groupName, otherGroupName});
when(dispatcher.getGroup(METALAKE, groupName)).thenReturn(group);
- when(dispatcher.getGroupByExternalId(METALAKE, GROUP_EXT_ID)).thenReturn(externalIdGroup);
- when(dispatcher.getGroupById(METALAKE, GROUP_ID)).thenReturn(group);
- when(dispatcher.alterGroupById(eq(METALAKE), eq(GROUP_ID), any(GroupChange[].class)))
- .thenReturn(group);
when(dispatcher.getGroup(METALAKE, inExistGroupName))
.thenThrow(new NoSuchGroupException("group not found"));
when(dispatcher.getGroup(INEXIST_METALAKE, groupName))
@@ -888,7 +748,6 @@ public class TestGroupEvent {
private void validateGroup(GroupInfo groupInfo, Group group) {
Assertions.assertEquals(group.id(), groupInfo.id());
Assertions.assertEquals(group.name(), groupInfo.name());
- Assertions.assertEquals(Optional.ofNullable(group.externalId()), groupInfo.externalId());
Assertions.assertEquals(group.roles(), groupInfo.roles());
}
}
diff --git a/core/src/test/java/org/apache/gravitino/listener/api/event/TestUserEvent.java b/core/src/test/java/org/apache/gravitino/listener/api/event/TestUserEvent.java
index 8845a36bf5..e778eda09a 100644
--- a/core/src/test/java/org/apache/gravitino/listener/api/event/TestUserEvent.java
+++ b/core/src/test/java/org/apache/gravitino/listener/api/event/TestUserEvent.java
@@ -30,10 +30,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.apache.gravitino.NameIdentifier;
-import org.apache.gravitino.authorization.AuthorizationUtils;
import org.apache.gravitino.authorization.PagedResult;
import org.apache.gravitino.authorization.User;
-import org.apache.gravitino.authorization.UserChange;
import org.apache.gravitino.bulk.BulkItemResult;
import org.apache.gravitino.bulk.UserAdd;
import org.apache.gravitino.exceptions.GravitinoRuntimeException;
@@ -53,8 +51,6 @@ import org.junit.jupiter.api.TestInstance;
public class TestUserEvent {
private static final String METALAKE = "demo_metalake";
private static final String INEXIST_METALAKE = "inexist_metalake";
- private static final String USER_EXT_ID = "ext-user-1";
- private static final long USER_ID = 1L;
private AccessControlEventDispatcher dispatcher;
private AccessControlEventDispatcher failureDispatcher;
private DummyEventListener dummyEventListener;
@@ -62,7 +58,6 @@ public class TestUserEvent {
private String otherUserName;
private String inExistUserName;
private User user;
- private User externalIdUser;
private User otherUser;
private NameIdentifier identifier;
private NameIdentifier otherIdentifier;
@@ -76,7 +71,6 @@ public class TestUserEvent {
this.otherUserName = "user_admin";
this.inExistUserName = "user_not_exist";
this.user = getMockUser(userName, ImmutableList.of("test", "engineer"));
- this.externalIdUser = getMockUserWithExtId(userName, USER_EXT_ID, true, user.roles());
this.otherUser = getMockUser(otherUserName, null);
this.identifier = NameIdentifierUtil.ofUser(METALAKE, userName);
this.otherIdentifier = NameIdentifierUtil.ofUser(METALAKE, otherUserName);
@@ -98,7 +92,6 @@ public class TestUserEvent {
Assertions.assertEquals(1L, info.id());
Assertions.assertEquals("mock_user", info.name());
- Assertions.assertEquals(Optional.empty(), info.externalId());
Assertions.assertEquals(ImmutableList.of("admin"), info.roles());
}
@@ -570,27 +563,11 @@ public class TestUserEvent {
Assertions.assertEquals(revokedRoles, revokeUserRolesFailureEvent.roles());
}
- @Test
- void testAddUserWithExternalIdEvent() {
- dispatcher.addUser(METALAKE, userName, USER_EXT_ID, true);
-
- PreEvent preEvent = dummyEventListener.popPreEvent();
- Assertions.assertEquals(AddUserPreEvent.class, preEvent.getClass());
- Assertions.assertEquals(OperationType.ADD_USER, preEvent.operationType());
-
- Event event = dummyEventListener.popPostEvent();
- Assertions.assertEquals(AddUserEvent.class, event.getClass());
- Assertions.assertEquals(OperationType.ADD_USER, event.operationType());
- }
-
@Test
void testBulkAddUsersDispatchesPerUserEvents() {
dummyEventListener.clear();
- dispatcher.addUsers(
- METALAKE,
- Arrays.asList(
- new UserAdd(userName, USER_EXT_ID, true), new UserAdd(otherUserName, null, null)));
+ dispatcher.addUsers(METALAKE, Arrays.asList(new UserAdd(userName), new UserAdd(otherUserName)));
Assertions.assertEquals(2, dummyEventListener.getPreEvents().size());
PreEvent firstPreEvent = dummyEventListener.getPreEvents().get(0);
@@ -614,33 +591,6 @@ public class TestUserEvent {
Assertions.assertEquals(otherUserName, ((AddUserFailureEvent) secondEvent).userName());
}
- @Test
- void testGetUserByExternalIdEvent() {
- dispatcher.getUserByExternalId(METALAKE, USER_EXT_ID);
-
- PreEvent preEvent = dummyEventListener.popPreEvent();
- Assertions.assertEquals(GetUserByExternalIdPreEvent.class, preEvent.getClass());
- Assertions.assertEquals(
- AuthorizationUtils.ofUserExternalId(METALAKE, USER_EXT_ID), preEvent.identifier());
-
- Event event = dummyEventListener.popPostEvent();
- Assertions.assertEquals(GetUserByExternalIdEvent.class, event.getClass());
- Assertions.assertEquals(OperationType.GET_USER_BY_EXTERNAL_ID, event.operationType());
- }
-
- @Test
- void testRemoveUserByExternalIdEvent() {
- dispatcher.removeUserByExternalId(METALAKE, USER_EXT_ID);
-
- PreEvent preEvent = dummyEventListener.popPreEvent();
- Assertions.assertEquals(RemoveUserByExternalIdPreEvent.class, preEvent.getClass());
- Assertions.assertEquals(OperationType.REMOVE_USER_BY_EXTERNAL_ID, preEvent.operationType());
-
- Event event = dummyEventListener.popPostEvent();
- Assertions.assertEquals(RemoveUserByExternalIdEvent.class, event.getClass());
- Assertions.assertEquals(OperationType.REMOVE_USER_BY_EXTERNAL_ID, event.operationType());
- }
-
@Test
void testBulkRemoveUsersDispatchesPerUserEvents() {
dummyEventListener.clear();
@@ -670,105 +620,10 @@ public class TestUserEvent {
Assertions.assertEquals(inExistUserName, ((RemoveUserFailureEvent) secondEvent).userName());
}
- @Test
- void testGetUserByExternalIdFailureEvent() {
- Assertions.assertThrowsExactly(
- GravitinoRuntimeException.class,
- () -> failureDispatcher.getUserByExternalId(METALAKE, USER_EXT_ID));
-
- dummyEventListener.popPreEvent();
- Event event = dummyEventListener.popPostEvent();
- Assertions.assertEquals(GetUserByExternalIdFailureEvent.class, event.getClass());
- Assertions.assertEquals(OperationType.GET_USER_BY_EXTERNAL_ID, event.operationType());
- }
-
- @Test
- void testGetUserByIdEvent() {
- dispatcher.getUserById(METALAKE, USER_ID);
-
- PreEvent preEvent = dummyEventListener.popPreEvent();
- Assertions.assertEquals(GetUserByIdPreEvent.class, preEvent.getClass());
- Assertions.assertEquals(OperationType.GET_USER_BY_ID, preEvent.operationType());
- Assertions.assertEquals(USER_ID, ((GetUserByIdPreEvent) preEvent).userId());
- Assertions.assertEquals(AuthorizationUtils.ofUserId(METALAKE, USER_ID), preEvent.identifier());
-
- Event event = dummyEventListener.popPostEvent();
- Assertions.assertEquals(GetUserByIdEvent.class, event.getClass());
- Assertions.assertEquals(OperationType.GET_USER_BY_ID, event.operationType());
- validateUserInfo(((GetUserByIdEvent) event).loadedUserInfo(), user);
- }
-
- @Test
- void testGetUserByIdFailureEvent() {
- Assertions.assertThrowsExactly(
- GravitinoRuntimeException.class, () -> failureDispatcher.getUserById(METALAKE, USER_ID));
-
- dummyEventListener.popPreEvent();
- Event event = dummyEventListener.popPostEvent();
- Assertions.assertEquals(GetUserByIdFailureEvent.class, event.getClass());
- Assertions.assertEquals(OperationType.GET_USER_BY_ID, event.operationType());
- Assertions.assertEquals(USER_ID, ((GetUserByIdFailureEvent) event).userId());
- }
-
- @Test
- void testRemoveUserByIdEvent() {
- dispatcher.removeUserById(METALAKE, USER_ID);
-
- PreEvent preEvent = dummyEventListener.popPreEvent();
- Assertions.assertEquals(RemoveUserByIdPreEvent.class, preEvent.getClass());
- Assertions.assertEquals(OperationType.REMOVE_USER_BY_ID, preEvent.operationType());
- Assertions.assertEquals(USER_ID, ((RemoveUserByIdPreEvent) preEvent).userId());
-
- Event event = dummyEventListener.popPostEvent();
- Assertions.assertEquals(RemoveUserByIdEvent.class, event.getClass());
- Assertions.assertEquals(OperationType.REMOVE_USER_BY_ID, event.operationType());
- Assertions.assertTrue(((RemoveUserByIdEvent) event).isExists());
- }
-
- @Test
- void testAlterUserEvent() {
- UserChange[] changes =
- new UserChange[] {
- UserChange.updateEnabled(false), UserChange.updateExternalId("ext-user-2")
- };
- dispatcher.alterUserById(METALAKE, USER_ID, changes);
-
- PreEvent preEvent = dummyEventListener.popPreEvent();
- Assertions.assertEquals(AlterUserPreEvent.class, preEvent.getClass());
- Assertions.assertEquals(OperationType.ALTER_USER, preEvent.operationType());
- AlterUserPreEvent alterPreEvent = (AlterUserPreEvent) preEvent;
- Assertions.assertEquals(USER_ID, alterPreEvent.userId());
- Assertions.assertArrayEquals(changes, alterPreEvent.changes());
-
- Event event = dummyEventListener.popPostEvent();
- Assertions.assertEquals(AlterUserEvent.class, event.getClass());
- Assertions.assertEquals(OperationType.ALTER_USER, event.operationType());
- AlterUserEvent alterEvent = (AlterUserEvent) event;
- Assertions.assertArrayEquals(changes, alterEvent.changes());
- validateUserInfo(alterEvent.updatedUserInfo(), user);
- }
-
- @Test
- void testAlterUserFailureEvent() {
- UserChange change = UserChange.updateEnabled(true);
- Assertions.assertThrowsExactly(
- GravitinoRuntimeException.class,
- () -> failureDispatcher.alterUserById(METALAKE, USER_ID, change));
-
- dummyEventListener.popPreEvent();
- Event event = dummyEventListener.popPostEvent();
- Assertions.assertEquals(AlterUserFailureEvent.class, event.getClass());
- Assertions.assertEquals(OperationType.ALTER_USER, event.operationType());
- AlterUserFailureEvent failureEvent = (AlterUserFailureEvent) event;
- Assertions.assertEquals(USER_ID, failureEvent.userId());
- Assertions.assertArrayEquals(new UserChange[] {change}, failureEvent.changes());
- }
-
private AccessControlEventDispatcher mockUserDispatcher() {
AccessControlEventDispatcher dispatcher = mock(AccessControlEventDispatcher.class);
when(dispatcher.addUser(METALAKE, userName)).thenReturn(user);
when(dispatcher.addUser(METALAKE, otherUserName)).thenReturn(otherUser);
- when(dispatcher.addUser(METALAKE, userName, USER_EXT_ID, true)).thenReturn(externalIdUser);
when(dispatcher.addUsers(eq(METALAKE), any()))
.thenReturn(
Arrays.asList(
@@ -778,7 +633,6 @@ public class TestUserEvent {
when(dispatcher.removeUser(METALAKE, userName)).thenReturn(true);
when(dispatcher.removeUser(METALAKE, inExistUserName)).thenReturn(false);
- when(dispatcher.removeUserByExternalId(METALAKE, USER_EXT_ID)).thenReturn(true);
when(dispatcher.removeUsers(eq(METALAKE), any(), any()))
.thenReturn(
Arrays.asList(
@@ -793,11 +647,6 @@ public class TestUserEvent {
when(dispatcher.listUserNames(METALAKE)).thenReturn(new String[] {userName, otherUserName});
when(dispatcher.getUser(METALAKE, userName)).thenReturn(user);
- when(dispatcher.getUserByExternalId(METALAKE, USER_EXT_ID)).thenReturn(externalIdUser);
- when(dispatcher.getUserById(METALAKE, USER_ID)).thenReturn(user);
- when(dispatcher.removeUserById(METALAKE, USER_ID)).thenReturn(true);
- when(dispatcher.alterUserById(eq(METALAKE), eq(USER_ID), any(UserChange[].class)))
- .thenReturn(user);
when(dispatcher.getUser(METALAKE, inExistUserName))
.thenThrow(new NoSuchUserException("user not found"));
when(dispatcher.getUser(INEXIST_METALAKE, userName))
@@ -826,22 +675,9 @@ public class TestUserEvent {
return user;
}
- private User getMockUserWithExtId(
- String name, String externalId, boolean enabled, List<String> roles) {
- User user = mock(User.class);
- when(user.id()).thenReturn(1L);
- when(user.name()).thenReturn(name);
- when(user.externalId()).thenReturn(externalId);
- when(user.enabled()).thenReturn(enabled);
- when(user.roles()).thenReturn(roles);
-
- return user;
- }
-
private void validateUserInfo(UserInfo userInfo, User expectedUser) {
Assertions.assertEquals(expectedUser.id(), userInfo.id());
Assertions.assertEquals(userInfo.name(), expectedUser.name());
- Assertions.assertEquals(Optional.ofNullable(expectedUser.externalId()), userInfo.externalId());
Assertions.assertEquals(userInfo.roles(), expectedUser.roles());
}
}
diff --git a/core/src/test/java/org/apache/gravitino/storage/memory/TestMemoryEntityStore.java b/core/src/test/java/org/apache/gravitino/storage/memory/TestMemoryEntityStore.java
index f23b8655b7..59c8ebbd51 100644
--- a/core/src/test/java/org/apache/gravitino/storage/memory/TestMemoryEntityStore.java
+++ b/core/src/test/java/org/apache/gravitino/storage/memory/TestMemoryEntityStore.java
@@ -41,8 +41,6 @@ import org.apache.gravitino.HasIdentifier;
import org.apache.gravitino.Metalake;
import org.apache.gravitino.NameIdentifier;
import org.apache.gravitino.Namespace;
-import org.apache.gravitino.SupportsExternalIdOperations;
-import org.apache.gravitino.SupportsIdOperations;
import org.apache.gravitino.TestCatalog;
import org.apache.gravitino.authorization.AuthorizationUtils;
import org.apache.gravitino.authorization.Privileges;
@@ -67,8 +65,7 @@ import org.mockito.Mockito;
public class TestMemoryEntityStore {
- public static class InMemoryEntityStore
- implements EntityStore, SupportsExternalIdOperations, SupportsIdOperations {
+ public static class InMemoryEntityStore implements EntityStore {
private final Map<NameIdentifier, Entity> entityMap;
private final Lock lock;
@@ -151,158 +148,6 @@ public class TestMemoryEntityStore {
return e;
}
- @Override
- public SupportsExternalIdOperations externalIdOperations() {
- return this;
- }
-
- @Override
- public SupportsIdOperations idOperations() {
- return this;
- }
-
- @Override
- public <E extends Entity & HasIdentifier> E getByExternalId(
- NameIdentifier ident, EntityType entityType, Class<E> type)
- throws NoSuchEntityException, IOException {
- if (entityType != EntityType.USER && entityType != EntityType.GROUP) {
- throw new UnsupportedOperationException(
- "Get by external id is not supported for entity type: " + entityType);
- }
-
- String externalId;
- Namespace entityNamespace;
- if (entityType == EntityType.USER) {
- AuthorizationUtils.checkUserExternalId(ident);
- externalId = ident.name();
- entityNamespace = AuthorizationUtils.ofUserNamespace(ident.namespace().level(0));
- } else {
- AuthorizationUtils.checkGroupExternalId(ident);
- externalId = ident.name();
- entityNamespace = AuthorizationUtils.ofGroupNamespace(ident.namespace().level(0));
- }
-
- for (Map.Entry<NameIdentifier, Entity> entry : entityMap.entrySet()) {
- Entity entity = entry.getValue();
- if (!entity.type().equals(entityType)
- || !entry.getKey().namespace().equals(entityNamespace)) {
- continue;
- }
-
- String entityExternalId = null;
- if (entity instanceof UserEntity userEntity) {
- entityExternalId = userEntity.externalId();
- } else if (entity instanceof GroupEntity groupEntity) {
- entityExternalId = groupEntity.externalId();
- }
-
- if (externalId.equals(entityExternalId)) {
- return (E) entity;
- }
- }
-
- throw new NoSuchEntityException(
- NoSuchEntityException.NO_SUCH_ENTITY_MESSAGE,
- entityType.name().toLowerCase(),
- externalId);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <E extends Entity & HasIdentifier> E updateByExternalId(
- NameIdentifier ident, EntityType entityType, Class<E> type, Function<E, E> updater)
- throws NoSuchEntityException, IOException {
- E entity = getByExternalId(ident, entityType, type);
- E updated = updater.apply(entity);
- return update(entity.nameIdentifier(), type, entityType, e -> updated);
- }
-
- @Override
- public boolean deleteByExternalId(NameIdentifier ident, EntityType entityType)
- throws IOException {
- try {
- if (entityType == EntityType.USER) {
- UserEntity user = getByExternalId(ident, entityType, UserEntity.class);
- return delete(user.nameIdentifier(), entityType);
- } else if (entityType == EntityType.GROUP) {
- GroupEntity group = getByExternalId(ident, entityType, GroupEntity.class);
- return delete(group.nameIdentifier(), entityType);
- }
- throw new UnsupportedOperationException(
- "Delete by external id is not supported for entity type: " + entityType);
- } catch (NoSuchEntityException e) {
- return false;
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <E extends Entity & HasIdentifier> E getById(
- NameIdentifier ident, EntityType entityType, Class<E> type)
- throws NoSuchEntityException, IOException {
- if (entityType != EntityType.USER && entityType != EntityType.GROUP) {
- throw new UnsupportedOperationException(
- "Get by id is not supported for entity type: " + entityType);
- }
-
- long entityId;
- Namespace entityNamespace;
- if (entityType == EntityType.USER) {
- AuthorizationUtils.checkUserId(ident);
- entityId = Long.parseLong(ident.name());
- entityNamespace = AuthorizationUtils.ofUserNamespace(ident.namespace().level(0));
- } else {
- AuthorizationUtils.checkGroupId(ident);
- entityId = Long.parseLong(ident.name());
- entityNamespace = AuthorizationUtils.ofGroupNamespace(ident.namespace().level(0));
- }
-
- for (Map.Entry<NameIdentifier, Entity> entry : entityMap.entrySet()) {
- Entity entity = entry.getValue();
- if (!entity.type().equals(entityType)
- || !entry.getKey().namespace().equals(entityNamespace)) {
- continue;
- }
-
- if (entity instanceof HasIdentifier hasIdentifier
- && java.util.Objects.equals(hasIdentifier.id(), entityId)) {
- return (E) entity;
- }
- }
-
- throw new NoSuchEntityException(
- NoSuchEntityException.NO_SUCH_ENTITY_MESSAGE,
- entityType.name().toLowerCase(),
- String.valueOf(entityId));
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <E extends Entity & HasIdentifier> E updateById(
- NameIdentifier ident, EntityType entityType, Class<E> type, Function<E, E> updater)
- throws NoSuchEntityException, IOException {
- E entity = getById(ident, entityType, type);
- E updated = updater.apply(entity);
- return update(entity.nameIdentifier(), type, entityType, e -> updated);
- }
-
- @Override
- public boolean deleteById(NameIdentifier ident, EntityType entityType) throws IOException {
- try {
- if (entityType == EntityType.USER) {
- UserEntity user = getById(ident, entityType, UserEntity.class);
- return delete(user.nameIdentifier(), entityType);
- } else if (entityType == EntityType.GROUP) {
- GroupEntity group = getById(ident, entityType, GroupEntity.class);
- return delete(group.nameIdentifier(), entityType);
- }
- throw new UnsupportedOperationException(
- "Delete by id is not supported for entity type: " + entityType);
- } catch (NoSuchEntityException e) {
- return false;
- }
- }
-
@Override
public <E extends Entity & HasIdentifier> List<E> batchGet(
List<NameIdentifier> idents, EntityType entityType, Class<E> e) {
diff --git a/core/src/test/java/org/apache/gravitino/storage/relational/mapper/provider/base/TestAuthMappers.java b/core/src/test/java/org/apache/gravitino/storage/relational/mapper/provider/base/TestAuthMappers.java
index 39aa1e3f02..79995003a8 100644
--- a/core/src/test/java/org/apache/gravitino/storage/relational/mapper/provider/base/TestAuthMappers.java
+++ b/core/src/test/java/org/apache/gravitino/storage/relational/mapper/provider/base/TestAuthMappers.java
@@ -444,7 +444,6 @@ public class TestAuthMappers {
.withUserId(userId)
.withUserName(userName)
.withMetalakeId(metalakeId)
- .withEnabled(true)
.withAuditInfo(auditInfo.toString())
.withCurrentVersion(1L)
.withLastVersion(0L)
diff --git a/core/src/test/java/org/apache/gravitino/storage/relational/mapper/provider/base/TestUserRoleRelMapper.java b/core/src/test/java/org/apache/gravitino/storage/relational/mapper/provider/base/TestUserRoleRelMapper.java
index 1c99ea8e89..38e9b044cc 100644
--- a/core/src/test/java/org/apache/gravitino/storage/relational/mapper/provider/base/TestUserRoleRelMapper.java
+++ b/core/src/test/java/org/apache/gravitino/storage/relational/mapper/provider/base/TestUserRoleRelMapper.java
@@ -166,7 +166,6 @@ public class TestUserRoleRelMapper {
.withUserId(1L)
.withUserName("user1")
.withMetalakeId(1L)
- .withEnabled(true)
.withAuditInfo(auditInfo.toString())
.withCurrentVersion(1L)
.withLastVersion(0L)
diff --git a/core/src/test/java/org/apache/gravitino/storage/relational/mapper/provider/h2/TestGroupMetaH2Provider.java b/core/src/test/java/org/apache/gravitino/storage/relational/mapper/provider/h2/TestGroupMetaH2Provider.java
index 06da33b3e6..69cbb2e248 100644
--- a/core/src/test/java/org/apache/gravitino/storage/relational/mapper/provider/h2/TestGroupMetaH2Provider.java
+++ b/core/src/test/java/org/apache/gravitino/storage/relational/mapper/provider/h2/TestGroupMetaH2Provider.java
@@ -57,7 +57,6 @@ class TestGroupMetaH2Provider {
+ "group_id BIGINT, "
+ "group_name VARCHAR(255), "
+ "metalake_id BIGINT, "
- + "external_id VARCHAR(256), "
+ "audit_info VARCHAR(255), "
+ "current_version BIGINT, "
+ "last_version BIGINT, "
@@ -76,7 +75,7 @@ class TestGroupMetaH2Provider {
@Test
void testListExtendedGroupPOsByMetalakeIdWithoutRoles() throws SQLException {
- statement.execute("INSERT INTO group_meta VALUES (1, 'g1', 1, null, 'audit', 0, 0, 0)");
+ statement.execute("INSERT INTO group_meta VALUES (1, 'g1', 1, 'audit', 0, 0, 0)");
String sql =
groupMetaH2Provider
.listExtendedGroupPOsByMetalakeId(1L)
@@ -90,7 +89,7 @@ class TestGroupMetaH2Provider {
@Test
void testListExtendedGroupPOsByMetalakeIdWithRoles() throws SQLException {
- statement.execute("INSERT INTO group_meta VALUES (2, 'g2', 2, null, 'audit2', 0, 0, 0)");
+ statement.execute("INSERT INTO group_meta VALUES (2, 'g2', 2, 'audit2', 0, 0, 0)");
statement.execute("INSERT INTO role_meta VALUES (1, 'role1', 0)");
statement.execute("INSERT INTO role_meta VALUES (2, 'role2', 0)");
statement.execute("INSERT INTO group_role_rel VALUES (2, 1, 0)");
@@ -109,7 +108,7 @@ class TestGroupMetaH2Provider {
@Test
void testListExtendedGroupPOsByMetalakeIdWithInvalidRoles() throws SQLException {
- statement.execute("INSERT INTO group_meta VALUES (3, 'g3', 3, null, 'audit3', 0, 0, 0)");
+ statement.execute("INSERT INTO group_meta VALUES (3, 'g3', 3, 'audit3', 0, 0, 0)");
statement.execute("INSERT INTO role_meta VALUES (3, 'role3', 0)");
statement.execute("INSERT INTO role_meta VALUES (4, '', 0)");
statement.execute("INSERT INTO role_meta VALUES (5, null, 0)");
diff --git a/core/src/test/java/org/apache/gravitino/storage/relational/service/TestGroupMetaService.java b/core/src/test/java/org/apache/gravitino/storage/relational/service/TestGroupMetaService.java
index 90f850c709..c08b4ecc82 100644
--- a/core/src/test/java/org/apache/gravitino/storage/relational/service/TestGroupMetaService.java
+++ b/core/src/test/java/org/apache/gravitino/storage/relational/service/TestGroupMetaService.java
@@ -39,7 +39,6 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.gravitino.Entity;
import org.apache.gravitino.EntityAlreadyExistsException;
-import org.apache.gravitino.NameIdentifier;
import org.apache.gravitino.Namespace;
import org.apache.gravitino.authorization.AuthorizationUtils;
import org.apache.gravitino.authorization.PagedResult;
@@ -1072,20 +1071,6 @@ class TestGroupMetaService extends TestJDBCBackend {
GroupMetaMapper.class, mapper -> mapper.getGroupUpdatedAt(metalakeName, groupName));
}
- @TestTemplate
- void testGroupExtId() throws IOException {
- GroupMetaService svc = groupMetaService();
- svc.insertGroup(groupWithExtId("g1", "ext-1"), false);
- GroupEntity found = svc.getGroupByExternalId(groupExtIdent("ext-1"));
- Assertions.assertEquals("g1", found.name());
- Assertions.assertEquals("ext-1", found.externalId());
- assertThrowsExt(
- NoSuchEntityException.class,
- () -> svc.getGroupByExternalId(groupExtIdent("missing-ext-id")));
- assertThrowsExt(
- IllegalArgumentException.class, () -> svc.getGroupByExternalId(groupExtIdent("")));
- }
-
@TestTemplate
void testConcurrentUpdateDoesNotChangeRolesOnConflict() throws IOException {
createAndInsertMakeLake(metalakeName);
@@ -1132,7 +1117,6 @@ class TestGroupMetaService extends TestJDBCBackend {
.withId(oldGroup.id())
.withName(oldGroup.name())
.withNamespace(oldGroup.namespace())
- .withExternalId(oldGroup.externalId())
.withRoleNames(roleNames)
.withRoleIds(roleIds)
.withAuditInfo(oldGroup.auditInfo())
@@ -1144,21 +1128,17 @@ class TestGroupMetaService extends TestJDBCBackend {
assertEquals(Sets.newHashSet(role1.id()), Sets.newHashSet(storedGroup.roleIds()));
}
- @TestTemplate
- void testExtDup() throws IOException {
- GroupMetaService svc = groupMetaService();
- svc.insertGroup(groupWithExtId("g1", "ext-1"), false);
- assertThrowsExt(
- EntityAlreadyExistsException.class,
- () -> svc.insertGroup(groupWithExtId("g2", "ext-1"), false));
- }
-
@TestTemplate
void testCreateLocksMetalakeWithoutChangingVersion() throws IOException {
createAndInsertMakeLake(metalakeName);
GroupMetaService service = GroupMetaService.getInstance();
MetalakePO beforeCreate = getMetalakePO();
- GroupEntity group = groupWithExtId("fenced-group", "fenced-group-ext-id");
+ GroupEntity group =
+ createGroupEntity(
+ RandomIdGenerator.INSTANCE.nextId(),
+ AuthorizationUtils.ofGroupNamespace(metalakeName),
+ "fenced-group",
+ AUDIT_INFO);
service.insertGroup(group, false);
@@ -1166,7 +1146,12 @@ class TestGroupMetaService extends TestJDBCBackend {
assertEquals(beforeCreate.getCurrentVersion(), afterCreate.getCurrentVersion());
assertEquals(beforeCreate.getLastVersion(), afterCreate.getLastVersion());
- GroupEntity duplicate = groupWithExtId(group.name(), "another-ext-id");
+ GroupEntity duplicate =
+ createGroupEntity(
+ RandomIdGenerator.INSTANCE.nextId(),
+ AuthorizationUtils.ofGroupNamespace(metalakeName),
+ group.name(),
+ AUDIT_INFO);
Assertions.assertThrows(
EntityAlreadyExistsException.class, () -> service.insertGroup(duplicate, false));
@@ -1178,7 +1163,12 @@ class TestGroupMetaService extends TestJDBCBackend {
@TestTemplate
void testOverwriteInsertAdvancesVersion() throws IOException {
GroupMetaService service = groupMetaService();
- GroupEntity group = groupWithExtId("overwrite-group", "overwrite-group-ext-id");
+ GroupEntity group =
+ createGroupEntity(
+ RandomIdGenerator.INSTANCE.nextId(),
+ AuthorizationUtils.ofGroupNamespace(metalakeName),
+ "overwrite-group",
+ AUDIT_INFO);
service.insertGroup(group, false);
GroupPO initialPO = getGroupPO(group.name());
@@ -1195,38 +1185,15 @@ class TestGroupMetaService extends TestJDBCBackend {
assertEquals(0, staleDelete);
}
- @TestTemplate
- void testMetadataOnlyUpdateUsesOcc() throws IOException {
- GroupMetaService service = groupMetaService();
- GroupEntity group = groupWithExtId("metadata-only-group", "metadata-only-ext-id");
- service.insertGroup(group, false);
- GroupPO beforeUpdate = getGroupPO(group.name());
-
- service.updateGroup(
- group.nameIdentifier(), (GroupEntity oldGroup) -> copyGroup(oldGroup, "updated-ext-id"));
-
- GroupPO afterUpdate = getGroupPO(group.name());
- assertEquals(beforeUpdate.getCurrentVersion() + 1, afterUpdate.getCurrentVersion());
- assertEquals(
- "updated-ext-id", service.getGroupByIdentifier(group.nameIdentifier()).externalId());
-
- Assertions.assertThrows(
- OptimisticLockException.class,
- () ->
- service.updateGroup(
- group.nameIdentifier(),
- (GroupEntity oldGroup) -> {
- advanceGroupVersion(group.id());
- return copyGroup(oldGroup, "conflicting-ext-id");
- }));
- assertEquals(
- "updated-ext-id", service.getGroupByIdentifier(group.nameIdentifier()).externalId());
- }
-
@TestTemplate
void testStaleDeleteReportsConflict() throws IOException {
GroupMetaService service = groupMetaService();
- GroupEntity group = groupWithExtId("stale-delete-group", "stale-delete-group-ext-id");
+ GroupEntity group =
+ createGroupEntity(
+ RandomIdGenerator.INSTANCE.nextId(),
+ AuthorizationUtils.ofGroupNamespace(metalakeName),
+ "stale-delete-group",
+ AUDIT_INFO);
service.insertGroup(group, false);
GroupPO staleGroupPO = getGroupPO(group.name());
advanceGroupVersion(group.id());
@@ -1237,58 +1204,6 @@ class TestGroupMetaService extends TestJDBCBackend {
assertEquals(group.id(), service.getGroupByIdentifier(group.nameIdentifier()).id());
}
- @TestTemplate
- void testAlterReportsNoSuchWhenGroupIsDeletedConcurrently() throws IOException {
- GroupMetaService service = groupMetaService();
- GroupEntity group = groupWithExtId("deleted-during-alter", "deleted-during-alter-ext-id");
- service.insertGroup(group, false);
-
- Assertions.assertThrows(
- NoSuchEntityException.class,
- () ->
- service.updateGroup(
- group.nameIdentifier(),
- (GroupEntity oldGroup) -> {
- service.deleteGroup(group.nameIdentifier());
- return copyGroup(oldGroup, "ignored-ext-id");
- }));
- }
-
- @TestTemplate
- void testByIdWritesUseOcc() throws IOException {
- GroupMetaService service = groupMetaService();
- GroupEntity group = groupWithExtId("by-id-group", "by-id-group-ext-id");
- service.insertGroup(group, false);
-
- Assertions.assertThrows(
- OptimisticLockException.class,
- () ->
- service.updateGroupById(
- metalakeName,
- group.id(),
- (GroupEntity oldGroup) -> {
- advanceGroupVersion(group.id());
- return copyGroup(oldGroup, "conflicting-by-id-ext-id");
- }));
- assertEquals(
- "by-id-group-ext-id", service.getGroupByIdentifier(group.nameIdentifier()).externalId());
-
- assertTrue(service.deleteGroupById(metalakeName, group.id()));
- assertFalse(service.deleteGroupById(metalakeName, group.id()));
- }
-
- @TestTemplate
- void testGroupExtDel() throws IOException {
- GroupMetaService svc = groupMetaService();
- svc.insertGroup(groupWithExtId("g1", "ext-del-by"), false);
- GroupEntity group = svc.getGroupByExternalId(groupExtIdent("ext-del-by"));
- Assertions.assertEquals("g1", group.name());
- Assertions.assertTrue(svc.deleteGroup(group.nameIdentifier()));
- assertThrowsExt(
- NoSuchEntityException.class, () -> svc.getGroupByExternalId(groupExtIdent("ext-del-by")));
- assertThrowsExt(NoSuchEntityException.class, () -> svc.deleteGroup(group.nameIdentifier()));
- }
-
@TestTemplate
void testGroupPagination() throws IOException {
AuditInfo auditInfo =
@@ -1418,10 +1333,6 @@ class TestGroupMetaService extends TestJDBCBackend {
Sets.newHashSet(page.items().get(0).roleNames()));
}
- private NameIdentifier groupExtIdent(String externalId) {
- return AuthorizationUtils.ofGroupExternalId(metalakeName, externalId);
- }
-
private GroupMetaService groupMetaService() throws IOException {
createAndInsertMakeLake(metalakeName);
return GroupMetaService.getInstance();
@@ -1439,32 +1350,10 @@ class TestGroupMetaService extends TestJDBCBackend {
mapper -> mapper.selectGroupMetaByMetalakeIdAndName(metalakePO.getMetalakeId(), groupName));
}
- private GroupEntity copyGroup(GroupEntity group, String externalId) {
- return GroupEntity.builder()
- .withId(group.id())
- .withName(group.name())
- .withNamespace(group.namespace())
- .withExternalId(externalId)
- .withRoleNames(group.roleNames())
- .withRoleIds(group.roleIds())
- .withAuditInfo(group.auditInfo())
- .build();
- }
-
private void assertThrowsExt(Class<? extends Exception> type, Executable executable) {
Assertions.assertThrows(type, executable);
}
- private GroupEntity groupWithExtId(String name, String externalId) {
- return GroupEntity.builder()
- .withId(RandomIdGenerator.INSTANCE.nextId())
- .withName(name)
- .withNamespace(AuthorizationUtils.ofGroupNamespace(metalakeName))
- .withExternalId(externalId)
- .withAuditInfo(AUDIT_INFO)
- .build();
- }
-
private GroupEntity createGroupEntity(
Long id, Namespace namespace, String name, AuditInfo auditInfo) {
return GroupEntity.builder()
diff --git a/core/src/test/java/org/apache/gravitino/storage/relational/service/TestUserMetaService.java b/core/src/test/java/org/apache/gravitino/storage/relational/service/TestUserMetaService.java
index 59e72f1412..aeebb52f7f 100644
--- a/core/src/test/java/org/apache/gravitino/storage/relational/service/TestUserMetaService.java
+++ b/core/src/test/java/org/apache/gravitino/storage/relational/service/TestUserMetaService.java
@@ -40,7 +40,6 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.gravitino.Entity;
import org.apache.gravitino.EntityAlreadyExistsException;
-import org.apache.gravitino.NameIdentifier;
import org.apache.gravitino.Namespace;
import org.apache.gravitino.authorization.AuthorizationUtils;
import org.apache.gravitino.authorization.PagedResult;
@@ -1402,81 +1401,12 @@ class TestUserMetaService extends TestJDBCBackend {
Sets.newHashSet(page.items().get(0).roleNames()));
}
- @TestTemplate
- void testUserExtId() throws IOException {
- UserMetaService svc = userMetaService();
- svc.insertUser(userWithExtId("u1", "ext-1"), false);
- UserEntity found = svc.getUserByExternalId(userExtIdent("ext-1"));
- Assertions.assertEquals("u1", found.name());
- Assertions.assertEquals("ext-1", found.externalId());
- assertThrowsExt(
- NoSuchEntityException.class, () -> svc.getUserByExternalId(userExtIdent("missing-ext-id")));
- assertThrowsExt(
- IllegalArgumentException.class, () -> svc.getUserByExternalId(userExtIdent("")));
- assertThrowsExt(
- NoSuchEntityException.class,
- () -> svc.updateUserByExternalId(userExtIdent("missing-ext-id"), enabledUpdater(false)));
- }
-
- @TestTemplate
- void testExtEnable() throws IOException {
- UserMetaService svc = userMetaService();
- svc.insertUser(userWithExtId("u1", "ext-1"), false);
- Assertions.assertFalse(
- svc.updateUserByExternalId(userExtIdent("ext-1"), enabledUpdater(false)).enabled());
- Assertions.assertTrue(
- svc.updateUserByExternalId(userExtIdent("ext-1"), enabledUpdater(true)).enabled());
-
- svc.insertUser(userWithExtId("u2", "ext-db"), false);
- long updatedAtBefore = queryUpdatedAtByExtId("ext-db");
- svc.updateUserByExternalId(userExtIdent("ext-db"), enabledUpdater(false));
- Assertions.assertFalse(queryEnabledByExtId("ext-db"));
- long updatedAtAfterDisable = queryUpdatedAtByExtId("ext-db");
- Assertions.assertTrue(updatedAtAfterDisable >= updatedAtBefore);
-
- svc.updateUserByExternalId(userExtIdent("ext-db"), enabledUpdater(true));
- Assertions.assertTrue(queryEnabledByExtId("ext-db"));
- Assertions.assertTrue(queryUpdatedAtByExtId("ext-db") >= updatedAtAfterDisable);
- }
-
- @TestTemplate
- void testExtEnableDel() throws IOException {
- UserMetaService svc = userMetaService();
- UserEntity user = userWithExtId("u1", "ext-del");
- svc.insertUser(user, false);
- Assertions.assertTrue(svc.deleteUser(user.nameIdentifier()));
- assertThrowsExt(
- NoSuchEntityException.class,
- () -> svc.updateUserByExternalId(userExtIdent("ext-del"), enabledUpdater(false)));
- }
-
- @TestTemplate
- void testUserExtDel() throws IOException {
- UserMetaService svc = userMetaService();
- svc.insertUser(userWithExtId("u1", "ext-del-by"), false);
- UserEntity user = svc.getUserByExternalId(userExtIdent("ext-del-by"));
- Assertions.assertEquals("u1", user.name());
- Assertions.assertTrue(svc.deleteUser(user.nameIdentifier()));
- assertThrowsExt(
- NoSuchEntityException.class, () -> svc.getUserByExternalId(userExtIdent("ext-del-by")));
- assertThrowsExt(NoSuchEntityException.class, () -> svc.deleteUser(user.nameIdentifier()));
- }
-
- @TestTemplate
- void testExtDup() throws IOException {
- UserMetaService svc = userMetaService();
- svc.insertUser(userWithExtId("u1", "ext-1"), false);
- assertThrowsExt(
- EntityAlreadyExistsException.class,
- () -> svc.insertUser(userWithExtId("u2", "ext-1"), false));
- }
-
@TestTemplate
void testCreateLocksMetalakeWithoutChangingVersion() throws IOException {
createAndInsertMakeLake(metalakeName);
UserMetaService service = UserMetaService.getInstance();
MetalakePO beforeCreate = getMetalakePO();
- UserEntity user = userWithExtId("fenced-user", "fenced-user-ext-id");
+ UserEntity user = simpleUser("fenced-user");
service.insertUser(user, false);
@@ -1484,7 +1414,7 @@ class TestUserMetaService extends TestJDBCBackend {
assertEquals(beforeCreate.getCurrentVersion(), afterCreate.getCurrentVersion());
assertEquals(beforeCreate.getLastVersion(), afterCreate.getLastVersion());
- UserEntity duplicate = userWithExtId(user.name(), "another-ext-id");
+ UserEntity duplicate = simpleUser(user.name());
Assertions.assertThrows(
EntityAlreadyExistsException.class, () -> service.insertUser(duplicate, false));
@@ -1496,7 +1426,7 @@ class TestUserMetaService extends TestJDBCBackend {
@TestTemplate
void testOverwriteInsertAdvancesVersion() throws IOException {
UserMetaService service = userMetaService();
- UserEntity user = userWithExtId("overwrite-user", "overwrite-user-ext-id");
+ UserEntity user = simpleUser("overwrite-user");
service.insertUser(user, false);
UserPO initialPO = getUserPO(user.name());
@@ -1512,35 +1442,10 @@ class TestUserMetaService extends TestJDBCBackend {
assertEquals(0, staleDelete);
}
- @TestTemplate
- void testMetadataOnlyUpdateUsesOcc() throws IOException {
- UserMetaService service = userMetaService();
- UserEntity user = userWithExtId("metadata-only-user", "metadata-only-ext-id");
- service.insertUser(user, false);
- UserPO beforeUpdate = getUserPO(user.name());
-
- service.updateUser(user.nameIdentifier(), enabledUpdater(false));
-
- UserPO afterUpdate = getUserPO(user.name());
- assertEquals(beforeUpdate.getCurrentVersion() + 1, afterUpdate.getCurrentVersion());
- assertFalse(service.getUserByIdentifier(user.nameIdentifier()).enabled());
-
- Assertions.assertThrows(
- OptimisticLockException.class,
- () ->
- service.updateUser(
- user.nameIdentifier(),
- (UserEntity oldUser) -> {
- advanceUserVersion(user.id());
- return enabledUpdater(true).apply(oldUser);
- }));
- assertFalse(service.getUserByIdentifier(user.nameIdentifier()).enabled());
- }
-
@TestTemplate
void testStaleDeleteReportsConflict() throws IOException {
UserMetaService service = userMetaService();
- UserEntity user = userWithExtId("stale-delete-user", "stale-delete-ext-id");
+ UserEntity user = simpleUser("stale-delete-user");
service.insertUser(user, false);
UserPO staleUserPO = getUserPO(user.name());
advanceUserVersion(user.id());
@@ -1551,23 +1456,6 @@ class TestUserMetaService extends TestJDBCBackend {
assertEquals(user.id(), service.getUserByIdentifier(user.nameIdentifier()).id());
}
- @TestTemplate
- void testAlterReportsNoSuchWhenUserIsDeletedConcurrently() throws IOException {
- UserMetaService service = userMetaService();
- UserEntity user = userWithExtId("deleted-during-alter", "deleted-during-alter-ext-id");
- service.insertUser(user, false);
-
- Assertions.assertThrows(
- NoSuchEntityException.class,
- () ->
- service.updateUser(
- user.nameIdentifier(),
- (UserEntity oldUser) -> {
- service.deleteUser(user.nameIdentifier());
- return enabledUpdater(false).apply(oldUser);
- }));
- }
-
@TestTemplate
void testConcurrentUpdateDoesNotChangeRolesOnConflict() throws IOException {
createAndInsertMakeLake(metalakeName);
@@ -1614,8 +1502,6 @@ class TestUserMetaService extends TestJDBCBackend {
.withId(oldUser.id())
.withName(oldUser.name())
.withNamespace(oldUser.namespace())
- .withExternalId(oldUser.externalId())
- .withEnabled(oldUser.enabled())
.withRoleNames(roleNames)
.withRoleIds(roleIds)
.withAuditInfo(oldUser.auditInfo())
@@ -1627,73 +1513,6 @@ class TestUserMetaService extends TestJDBCBackend {
assertEquals(Sets.newHashSet(role1.id()), Sets.newHashSet(storedUser.roleIds()));
}
- @TestTemplate
- void testConcurrentExternalIdUpdateRollsBackOnConflict() throws IOException {
- UserMetaService service = userMetaService();
- UserEntity user = userWithExtId("concurrent-user", "concurrent-ext-id");
- service.insertUser(user, false);
-
- Assertions.assertThrows(
- OptimisticLockException.class,
- () ->
- service.updateUserByExternalId(
- userExtIdent(user.externalId()),
- (UserEntity oldUser) -> {
- advanceUserVersion(user.id());
- return UserEntity.builder()
- .withId(oldUser.id())
- .withName(oldUser.name())
- .withNamespace(oldUser.namespace())
- .withExternalId(oldUser.externalId())
- .withEnabled(false)
- .withRoleNames(oldUser.roleNames())
- .withRoleIds(oldUser.roleIds())
- .withAuditInfo(oldUser.auditInfo())
- .build();
- }));
-
- assertTrue(queryEnabledByExtId(user.externalId()));
- }
-
- @TestTemplate
- void testConcurrentByIdUpdateRollsBackOnConflict() throws IOException {
- UserMetaService service = userMetaService();
- UserEntity user = userWithExtId("concurrent-by-id-user", "concurrent-by-id-ext-id");
- service.insertUser(user, false);
-
- Assertions.assertThrows(
- OptimisticLockException.class,
- () ->
- service.updateUserById(
- metalakeName,
- user.id(),
- (UserEntity oldUser) -> {
- advanceUserVersion(user.id());
- return UserEntity.builder()
- .withId(oldUser.id())
- .withName(oldUser.name())
- .withNamespace(oldUser.namespace())
- .withExternalId(oldUser.externalId())
- .withEnabled(false)
- .withRoleNames(oldUser.roleNames())
- .withRoleIds(oldUser.roleIds())
- .withAuditInfo(oldUser.auditInfo())
- .build();
- }));
-
- assertTrue(queryEnabledByExtId(user.externalId()));
- }
-
- @TestTemplate
- void testDeleteUserById() throws IOException {
- UserMetaService service = userMetaService();
- UserEntity user = userWithExtId("delete-by-id-user", "delete-by-id-ext-id");
- service.insertUser(user, false);
-
- assertTrue(service.deleteUserById(metalakeName, user.id()));
- assertFalse(service.deleteUserById(metalakeName, user.id()));
- }
-
private UserMetaService userMetaService() throws IOException {
createAndInsertMakeLake(metalakeName);
return UserMetaService.getInstance();
@@ -1715,13 +1534,11 @@ class TestUserMetaService extends TestJDBCBackend {
Assertions.assertThrows(type, executable);
}
- private UserEntity userWithExtId(String name, String externalId) {
+ private UserEntity simpleUser(String name) {
return UserEntity.builder()
.withId(RandomIdGenerator.INSTANCE.nextId())
.withName(name)
.withNamespace(AuthorizationUtils.ofUserNamespace(metalakeName))
- .withExternalId(externalId)
- .withEnabled(true)
.withAuditInfo(AUDIT_INFO)
.build();
}
@@ -1730,58 +1547,6 @@ class TestUserMetaService extends TestJDBCBackend {
return AuthorizationUtils.ofUserNamespace(metalakeName);
}
- private NameIdentifier userExtIdent(String externalId) {
- return AuthorizationUtils.ofUserExternalId(metalakeName, externalId);
- }
-
- private Function<UserEntity, UserEntity> enabledUpdater(boolean enabled) {
- return user ->
- UserEntity.builder()
- .withId(user.id())
- .withName(user.name())
- .withNamespace(user.namespace())
- .withExternalId(user.externalId())
- .withEnabled(enabled)
- .withRoleNames(user.roleNames())
- .withRoleIds(user.roleIds())
- .withAuditInfo(user.auditInfo())
- .build();
- }
-
- private boolean queryEnabledByExtId(String externalId) {
- try (SqlSession sqlSession =
- SqlSessionFactoryHelper.getInstance().getSqlSessionFactory().openSession(true);
- Connection connection = sqlSession.getConnection();
- Statement statement = connection.createStatement();
- ResultSet rs =
- statement.executeQuery(
- String.format(
- "SELECT enabled FROM user_meta WHERE external_id = '%s' AND deleted_at = 0",
- externalId))) {
- Assertions.assertTrue(rs.next());
- return rs.getBoolean(1);
- } catch (SQLException e) {
- throw new RuntimeException("Query user enabled failed", e);
- }
- }
-
- private long queryUpdatedAtByExtId(String externalId) {
- try (SqlSession sqlSession =
- SqlSessionFactoryHelper.getInstance().getSqlSessionFactory().openSession(true);
- Connection connection = sqlSession.getConnection();
- Statement statement = connection.createStatement();
- ResultSet rs =
- statement.executeQuery(
- String.format(
- "SELECT updated_at FROM user_meta WHERE external_id = '%s' AND deleted_at = 0",
- externalId))) {
- Assertions.assertTrue(rs.next());
- return rs.getLong(1);
- } catch (SQLException e) {
- throw new RuntimeException("Query user updated_at failed", e);
- }
- }
-
private Integer countUsers(Long metalakeId) {
int count = 0;
try (SqlSession sqlSession =
diff --git a/core/src/test/java/org/apache/gravitino/storage/relational/utils/TestPOConverters.java b/core/src/test/java/org/apache/gravitino/storage/relational/utils/TestPOConverters.java
index bce2ac19d8..4a23e64bc6 100644
--- a/core/src/test/java/org/apache/gravitino/storage/relational/utils/TestPOConverters.java
+++ b/core/src/test/java/org/apache/gravitino/storage/relational/utils/TestPOConverters.java
@@ -886,7 +886,6 @@ public class TestPOConverters {
.withGroupId(initialGroupPO.getGroupId())
.withGroupName(initialGroupPO.getGroupName())
.withMetalakeId(initialGroupPO.getMetalakeId())
- .withExternalId(initialGroupPO.getExternalId())
.withAuditInfo(initialGroupPO.getAuditInfo())
.withCurrentVersion(7L)
.withLastVersion(3L)
@@ -912,8 +911,6 @@ public class TestPOConverters {
.withUserId(initialUserPO.getUserId())
.withUserName(initialUserPO.getUserName())
.withMetalakeId(initialUserPO.getMetalakeId())
- .withExternalId(initialUserPO.getExternalId())
- .withEnabled(initialUserPO.getEnabled())
.withAuditInfo(initialUserPO.getAuditInfo())
.withCurrentVersion(7L)
.withLastVersion(3L)
diff --git a/docs/open-api/bulk.yaml b/docs/open-api/bulk.yaml
index ab35a5ed28..ee48563844 100644
--- a/docs/open-api/bulk.yaml
+++ b/docs/open-api/bulk.yaml
@@ -339,8 +339,8 @@ components:
BulkUserAddRequest:
value: {
"users": [
- {"name": "alice", "externalId": "ext-alice", "enabled": true},
- {"name": "bob", "enabled": true}
+ {"name": "alice"},
+ {"name": "bob"}
]
}
@@ -352,7 +352,7 @@ components:
BulkGroupAddRequest:
value: {
"groups": [
- {"name": "engineers", "externalId": "ext-engineers"},
+ {"name": "engineers"},
{"name": "analysts"}
]
}
@@ -368,8 +368,6 @@ components:
"users": [
{
"name": "alice",
- "externalId": "ext-alice",
- "enabled": true,
"roles": [],
"audit": {
"creator": "gravitino",
@@ -411,7 +409,6 @@ components:
"groups": [
{
"name": "engineers",
- "externalId": "ext-engineers",
"roles": [],
"audit": {
"creator": "gravitino",
diff --git a/docs/open-api/groups.yaml b/docs/open-api/groups.yaml
index 464bd6b3ad..eb1cc8b8b2 100644
--- a/docs/open-api/groups.yaml
+++ b/docs/open-api/groups.yaml
@@ -163,9 +163,6 @@ components:
name:
type: string
description: The name of the group
- externalId:
- type: string
- description: The external identifier of the group
roles:
type: array
items:
@@ -182,9 +179,6 @@ components:
name:
type: string
description: The name of the group
- externalId:
- type: string
- description: The external identifier of the group
responses:
GroupResponse:
@@ -217,8 +211,7 @@ components:
examples:
GroupAddRequest:
value: {
- "name": "group",
- "externalId": "ext-group"
+ "name": "group"
}
NameListResponse:
diff --git a/docs/open-api/users.yaml b/docs/open-api/users.yaml
index 39974c0fd6..335ba837f9 100644
--- a/docs/open-api/users.yaml
+++ b/docs/open-api/users.yaml
@@ -163,12 +163,6 @@ components:
name:
type: string
description: The name of the user
- externalId:
- type: string
- description: The external identifier of the user
- enabled:
- type: boolean
- description: Whether the user is enabled
default: true
roles:
type: array
@@ -186,12 +180,6 @@ components:
name:
type: string
description: The name of the user
- externalId:
- type: string
- description: The external identifier of the user
- enabled:
- type: boolean
- description: Whether the user is enabled
default: true
responses:
@@ -225,9 +213,7 @@ components:
examples:
UserAddRequest:
value: {
- "name": "user",
- "externalId": "ext-user",
- "enabled": true
+ "name": "user"
}
NameListResponse:
diff --git a/scripts/h2/schema-2.0.0-h2.sql b/scripts/h2/schema-2.0.0-h2.sql
index 9b185bcc0b..30c197e1bf 100644
--- a/scripts/h2/schema-2.0.0-h2.sql
+++ b/scripts/h2/schema-2.0.0-h2.sql
@@ -171,8 +171,6 @@ CREATE TABLE IF NOT EXISTS `user_meta` (
`user_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'user id',
`user_name` VARCHAR(128) NOT NULL COMMENT 'username',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
- `external_id` VARCHAR(256) DEFAULT NULL COMMENT 'external identifier from an upstream identity system',
- `enabled` TINYINT(1) NOT NULL DEFAULT 1 COMMENT 'whether the user is enabled, 0 is disabled, 1 is enabled',
`audit_info` CLOB NOT NULL COMMENT 'user audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'user current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'user last version',
@@ -180,7 +178,6 @@ CREATE TABLE IF NOT EXISTS `user_meta` (
`updated_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'updated at',
PRIMARY KEY (`user_id`),
CONSTRAINT `uk_mid_us_del` UNIQUE (`metalake_id`, `user_name`, `deleted_at`),
- CONSTRAINT `uk_mid_ueid_del` UNIQUE (`metalake_id`, `external_id`, `deleted_at`),
KEY `idx_user_meta_name_del_upd` (`metalake_id`, `user_name`, `deleted_at`, `updated_at`)
) ENGINE=InnoDB;
@@ -230,7 +227,6 @@ CREATE TABLE IF NOT EXISTS `group_meta` (
`group_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'group id',
`group_name` VARCHAR(128) NOT NULL COMMENT 'group name',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
- `external_id` VARCHAR(256) DEFAULT NULL COMMENT 'external identifier from an upstream identity system',
`audit_info` CLOB NOT NULL COMMENT 'group audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'group current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'group last version',
@@ -238,7 +234,6 @@ CREATE TABLE IF NOT EXISTS `group_meta` (
`updated_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'updated at',
PRIMARY KEY (`group_id`),
CONSTRAINT `uk_mid_gr_del` UNIQUE (`metalake_id`, `group_name`, `deleted_at`),
- CONSTRAINT `uk_mid_geid_del` UNIQUE (`metalake_id`, `external_id`, `deleted_at`),
KEY `idx_group_meta_name_del_upd` (`metalake_id`, `group_name`, `deleted_at`, `updated_at`)
) ENGINE=InnoDB;
diff --git a/scripts/h2/upgrade-1.3.0-to-2.0.0-h2.sql b/scripts/h2/upgrade-1.3.0-to-2.0.0-h2.sql
index 5ba0d646b8..558ad6a79a 100644
--- a/scripts/h2/upgrade-1.3.0-to-2.0.0-h2.sql
+++ b/scripts/h2/upgrade-1.3.0-to-2.0.0-h2.sql
@@ -17,13 +17,8 @@
-- under the License.
--
-ALTER TABLE `user_meta` ADD COLUMN `external_id` VARCHAR(256) DEFAULT NULL COMMENT 'external identifier from an upstream identity system' AFTER `metalake_id`;
-ALTER TABLE `user_meta` ADD COLUMN `enabled` TINYINT(1) NOT NULL DEFAULT 1 COMMENT 'whether the user is enabled, 0 is disabled, 1 is enabled' AFTER `external_id`;
-ALTER TABLE `group_meta` ADD COLUMN `external_id` VARCHAR(256) DEFAULT NULL COMMENT 'external identifier from an upstream identity system' AFTER `metalake_id`;
-CREATE UNIQUE INDEX IF NOT EXISTS `uk_mid_ueid_del` ON `user_meta` (`metalake_id`, `external_id`, `deleted_at`);
-CREATE UNIQUE INDEX IF NOT EXISTS `uk_mid_geid_del` ON `group_meta` (`metalake_id`, `external_id`, `deleted_at`);
ALTER TABLE `table_column_version_info`
ALTER COLUMN `column_comment` VARCHAR(4096) DEFAULT '';
diff --git a/scripts/mysql/schema-2.0.0-mysql.sql b/scripts/mysql/schema-2.0.0-mysql.sql
index a6f64a62d8..8f26d9f723 100644
--- a/scripts/mysql/schema-2.0.0-mysql.sql
+++ b/scripts/mysql/schema-2.0.0-mysql.sql
@@ -162,8 +162,6 @@ CREATE TABLE IF NOT EXISTS `user_meta` (
`user_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'user id',
`user_name` VARCHAR(128) NOT NULL COMMENT 'username',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
- `external_id` VARCHAR(256) DEFAULT NULL COMMENT 'external identifier from an upstream identity system',
- `enabled` TINYINT(1) NOT NULL DEFAULT 1 COMMENT 'whether the user is enabled, 0 is disabled, 1 is enabled',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'user audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'user current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'user last version',
@@ -171,7 +169,6 @@ CREATE TABLE IF NOT EXISTS `user_meta` (
`updated_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'updated at',
PRIMARY KEY (`user_id`),
UNIQUE KEY `uk_mid_us_del` (`metalake_id`, `user_name`, `deleted_at`),
- UNIQUE KEY `uk_mid_ueid_del` (`metalake_id`, `external_id`, `deleted_at`),
KEY `idx_user_meta_name_del_upd` (`metalake_id`, `user_name`, `deleted_at`, `updated_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'user metadata';
@@ -221,7 +218,6 @@ CREATE TABLE IF NOT EXISTS `group_meta` (
`group_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'group id',
`group_name` VARCHAR(128) NOT NULL COMMENT 'group name',
`metalake_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'metalake id',
- `external_id` VARCHAR(256) DEFAULT NULL COMMENT 'external identifier from an upstream identity system',
`audit_info` MEDIUMTEXT NOT NULL COMMENT 'group audit info',
`current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'group current version',
`last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'group last version',
@@ -229,7 +225,6 @@ CREATE TABLE IF NOT EXISTS `group_meta` (
`updated_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'updated at',
PRIMARY KEY (`group_id`),
UNIQUE KEY `uk_mid_gr_del` (`metalake_id`, `group_name`, `deleted_at`),
- UNIQUE KEY `uk_mid_geid_del` (`metalake_id`, `external_id`, `deleted_at`),
KEY `idx_group_meta_name_del_upd` (`metalake_id`, `group_name`, `deleted_at`, `updated_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'group metadata';
diff --git a/scripts/mysql/upgrade-1.3.0-to-2.0.0-mysql.sql b/scripts/mysql/upgrade-1.3.0-to-2.0.0-mysql.sql
index aa7203f5ef..f6fd86b02f 100644
--- a/scripts/mysql/upgrade-1.3.0-to-2.0.0-mysql.sql
+++ b/scripts/mysql/upgrade-1.3.0-to-2.0.0-mysql.sql
@@ -17,16 +17,6 @@
-- under the License.
--
-ALTER TABLE `user_meta`
- ADD COLUMN `external_id` VARCHAR(256) DEFAULT NULL COMMENT 'external identifier from an upstream identity system' AFTER `metalake_id`,
- ADD COLUMN `enabled` TINYINT(1) NOT NULL DEFAULT 1 COMMENT 'whether the user is enabled, 0 is disabled, 1 is enabled' AFTER `external_id`;
-
-ALTER TABLE `group_meta`
- ADD COLUMN `external_id` VARCHAR(256) DEFAULT NULL COMMENT 'external identifier from an upstream identity system' AFTER `metalake_id`;
-
-CREATE UNIQUE INDEX `uk_mid_ueid_del` ON `user_meta` (`metalake_id`, `external_id`, `deleted_at`);
-CREATE UNIQUE INDEX `uk_mid_geid_del` ON `group_meta` (`metalake_id`, `external_id`, `deleted_at`);
-
ALTER TABLE `table_column_version_info`
MODIFY COLUMN `column_comment` VARCHAR(4096) DEFAULT '' COMMENT 'column comment';
diff --git a/scripts/postgresql/schema-2.0.0-postgresql.sql b/scripts/postgresql/schema-2.0.0-postgresql.sql
index 2fdcb694f3..6e15ca5f40 100644
--- a/scripts/postgresql/schema-2.0.0-postgresql.sql
+++ b/scripts/postgresql/schema-2.0.0-postgresql.sql
@@ -286,24 +286,19 @@ CREATE TABLE IF NOT EXISTS user_meta (
user_id BIGINT NOT NULL,
user_name VARCHAR(128) NOT NULL,
metalake_id BIGINT NOT NULL,
- external_id VARCHAR(256) DEFAULT NULL,
- enabled BOOLEAN NOT NULL DEFAULT TRUE,
audit_info TEXT NOT NULL,
current_version INT NOT NULL DEFAULT 1,
last_version INT NOT NULL DEFAULT 1,
deleted_at BIGINT NOT NULL DEFAULT 0,
updated_at BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (user_id),
- UNIQUE (metalake_id, user_name, deleted_at),
- UNIQUE (metalake_id, external_id, deleted_at)
+ UNIQUE (metalake_id, user_name, deleted_at)
);
COMMENT ON TABLE user_meta IS 'user metadata';
COMMENT ON COLUMN user_meta.user_id IS 'user id';
COMMENT ON COLUMN user_meta.user_name IS 'username';
COMMENT ON COLUMN user_meta.metalake_id IS 'metalake id';
-COMMENT ON COLUMN user_meta.external_id IS 'external identifier from an upstream identity system';
-COMMENT ON COLUMN user_meta.enabled IS 'whether the user is enabled, 0 is disabled, 1 is enabled';
COMMENT ON COLUMN user_meta.audit_info IS 'user audit info';
COMMENT ON COLUMN user_meta.current_version IS 'user current version';
COMMENT ON COLUMN user_meta.last_version IS 'user last version';
@@ -392,22 +387,19 @@ CREATE TABLE IF NOT EXISTS group_meta (
group_id BIGINT NOT NULL,
group_name VARCHAR(128) NOT NULL,
metalake_id BIGINT NOT NULL,
- external_id VARCHAR(256) DEFAULT NULL,
audit_info TEXT NOT NULL,
current_version INT NOT NULL DEFAULT 1,
last_version INT NOT NULL DEFAULT 1,
deleted_at BIGINT NOT NULL DEFAULT 0,
updated_at BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (group_id),
- UNIQUE (metalake_id, group_name, deleted_at),
- UNIQUE (metalake_id, external_id, deleted_at)
+ UNIQUE (metalake_id, group_name, deleted_at)
);
COMMENT ON TABLE group_meta IS 'group metadata';
COMMENT ON COLUMN group_meta.group_id IS 'group id';
COMMENT ON COLUMN group_meta.group_name IS 'group name';
COMMENT ON COLUMN group_meta.metalake_id IS 'metalake id';
-COMMENT ON COLUMN group_meta.external_id IS 'external identifier from an upstream identity system';
COMMENT ON COLUMN group_meta.audit_info IS 'group audit info';
COMMENT ON COLUMN group_meta.current_version IS 'group current version';
COMMENT ON COLUMN group_meta.last_version IS 'group last version';
diff --git a/scripts/postgresql/upgrade-1.3.0-to-2.0.0-postgresql.sql b/scripts/postgresql/upgrade-1.3.0-to-2.0.0-postgresql.sql
index 77e3b79c02..25940bec3b 100644
--- a/scripts/postgresql/upgrade-1.3.0-to-2.0.0-postgresql.sql
+++ b/scripts/postgresql/upgrade-1.3.0-to-2.0.0-postgresql.sql
@@ -17,17 +17,9 @@
-- under the License.
--
-ALTER TABLE user_meta ADD COLUMN IF NOT EXISTS external_id VARCHAR(256) DEFAULT NULL;
-ALTER TABLE user_meta ADD COLUMN IF NOT EXISTS enabled BOOLEAN NOT NULL DEFAULT TRUE;
-ALTER TABLE group_meta ADD COLUMN IF NOT EXISTS external_id VARCHAR(256) DEFAULT NULL;
-COMMENT ON COLUMN user_meta.external_id IS 'external identifier from an upstream identity system';
-COMMENT ON COLUMN user_meta.enabled IS 'whether the user is enabled, 0 is disabled, 1 is enabled';
-COMMENT ON COLUMN group_meta.external_id IS 'external identifier from an upstream identity system';
-CREATE UNIQUE INDEX IF NOT EXISTS uk_mid_ueid_del ON user_meta (metalake_id, external_id, deleted_at);
-CREATE UNIQUE INDEX IF NOT EXISTS uk_mid_geid_del ON group_meta (metalake_id, external_id, deleted_at);
ALTER TABLE table_column_version_info
ALTER COLUMN column_comment TYPE VARCHAR(4096);
diff --git a/server/src/main/java/org/apache/gravitino/server/web/rest/BulkOperations.java b/server/src/main/java/org/apache/gravitino/server/web/rest/BulkOperations.java
index 779b463dde..9c9eb8796f 100644
--- a/server/src/main/java/org/apache/gravitino/server/web/rest/BulkOperations.java
+++ b/server/src/main/java/org/apache/gravitino/server/web/rest/BulkOperations.java
@@ -120,10 +120,7 @@ public class BulkOperations {
accessControlDispatcher.addUsers(
metalake,
Arrays.stream(request.getUsers())
- .map(
- user ->
- new UserAdd(
- user.getName(), user.getExternalId(), user.getEnabled()))
+ .map(user -> new UserAdd(user.getName()))
.collect(Collectors.toList()));
UserDTO[] users =
results.stream()
@@ -229,7 +226,7 @@ public class BulkOperations {
accessControlDispatcher.addGroups(
metalake,
Arrays.stream(request.getGroups())
- .map(group -> new GroupAdd(group.getName(), group.getExternalId()))
+ .map(group -> new GroupAdd(group.getName()))
.collect(Collectors.toList()));
GroupDTO[] groups =
results.stream()
diff --git a/server/src/main/java/org/apache/gravitino/server/web/rest/GroupOperations.java b/server/src/main/java/org/apache/gravitino/server/web/rest/GroupOperations.java
index 3e1ec2b643..a6487080a3 100644
--- a/server/src/main/java/org/apache/gravitino/server/web/rest/GroupOperations.java
+++ b/server/src/main/java/org/apache/gravitino/server/web/rest/GroupOperations.java
@@ -31,7 +31,6 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
-import org.apache.commons.lang3.StringUtils;
import org.apache.gravitino.Entity;
import org.apache.gravitino.GravitinoEnv;
import org.apache.gravitino.MetadataObject;
@@ -129,11 +128,7 @@ public class GroupOperations {
() -> {
request.validate();
MetalakeManager.checkMetalakeInUse(metalake);
- Group addedGroup =
- StringUtils.isNotBlank(request.getExternalId())
- ? accessControlManager.addGroup(
- metalake, request.getName(), request.getExternalId())
- : accessControlManager.addGroup(metalake, request.getName());
+ Group addedGroup = accessControlManager.addGroup(metalake, request.getName());
return Utils.ok(new GroupResponse(DTOConverters.toDTO(addedGroup)));
});
} catch (Exception e) {
diff --git a/server/src/main/java/org/apache/gravitino/server/web/rest/UserOperations.java b/server/src/main/java/org/apache/gravitino/server/web/rest/UserOperations.java
index 9a8039c5c1..2ea92f162a 100644
--- a/server/src/main/java/org/apache/gravitino/server/web/rest/UserOperations.java
+++ b/server/src/main/java/org/apache/gravitino/server/web/rest/UserOperations.java
@@ -20,7 +20,6 @@ package org.apache.gravitino.server.web.rest;
import com.codahale.metrics.annotation.ResponseMetered;
import com.codahale.metrics.annotation.Timed;
-import java.util.Optional;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
@@ -32,7 +31,6 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
-import org.apache.commons.lang3.StringUtils;
import org.apache.gravitino.Entity;
import org.apache.gravitino.GravitinoEnv;
import org.apache.gravitino.MetadataObject;
@@ -171,14 +169,7 @@ public class UserOperations {
() -> {
request.validate();
MetalakeManager.checkMetalakeInUse(metalake);
- User addedUser =
- StringUtils.isNotBlank(request.getExternalId())
- ? accessControlManager.addUser(
- metalake,
- request.getName(),
- request.getExternalId(),
- Optional.ofNullable(request.getEnabled()).orElse(true))
- : accessControlManager.addUser(metalake, request.getName());
+ User addedUser = accessControlManager.addUser(metalake, request.getName());
return Utils.ok(new UserResponse(DTOConverters.toDTO(addedUser)));
});
} catch (Exception e) {
diff --git a/server/src/test/java/org/apache/gravitino/server/web/rest/TestBulkOperations.java b/server/src/test/java/org/apache/gravitino/server/web/rest/TestBulkOperations.java
index 1d843b4728..d309b1567b 100644
--- a/server/src/test/java/org/apache/gravitino/server/web/rest/TestBulkOperations.java
+++ b/server/src/test/java/org/apache/gravitino/server/web/rest/TestBulkOperations.java
@@ -182,9 +182,7 @@ public class TestBulkOperations extends BaseOperationsTest {
BulkUserAddRequest request =
new BulkUserAddRequest(
- new UserAddRequest[] {
- new UserAddRequest("user1", "ext-user1", false), new UserAddRequest("user2")
- });
+ new UserAddRequest[] {new UserAddRequest("user1"), new UserAddRequest("user2")});
Response response =
target("/bulk/metalakes/metalake1/users/add")
.request(MediaType.APPLICATION_JSON_TYPE)
@@ -207,8 +205,6 @@ public class TestBulkOperations extends BaseOperationsTest {
ArgumentCaptor<List<UserAdd>> usersCaptor = ArgumentCaptor.forClass(List.class);
Mockito.verify(manager).addUsers(eq("metalake1"), usersCaptor.capture());
Assertions.assertEquals("user1", usersCaptor.getValue().get(0).name());
- Assertions.assertEquals("ext-user1", usersCaptor.getValue().get(0).externalId());
- Assertions.assertEquals(false, usersCaptor.getValue().get(0).enabled());
}
@Test
@@ -258,9 +254,7 @@ public class TestBulkOperations extends BaseOperationsTest {
BulkGroupAddRequest request =
new BulkGroupAddRequest(
- new GroupAddRequest[] {
- new GroupAddRequest("group1", "ext-group1"), new GroupAddRequest("group2")
- });
+ new GroupAddRequest[] {new GroupAddRequest("group1"), new GroupAddRequest("group2")});
Response response =
target("/bulk/metalakes/metalake1/groups/add")
.request(MediaType.APPLICATION_JSON_TYPE)
@@ -283,7 +277,6 @@ public class TestBulkOperations extends BaseOperationsTest {
ArgumentCaptor<List<GroupAdd>> groupsCaptor = ArgumentCaptor.forClass(List.class);
Mockito.verify(manager).addGroups(eq("metalake1"), groupsCaptor.capture());
Assertions.assertEquals("group1", groupsCaptor.getValue().get(0).name());
- Assertions.assertEquals("ext-group1", groupsCaptor.getValue().get(0).externalId());
}
@Test
diff --git a/server/src/test/java/org/apache/gravitino/server/web/rest/TestGroupOperations.java b/server/src/test/java/org/apache/gravitino/server/web/rest/TestGroupOperations.java
index a632578efe..8d89d4a682 100644
--- a/server/src/test/java/org/apache/gravitino/server/web/rest/TestGroupOperations.java
+++ b/server/src/test/java/org/apache/gravitino/server/web/rest/TestGroupOperations.java
@@ -235,38 +235,6 @@ public class TestGroupOperations extends BaseOperationsTest {
assertNullRequestBodyRejected(resp);
}
- @Test
- public void testAddGroupWithExternalId() throws IOException {
- GroupAddRequest req = new GroupAddRequest("group1", "ext-group-1");
- Group group =
- GroupEntity.builder()
- .withId(1L)
- .withName("group1")
- .withExternalId("ext-group-1")
- .withRoleNames(Collections.emptyList())
- .withAuditInfo(
- AuditInfo.builder().withCreator("creator").withCreateTime(Instant.now()).build())
- .build();
-
- when(manager.addGroup(any(), any(), any())).thenReturn(group);
-
- BaseMetalake metalake = mock(BaseMetalake.class);
- PropertiesMetadata propertiesMetadata = mock(PropertiesMetadata.class);
- when(propertiesMetadata.getOrDefault(any(), any())).thenReturn(true);
- when(metalake.propertiesMetadata()).thenReturn(propertiesMetadata);
- when(entityStore.get(any(), any(), any())).thenReturn(metalake);
-
- Response resp =
- target("/metalakes/metalake1/groups")
- .request(MediaType.APPLICATION_JSON_TYPE)
- .accept("application/vnd.gravitino.v1+json")
- .post(Entity.entity(req, MediaType.APPLICATION_JSON_TYPE));
-
- Assertions.assertEquals(Status.OK.getStatusCode(), resp.getStatus());
- GroupResponse groupResponse = resp.readEntity(GroupResponse.class);
- Assertions.assertEquals("ext-group-1", groupResponse.getGroup().externalId());
- }
-
@Test
public void testGetGroup() throws IOException {
Group group = buildGroup("group1");
diff --git a/server/src/test/java/org/apache/gravitino/server/web/rest/TestUserOperations.java b/server/src/test/java/org/apache/gravitino/server/web/rest/TestUserOperations.java
index 7eb57051e0..a5940ee74c 100644
--- a/server/src/test/java/org/apache/gravitino/server/web/rest/TestUserOperations.java
+++ b/server/src/test/java/org/apache/gravitino/server/web/rest/TestUserOperations.java
@@ -221,40 +221,6 @@ public class TestUserOperations extends BaseOperationsTest {
Assertions.assertEquals(RuntimeException.class.getSimpleName(), errorResponse2.getType());
}
- @Test
- public void testAddUserWithExternalId() throws IOException {
- UserAddRequest req = new UserAddRequest("user1", "ext-1", false);
- User user =
- UserEntity.builder()
- .withId(1L)
- .withName("user1")
- .withExternalId("ext-1")
- .withEnabled(false)
- .withRoleNames(Collections.emptyList())
- .withAuditInfo(
- AuditInfo.builder().withCreator("creator").withCreateTime(Instant.now()).build())
- .build();
-
- when(manager.addUser(any(), any(), any(), any(Boolean.class))).thenReturn(user);
-
- BaseMetalake metalake = mock(BaseMetalake.class);
- PropertiesMetadata propertiesMetadata = mock(PropertiesMetadata.class);
- when(propertiesMetadata.getOrDefault(any(), any())).thenReturn(true);
- when(metalake.propertiesMetadata()).thenReturn(propertiesMetadata);
- when(entityStore.get(any(), any(), any())).thenReturn(metalake);
-
- Response resp =
- target("/metalakes/metalake1/users")
- .request(MediaType.APPLICATION_JSON_TYPE)
- .accept("application/vnd.gravitino.v1+json")
- .post(Entity.entity(req, MediaType.APPLICATION_JSON_TYPE));
-
- Assertions.assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus());
- UserResponse userResponse = resp.readEntity(UserResponse.class);
- Assertions.assertEquals("ext-1", userResponse.getUser().externalId());
- Assertions.assertFalse(userResponse.getUser().enabled());
- }
-
@Test
public void testGetUser() throws IOException {