Fixes #11404 - build resource operation list programmatically (#11432)

This commit is contained in:
Suresh Srinivas 2023-05-04 10:05:36 -07:00 committed by GitHub
parent c35a576be3
commit ad1ecff79f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
48 changed files with 205 additions and 688 deletions

View File

@ -33,6 +33,7 @@ import org.openmetadata.schema.EntityInterface;
import org.openmetadata.schema.entity.services.ServiceType;
import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.schema.type.Include;
import org.openmetadata.schema.type.MetadataOperation;
import org.openmetadata.schema.type.TagLabel;
import org.openmetadata.service.exception.CatalogExceptionMessage;
import org.openmetadata.service.exception.EntityNotFoundException;
@ -179,7 +180,11 @@ public final class Entity {
private Entity() {}
public static <T extends EntityInterface> void registerEntity(
Class<T> clazz, String entity, EntityDAO<T> dao, EntityRepository<T> entityRepository) {
Class<T> clazz,
String entity,
EntityDAO<T> dao,
EntityRepository<T> entityRepository,
List<MetadataOperation> entitySpecificOperations) {
DAO_MAP.put(entity, dao);
ENTITY_REPOSITORY_MAP.put(entity, entityRepository);
EntityInterface.CANONICAL_ENTITY_NAME_MAP.put(entity.toLowerCase(Locale.ROOT), entity);
@ -187,6 +192,8 @@ public final class Entity {
ENTITY_LIST.add(entity);
Collections.sort(ENTITY_LIST);
// Set up entity operations for permissions
ResourceRegistry.addResource(entity, entitySpecificOperations);
LOG.info("Registering entity {} {}", clazz, entity);
}
@ -313,8 +320,8 @@ public final class Entity {
return entityRepository;
}
public static <T extends EntityInterface> List<TagLabel> getEntityTags(String entityType, EntityInterface entity) {
EntityRepository<T> entityRepository = (EntityRepository<T>) getEntityRepository(entityType);
public static List<TagLabel> getEntityTags(String entityType, EntityInterface entity) {
EntityRepository<? extends EntityInterface> entityRepository = getEntityRepository(entityType);
return listOrEmpty(entityRepository.getAllTags(entity));
}

View File

@ -1,11 +1,18 @@
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;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import org.openmetadata.schema.type.MetadataOperation;
import org.openmetadata.schema.type.ResourceDescriptor;
import org.openmetadata.service.exception.CatalogExceptionMessage;
@ -15,11 +22,22 @@ public class ResourceRegistry {
public static final Map<String, MetadataOperation> FIELD_TO_EDIT_OPERATION_MAP = new HashMap<>();
public static final Map<MetadataOperation, String> EDIT_OPERATION_TO_OPERATION_MAP = new HashMap<>();
// Operations common to all the entities
public static final List<MetadataOperation> COMMON_OPERATIONS =
new ArrayList<>(
listOf(
MetadataOperation.CREATE,
MetadataOperation.DELETE,
MetadataOperation.VIEW_ALL,
MetadataOperation.EDIT_ALL,
MetadataOperation.EDIT_DESCRIPTION,
MetadataOperation.EDIT_DISPLAY_NAME));
static {
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, Entity.FIELD_OWNER);
mapFieldOperation(MetadataOperation.EDIT_OWNER, FIELD_OWNER);
mapFieldOperation(MetadataOperation.EDIT_CUSTOM_FIELDS, "extension");
mapFieldOperation(MetadataOperation.EDIT_USERS, "users");
mapFieldOperation(MetadataOperation.EDIT_ROLE, "defaultRoles");
@ -27,14 +45,28 @@ public class ResourceRegistry {
mapFieldOperation(MetadataOperation.EDIT_POLICY, "policies");
mapFieldOperation(MetadataOperation.EDIT_TEAMS, "teams");
// TODO tier, lineage, statues, reviewers, tests, queries, data profile, sample data
// Set up "all" resource descriptor that includes operations for all entities
List<MetadataOperation> allOperations = Arrays.asList(MetadataOperation.values());
Collections.sort(allOperations);
RESOURCE_DESCRIPTORS.add(new ResourceDescriptor().withName("all").withOperations(allOperations));
}
private ResourceRegistry() {}
public static void initialize(List<ResourceDescriptor> resourceDescriptors) {
RESOURCE_DESCRIPTORS.clear();
RESOURCE_DESCRIPTORS.addAll(resourceDescriptors);
public static void addResource(String resourceName, List<MetadataOperation> entitySpecificOperations) {
// If resourceName already exists, then no need to add the resource again
if (RESOURCE_DESCRIPTORS.stream().anyMatch(d -> d.getName().equals(resourceName))) {
return;
}
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);
}
public static List<ResourceDescriptor> listResourceDescriptors() {

View File

@ -22,14 +22,14 @@ public class ActivityFeedAlertCache {
protected static EventSubscriptionRepository EVENT_SUB_REPOSITORY;
private static String activityFeedAlertName;
public static void initialize(String alertName, CollectionDAO dao) {
public static void initialize(String alertName, CollectionDAO dao, EventSubscriptionRepository repo) {
if (!INITIALIZED) {
EVENT_SUB_CACHE =
CacheBuilder.newBuilder()
.maximumSize(1000)
.expireAfterWrite(3, TimeUnit.MINUTES)
.build(new ActivityFeedAlertLoader());
EVENT_SUB_REPOSITORY = new EventSubscriptionRepository(dao);
EVENT_SUB_REPOSITORY = repo;
INITIALIZED = true;
activityFeedAlertName = alertName;
}

View File

@ -30,7 +30,7 @@ public class BotRepository extends EntityRepository<Bot> {
static final String BOT_UPDATE_FIELDS = "botUser";
public BotRepository(CollectionDAO dao) {
super(BotResource.COLLECTION_PATH, Entity.BOT, Bot.class, dao.botDAO(), dao, "", BOT_UPDATE_FIELDS);
super(BotResource.COLLECTION_PATH, Entity.BOT, Bot.class, dao.botDAO(), dao, "", BOT_UPDATE_FIELDS, null);
}
@Override

View File

@ -13,6 +13,7 @@
package org.openmetadata.service.jdbi3;
import static org.openmetadata.common.utils.CommonUtil.listOf;
import static org.openmetadata.service.Entity.FIELD_FOLLOWERS;
import com.fasterxml.jackson.core.JsonProcessingException;
@ -23,6 +24,7 @@ import org.openmetadata.schema.entity.data.Chart;
import org.openmetadata.schema.entity.services.DashboardService;
import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.schema.type.Include;
import org.openmetadata.schema.type.MetadataOperation;
import org.openmetadata.schema.type.Relationship;
import org.openmetadata.service.Entity;
import org.openmetadata.service.resources.charts.ChartResource;
@ -42,7 +44,8 @@ public class ChartRepository extends EntityRepository<Chart> {
dao.chartDAO(),
dao,
CHART_PATCH_FIELDS,
CHART_UPDATE_FIELDS);
CHART_UPDATE_FIELDS,
listOf(MetadataOperation.VIEW_USAGE, MetadataOperation.EDIT_LINEAGE));
}
@Override

View File

@ -42,7 +42,8 @@ public class ClassificationRepository extends EntityRepository<Classification> {
dao.classificationDAO(),
dao,
"",
"");
"",
null);
}
@Override

View File

@ -39,7 +39,8 @@ public class ContainerRepository extends EntityRepository<Container> {
dao.containerDAO(),
dao,
CONTAINER_PATCH_FIELDS,
CONTAINER_UPDATE_FIELDS);
CONTAINER_UPDATE_FIELDS,
null);
}
@Override

View File

@ -13,6 +13,7 @@
package org.openmetadata.service.jdbi3;
import static org.openmetadata.common.utils.CommonUtil.listOf;
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
import static org.openmetadata.service.Entity.FIELD_FOLLOWERS;
import static org.openmetadata.service.Entity.FIELD_TAGS;
@ -28,6 +29,7 @@ import org.openmetadata.schema.entity.services.DashboardService;
import org.openmetadata.schema.type.Column;
import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.schema.type.Include;
import org.openmetadata.schema.type.MetadataOperation;
import org.openmetadata.schema.type.Relationship;
import org.openmetadata.schema.type.TagLabel;
import org.openmetadata.service.Entity;
@ -53,7 +55,8 @@ public class DashboardDataModelRepository extends EntityRepository<DashboardData
dao.dataModelDAO(),
dao,
DATA_MODEL_PATCH_FIELDS,
DATA_MODEL_UPDATE_FIELDS);
DATA_MODEL_UPDATE_FIELDS,
listOf(MetadataOperation.EDIT_LINEAGE));
}
@Override

