mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-18 13:31:41 +00:00
parent
65c5b44eaa
commit
52cd031036
@ -193,7 +193,7 @@ public final class Entity {
|
||||
Collections.sort(ENTITY_LIST);
|
||||
|
||||
// Set up entity operations for permissions
|
||||
ResourceRegistry.addResource(entity, entitySpecificOperations);
|
||||
ResourceRegistry.addResource(entity, entitySpecificOperations, getEntityFields(clazz));
|
||||
LOG.info("Registering entity {} {}", clazz, entity);
|
||||
}
|
||||
|
||||
@ -345,7 +345,7 @@ public final class Entity {
|
||||
}
|
||||
|
||||
public static Class<? extends EntityInterface> getEntityClassFromType(String entityType) {
|
||||
return EntityInterface.ENTITY_TYPE_TO_CLASS_MAP.get(entityType);
|
||||
return EntityInterface.ENTITY_TYPE_TO_CLASS_MAP.get(entityType.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,6 @@ package org.openmetadata.service;
|
||||
|
||||
import static org.openmetadata.common.utils.CommonUtil.listOf;
|
||||
import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
|
||||
import static org.openmetadata.service.Entity.FIELD_OWNER;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -37,7 +36,7 @@ public class ResourceRegistry {
|
||||
mapFieldOperation(MetadataOperation.EDIT_DESCRIPTION, Entity.FIELD_DESCRIPTION);
|
||||
mapFieldOperation(MetadataOperation.EDIT_DISPLAY_NAME, Entity.FIELD_DISPLAY_NAME);
|
||||
mapFieldOperation(MetadataOperation.EDIT_TAGS, Entity.FIELD_TAGS);
|
||||
mapFieldOperation(MetadataOperation.EDIT_OWNER, FIELD_OWNER);
|
||||
mapFieldOperation(MetadataOperation.EDIT_OWNER, Entity.FIELD_OWNER);
|
||||
mapFieldOperation(MetadataOperation.EDIT_CUSTOM_FIELDS, "extension");
|
||||
mapFieldOperation(MetadataOperation.EDIT_USERS, "users");
|
||||
mapFieldOperation(MetadataOperation.EDIT_ROLE, "defaultRoles");
|
||||
@ -54,19 +53,43 @@ public class ResourceRegistry {
|
||||
|
||||
private ResourceRegistry() {}
|
||||
|
||||
public static void addResource(String resourceName, List<MetadataOperation> entitySpecificOperations) {
|
||||
public static void addResource(
|
||||
String resourceName, List<MetadataOperation> entitySpecificOperations, List<String> entityFields) {
|
||||
// If resourceName already exists, then no need to add the resource again
|
||||
if (RESOURCE_DESCRIPTORS.stream().anyMatch(d -> d.getName().equals(resourceName))) {
|
||||
return;
|
||||
}
|
||||
ResourceDescriptor resourceDescriptor =
|
||||
new ResourceDescriptor()
|
||||
.withName(resourceName)
|
||||
.withOperations(getOperations(resourceName, entitySpecificOperations, entityFields));
|
||||
RESOURCE_DESCRIPTORS.sort(Comparator.comparing(ResourceDescriptor::getName));
|
||||
RESOURCE_DESCRIPTORS.add(resourceDescriptor);
|
||||
}
|
||||
|
||||
private static List<MetadataOperation> getOperations(
|
||||
String resourceName, List<MetadataOperation> entitySpecificOperations, List<String> entityFields) {
|
||||
Set<MetadataOperation> operations = new TreeSet<>(COMMON_OPERATIONS);
|
||||
if (!nullOrEmpty(entitySpecificOperations)) {
|
||||
operations.addAll(entitySpecificOperations);
|
||||
}
|
||||
ResourceDescriptor resourceDescriptor =
|
||||
new ResourceDescriptor().withName(resourceName).withOperations(new ArrayList<>(operations));
|
||||
RESOURCE_DESCRIPTORS.sort(Comparator.comparing(ResourceDescriptor::getName));
|
||||
RESOURCE_DESCRIPTORS.add(resourceDescriptor);
|
||||
// Set up operations based on common fields present in an entity
|
||||
if (entityFields.contains(Entity.FIELD_TAGS)) {
|
||||
operations.add(MetadataOperation.EDIT_TAGS);
|
||||
}
|
||||
if (entityFields.contains(Entity.FIELD_OWNER)) {
|
||||
operations.add(MetadataOperation.EDIT_OWNER);
|
||||
}
|
||||
if (entityFields.contains(Entity.FIELD_EXTENSION)) {
|
||||
operations.add(MetadataOperation.EDIT_CUSTOM_FIELDS);
|
||||
}
|
||||
if (entityFields.contains("roles") || entityFields.contains("defaultRoles")) {
|
||||
operations.add(MetadataOperation.EDIT_ROLE);
|
||||
}
|
||||
if (entityFields.contains("reviewers")) {
|
||||
operations.add(MetadataOperation.EDIT_REVIEWERS);
|
||||
}
|
||||
return new ArrayList<>(operations);
|
||||
}
|
||||
|
||||
public static List<ResourceDescriptor> listResourceDescriptors() {
|
||||
|
@ -56,7 +56,7 @@ public class DashboardDataModelRepository extends EntityRepository<DashboardData
|
||||
dao,
|
||||
DATA_MODEL_PATCH_FIELDS,
|
||||
DATA_MODEL_UPDATE_FIELDS,
|
||||
listOf(MetadataOperation.EDIT_LINEAGE));
|
||||
listOf(MetadataOperation.VIEW_USAGE, MetadataOperation.EDIT_LINEAGE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -107,7 +107,7 @@ public class FeedRepository {
|
||||
|
||||
public FeedRepository(CollectionDAO dao) {
|
||||
this.dao = dao;
|
||||
ResourceRegistry.addResource("feed", null);
|
||||
ResourceRegistry.addResource("feed", null, Entity.getEntityFields(Thread.class));
|
||||
}
|
||||
|
||||
public enum FilterType {
|
||||
|
@ -113,6 +113,7 @@ public class TableRepository extends EntityRepository<Table> {
|
||||
MetadataOperation.VIEW_QUERIES,
|
||||
MetadataOperation.VIEW_DATA_PROFILE,
|
||||
MetadataOperation.VIEW_SAMPLE_DATA,
|
||||
MetadataOperation.VIEW_USAGE,
|
||||
MetadataOperation.EDIT_TESTS,
|
||||
MetadataOperation.EDIT_QUERIES,
|
||||
MetadataOperation.EDIT_DATA_PROFILE,
|
||||
|
@ -92,7 +92,7 @@ public class TeamRepository extends EntityRepository<Team> {
|
||||
dao,
|
||||
TEAM_PATCH_FIELDS,
|
||||
TEAM_UPDATE_FIELDS,
|
||||
listOf(MetadataOperation.EDIT_ROLE, MetadataOperation.EDIT_USERS));
|
||||
listOf(MetadataOperation.EDIT_POLICY, MetadataOperation.EDIT_USERS));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -77,7 +77,7 @@ public class UserRepository extends EntityRepository<User> {
|
||||
dao,
|
||||
USER_PATCH_FIELDS,
|
||||
USER_UPDATE_FIELDS,
|
||||
listOf(MetadataOperation.EDIT_ROLE, MetadataOperation.EDIT_TEAMS));
|
||||
listOf(MetadataOperation.EDIT_TEAMS));
|
||||
organization = dao.teamDAO().findEntityReferenceByName(Entity.ORGANIZATION_NAME, Include.ALL);
|
||||
}
|
||||
|
||||
|
@ -1724,11 +1724,6 @@ public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
|
||||
assertReference(USER2_REF, schema.getOwner()); // Owner remains the same
|
||||
}
|
||||
|
||||
public void checkLocationDeleted(UUID tableId, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
Table getTable = getEntity(tableId, "location", authHeaders);
|
||||
assertNull(getTable.getLocation());
|
||||
}
|
||||
|
||||
void assertFields(List<Table> tableList, String fieldsParam) {
|
||||
tableList.forEach(t -> assertFields(t, fieldsParam));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user