View File

@ -13,6 +13,7 @@
package org.openmetadata.service.jdbi3;
import static org.openmetadata.common.utils.CommonUtil.listOf;
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
import static org.openmetadata.service.Entity.FIELD_FOLLOWERS;
@ -45,7 +46,8 @@ public class DashboardRepository extends EntityRepository<Dashboard> {
dao.dashboardDAO(),
dao,
DASHBOARD_PATCH_FIELDS,
DASHBOARD_UPDATE_FIELDS);
DASHBOARD_UPDATE_FIELDS,
listOf(MetadataOperation.VIEW_USAGE, MetadataOperation.EDIT_LINEAGE));
}
@Override

View File

@ -81,7 +81,8 @@ public class DataInsightChartRepository extends EntityRepository<DataInsightChar
dao.dataInsightChartDAO(),
dao,
PATCH_FIELDS,
UPDATE_FIELDS);
UPDATE_FIELDS,
null);
}
@Override

View File

@ -39,7 +39,8 @@ public class DatabaseRepository extends EntityRepository<Database> {
dao.databaseDAO(),
dao,
DATABASE_PATCH_FIELDS,
DATABASE_UPDATE_FIELDS);
DATABASE_UPDATE_FIELDS,
null);
}
@Override

View File

@ -43,7 +43,8 @@ public class DatabaseSchemaRepository extends EntityRepository<DatabaseSchema> {
dao.databaseSchemaDAO(),
dao,
DATABASE_SCHEMA_PATCH_FIELDS,
DATABASE_SCHEMA_UPDATE_FIELDS);
DATABASE_SCHEMA_UPDATE_FIELDS,
null);
}
@Override

View File

@ -86,6 +86,7 @@ import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.schema.type.EventType;
import org.openmetadata.schema.type.FieldChange;
import org.openmetadata.schema.type.Include;
import org.openmetadata.schema.type.MetadataOperation;
import org.openmetadata.schema.type.ProviderType;
import org.openmetadata.schema.type.Relationship;
import org.openmetadata.schema.type.TagLabel;
@ -171,7 +172,8 @@ public abstract class EntityRepository<T extends EntityInterface> {
EntityDAO<T> entityDAO,
CollectionDAO collectionDAO,
String patchFields,
String putFields) {
String putFields,
List<MetadataOperation> entitySpecificOperations) {
this.collectionPath = collectionPath;
this.entityClass = entityClass;
allowedFields = getEntityFields(entityClass);
@ -186,7 +188,7 @@ public abstract class EntityRepository<T extends EntityInterface> {
this.supportsSoftDelete = allowedFields.contains(FIELD_DELETED);
this.supportsFollower = allowedFields.contains(FIELD_FOLLOWERS);
this.supportsVotes = allowedFields.contains(FIELD_VOTES);
Entity.registerEntity(entityClass, entityType, dao, this);
Entity.registerEntity(entityClass, entityType, dao, this, entitySpecificOperations);
}
/**

View File

@ -47,7 +47,8 @@ public class EventSubscriptionRepository extends EntityRepository<EventSubscript
dao.eventSubscriptionDAO(),
dao,
ALERT_PATCH_FIELDS,
ALERT_UPDATE_FIELDS);
ALERT_UPDATE_FIELDS,
null);
}
@Override

View File

@ -87,6 +87,7 @@ import org.openmetadata.schema.type.TaskStatus;
import org.openmetadata.schema.type.TaskType;
import org.openmetadata.schema.type.ThreadType;
import org.openmetadata.service.Entity;
import org.openmetadata.service.ResourceRegistry;
import org.openmetadata.service.exception.EntityNotFoundException;
import org.openmetadata.service.resources.feeds.FeedResource;
import org.openmetadata.service.resources.feeds.FeedUtil;
@ -106,6 +107,7 @@ public class FeedRepository {
public FeedRepository(CollectionDAO dao) {
this.dao = dao;
ResourceRegistry.addResource("feed", null);
}
public enum FilterType {
@ -802,7 +804,6 @@ public class FeedRepository {
if (!thread.getType().equals(ThreadType.Task)) {
return; // Nothing to resolve
}
List<EntityReference> assignees = thread.getTask().getAssignees();
EntityLink about = EntityLink.parse(thread.getAbout());
EntityReference aboutRef = EntityUtil.validateEntityLink(about);
@ -822,6 +823,7 @@ public class FeedRepository {
// - Creator of the task
// - logged-in user or the teams they belong to were assigned the task
// - logged-in user or the teams they belong to, owns the entity that the task is about
List<EntityReference> assignees = thread.getTask().getAssignees();
if (!thread.getCreatedBy().equals(userName)
&& assignees.stream().noneMatch(assignee -> assignee.getName().equals(userName))
&& assignees.stream().noneMatch(assignee -> teamNames.contains(assignee.getName()))

View File

@ -70,7 +70,8 @@ public class GlossaryRepository extends EntityRepository<Glossary> {
dao.glossaryDAO(),
dao,
PATCH_FIELDS,
UPDATE_FIELDS);
UPDATE_FIELDS,
null);
}
@Override

View File

@ -63,7 +63,8 @@ public class GlossaryTermRepository extends EntityRepository<GlossaryTerm> {
dao.glossaryTermDAO(),
dao,
PATCH_FIELDS,
UPDATE_FIELDS);
UPDATE_FIELDS,
null);
}
@Override

View File

@ -63,7 +63,8 @@ public class IngestionPipelineRepository extends EntityRepository<IngestionPipel
dao.ingestionPipelineDAO(),
dao,
PATCH_FIELDS,
UPDATE_FIELDS);
UPDATE_FIELDS,
null);
}
@Override

View File

@ -42,7 +42,7 @@ public class KpiRepository extends EntityRepository<Kpi> {
public static final String KPI_RESULT_EXTENSION = "kpi.kpiResult";
public KpiRepository(CollectionDAO dao) {
super(KpiResource.COLLECTION_PATH, KPI, Kpi.class, dao.kpiDAO(), dao, PATCH_FIELDS, UPDATE_FIELDS);
super(KpiResource.COLLECTION_PATH, KPI, Kpi.class, dao.kpiDAO(), dao, PATCH_FIELDS, UPDATE_FIELDS, null);
}
@Override

View File

@ -37,7 +37,8 @@ public class MetricsRepository extends EntityRepository<Metrics> {
dao.metricsDAO(),
dao,
"",
METRICS_UPDATE_FIELDS);
METRICS_UPDATE_FIELDS,
null);
}
@Override

View File

@ -56,7 +56,8 @@ public class MlModelRepository extends EntityRepository<MlModel> {
dao.mlModelDAO(),
dao,
MODEL_PATCH_FIELDS,
MODEL_UPDATE_FIELDS);
MODEL_UPDATE_FIELDS,
null);
}
@Override

View File

@ -13,6 +13,7 @@
package org.openmetadata.service.jdbi3;
import static org.openmetadata.common.utils.CommonUtil.listOf;
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
import static org.openmetadata.service.Entity.FIELD_FOLLOWERS;
@ -30,6 +31,7 @@ import org.openmetadata.schema.entity.data.PipelineStatus;
import org.openmetadata.schema.entity.services.PipelineService;
import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.schema.type.Include;
import org.openmetadata.schema.type.MetadataOperation;
import org.openmetadata.schema.type.Relationship;
import org.openmetadata.schema.type.Status;
import org.openmetadata.schema.type.TagLabel;
@ -56,7 +58,8 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
dao.pipelineDAO(),
dao,
PIPELINE_PATCH_FIELDS,
PIPELINE_UPDATE_FIELDS);
PIPELINE_UPDATE_FIELDS,
listOf(MetadataOperation.EDIT_LINEAGE, MetadataOperation.EDIT_STATUS));
}
@Override

View File

@ -60,7 +60,8 @@ public class PolicyRepository extends EntityRepository<Policy> {
dao.policyDAO(),
dao,
POLICY_PATCH_FIELDS,
POLICY_UPDATE_FIELDS);
POLICY_UPDATE_FIELDS,
null);
}
@Override

View File

@ -37,7 +37,8 @@ public class QueryRepository extends EntityRepository<Query> {
dao.queryDAO(),
dao,
QUERY_PATCH_FIELDS,
QUERY_UPDATE_FIELDS);
QUERY_UPDATE_FIELDS,
null);
}
@Override

View File

@ -28,7 +28,15 @@ public class ReportRepository extends EntityRepository<Report> {
private static final String REPORT_UPDATE_FIELDS = "owner";
public ReportRepository(CollectionDAO dao) {
super(ReportResource.COLLECTION_PATH, Entity.REPORT, Report.class, dao.reportDAO(), dao, "", REPORT_UPDATE_FIELDS);
super(
ReportResource.COLLECTION_PATH,
Entity.REPORT,
Report.class,
dao.reportDAO(),
dao,
"",
REPORT_UPDATE_FIELDS,
null);
}
@Override

View File

@ -39,7 +39,7 @@ import org.openmetadata.service.util.EntityUtil.Fields;
@Slf4j
public class RoleRepository extends EntityRepository<Role> {
public RoleRepository(CollectionDAO dao) {
super(RoleResource.COLLECTION_PATH, Entity.ROLE, Role.class, dao.roleDAO(), dao, POLICIES, POLICIES);
super(RoleResource.COLLECTION_PATH, Entity.ROLE, Role.class, dao.roleDAO(), dao, POLICIES, POLICIES, null);
}
@Override

View File

@ -54,7 +54,7 @@ public abstract class ServiceEntityRepository<
Class<S> serviceConnectionClass,
String updatedFields,
ServiceType serviceType) {
super(collectionPath, service, entityDAO.getEntityClass(), entityDAO, dao, PATCH_FIELDS, updatedFields);
super(collectionPath, service, entityDAO.getEntityClass(), entityDAO, dao, PATCH_FIELDS, updatedFields, null);
this.serviceConnectionClass = serviceConnectionClass;
this.serviceType = serviceType;
}

View File

@ -15,6 +15,7 @@ package org.openmetadata.service.jdbi3;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.toUnmodifiableList;
import static org.openmetadata.common.utils.CommonUtil.listOf;
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
import static org.openmetadata.schema.type.Include.ALL;
@ -58,6 +59,7 @@ import org.openmetadata.schema.type.DailyCount;
import org.openmetadata.schema.type.DataModel;
import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.schema.type.JoinedWith;
import org.openmetadata.schema.type.MetadataOperation;
import org.openmetadata.schema.type.Relationship;
import org.openmetadata.schema.type.SystemProfile;
import org.openmetadata.schema.type.TableConstraint;
@ -104,7 +106,18 @@ public class TableRepository extends EntityRepository<Table> {
daoCollection.tableDAO(),
daoCollection,
TABLE_PATCH_FIELDS,
TABLE_UPDATE_FIELDS);
TABLE_UPDATE_FIELDS,
listOf(
MetadataOperation.VIEW_BASIC,
MetadataOperation.VIEW_TESTS,
MetadataOperation.VIEW_QUERIES,
MetadataOperation.VIEW_DATA_PROFILE,
MetadataOperation.VIEW_SAMPLE_DATA,
MetadataOperation.EDIT_TESTS,
MetadataOperation.EDIT_QUERIES,
MetadataOperation.EDIT_DATA_PROFILE,
MetadataOperation.EDIT_SAMPLE_DATA,
MetadataOperation.EDIT_LINEAGE));
}
@Override

View File

@ -40,7 +40,7 @@ import org.openmetadata.service.util.FullyQualifiedName;
@Slf4j
public class TagRepository extends EntityRepository<Tag> {
public TagRepository(CollectionDAO dao) {
super(TagResource.TAG_COLLECTION_PATH, Entity.TAG, Tag.class, dao.tagDAO(), dao, "", "");
super(TagResource.TAG_COLLECTION_PATH, Entity.TAG, Tag.class, dao.tagDAO(), dao, "", "", null);
}
@Override

View File

@ -13,6 +13,7 @@
package org.openmetadata.service.jdbi3;
import static org.openmetadata.common.utils.CommonUtil.listOf;
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
import static org.openmetadata.csv.CsvUtil.addEntityReferences;
@ -59,6 +60,7 @@ import org.openmetadata.schema.entity.teams.Team;
import org.openmetadata.schema.entity.teams.TeamHierarchy;
import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.schema.type.Include;
import org.openmetadata.schema.type.MetadataOperation;
import org.openmetadata.schema.type.Relationship;
import org.openmetadata.schema.type.csv.CsvDocumentation;
import org.openmetadata.schema.type.csv.CsvErrorType;
@ -82,7 +84,15 @@ public class TeamRepository extends EntityRepository<Team> {
private Team organization = null;
public TeamRepository(CollectionDAO dao) {
super(TeamResource.COLLECTION_PATH, TEAM, Team.class, dao.teamDAO(), dao, TEAM_PATCH_FIELDS, TEAM_UPDATE_FIELDS);
super(
TeamResource.COLLECTION_PATH,
TEAM,
Team.class,
dao.teamDAO(),
dao,
TEAM_PATCH_FIELDS,
TEAM_UPDATE_FIELDS,
listOf(MetadataOperation.EDIT_ROLE, MetadataOperation.EDIT_USERS));
}
@Override

View File

@ -41,7 +41,7 @@ public class TestCaseRepository extends EntityRepository<TestCase> {
public static final String TESTCASE_RESULT_EXTENSION = "testCase.testCaseResult";
public TestCaseRepository(CollectionDAO dao) {
super(COLLECTION_PATH, TEST_CASE, TestCase.class, dao.testCaseDAO(), dao, PATCH_FIELDS, UPDATE_FIELDS);
super(COLLECTION_PATH, TEST_CASE, TestCase.class, dao.testCaseDAO(), dao, PATCH_FIELDS, UPDATE_FIELDS, null);
}
@Override

View File

@ -27,7 +27,8 @@ public class TestConnectionDefinitionRepository extends EntityRepository<TestCon
dao.testConnectionDefinitionDAO(),
dao,
PATCH_FIELDS,
UPDATE_FIELDS);
UPDATE_FIELDS,
null);
}
@Override

View File

@ -21,7 +21,8 @@ public class TestDefinitionRepository extends EntityRepository<TestDefinition> {
dao.testDefinitionDAO(),
dao,
PATCH_FIELDS,
UPDATE_FIELDS);
UPDATE_FIELDS,
null);
}
@Override

View File

@ -26,7 +26,8 @@ public class TestSuiteRepository extends EntityRepository<TestSuite> {
dao.testSuiteDAO(),
dao,
PATCH_FIELDS,
UPDATE_FIELDS);
UPDATE_FIELDS,
null);
}
@Override

View File

@ -65,7 +65,8 @@ public class TopicRepository extends EntityRepository<Topic> {
dao.topicDAO(),
dao,
TOPIC_PATCH_FIELDS,
TOPIC_UPDATE_FIELDS);
TOPIC_UPDATE_FIELDS,
null);
}
@Override

View File

@ -49,7 +49,15 @@ public class TypeRepository extends EntityRepository<Type> {
private static final String PATCH_FIELDS = "customProperties";
public TypeRepository(CollectionDAO dao) {
super(TypeResource.COLLECTION_PATH, Entity.TYPE, Type.class, dao.typeEntityDAO(), dao, PATCH_FIELDS, UPDATE_FIELDS);
super(
TypeResource.COLLECTION_PATH,
Entity.TYPE,
Type.class,
dao.typeEntityDAO(),
dao,
PATCH_FIELDS,
UPDATE_FIELDS,
null);
}
@Override

View File

@ -13,6 +13,7 @@
package org.openmetadata.service.jdbi3;
import static org.openmetadata.common.utils.CommonUtil.listOf;
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
import static org.openmetadata.csv.CsvUtil.addEntityReferences;
@ -41,6 +42,7 @@ import org.openmetadata.schema.entity.teams.Team;
import org.openmetadata.schema.entity.teams.User;
import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.schema.type.Include;
import org.openmetadata.schema.type.MetadataOperation;
import org.openmetadata.schema.type.Relationship;
import org.openmetadata.schema.type.csv.CsvDocumentation;
import org.openmetadata.schema.type.csv.CsvErrorType;
@ -67,7 +69,15 @@ public class UserRepository extends EntityRepository<User> {
private final EntityReference organization;
public UserRepository(CollectionDAO dao) {
super(UserResource.COLLECTION_PATH, USER, User.class, dao.userDAO(), dao, USER_PATCH_FIELDS, USER_UPDATE_FIELDS);
super(
UserResource.COLLECTION_PATH,
USER,
User.class,
dao.userDAO(),
dao,
USER_PATCH_FIELDS,
USER_UPDATE_FIELDS,
listOf(MetadataOperation.EDIT_ROLE, MetadataOperation.EDIT_TEAMS));
organization = dao.teamDAO().findEntityReferenceByName(Entity.ORGANIZATION_NAME, Include.ALL);
}

View File

@ -28,7 +28,8 @@ public class WebAnalyticEventRepository extends EntityRepository<WebAnalyticEven
dao.webAnalyticEventDAO(),
dao,
PATCH_FIELDS,
UPDATE_FIELDS);
UPDATE_FIELDS,
null);
}
@Override

View File

@ -25,7 +25,8 @@ public class WorkflowRepository extends EntityRepository<Workflow> {
dao.workflowDAO(),
dao,
PATCH_FIELDS,
UPDATE_FIELDS);
UPDATE_FIELDS,
null);
}
@Override

View File

@ -119,7 +119,7 @@ public class EventSubscriptionResource extends EntityResource<EventSubscription,
try {
dao.initSeedDataFromResources();
EventsSubscriptionRegistry.initialize(listOrEmpty(EventSubscriptionResource.getDescriptors()));
ActivityFeedAlertCache.initialize("ActivityFeedAlert", daoCollection);
ActivityFeedAlertCache.initialize("ActivityFeedAlert", daoCollection, dao);
initializeEventSubscriptions();
} catch (Exception ex) {
// Starting application should not fail

View File

@ -13,8 +13,6 @@
package org.openmetadata.service.resources.policies;
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
import io.swagger.v3.oas.annotations.ExternalDocumentation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@ -48,7 +46,6 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.core.UriInfo;
import lombok.extern.slf4j.Slf4j;
import org.openmetadata.common.utils.CommonUtil;
import org.openmetadata.schema.api.data.RestoreEntity;
import org.openmetadata.schema.api.policies.CreatePolicy;
import org.openmetadata.schema.entity.policies.Policy;
@ -72,7 +69,6 @@ import org.openmetadata.service.security.Authorizer;
import org.openmetadata.service.security.policyevaluator.CompiledRule;
import org.openmetadata.service.security.policyevaluator.PolicyCache;
import org.openmetadata.service.security.policyevaluator.RuleEvaluator;
import org.openmetadata.service.util.EntityUtil;
import org.openmetadata.service.util.JsonUtils;
import org.openmetadata.service.util.ResultList;
@ -103,7 +99,6 @@ public class PolicyResource extends EntityResource<Policy, PolicyRepository> {
public void initialize(OpenMetadataApplicationConfig config) throws IOException {
// Load any existing rules from database, before loading seed data.
dao.initSeedDataFromResources();
ResourceRegistry.initialize(listOrEmpty(PolicyResource.getResourceDescriptors()));
PolicyCache.initialize();
}
@ -475,20 +470,4 @@ public class PolicyResource extends EntityResource<Policy, PolicyRepository> {
}
return policy;
}
public static List<ResourceDescriptor> getResourceDescriptors() throws IOException {
List<String> jsonDataFiles = EntityUtil.getJsonDataResources(".*json/data/ResourceDescriptors.json$");
if (jsonDataFiles.size() != 1) {
LOG.warn("Invalid number of jsonDataFiles {}. Only one expected.", jsonDataFiles.size());
return null;
}
String jsonDataFile = jsonDataFiles.get(0);
try {
String json = CommonUtil.getResourceAsStream(PolicyResource.class.getClassLoader(), jsonDataFile);
return JsonUtils.readObjects(json, ResourceDescriptor.class);
} catch (Exception e) {
LOG.warn("Failed to initialize the resource descriptors from file {}", jsonDataFile, e);
}
return null;
}
}

View File

@ -87,6 +87,14 @@ public class TagLabelCache {
return INSTANCE;
}
public static void cleanUp() {
CLASSIFICATION_CACHE.cleanUp();
TAG_CACHE.cleanUp();
GLOSSARY_CACHE.cleanUp();
GLOSSARY_TERM_CACHE.cleanUp();
INITIALIZED = false;
}
public Classification getClassification(String classificationName) {
try {
return CLASSIFICATION_CACHE.get(classificationName);

View File

@ -1,582 +0,0 @@
[
{
"name" : "all",
"operations" : [
"All",
"Create",
"Delete",
"ViewAll",
"ViewUsage",
"ViewTests",
"ViewQueries",
"ViewDataProfile",
"ViewSampleData",
"EditAll",
"EditCustomFields",
"EditDescription",
"EditDataProfile",
"EditDisplayName",
"EditLineage",
"EditPolicy",
"EditOwner",
"EditQueries",
"EditReviewers",
"EditRole",
"EditSampleData",
"EditStatus",
"EditTags",
"EditTeams",
"EditTier",
"EditTests",
"EditUsers"
]
},
{
"name" : "bot",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditDescription",
"EditDisplayName",
"EditCustomFields"
]
},
{
"name": "chart",
"operations": [
"Create",
"Delete",
"ViewAll",
"ViewUsage",
"EditAll",
"EditDescription",
"EditDisplayName",
"EditTags",
"EditOwner",
"EditTier",
"EditCustomFields",
"EditLineage"
]
},
{
"name" : "query",
"operations" : [
"Create",
"Delete",
"ViewAll",
"ViewQueries",
"EditAll",
"EditDescription",
"EditDisplayName",
"EditOwner",
"EditTags"
]
},
{
"name" : "dashboard",
"operations" : [
"Create",
"Delete",
"ViewAll",
"ViewUsage",
"EditAll",
"EditCustomFields",
"EditDescription",
"EditDisplayName",
"EditLineage",
"EditOwner",
"EditTags",
"EditTier"
]
},
{
"name" : "dashboardService",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditCustomFields",
"EditDescription",
"EditDisplayName",
"EditOwner",
"EditTags"
]
},
{
"name" : "database",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditCustomFields",
"EditDescription",
"EditDisplayName",
"EditOwner",
"EditTags"
]
},
{
"name" : "databaseSchema",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditCustomFields",
"EditDescription",
"EditDisplayName",
"EditOwner",
"EditTags"
]
},
{
"name" : "databaseService",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditCustomFields",
"EditDescription",
"EditDisplayName",
"EditOwner",
"EditTags"
]
},
{
"name" : "glossary",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditCustomFields",
"EditDescription",
"EditDisplayName",
"EditOwner",
"EditTags"
]
},
{
"name" : "glossaryTerm",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditCustomFields",
"EditDescription",
"EditDisplayName",
"EditOwner",
"EditTags"
]
},
{
"name" : "ingestionPipeline",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditDescription",
"EditDisplayName",
"EditCustomFields"
]
},
{
"name" : "messagingService",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditDescription",
"EditDisplayName",
"EditCustomFields",
"EditOwner",
"EditTags"
]
},
{
"name" : "metrics",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditDescription",
"EditDisplayName",
"EditCustomFields",
"EditOwner",
"EditTags"
]
},
{
"name" : "mlmodel",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditCustomFields",
"EditDescription",
"EditDisplayName",
"EditOwner",
"EditTags"
]
},
{
"name" : "mlmodelService",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditCustomFields",
"EditDescription",
"EditDisplayName",
"EditOwner",
"EditTags"
]
},
{
"name" : "container",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditCustomFields",
"EditDescription",
"EditDisplayName",
"EditOwner",
"EditTags"
]
},
{
"name" : "pipeline",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditCustomFields",
"EditDescription",
"EditDisplayName",
"EditLineage",
"EditOwner",
"EditStatus",
"EditTags"
]
},
{
"name" : "pipelineService",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditCustomFields",
"EditDescription",
"EditDisplayName",
"EditOwner",
"EditTags"
]
},
{
"name" : "policy",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditDescription",
"EditDisplayName",
"EditCustomFields",
"EditOwner"
]
},
{
"name" : "report",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditDescription",
"EditDisplayName",
"EditCustomFields",
"EditOwner"
]
},
{
"name" : "role",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditDescription",
"EditDisplayName",
"EditCustomFields"
]
},
{
"name" : "storageService",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditCustomFields",
"EditDescription",
"EditDisplayName",
"EditOwner",
"EditTags"
]
},
{
"name" : "table",
"operations" : [
"Create",
"Delete",
"ViewAll",
"ViewBasic",
"ViewUsage",
"ViewTests",
"ViewQueries",
"ViewDataProfile",
"ViewSampleData",
"EditAll",
"EditDescription",
"EditDisplayName",
"EditTags",
"EditOwner",
"EditTier",
"EditCustomFields",
"EditTests",
"EditQueries",
"EditDataProfile",
"EditSampleData",
"EditLineage"
]
},
{
"name" : "tag",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditDescription",
"EditDisplayName",
"EditCustomFields"
]
},
{
"name" : "classification",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditDescription",
"EditDisplayName",
"EditCustomFields"
]
},
{
"name" : "team",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditCustomFields",
"EditDescription",
"EditDisplayName",
"EditOwner",
"EditPolicy",
"EditRole",
"EditUsers"
]
},
{
"name" : "topic",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditCustomFields",
"EditDescription",
"EditDisplayName",
"EditOwner",
"EditTags"
]
},
{
"name" : "user",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditCustomFields",
"EditDescription",
"EditDisplayName",
"EditRole",
"EditTeams"
]
},
{
"name" : "webhook",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditDescription",
"EditDisplayName",
"EditCustomFields"
]
},
{
"name" : "events",
"operations" : [
"ViewAll"
]
},
{
"name" : "feed",
"operations" : [
"Create",
"Delete",
"ViewAll"
]
},
{
"name" : "testSuite",
"operations" : [
"Create",
"Delete",
"ViewAll"
]
},
{
"name" : "testDefinition",
"operations" : [
"Create",
"Delete",
"ViewAll"
]
},
{
"name" : "testCase",
"operations" : [
"Create",
"Delete",
"ViewAll"
]
},
{
"name" : "testConnectionDefinition",
"operations" : [
"Create",
"Delete",
"ViewAll"
]
},
{
"name" : "type",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditDescription",
"EditDisplayName"
]
},
{
"name" : "webAnalyticEvent",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditDescription",
"EditDisplayName"
]
},
{
"name" : "dataInsightChart",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditDescription"
]
},
{
"name" : "kpi",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditDescription"
]
},
{
"name" : "workflow",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditOwner"
]
},
{
"name" : "metadataService",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditAll",
"EditCustomFields",
"EditDescription",
"EditDisplayName",
"EditOwner",
"EditTags"
]
},
{
"name" : "eventsubscription",
"operations" : [
"Create",
"Delete",
"ViewAll",
"EditDescription"
]
},
{
"name": "dashboardDataModel",
"operations": [
"Create",
"Delete",
"ViewAll",
"ViewUsage",
"EditAll",
"EditDescription",
"EditDisplayName",
"EditLineage",
"EditOwner",
"EditTags"
]
}
]

View File

@ -42,7 +42,8 @@ public class EntityCsvTest {
@BeforeAll
public static void setup() {
Entity.registerEntity(Table.class, Entity.TABLE, Mockito.mock(TableDAO.class), Mockito.mock(TableRepository.class));
Entity.registerEntity(
Table.class, Entity.TABLE, Mockito.mock(TableDAO.class), Mockito.mock(TableRepository.class), null);
}
@Test

View File

@ -32,6 +32,7 @@ import org.junit.jupiter.api.TestInstance;
import org.openmetadata.service.fernet.Fernet;
import org.openmetadata.service.resources.CollectionRegistry;
import org.openmetadata.service.resources.events.WebhookCallbackResource;
import org.openmetadata.service.resources.tags.TagLabelCache;
import org.openmetadata.service.security.policyevaluator.PolicyCache;
import org.openmetadata.service.security.policyevaluator.RoleCache;
import org.openmetadata.service.security.policyevaluator.SubjectCache;
@ -104,6 +105,7 @@ public abstract class OpenMetadataApplicationTest {
SubjectCache.cleanUp();
PolicyCache.cleanUp();
RoleCache.cleanUp();
TagLabelCache.cleanUp();
}
public static Client getClient() {

View File

@ -1,52 +1,43 @@
package org.openmetadata.service.security.policyevaluator;
import static org.junit.jupiter.api.Assertions.*;
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
import static org.openmetadata.common.utils.CommonUtil.listOf;
import static org.openmetadata.service.Entity.ALL_RESOURCES;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.junit.jupiter.api.Test;
import org.openmetadata.schema.entity.policies.accessControl.Rule;
import org.openmetadata.schema.type.ResourceDescriptor;
import org.openmetadata.service.resources.policies.PolicyResource;
class CompiledRuleTest {
private static final List<String> RESOURCE_LIST = listOf("all", "table", "topic", "database", "databaseService");
@Test
void testResourceMatchAll() throws IOException {
void testResourceMatchAll() {
// Rule with resource set to ALL_RESOURCES matches all the resources
CompiledRule rule = new CompiledRule(new Rule().withName("test").withResources(List.of(ALL_RESOURCES)));
List<ResourceDescriptor> resourceDescriptors = listOrEmpty(PolicyResource.getResourceDescriptors());
assertTrue(resourceDescriptors.size() > 0);
for (ResourceDescriptor resourceDescriptor : resourceDescriptors) {
assertTrue(rule.matchResource(resourceDescriptor.getName()));
for (String resourceName : RESOURCE_LIST) {
assertTrue(rule.matchResource(resourceName));
}
}
@Test
void testResourceMatch() throws IOException {
List<ResourceDescriptor> resourceDescriptors = listOrEmpty(PolicyResource.getResourceDescriptors());
void testResourceMatch() {
// Create a random list of resources
Random random = new Random();
List<String> ruleResources = new ArrayList<>();
for (ResourceDescriptor resourceDescriptor : resourceDescriptors) {
if (random.nextBoolean() && !resourceDescriptor.getName().equalsIgnoreCase(ALL_RESOURCES)) {
ruleResources.add(resourceDescriptor.getName());
for (String resource : RESOURCE_LIST) {
if (random.nextBoolean() && !resource.equalsIgnoreCase(ALL_RESOURCES)) {
ruleResources.add(resource);
}
}
assertTrue(ruleResources.size() > 0); // Ensure we are setting at least one resource in a rule
CompiledRule rule = new CompiledRule(new Rule().withName("test").withResources(ruleResources));
for (ResourceDescriptor resourceDescriptor : resourceDescriptors) {
String resourceName = resourceDescriptor.getName();
for (String resource : RESOURCE_LIST) {
assertEquals(
rule.matchResource(resourceName),
ruleResources.contains(resourceName),
"Resource name " + resourceName + " not matched");
rule.matchResource(resource), ruleResources.contains(resource), "Resource name " + resource + " not matched");
}
}
}

View File

@ -3,6 +3,7 @@ package org.openmetadata.service.security.policyevaluator;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.openmetadata.common.utils.CommonUtil.listOf;
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
import static org.openmetadata.service.security.policyevaluator.CompiledRule.parseExpression;
@ -44,24 +45,20 @@ class RuleEvaluatorTest {
@BeforeAll
public static void setup() {
Entity.registerEntity(User.class, Entity.USER, Mockito.mock(UserDAO.class), Mockito.mock(UserRepository.class));
Entity.registerEntity(Team.class, Entity.TEAM, Mockito.mock(TeamDAO.class), Mockito.mock(TeamRepository.class));
Entity.registerEntity(Role.class, Entity.ROLE, Mockito.mock(RoleDAO.class), Mockito.mock(RoleRepository.class));
Entity.registerEntity(User.class, Entity.USER, mock(UserDAO.class), mock(UserRepository.class), null);
Entity.registerEntity(Team.class, Entity.TEAM, mock(TeamDAO.class), mock(TeamRepository.class), null);
Entity.registerEntity(Role.class, Entity.ROLE, mock(RoleDAO.class), mock(RoleRepository.class), null);
SubjectCache.initialize();
RoleCache.initialize();
TableRepository tableRepository = Mockito.mock(TableRepository.class);
TableRepository tableRepository = mock(TableRepository.class);
Mockito.when(tableRepository.getAllTags(any()))
.thenAnswer((Answer<List<TagLabel>>) invocationOnMock -> table.getTags());
Entity.registerEntity(Table.class, Entity.TABLE, Mockito.mock(TableDAO.class), tableRepository);
Entity.registerEntity(Table.class, Entity.TABLE, mock(TableDAO.class), tableRepository, null);
user = new User().withId(UUID.randomUUID()).withName("user");
resourceContext =
ResourceContext.builder()
.resource("table")
.entity(table)
.entityRepository(Mockito.mock(TableRepository.class))
.build();
ResourceContext.builder().resource("table").entity(table).entityRepository(mock(TableRepository.class)).build();
subjectContext = new SubjectContext(user);
RuleEvaluator ruleEvaluator = new RuleEvaluator(null, subjectContext, resourceContext);

View File

@ -15,6 +15,7 @@ package org.openmetadata.service.security.policyevaluator;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
import java.util.ArrayList;
@ -24,7 +25,6 @@ import java.util.UUID;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.openmetadata.schema.EntityInterface;
import org.openmetadata.schema.entity.policies.Policy;
import org.openmetadata.schema.entity.policies.accessControl.Rule;
@ -70,11 +70,10 @@ public class SubjectContextTest {
@BeforeAll
public static void setup() {
Entity.registerEntity(User.class, Entity.USER, Mockito.mock(UserDAO.class), Mockito.mock(UserRepository.class));
Entity.registerEntity(Team.class, Entity.TEAM, Mockito.mock(TeamDAO.class), Mockito.mock(TeamRepository.class));
Entity.registerEntity(
Policy.class, Entity.POLICY, Mockito.mock(PolicyDAO.class), Mockito.mock(PolicyRepository.class));
Entity.registerEntity(Role.class, Entity.ROLE, Mockito.mock(RoleDAO.class), Mockito.mock(RoleRepository.class));
Entity.registerEntity(User.class, Entity.USER, mock(UserDAO.class), mock(UserRepository.class), null);
Entity.registerEntity(Team.class, Entity.TEAM, mock(TeamDAO.class), mock(TeamRepository.class), null);
Entity.registerEntity(Policy.class, Entity.POLICY, mock(PolicyDAO.class), mock(PolicyRepository.class), null);
Entity.registerEntity(Role.class, Entity.ROLE, mock(RoleDAO.class), mock(RoleRepository.class), null);
PolicyCache.initialize();
RoleCache.initialize();
SubjectCache.initialize();