mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-08 00:58:06 +00:00
* Simplify ListAfter code for reducing code verbosity * Move allowed fields functionality to EntityResource and reduce number of fields requested for authorization
This commit is contained in:
parent
6dbb1e578d
commit
3fe7b0cd76
@ -13,8 +13,6 @@
|
|||||||
|
|
||||||
package org.openmetadata.catalog;
|
package org.openmetadata.catalog;
|
||||||
|
|
||||||
import static org.openmetadata.catalog.resources.teams.UserResource.ALLOWED_FIELDS;
|
|
||||||
|
|
||||||
import com.codahale.metrics.health.HealthCheck;
|
import com.codahale.metrics.health.HealthCheck;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -22,12 +20,11 @@ import org.jdbi.v3.core.Jdbi;
|
|||||||
import org.openmetadata.catalog.jdbi3.CollectionDAO;
|
import org.openmetadata.catalog.jdbi3.CollectionDAO;
|
||||||
import org.openmetadata.catalog.jdbi3.ListFilter;
|
import org.openmetadata.catalog.jdbi3.ListFilter;
|
||||||
import org.openmetadata.catalog.jdbi3.UserRepository;
|
import org.openmetadata.catalog.jdbi3.UserRepository;
|
||||||
import org.openmetadata.catalog.util.EntityUtil;
|
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class CatalogHealthCheck extends HealthCheck {
|
public class CatalogHealthCheck extends HealthCheck {
|
||||||
private final UserRepository userRepository;
|
private final UserRepository userRepository;
|
||||||
private final EntityUtil.Fields fields = new EntityUtil.Fields(ALLOWED_FIELDS, "profile");
|
|
||||||
|
|
||||||
public CatalogHealthCheck(Jdbi jdbi) {
|
public CatalogHealthCheck(Jdbi jdbi) {
|
||||||
super();
|
super();
|
||||||
@ -39,7 +36,7 @@ public class CatalogHealthCheck extends HealthCheck {
|
|||||||
protected Result check() throws Exception {
|
protected Result check() throws Exception {
|
||||||
try {
|
try {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter();
|
||||||
userRepository.listAfter(null, fields, filter, 1, null);
|
userRepository.listAfter(null, Fields.EMPTY_FIELDS, filter, 1, null);
|
||||||
return Result.healthy();
|
return Result.healthy();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.error("Health check error {}", e.getMessage());
|
LOG.error("Health check error {}", e.getMessage());
|
||||||
|
@ -216,21 +216,11 @@ public final class Entity {
|
|||||||
return entityRepository.getEntityInterface(entity);
|
return entityRepository.getEntityInterface(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T getEntity(EntityReference ref, EntityUtil.Fields fields) throws IOException, ParseException {
|
|
||||||
return getEntity(ref, fields, Include.NON_DELETED);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T getEntity(EntityReference ref, EntityUtil.Fields fields, Include include)
|
public static <T> T getEntity(EntityReference ref, EntityUtil.Fields fields, Include include)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
return getEntity(ref.getType(), ref.getId(), fields, include);
|
return getEntity(ref.getType(), ref.getId(), fields, include);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Retrieve the entity using id from given entity reference and fields */
|
|
||||||
public static <T> T getEntity(String entityType, UUID id, EntityUtil.Fields fields)
|
|
||||||
throws IOException, ParseException {
|
|
||||||
return getEntity(entityType, id, fields, Include.NON_DELETED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Retrieve the entity using id from given entity reference and fields */
|
/** Retrieve the entity using id from given entity reference and fields */
|
||||||
public static <T> T getEntity(String entityType, UUID id, EntityUtil.Fields fields, Include include)
|
public static <T> T getEntity(String entityType, UUID id, EntityUtil.Fields fields, Include include)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
|
@ -31,10 +31,8 @@ import org.openmetadata.catalog.util.EntityUtil;
|
|||||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||||
|
|
||||||
public class AirflowPipelineRepository extends EntityRepository<AirflowPipeline> {
|
public class AirflowPipelineRepository extends EntityRepository<AirflowPipeline> {
|
||||||
private static final Fields AIRFLOW_PIPELINE_UPDATE_FIELDS =
|
private static final String AIRFLOW_PIPELINE_UPDATE_FIELDS = FIELD_OWNER;
|
||||||
new Fields(AirflowPipelineResource.ALLOWED_FIELDS, FIELD_OWNER);
|
private static final String AIRFLOW_PIPELINE_PATCH_FIELDS = FIELD_OWNER;
|
||||||
private static final Fields AIRFLOW_PIPELINE_PATCH_FIELDS =
|
|
||||||
new Fields(AirflowPipelineResource.ALLOWED_FIELDS, FIELD_OWNER);
|
|
||||||
|
|
||||||
public AirflowPipelineRepository(CollectionDAO dao) {
|
public AirflowPipelineRepository(CollectionDAO dao) {
|
||||||
super(
|
super(
|
||||||
|
@ -26,14 +26,7 @@ import org.openmetadata.catalog.util.EntityUtil.Fields;
|
|||||||
|
|
||||||
public class BotsRepository extends EntityRepository<Bots> {
|
public class BotsRepository extends EntityRepository<Bots> {
|
||||||
public BotsRepository(CollectionDAO dao) {
|
public BotsRepository(CollectionDAO dao) {
|
||||||
super(
|
super(BotsResource.COLLECTION_PATH, Entity.BOTS, Bots.class, dao.botsDAO(), dao, "", "");
|
||||||
BotsResource.COLLECTION_PATH,
|
|
||||||
Entity.BOTS,
|
|
||||||
Bots.class,
|
|
||||||
dao.botsDAO(),
|
|
||||||
dao,
|
|
||||||
Fields.EMPTY_FIELDS,
|
|
||||||
Fields.EMPTY_FIELDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,8 +38,8 @@ import org.openmetadata.catalog.util.EntityUtil.Fields;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ChartRepository extends EntityRepository<Chart> {
|
public class ChartRepository extends EntityRepository<Chart> {
|
||||||
private static final Fields CHART_UPDATE_FIELDS = new Fields(ChartResource.ALLOWED_FIELDS, "owner");
|
private static final String CHART_UPDATE_FIELDS = "owner";
|
||||||
private static final Fields CHART_PATCH_FIELDS = new Fields(ChartResource.ALLOWED_FIELDS, "owner,tags");
|
private static final String CHART_PATCH_FIELDS = "owner,tags";
|
||||||
|
|
||||||
public ChartRepository(CollectionDAO dao) {
|
public ChartRepository(CollectionDAO dao) {
|
||||||
super(
|
super(
|
||||||
|
@ -39,10 +39,8 @@ import org.openmetadata.catalog.util.EntityUtil;
|
|||||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||||
|
|
||||||
public class DashboardRepository extends EntityRepository<Dashboard> {
|
public class DashboardRepository extends EntityRepository<Dashboard> {
|
||||||
private static final Fields DASHBOARD_UPDATE_FIELDS =
|
private static final String DASHBOARD_UPDATE_FIELDS = "owner,tags,charts";
|
||||||
new Fields(DashboardResource.ALLOWED_FIELDS, "owner,tags,charts");
|
private static final String DASHBOARD_PATCH_FIELDS = "owner,tags,charts";
|
||||||
private static final Fields DASHBOARD_PATCH_FIELDS =
|
|
||||||
new Fields(DashboardResource.ALLOWED_FIELDS, "owner,tags,charts");
|
|
||||||
|
|
||||||
public DashboardRepository(CollectionDAO dao) {
|
public DashboardRepository(CollectionDAO dao) {
|
||||||
super(
|
super(
|
||||||
|
@ -31,7 +31,7 @@ import org.openmetadata.catalog.util.EntityUtil;
|
|||||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||||
|
|
||||||
public class DashboardServiceRepository extends EntityRepository<DashboardService> {
|
public class DashboardServiceRepository extends EntityRepository<DashboardService> {
|
||||||
private static final Fields UPDATE_FIELDS = new Fields(DashboardServiceResource.ALLOWED_FIELDS, "owner");
|
private static final String UPDATE_FIELDS = "owner";
|
||||||
|
|
||||||
public DashboardServiceRepository(CollectionDAO dao) {
|
public DashboardServiceRepository(CollectionDAO dao) {
|
||||||
super(
|
super(
|
||||||
@ -40,7 +40,7 @@ public class DashboardServiceRepository extends EntityRepository<DashboardServic
|
|||||||
DashboardService.class,
|
DashboardService.class,
|
||||||
dao.dashboardServiceDAO(),
|
dao.dashboardServiceDAO(),
|
||||||
dao,
|
dao,
|
||||||
Fields.EMPTY_FIELDS,
|
"",
|
||||||
UPDATE_FIELDS);
|
UPDATE_FIELDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ import org.openmetadata.catalog.util.EntityUtil.Fields;
|
|||||||
import org.openmetadata.catalog.util.JsonUtils;
|
import org.openmetadata.catalog.util.JsonUtils;
|
||||||
|
|
||||||
public class DatabaseRepository extends EntityRepository<Database> {
|
public class DatabaseRepository extends EntityRepository<Database> {
|
||||||
private static final Fields DATABASE_UPDATE_FIELDS = new Fields(DatabaseResource.ALLOWED_FIELDS, "owner");
|
private static final String DATABASE_UPDATE_FIELDS = "owner";
|
||||||
private static final Fields DATABASE_PATCH_FIELDS = DATABASE_UPDATE_FIELDS;
|
private static final String DATABASE_PATCH_FIELDS = DATABASE_UPDATE_FIELDS;
|
||||||
|
|
||||||
public DatabaseRepository(CollectionDAO dao) {
|
public DatabaseRepository(CollectionDAO dao) {
|
||||||
super(
|
super(
|
||||||
|
@ -40,7 +40,7 @@ import org.openmetadata.catalog.util.EntityUtil.Fields;
|
|||||||
import org.openmetadata.catalog.util.JsonUtils;
|
import org.openmetadata.catalog.util.JsonUtils;
|
||||||
|
|
||||||
public class DatabaseServiceRepository extends EntityRepository<DatabaseService> {
|
public class DatabaseServiceRepository extends EntityRepository<DatabaseService> {
|
||||||
private static final Fields UPDATE_FIELDS = new Fields(DatabaseServiceResource.ALLOWED_FIELDS, "owner");
|
private static final String UPDATE_FIELDS = "owner";
|
||||||
private final Fernet fernet;
|
private final Fernet fernet;
|
||||||
|
|
||||||
public DatabaseServiceRepository(CollectionDAO dao) {
|
public DatabaseServiceRepository(CollectionDAO dao) {
|
||||||
@ -50,7 +50,7 @@ public class DatabaseServiceRepository extends EntityRepository<DatabaseService>
|
|||||||
DatabaseService.class,
|
DatabaseService.class,
|
||||||
dao.dbServiceDAO(),
|
dao.dbServiceDAO(),
|
||||||
dao,
|
dao,
|
||||||
Fields.EMPTY_FIELDS,
|
"",
|
||||||
UPDATE_FIELDS);
|
UPDATE_FIELDS);
|
||||||
fernet = Fernet.getInstance();
|
fernet = Fernet.getInstance();
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ public class DatabaseServiceRepository extends EntityRepository<DatabaseService>
|
|||||||
if (!fernet.isKeyDefined()) {
|
if (!fernet.isKeyDefined()) {
|
||||||
throw new IllegalArgumentException(CatalogExceptionMessage.FERNET_KEY_NULL);
|
throw new IllegalArgumentException(CatalogExceptionMessage.FERNET_KEY_NULL);
|
||||||
}
|
}
|
||||||
ListFilter filter = new ListFilter().addQueryParam("include", Include.ALL.value());
|
ListFilter filter = new ListFilter(Include.NON_DELETED);
|
||||||
List<String> jsons = dao.listAfter(filter, Integer.MAX_VALUE, "");
|
List<String> jsons = dao.listAfter(filter, Integer.MAX_VALUE, "");
|
||||||
for (String json : jsons) {
|
for (String json : jsons) {
|
||||||
DatabaseService databaseService = JsonUtils.readValue(json, DatabaseService.class);
|
DatabaseService databaseService = JsonUtils.readValue(json, DatabaseService.class);
|
||||||
|
@ -113,6 +113,7 @@ public abstract class EntityRepository<T> {
|
|||||||
private final String entityType;
|
private final String entityType;
|
||||||
protected final EntityDAO<T> dao;
|
protected final EntityDAO<T> dao;
|
||||||
protected final CollectionDAO daoCollection;
|
protected final CollectionDAO daoCollection;
|
||||||
|
protected final List<String> allowedFields;
|
||||||
protected boolean supportsSoftDelete = true;
|
protected boolean supportsSoftDelete = true;
|
||||||
protected final boolean supportsTags;
|
protected final boolean supportsTags;
|
||||||
protected final boolean supportsOwner;
|
protected final boolean supportsOwner;
|
||||||
@ -130,17 +131,17 @@ public abstract class EntityRepository<T> {
|
|||||||
Class<T> entityClass,
|
Class<T> entityClass,
|
||||||
EntityDAO<T> entityDAO,
|
EntityDAO<T> entityDAO,
|
||||||
CollectionDAO collectionDAO,
|
CollectionDAO collectionDAO,
|
||||||
Fields patchFields,
|
String patchFields,
|
||||||
Fields putFields) {
|
String putFields) {
|
||||||
this.collectionPath = collectionPath;
|
this.collectionPath = collectionPath;
|
||||||
this.entityClass = entityClass;
|
this.entityClass = entityClass;
|
||||||
|
allowedFields = getEntityFields(entityClass);
|
||||||
this.dao = entityDAO;
|
this.dao = entityDAO;
|
||||||
this.daoCollection = collectionDAO;
|
this.daoCollection = collectionDAO;
|
||||||
this.patchFields = patchFields;
|
this.patchFields = getFields(patchFields);
|
||||||
this.putFields = putFields;
|
this.putFields = getFields(putFields);
|
||||||
this.entityType = entityType;
|
this.entityType = entityType;
|
||||||
|
|
||||||
List<String> allowedFields = getEntityFields(entityClass);
|
|
||||||
this.supportsTags = allowedFields.contains("tags");
|
this.supportsTags = allowedFields.contains("tags");
|
||||||
this.supportsOwner = allowedFields.contains("owner");
|
this.supportsOwner = allowedFields.contains("owner");
|
||||||
this.supportsFollower = allowedFields.contains("followers");
|
this.supportsFollower = allowedFields.contains("followers");
|
||||||
@ -571,14 +572,14 @@ public abstract class EntityRepository<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Fields FIELDS_OWNER = new Fields(List.of(FIELD_OWNER), FIELD_OWNER);
|
|
||||||
|
|
||||||
// TODO fix this
|
|
||||||
public final EntityReference getOriginalOwner(T entity) throws IOException, ParseException {
|
public final EntityReference getOriginalOwner(T entity) throws IOException, ParseException {
|
||||||
|
if (!supportsOwner) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
// Try to find the owner if entity exists
|
// Try to find the owner if entity exists
|
||||||
try {
|
try {
|
||||||
String fqn = getFullyQualifiedName(entity);
|
String fqn = getFullyQualifiedName(entity);
|
||||||
entity = getByName(null, fqn, FIELDS_OWNER);
|
entity = getByName(null, fqn, getFields(FIELD_OWNER));
|
||||||
return getEntityInterface(entity).getOwner();
|
return getEntityInterface(entity).getOwner();
|
||||||
} catch (EntityNotFoundException e) {
|
} catch (EntityNotFoundException e) {
|
||||||
// If entity is not found, we can return null for owner and ignore this exception
|
// If entity is not found, we can return null for owner and ignore this exception
|
||||||
@ -794,6 +795,9 @@ public abstract class EntityRepository<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public EntityReference getOwner(UUID id, String entityType) throws IOException, ParseException {
|
public EntityReference getOwner(UUID id, String entityType) throws IOException, ParseException {
|
||||||
|
if (!supportsOwner) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
List<EntityReference> refs = findFrom(id, entityType, Relationship.OWNS);
|
List<EntityReference> refs = findFrom(id, entityType, Relationship.OWNS);
|
||||||
ensureSingleRelationship(entityType, id, refs, "owners", false);
|
ensureSingleRelationship(entityType, id, refs, "owners", false);
|
||||||
return refs.isEmpty() ? null : Entity.getEntityReferenceById(refs.get(0).getType(), refs.get(0).getId(), ALL);
|
return refs.isEmpty() ? null : Entity.getEntityReferenceById(refs.get(0).getType(), refs.get(0).getId(), ALL);
|
||||||
@ -834,6 +838,10 @@ public abstract class EntityRepository<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final Fields getFields(String fields) {
|
||||||
|
return new Fields(allowedFields, fields);
|
||||||
|
}
|
||||||
|
|
||||||
enum Operation {
|
enum Operation {
|
||||||
PUT,
|
PUT,
|
||||||
PATCH,
|
PATCH,
|
||||||
|
@ -40,8 +40,8 @@ import org.openmetadata.catalog.util.EntityUtil.Fields;
|
|||||||
import org.openmetadata.catalog.util.JsonUtils;
|
import org.openmetadata.catalog.util.JsonUtils;
|
||||||
|
|
||||||
public class GlossaryRepository extends EntityRepository<Glossary> {
|
public class GlossaryRepository extends EntityRepository<Glossary> {
|
||||||
private static final Fields UPDATE_FIELDS = new Fields(GlossaryResource.ALLOWED_FIELDS, "owner,tags,reviewers");
|
private static final String UPDATE_FIELDS = "owner,tags,reviewers";
|
||||||
private static final Fields PATCH_FIELDS = new Fields(GlossaryResource.ALLOWED_FIELDS, "owner,tags,reviewers");
|
private static final String PATCH_FIELDS = "owner,tags,reviewers";
|
||||||
|
|
||||||
public GlossaryRepository(CollectionDAO dao) {
|
public GlossaryRepository(CollectionDAO dao) {
|
||||||
super(
|
super(
|
||||||
|
@ -46,10 +46,8 @@ import org.openmetadata.catalog.util.JsonUtils;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class GlossaryTermRepository extends EntityRepository<GlossaryTerm> {
|
public class GlossaryTermRepository extends EntityRepository<GlossaryTerm> {
|
||||||
private static final Fields UPDATE_FIELDS =
|
private static final String UPDATE_FIELDS = "tags,references,relatedTerms,reviewers,synonyms";
|
||||||
new Fields(GlossaryTermResource.ALLOWED_FIELDS, "tags,references,relatedTerms,reviewers,synonyms");
|
private static final String PATCH_FIELDS = "tags,references,relatedTerms,reviewers,synonyms";
|
||||||
private static final Fields PATCH_FIELDS =
|
|
||||||
new Fields(GlossaryTermResource.ALLOWED_FIELDS, "tags,references,relatedTerms,reviewers,synonyms");
|
|
||||||
|
|
||||||
public GlossaryTermRepository(CollectionDAO dao) {
|
public GlossaryTermRepository(CollectionDAO dao) {
|
||||||
super(
|
super(
|
||||||
|
@ -3,16 +3,29 @@ package org.openmetadata.catalog.jdbi3;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.openmetadata.catalog.Entity;
|
import org.openmetadata.catalog.Entity;
|
||||||
|
import org.openmetadata.catalog.type.Include;
|
||||||
|
|
||||||
public class ListFilter {
|
public class ListFilter {
|
||||||
|
private final Include include;
|
||||||
Map<String, String> queryParams = new HashMap<>();
|
Map<String, String> queryParams = new HashMap<>();
|
||||||
|
|
||||||
|
public ListFilter() {
|
||||||
|
this(Include.NON_DELETED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ListFilter(Include include) {
|
||||||
|
this.include = include;
|
||||||
|
}
|
||||||
|
|
||||||
public ListFilter addQueryParam(String name, String value) {
|
public ListFilter addQueryParam(String name, String value) {
|
||||||
queryParams.put(name, value);
|
queryParams.put(name, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getQueryParam(String name) {
|
public String getQueryParam(String name) {
|
||||||
|
if (name.equals("include")) {
|
||||||
|
return include.value();
|
||||||
|
}
|
||||||
return queryParams.get(name);
|
return queryParams.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,12 +42,11 @@ public class ListFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getIncludeCondition(String tableName) {
|
public String getIncludeCondition(String tableName) {
|
||||||
String include = queryParams.get("include");
|
|
||||||
String columnName = tableName == null ? "deleted" : tableName + ".deleted";
|
String columnName = tableName == null ? "deleted" : tableName + ".deleted";
|
||||||
if (include == null || include.equals("non-deleted")) {
|
if (include == Include.NON_DELETED) {
|
||||||
return columnName + " = false";
|
return columnName + " = false";
|
||||||
}
|
}
|
||||||
if (include.equals("deleted")) {
|
if (include == Include.DELETED) {
|
||||||
return columnName + " = true";
|
return columnName + " = true";
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
@ -41,9 +41,9 @@ import org.openmetadata.catalog.util.ResultList;
|
|||||||
|
|
||||||
public class LocationRepository extends EntityRepository<Location> {
|
public class LocationRepository extends EntityRepository<Location> {
|
||||||
// Location fields that can be patched in a PATCH request
|
// Location fields that can be patched in a PATCH request
|
||||||
private static final Fields LOCATION_PATCH_FIELDS = new Fields(LocationResource.ALLOWED_FIELDS, "owner,tags");
|
private static final String LOCATION_PATCH_FIELDS = "owner,tags";
|
||||||
// Location fields that can be updated in a PUT request
|
// Location fields that can be updated in a PUT request
|
||||||
private static final Fields LOCATION_UPDATE_FIELDS = new Fields(LocationResource.ALLOWED_FIELDS, "owner,tags");
|
private static final String LOCATION_UPDATE_FIELDS = "owner,tags";
|
||||||
|
|
||||||
public LocationRepository(CollectionDAO dao) {
|
public LocationRepository(CollectionDAO dao) {
|
||||||
super(
|
super(
|
||||||
|
@ -32,7 +32,7 @@ import org.openmetadata.catalog.util.EntityUtil;
|
|||||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||||
|
|
||||||
public class MessagingServiceRepository extends EntityRepository<MessagingService> {
|
public class MessagingServiceRepository extends EntityRepository<MessagingService> {
|
||||||
private static final Fields UPDATE_FIELDS = new Fields(MessagingServiceResource.ALLOWED_FIELDS, "owner");
|
private static final String UPDATE_FIELDS = "owner";
|
||||||
|
|
||||||
public MessagingServiceRepository(CollectionDAO dao) {
|
public MessagingServiceRepository(CollectionDAO dao) {
|
||||||
super(
|
super(
|
||||||
@ -41,7 +41,7 @@ public class MessagingServiceRepository extends EntityRepository<MessagingServic
|
|||||||
MessagingService.class,
|
MessagingService.class,
|
||||||
dao.messagingServiceDAO(),
|
dao.messagingServiceDAO(),
|
||||||
dao,
|
dao,
|
||||||
Fields.EMPTY_FIELDS,
|
"",
|
||||||
UPDATE_FIELDS);
|
UPDATE_FIELDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import org.openmetadata.catalog.util.EntityUtil;
|
|||||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||||
|
|
||||||
public class MetricsRepository extends EntityRepository<Metrics> {
|
public class MetricsRepository extends EntityRepository<Metrics> {
|
||||||
private static final Fields METRICS_UPDATE_FIELDS = new Fields(MetricsResource.ALLOWED_FIELDS, "owner");
|
private static final String METRICS_UPDATE_FIELDS = "owner";
|
||||||
|
|
||||||
public MetricsRepository(CollectionDAO dao) {
|
public MetricsRepository(CollectionDAO dao) {
|
||||||
super(
|
super(
|
||||||
@ -43,7 +43,7 @@ public class MetricsRepository extends EntityRepository<Metrics> {
|
|||||||
Metrics.class,
|
Metrics.class,
|
||||||
dao.metricsDAO(),
|
dao.metricsDAO(),
|
||||||
dao,
|
dao,
|
||||||
Fields.EMPTY_FIELDS,
|
"",
|
||||||
METRICS_UPDATE_FIELDS);
|
METRICS_UPDATE_FIELDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ import org.openmetadata.catalog.util.EntityUtil.Fields;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class MlModelRepository extends EntityRepository<MlModel> {
|
public class MlModelRepository extends EntityRepository<MlModel> {
|
||||||
private static final Fields MODEL_UPDATE_FIELDS = new Fields(MlModelResource.ALLOWED_FIELDS, "owner,dashboard,tags");
|
private static final String MODEL_UPDATE_FIELDS = "owner,dashboard,tags";
|
||||||
private static final Fields MODEL_PATCH_FIELDS = new Fields(MlModelResource.ALLOWED_FIELDS, "owner,dashboard,tags");
|
private static final String MODEL_PATCH_FIELDS = "owner,dashboard,tags";
|
||||||
|
|
||||||
public MlModelRepository(CollectionDAO dao) {
|
public MlModelRepository(CollectionDAO dao) {
|
||||||
super(
|
super(
|
||||||
|
@ -48,8 +48,8 @@ import org.openmetadata.catalog.util.EntityUtil.Fields;
|
|||||||
import org.openmetadata.catalog.util.JsonUtils;
|
import org.openmetadata.catalog.util.JsonUtils;
|
||||||
|
|
||||||
public class PipelineRepository extends EntityRepository<Pipeline> {
|
public class PipelineRepository extends EntityRepository<Pipeline> {
|
||||||
private static final Fields PIPELINE_UPDATE_FIELDS = new Fields(PipelineResource.ALLOWED_FIELDS, "owner,tags,tasks");
|
private static final String PIPELINE_UPDATE_FIELDS = "owner,tags,tasks";
|
||||||
private static final Fields PIPELINE_PATCH_FIELDS = new Fields(PipelineResource.ALLOWED_FIELDS, "owner,tags,tasks");
|
private static final String PIPELINE_PATCH_FIELDS = "owner,tags,tasks";
|
||||||
|
|
||||||
public PipelineRepository(CollectionDAO dao) {
|
public PipelineRepository(CollectionDAO dao) {
|
||||||
super(
|
super(
|
||||||
|
@ -29,7 +29,7 @@ import org.openmetadata.catalog.util.EntityUtil;
|
|||||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||||
|
|
||||||
public class PipelineServiceRepository extends EntityRepository<PipelineService> {
|
public class PipelineServiceRepository extends EntityRepository<PipelineService> {
|
||||||
private static final Fields UPDATE_FIELDS = new Fields(PipelineServiceResource.ALLOWED_FIELDS, "owner");
|
private static final String UPDATE_FIELDS = "owner";
|
||||||
|
|
||||||
public PipelineServiceRepository(CollectionDAO dao) {
|
public PipelineServiceRepository(CollectionDAO dao) {
|
||||||
super(
|
super(
|
||||||
@ -38,7 +38,7 @@ public class PipelineServiceRepository extends EntityRepository<PipelineService>
|
|||||||
PipelineService.class,
|
PipelineService.class,
|
||||||
dao.pipelineServiceDAO(),
|
dao.pipelineServiceDAO(),
|
||||||
dao,
|
dao,
|
||||||
Fields.EMPTY_FIELDS,
|
"",
|
||||||
UPDATE_FIELDS);
|
UPDATE_FIELDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ import org.openmetadata.catalog.resources.policies.PolicyResource;
|
|||||||
import org.openmetadata.catalog.security.policyevaluator.PolicyEvaluator;
|
import org.openmetadata.catalog.security.policyevaluator.PolicyEvaluator;
|
||||||
import org.openmetadata.catalog.type.ChangeDescription;
|
import org.openmetadata.catalog.type.ChangeDescription;
|
||||||
import org.openmetadata.catalog.type.EntityReference;
|
import org.openmetadata.catalog.type.EntityReference;
|
||||||
import org.openmetadata.catalog.type.Include;
|
|
||||||
import org.openmetadata.catalog.type.MetadataOperation;
|
import org.openmetadata.catalog.type.MetadataOperation;
|
||||||
import org.openmetadata.catalog.type.PolicyType;
|
import org.openmetadata.catalog.type.PolicyType;
|
||||||
import org.openmetadata.catalog.type.Relationship;
|
import org.openmetadata.catalog.type.Relationship;
|
||||||
@ -47,8 +46,8 @@ import org.openmetadata.catalog.util.JsonUtils;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class PolicyRepository extends EntityRepository<Policy> {
|
public class PolicyRepository extends EntityRepository<Policy> {
|
||||||
private static final Fields POLICY_UPDATE_FIELDS = new Fields(PolicyResource.ALLOWED_FIELDS, "owner,location");
|
private static final String POLICY_UPDATE_FIELDS = "owner,location";
|
||||||
private static final Fields POLICY_PATCH_FIELDS = new Fields(PolicyResource.ALLOWED_FIELDS, "owner,location");
|
private static final String POLICY_PATCH_FIELDS = "owner,location";
|
||||||
public static final String ENABLED = "enabled";
|
public static final String ENABLED = "enabled";
|
||||||
|
|
||||||
private final PolicyEvaluator policyEvaluator;
|
private final PolicyEvaluator policyEvaluator;
|
||||||
@ -206,7 +205,7 @@ public class PolicyRepository extends EntityRepository<Policy> {
|
|||||||
|
|
||||||
private List<Policy> getAccessControlPolicies() throws IOException, ParseException {
|
private List<Policy> getAccessControlPolicies() throws IOException, ParseException {
|
||||||
EntityUtil.Fields fields = new EntityUtil.Fields(List.of("policyType", "rules", ENABLED));
|
EntityUtil.Fields fields = new EntityUtil.Fields(List.of("policyType", "rules", ENABLED));
|
||||||
ListFilter filter = new ListFilter().addQueryParam("include", Include.NON_DELETED.value());
|
ListFilter filter = new ListFilter();
|
||||||
List<String> jsons = daoCollection.policyDAO().listAfter(filter, Integer.MAX_VALUE, "");
|
List<String> jsons = daoCollection.policyDAO().listAfter(filter, Integer.MAX_VALUE, "");
|
||||||
List<Policy> policies = new ArrayList<>(jsons.size());
|
List<Policy> policies = new ArrayList<>(jsons.size());
|
||||||
for (String json : jsons) {
|
for (String json : jsons) {
|
||||||
|
@ -34,17 +34,10 @@ import org.openmetadata.catalog.util.EntityUtil.Fields;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ReportRepository extends EntityRepository<Report> {
|
public class ReportRepository extends EntityRepository<Report> {
|
||||||
private static final Fields REPORT_UPDATE_FIELDS = new Fields(ReportResource.ALLOWED_FIELDS, "owner");
|
private static final String REPORT_UPDATE_FIELDS = "owner";
|
||||||
|
|
||||||
public ReportRepository(CollectionDAO dao) {
|
public ReportRepository(CollectionDAO dao) {
|
||||||
super(
|
super(ReportResource.COLLECTION_PATH, Entity.REPORT, Report.class, dao.reportDAO(), dao, "", REPORT_UPDATE_FIELDS);
|
||||||
ReportResource.COLLECTION_PATH,
|
|
||||||
Entity.REPORT,
|
|
||||||
Report.class,
|
|
||||||
dao.reportDAO(),
|
|
||||||
dao,
|
|
||||||
Fields.EMPTY_FIELDS,
|
|
||||||
REPORT_UPDATE_FIELDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -37,7 +37,6 @@ import org.openmetadata.catalog.exception.EntityNotFoundException;
|
|||||||
import org.openmetadata.catalog.resources.teams.RoleResource;
|
import org.openmetadata.catalog.resources.teams.RoleResource;
|
||||||
import org.openmetadata.catalog.type.ChangeDescription;
|
import org.openmetadata.catalog.type.ChangeDescription;
|
||||||
import org.openmetadata.catalog.type.EntityReference;
|
import org.openmetadata.catalog.type.EntityReference;
|
||||||
import org.openmetadata.catalog.type.Include;
|
|
||||||
import org.openmetadata.catalog.type.PolicyType;
|
import org.openmetadata.catalog.type.PolicyType;
|
||||||
import org.openmetadata.catalog.type.Relationship;
|
import org.openmetadata.catalog.type.Relationship;
|
||||||
import org.openmetadata.catalog.util.EntityInterface;
|
import org.openmetadata.catalog.util.EntityInterface;
|
||||||
@ -48,18 +47,8 @@ import org.openmetadata.catalog.util.ResultList;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class RoleRepository extends EntityRepository<Role> {
|
public class RoleRepository extends EntityRepository<Role> {
|
||||||
static final Fields ROLE_UPDATE_FIELDS = new Fields(RoleResource.ALLOWED_FIELDS, null);
|
|
||||||
static final Fields ROLE_PATCH_FIELDS = new Fields(RoleResource.ALLOWED_FIELDS, null);
|
|
||||||
|
|
||||||
public RoleRepository(CollectionDAO dao) {
|
public RoleRepository(CollectionDAO dao) {
|
||||||
super(
|
super(RoleResource.COLLECTION_PATH, Entity.ROLE, Role.class, dao.roleDAO(), dao, "", "");
|
||||||
RoleResource.COLLECTION_PATH,
|
|
||||||
Entity.ROLE,
|
|
||||||
Role.class,
|
|
||||||
dao.roleDAO(),
|
|
||||||
dao,
|
|
||||||
ROLE_PATCH_FIELDS,
|
|
||||||
ROLE_UPDATE_FIELDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -328,7 +317,7 @@ public class RoleRepository extends EntityRepository<Role> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setDefaultToTrue(Role role) throws IOException, ParseException {
|
private void setDefaultToTrue(Role role) throws IOException, ParseException {
|
||||||
List<Role> defaultRoles = getDefaultRoles(null, ROLE_PATCH_FIELDS);
|
List<Role> defaultRoles = getDefaultRoles(null, Fields.EMPTY_FIELDS);
|
||||||
EntityRepository<Role> roleRepository = Entity.getEntityRepository(Entity.ROLE);
|
EntityRepository<Role> roleRepository = Entity.getEntityRepository(Entity.ROLE);
|
||||||
// Set default=FALSE for all existing default roles.
|
// Set default=FALSE for all existing default roles.
|
||||||
for (Role defaultRole : defaultRoles) {
|
for (Role defaultRole : defaultRoles) {
|
||||||
@ -336,8 +325,8 @@ public class RoleRepository extends EntityRepository<Role> {
|
|||||||
// Skip the current role which is being set with default=TRUE.
|
// Skip the current role which is being set with default=TRUE.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Role origDefaultRole = roleRepository.get(null, defaultRole.getId().toString(), ROLE_PATCH_FIELDS);
|
Role origDefaultRole = roleRepository.get(null, defaultRole.getId().toString(), Fields.EMPTY_FIELDS);
|
||||||
Role updatedDefaultRole = roleRepository.get(null, defaultRole.getId().toString(), ROLE_PATCH_FIELDS);
|
Role updatedDefaultRole = roleRepository.get(null, defaultRole.getId().toString(), Fields.EMPTY_FIELDS);
|
||||||
updatedDefaultRole = updatedDefaultRole.withDefaultRole(false);
|
updatedDefaultRole = updatedDefaultRole.withDefaultRole(false);
|
||||||
new RoleUpdater(origDefaultRole, updatedDefaultRole, Operation.PATCH).update();
|
new RoleUpdater(origDefaultRole, updatedDefaultRole, Operation.PATCH).update();
|
||||||
}
|
}
|
||||||
@ -366,10 +355,8 @@ public class RoleRepository extends EntityRepository<Role> {
|
|||||||
// Assumptions:
|
// Assumptions:
|
||||||
// - we will not have more than Integer.MAX_VALUE users in the system.
|
// - we will not have more than Integer.MAX_VALUE users in the system.
|
||||||
// - we do not need to update deleted user's roles.
|
// - we do not need to update deleted user's roles.
|
||||||
ListFilter filter = new ListFilter().addQueryParam("include", Include.NON_DELETED.value());
|
ListFilter filter = new ListFilter();
|
||||||
return userRepository
|
return userRepository.listAfter(null, Fields.EMPTY_FIELDS, filter, Integer.MAX_VALUE - 1, null).getData();
|
||||||
.listAfter(null, UserRepository.USER_UPDATE_FIELDS, filter, Integer.MAX_VALUE - 1, null)
|
|
||||||
.getData();
|
|
||||||
} catch (GeneralSecurityException | IOException | ParseException e) {
|
} catch (GeneralSecurityException | IOException | ParseException e) {
|
||||||
throw EntityNotFoundException.byMessage(CatalogExceptionMessage.entitiesNotFound(Entity.USER));
|
throw EntityNotFoundException.byMessage(CatalogExceptionMessage.entitiesNotFound(Entity.USER));
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ import org.openmetadata.catalog.type.EntityReference;
|
|||||||
import org.openmetadata.catalog.util.EntityInterface;
|
import org.openmetadata.catalog.util.EntityInterface;
|
||||||
|
|
||||||
public class StorageServiceRepository extends EntityRepository<StorageService> {
|
public class StorageServiceRepository extends EntityRepository<StorageService> {
|
||||||
private static final Fields UPDATE_FIELDS = new Fields(StorageServiceResource.ALLOWED_FIELDS, "owner");
|
private static final String UPDATE_FIELDS = "owner";
|
||||||
|
|
||||||
public StorageServiceRepository(CollectionDAO dao) {
|
public StorageServiceRepository(CollectionDAO dao) {
|
||||||
super(
|
super(
|
||||||
@ -37,7 +37,7 @@ public class StorageServiceRepository extends EntityRepository<StorageService> {
|
|||||||
StorageService.class,
|
StorageService.class,
|
||||||
dao.storageServiceDAO(),
|
dao.storageServiceDAO(),
|
||||||
dao,
|
dao,
|
||||||
Fields.EMPTY_FIELDS,
|
"",
|
||||||
UPDATE_FIELDS);
|
UPDATE_FIELDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,11 +81,9 @@ import org.openmetadata.common.utils.CommonUtil;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class TableRepository extends EntityRepository<Table> {
|
public class TableRepository extends EntityRepository<Table> {
|
||||||
// Table fields that can be patched in a PATCH request
|
// Table fields that can be patched in a PATCH request
|
||||||
static final Fields TABLE_PATCH_FIELDS =
|
static final String TABLE_PATCH_FIELDS = "owner,tags,tableConstraints,tablePartition";
|
||||||
new Fields(TableResource.ALLOWED_FIELDS, "owner,tags,tableConstraints,tablePartition");
|
|
||||||
// Table fields that can be updated in a PUT request
|
// Table fields that can be updated in a PUT request
|
||||||
static final Fields TABLE_UPDATE_FIELDS =
|
static final String TABLE_UPDATE_FIELDS = "owner,tags,tableConstraints,tablePartition,dataModel,profileSample";
|
||||||
new Fields(TableResource.ALLOWED_FIELDS, "owner,tags,tableConstraints,tablePartition,dataModel,profileSample");
|
|
||||||
|
|
||||||
public TableRepository(CollectionDAO dao) {
|
public TableRepository(CollectionDAO dao) {
|
||||||
super(
|
super(
|
||||||
|
@ -35,8 +35,8 @@ import org.openmetadata.catalog.util.EntityUtil;
|
|||||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||||
|
|
||||||
public class TeamRepository extends EntityRepository<Team> {
|
public class TeamRepository extends EntityRepository<Team> {
|
||||||
static final Fields TEAM_UPDATE_FIELDS = new Fields(TeamResource.ALLOWED_FIELDS, "owner,profile,users,defaultRoles");
|
static final String TEAM_UPDATE_FIELDS = "owner,profile,users,defaultRoles";
|
||||||
static final Fields TEAM_PATCH_FIELDS = new Fields(TeamResource.ALLOWED_FIELDS, "owner,profile,users,defaultRoles");
|
static final String TEAM_PATCH_FIELDS = "owner,profile,users,defaultRoles";
|
||||||
|
|
||||||
public TeamRepository(CollectionDAO dao) {
|
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);
|
||||||
|
@ -39,8 +39,8 @@ import org.openmetadata.catalog.util.EntityUtil;
|
|||||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||||
|
|
||||||
public class TopicRepository extends EntityRepository<Topic> {
|
public class TopicRepository extends EntityRepository<Topic> {
|
||||||
private static final Fields TOPIC_UPDATE_FIELDS = new Fields(TopicResource.ALLOWED_FIELDS, "owner,tags");
|
private static final String TOPIC_UPDATE_FIELDS = "owner,tags";
|
||||||
private static final Fields TOPIC_PATCH_FIELDS = new Fields(TopicResource.ALLOWED_FIELDS, "owner,tags");
|
private static final String TOPIC_PATCH_FIELDS = "owner,tags";
|
||||||
|
|
||||||
public static String getFQN(Topic topic) {
|
public static String getFQN(Topic topic) {
|
||||||
return (topic != null && topic.getService() != null)
|
return (topic != null && topic.getService() != null)
|
||||||
|
@ -33,6 +33,7 @@ import org.openmetadata.catalog.entity.teams.User;
|
|||||||
import org.openmetadata.catalog.resources.teams.UserResource;
|
import org.openmetadata.catalog.resources.teams.UserResource;
|
||||||
import org.openmetadata.catalog.type.ChangeDescription;
|
import org.openmetadata.catalog.type.ChangeDescription;
|
||||||
import org.openmetadata.catalog.type.EntityReference;
|
import org.openmetadata.catalog.type.EntityReference;
|
||||||
|
import org.openmetadata.catalog.type.Include;
|
||||||
import org.openmetadata.catalog.type.Relationship;
|
import org.openmetadata.catalog.type.Relationship;
|
||||||
import org.openmetadata.catalog.util.EntityInterface;
|
import org.openmetadata.catalog.util.EntityInterface;
|
||||||
import org.openmetadata.catalog.util.EntityUtil;
|
import org.openmetadata.catalog.util.EntityUtil;
|
||||||
@ -40,8 +41,8 @@ import org.openmetadata.catalog.util.EntityUtil.Fields;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class UserRepository extends EntityRepository<User> {
|
public class UserRepository extends EntityRepository<User> {
|
||||||
static final Fields USER_PATCH_FIELDS = new Fields(UserResource.ALLOWED_FIELDS, "profile,roles,teams");
|
static final String USER_PATCH_FIELDS = "profile,roles,teams";
|
||||||
static final Fields USER_UPDATE_FIELDS = new Fields(UserResource.ALLOWED_FIELDS, "profile,roles,teams");
|
static final String USER_UPDATE_FIELDS = "profile,roles,teams";
|
||||||
|
|
||||||
public UserRepository(CollectionDAO dao) {
|
public UserRepository(CollectionDAO dao) {
|
||||||
super(
|
super(
|
||||||
@ -82,7 +83,7 @@ public class UserRepository extends EntityRepository<User> {
|
|||||||
List<EntityReference> teamsRef = listOrEmpty(user.getTeams());
|
List<EntityReference> teamsRef = listOrEmpty(user.getTeams());
|
||||||
List<EntityReference> defaultRoles = new ArrayList<>();
|
List<EntityReference> defaultRoles = new ArrayList<>();
|
||||||
for (EntityReference teamRef : teamsRef) {
|
for (EntityReference teamRef : teamsRef) {
|
||||||
Team team = Entity.getEntity(teamRef, new Fields(List.of("defaultRoles")));
|
Team team = Entity.getEntity(teamRef, new Fields(List.of("defaultRoles")), Include.NON_DELETED);
|
||||||
if (team != null && team.getDefaultRoles() != null) {
|
if (team != null && team.getDefaultRoles() != null) {
|
||||||
defaultRoles.addAll(team.getDefaultRoles());
|
defaultRoles.addAll(team.getDefaultRoles());
|
||||||
}
|
}
|
||||||
|
@ -62,14 +62,7 @@ public class WebhookRepository extends EntityRepository<Webhook> {
|
|||||||
private static final ConcurrentHashMap<UUID, WebhookPublisher> webhookPublisherMap = new ConcurrentHashMap<>();
|
private static final ConcurrentHashMap<UUID, WebhookPublisher> webhookPublisherMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public WebhookRepository(CollectionDAO dao) {
|
public WebhookRepository(CollectionDAO dao) {
|
||||||
super(
|
super(WebhookResource.COLLECTION_PATH, Entity.WEBHOOK, Webhook.class, dao.webhookDAO(), dao, "", "");
|
||||||
WebhookResource.COLLECTION_PATH,
|
|
||||||
Entity.WEBHOOK,
|
|
||||||
Webhook.class,
|
|
||||||
dao.webhookDAO(),
|
|
||||||
dao,
|
|
||||||
Fields.EMPTY_FIELDS,
|
|
||||||
Fields.EMPTY_FIELDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,6 +28,10 @@ public abstract class EntityResource<T, K extends EntityRepository<T>> {
|
|||||||
this.authorizer = authorizer;
|
this.authorizer = authorizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final Fields getFields(String fields) {
|
||||||
|
return new Fields(allowedFields, fields);
|
||||||
|
}
|
||||||
|
|
||||||
public abstract T addHref(UriInfo uriInfo, T entity);
|
public abstract T addHref(UriInfo uriInfo, T entity);
|
||||||
|
|
||||||
public final ResultList<T> addHref(UriInfo uriInfo, ResultList<T> list) {
|
public final ResultList<T> addHref(UriInfo uriInfo, ResultList<T> list) {
|
||||||
@ -45,7 +49,7 @@ public abstract class EntityResource<T, K extends EntityRepository<T>> {
|
|||||||
String after)
|
String after)
|
||||||
throws GeneralSecurityException, IOException, ParseException {
|
throws GeneralSecurityException, IOException, ParseException {
|
||||||
RestUtil.validateCursors(before, after);
|
RestUtil.validateCursors(before, after);
|
||||||
Fields fields = new Fields(allowedFields, fieldsParam);
|
Fields fields = getFields(fieldsParam);
|
||||||
|
|
||||||
ResultList<T> resultList;
|
ResultList<T> resultList;
|
||||||
if (before != null) { // Reverse paging
|
if (before != null) { // Reverse paging
|
||||||
@ -58,14 +62,14 @@ public abstract class EntityResource<T, K extends EntityRepository<T>> {
|
|||||||
|
|
||||||
public T getInternal(UriInfo uriInfo, SecurityContext securityContext, String id, String fieldsParam, Include include)
|
public T getInternal(UriInfo uriInfo, SecurityContext securityContext, String id, String fieldsParam, Include include)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(allowedFields, fieldsParam);
|
Fields fields = getFields(fieldsParam);
|
||||||
return addHref(uriInfo, dao.get(uriInfo, id, fields, include));
|
return addHref(uriInfo, dao.get(uriInfo, id, fields, include));
|
||||||
}
|
}
|
||||||
|
|
||||||
public T getByNameInternal(
|
public T getByNameInternal(
|
||||||
UriInfo uriInfo, SecurityContext securityContext, String name, String fieldsParam, Include include)
|
UriInfo uriInfo, SecurityContext securityContext, String name, String fieldsParam, Include include)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(allowedFields, fieldsParam);
|
Fields fields = getFields(fieldsParam);
|
||||||
return addHref(uriInfo, dao.getByName(uriInfo, name, fields, include));
|
return addHref(uriInfo, dao.getByName(uriInfo, name, fields, include));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ import org.openmetadata.catalog.security.Authorizer;
|
|||||||
import org.openmetadata.catalog.security.SecurityUtil;
|
import org.openmetadata.catalog.security.SecurityUtil;
|
||||||
import org.openmetadata.catalog.type.EntityHistory;
|
import org.openmetadata.catalog.type.EntityHistory;
|
||||||
import org.openmetadata.catalog.type.Include;
|
import org.openmetadata.catalog.type.Include;
|
||||||
|
import org.openmetadata.catalog.util.EntityInterface;
|
||||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||||
import org.openmetadata.catalog.util.RestUtil;
|
import org.openmetadata.catalog.util.RestUtil;
|
||||||
import org.openmetadata.catalog.util.RestUtil.DeleteResponse;
|
import org.openmetadata.catalog.util.RestUtil.DeleteResponse;
|
||||||
@ -99,7 +100,6 @@ public class ChartResource extends EntityResource<Chart, ChartRepository> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final String FIELDS = "owner,followers,tags";
|
static final String FIELDS = "owner,followers,tags";
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(Chart.class);
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Operation(
|
@Operation(
|
||||||
@ -145,8 +145,7 @@ public class ChartResource extends EntityResource<Chart, ChartRepository> {
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include).addQueryParam("service", serviceParam);
|
||||||
filter.addQueryParam("include", include.value()).addQueryParam("service", serviceParam);
|
|
||||||
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,14 +303,11 @@ public class ChartResource extends EntityResource<Chart, ChartRepository> {
|
|||||||
}))
|
}))
|
||||||
JsonPatch patch)
|
JsonPatch patch)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, FIELDS);
|
Fields fields = getFields(Entity.FIELD_OWNER);
|
||||||
Chart chart = dao.get(uriInfo, id, fields);
|
Chart chart = dao.get(uriInfo, id, fields);
|
||||||
|
EntityInterface<Chart> entityInterface = dao.getEntityInterface(chart);
|
||||||
SecurityUtil.checkAdminRoleOrPermissions(
|
SecurityUtil.checkAdminRoleOrPermissions(
|
||||||
authorizer,
|
authorizer, securityContext, entityInterface.getEntityReference(), entityInterface.getOwner(), patch);
|
||||||
securityContext,
|
|
||||||
dao.getEntityInterface(chart).getEntityReference(),
|
|
||||||
dao.getOriginalOwner(chart),
|
|
||||||
patch);
|
|
||||||
|
|
||||||
PatchResponse<Chart> response =
|
PatchResponse<Chart> response =
|
||||||
dao.patch(uriInfo, UUID.fromString(id), securityContext.getUserPrincipal().getName(), patch);
|
dao.patch(uriInfo, UUID.fromString(id), securityContext.getUserPrincipal().getName(), patch);
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
package org.openmetadata.catalog.resources.dashboards;
|
package org.openmetadata.catalog.resources.dashboards;
|
||||||
|
|
||||||
|
import static org.openmetadata.catalog.Entity.FIELD_OWNER;
|
||||||
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.v3.oas.annotations.ExternalDocumentation;
|
import io.swagger.v3.oas.annotations.ExternalDocumentation;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@ -59,7 +61,6 @@ import org.openmetadata.catalog.security.Authorizer;
|
|||||||
import org.openmetadata.catalog.security.SecurityUtil;
|
import org.openmetadata.catalog.security.SecurityUtil;
|
||||||
import org.openmetadata.catalog.type.EntityHistory;
|
import org.openmetadata.catalog.type.EntityHistory;
|
||||||
import org.openmetadata.catalog.type.Include;
|
import org.openmetadata.catalog.type.Include;
|
||||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
|
||||||
import org.openmetadata.catalog.util.RestUtil.DeleteResponse;
|
import org.openmetadata.catalog.util.RestUtil.DeleteResponse;
|
||||||
import org.openmetadata.catalog.util.RestUtil.PatchResponse;
|
import org.openmetadata.catalog.util.RestUtil.PatchResponse;
|
||||||
import org.openmetadata.catalog.util.RestUtil.PutResponse;
|
import org.openmetadata.catalog.util.RestUtil.PutResponse;
|
||||||
@ -98,7 +99,6 @@ public class DashboardResource extends EntityResource<Dashboard, DashboardReposi
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final String FIELDS = "owner,charts,followers,tags,usageSummary";
|
static final String FIELDS = "owner,charts,followers,tags,usageSummary";
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(Dashboard.class);
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Valid
|
@Valid
|
||||||
@ -147,8 +147,7 @@ public class DashboardResource extends EntityResource<Dashboard, DashboardReposi
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include).addQueryParam("service", serviceParam);
|
||||||
filter.addQueryParam("include", include.value()).addQueryParam("service", serviceParam);
|
|
||||||
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,8 +307,7 @@ public class DashboardResource extends EntityResource<Dashboard, DashboardReposi
|
|||||||
}))
|
}))
|
||||||
JsonPatch patch)
|
JsonPatch patch)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, FIELDS);
|
Dashboard dashboard = dao.get(uriInfo, id, getFields(FIELD_OWNER));
|
||||||
Dashboard dashboard = dao.get(uriInfo, id, fields);
|
|
||||||
SecurityUtil.checkAdminRoleOrPermissions(
|
SecurityUtil.checkAdminRoleOrPermissions(
|
||||||
authorizer,
|
authorizer,
|
||||||
securityContext,
|
securityContext,
|
||||||
|
@ -59,6 +59,7 @@ import org.openmetadata.catalog.security.Authorizer;
|
|||||||
import org.openmetadata.catalog.security.SecurityUtil;
|
import org.openmetadata.catalog.security.SecurityUtil;
|
||||||
import org.openmetadata.catalog.type.EntityHistory;
|
import org.openmetadata.catalog.type.EntityHistory;
|
||||||
import org.openmetadata.catalog.type.Include;
|
import org.openmetadata.catalog.type.Include;
|
||||||
|
import org.openmetadata.catalog.util.EntityInterface;
|
||||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||||
import org.openmetadata.catalog.util.RestUtil.DeleteResponse;
|
import org.openmetadata.catalog.util.RestUtil.DeleteResponse;
|
||||||
import org.openmetadata.catalog.util.RestUtil.PatchResponse;
|
import org.openmetadata.catalog.util.RestUtil.PatchResponse;
|
||||||
@ -96,7 +97,6 @@ public class DatabaseResource extends EntityResource<Database, DatabaseRepositor
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final String FIELDS = "owner,tables,usageSummary,location";
|
static final String FIELDS = "owner,tables,usageSummary,location";
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(Database.class);
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Operation(
|
@Operation(
|
||||||
@ -144,8 +144,7 @@ public class DatabaseResource extends EntityResource<Database, DatabaseRepositor
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include).addQueryParam("service", serviceParam);
|
||||||
filter.addQueryParam("include", include.value()).addQueryParam("service", serviceParam);
|
|
||||||
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,7 +290,7 @@ public class DatabaseResource extends EntityResource<Database, DatabaseRepositor
|
|||||||
description = "Update an existing database using JsonPatch.",
|
description = "Update an existing database using JsonPatch.",
|
||||||
externalDocs = @ExternalDocumentation(description = "JsonPatch RFC", url = "https://tools.ietf.org/html/rfc6902"))
|
externalDocs = @ExternalDocumentation(description = "JsonPatch RFC", url = "https://tools.ietf.org/html/rfc6902"))
|
||||||
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
|
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
|
||||||
public Response updateDescription(
|
public Response patch(
|
||||||
@Context UriInfo uriInfo,
|
@Context UriInfo uriInfo,
|
||||||
@Context SecurityContext securityContext,
|
@Context SecurityContext securityContext,
|
||||||
@PathParam("id") String id,
|
@PathParam("id") String id,
|
||||||
@ -305,14 +304,10 @@ public class DatabaseResource extends EntityResource<Database, DatabaseRepositor
|
|||||||
}))
|
}))
|
||||||
JsonPatch patch)
|
JsonPatch patch)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, FIELDS);
|
Database database = dao.get(uriInfo, id, getFields(Entity.FIELD_OWNER));
|
||||||
Database database = dao.get(uriInfo, id, fields);
|
EntityInterface<Database> entityInterface = dao.getEntityInterface(database);
|
||||||
SecurityUtil.checkAdminRoleOrPermissions(
|
SecurityUtil.checkAdminRoleOrPermissions(
|
||||||
authorizer,
|
authorizer, securityContext, entityInterface.getEntityReference(), entityInterface.getOwner(), patch);
|
||||||
securityContext,
|
|
||||||
dao.getEntityInterface(database).getEntityReference(),
|
|
||||||
dao.getOriginalOwner(database),
|
|
||||||
patch);
|
|
||||||
|
|
||||||
PatchResponse<Database> response =
|
PatchResponse<Database> response =
|
||||||
dao.patch(uriInfo, UUID.fromString(id), securityContext.getUserPrincipal().getName(), patch);
|
dao.patch(uriInfo, UUID.fromString(id), securityContext.getUserPrincipal().getName(), patch);
|
||||||
@ -349,9 +344,8 @@ public class DatabaseResource extends EntityResource<Database, DatabaseRepositor
|
|||||||
@Context SecurityContext securityContext,
|
@Context SecurityContext securityContext,
|
||||||
@Parameter(description = "Id of the database", schema = @Schema(type = "string")) @PathParam("id") String id)
|
@Parameter(description = "Id of the database", schema = @Schema(type = "string")) @PathParam("id") String id)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, "location");
|
|
||||||
dao.deleteLocation(id);
|
dao.deleteLocation(id);
|
||||||
Database database = dao.get(uriInfo, id, fields);
|
Database database = dao.get(uriInfo, id, Fields.EMPTY_FIELDS);
|
||||||
return addHref(uriInfo, database);
|
return addHref(uriInfo, database);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
package org.openmetadata.catalog.resources.databases;
|
package org.openmetadata.catalog.resources.databases;
|
||||||
|
|
||||||
|
import static org.openmetadata.catalog.Entity.FIELD_OWNER;
|
||||||
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.v3.oas.annotations.ExternalDocumentation;
|
import io.swagger.v3.oas.annotations.ExternalDocumentation;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@ -26,7 +28,6 @@ import java.io.IOException;
|
|||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.json.JsonPatch;
|
import javax.json.JsonPatch;
|
||||||
@ -115,14 +116,6 @@ public class TableResource extends EntityResource<Table, TableRepository> {
|
|||||||
static final String FIELDS =
|
static final String FIELDS =
|
||||||
"tableConstraints,tablePartition,usageSummary,owner,profileSample,customMetrics,"
|
"tableConstraints,tablePartition,usageSummary,owner,profileSample,customMetrics,"
|
||||||
+ "tags,followers,joins,sampleData,viewDefinition,tableProfile,location,tableQueries,dataModel,tests";
|
+ "tags,followers,joins,sampleData,viewDefinition,tableProfile,location,tableQueries,dataModel,tests";
|
||||||
public static final List<String> ALLOWED_FIELDS;
|
|
||||||
|
|
||||||
static {
|
|
||||||
List<String> list = new ArrayList<>(Entity.getEntityFields(Table.class));
|
|
||||||
list.add("tests"); // Add a field parameter called tests that represent the fields - tableTests and columnTests
|
|
||||||
list.add("customMetrics"); // Add a field parameter to add customMetrics information to the columns
|
|
||||||
ALLOWED_FIELDS = Collections.unmodifiableList(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Operation(
|
@Operation(
|
||||||
@ -170,8 +163,7 @@ public class TableResource extends EntityResource<Table, TableRepository> {
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException, ParseException, GeneralSecurityException {
|
throws IOException, ParseException, GeneralSecurityException {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include).addQueryParam("database", databaseParam);
|
||||||
filter.addQueryParam("include", include.value()).addQueryParam("database", databaseParam);
|
|
||||||
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,8 +294,8 @@ public class TableResource extends EntityResource<Table, TableRepository> {
|
|||||||
})
|
})
|
||||||
public Response create(@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreateTable create)
|
public Response create(@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreateTable create)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
SecurityUtil.checkAdminOrBotRole(authorizer, securityContext);
|
|
||||||
Table table = getTable(securityContext, create);
|
Table table = getTable(securityContext, create);
|
||||||
|
SecurityUtil.checkAdminOrBotRole(authorizer, securityContext);
|
||||||
table = addHref(uriInfo, dao.create(uriInfo, validateNewTable(table)));
|
table = addHref(uriInfo, dao.create(uriInfo, validateNewTable(table)));
|
||||||
return Response.created(table.getHref()).entity(table).build();
|
return Response.created(table.getHref()).entity(table).build();
|
||||||
}
|
}
|
||||||
@ -352,8 +344,7 @@ public class TableResource extends EntityResource<Table, TableRepository> {
|
|||||||
}))
|
}))
|
||||||
JsonPatch patch)
|
JsonPatch patch)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, FIELDS);
|
Table table = dao.get(uriInfo, id, getFields(FIELD_OWNER));
|
||||||
Table table = dao.get(uriInfo, id, fields);
|
|
||||||
SecurityUtil.checkAdminRoleOrPermissions(
|
SecurityUtil.checkAdminRoleOrPermissions(
|
||||||
authorizer,
|
authorizer,
|
||||||
securityContext,
|
securityContext,
|
||||||
@ -638,7 +629,7 @@ public class TableResource extends EntityResource<Table, TableRepository> {
|
|||||||
@Context SecurityContext securityContext,
|
@Context SecurityContext securityContext,
|
||||||
@Parameter(description = "Id of the table", schema = @Schema(type = "string")) @PathParam("id") String id)
|
@Parameter(description = "Id of the table", schema = @Schema(type = "string")) @PathParam("id") String id)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, "location");
|
Fields fields = getFields("location");
|
||||||
dao.deleteLocation(id);
|
dao.deleteLocation(id);
|
||||||
Table table = dao.get(uriInfo, id, fields);
|
Table table = dao.get(uriInfo, id, fields);
|
||||||
return addHref(uriInfo, table);
|
return addHref(uriInfo, table);
|
||||||
|
@ -123,9 +123,7 @@ public class WebhookResource extends EntityResource<Webhook, WebhookRepository>
|
|||||||
Include include)
|
Include include)
|
||||||
throws IOException, ParseException, GeneralSecurityException {
|
throws IOException, ParseException, GeneralSecurityException {
|
||||||
RestUtil.validateCursors(before, after);
|
RestUtil.validateCursors(before, after);
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include);
|
||||||
filter.addQueryParam("include", include.value());
|
|
||||||
|
|
||||||
ResultList<Webhook> webhooks;
|
ResultList<Webhook> webhooks;
|
||||||
if (before != null) { // Reverse paging
|
if (before != null) { // Reverse paging
|
||||||
webhooks = dao.listBefore(uriInfo, Fields.EMPTY_FIELDS, filter, limitParam, before);
|
webhooks = dao.listBefore(uriInfo, Fields.EMPTY_FIELDS, filter, limitParam, before);
|
||||||
@ -277,9 +275,7 @@ public class WebhookResource extends EntityResource<Webhook, WebhookRepository>
|
|||||||
public Response updateWebhook(
|
public Response updateWebhook(
|
||||||
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreateWebhook create)
|
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreateWebhook create)
|
||||||
throws IOException, ParseException, InterruptedException {
|
throws IOException, ParseException, InterruptedException {
|
||||||
// TODO
|
SecurityUtil.checkAdminRole(authorizer, securityContext);
|
||||||
// SecurityUtil.checkAdminOrBotRole(authorizer, securityContext);
|
|
||||||
// Table table = getTable(securityContext, create);
|
|
||||||
Webhook webhook = getWebhook(securityContext, create);
|
Webhook webhook = getWebhook(securityContext, create);
|
||||||
webhook.setStatus(Boolean.TRUE.equals(webhook.getEnabled()) ? Status.ACTIVE : Status.DISABLED);
|
webhook.setStatus(Boolean.TRUE.equals(webhook.getEnabled()) ? Status.ACTIVE : Status.DISABLED);
|
||||||
PutResponse<Webhook> putResponse = dao.createOrUpdate(uriInfo, webhook);
|
PutResponse<Webhook> putResponse = dao.createOrUpdate(uriInfo, webhook);
|
||||||
|
@ -72,7 +72,6 @@ import org.openmetadata.catalog.util.ResultList;
|
|||||||
@Collection(name = "feeds")
|
@Collection(name = "feeds")
|
||||||
public class FeedResource {
|
public class FeedResource {
|
||||||
public static final String COLLECTION_PATH = "/v1/feed/";
|
public static final String COLLECTION_PATH = "/v1/feed/";
|
||||||
public static final List<String> ALLOWED_FIELDS = getAllowedFields();
|
|
||||||
|
|
||||||
private final FeedRepository dao;
|
private final FeedRepository dao;
|
||||||
private final Authorizer authorizer;
|
private final Authorizer authorizer;
|
||||||
|
@ -59,9 +59,7 @@ import org.openmetadata.catalog.resources.EntityResource;
|
|||||||
import org.openmetadata.catalog.security.Authorizer;
|
import org.openmetadata.catalog.security.Authorizer;
|
||||||
import org.openmetadata.catalog.security.SecurityUtil;
|
import org.openmetadata.catalog.security.SecurityUtil;
|
||||||
import org.openmetadata.catalog.type.EntityHistory;
|
import org.openmetadata.catalog.type.EntityHistory;
|
||||||
import org.openmetadata.catalog.type.EntityReference;
|
|
||||||
import org.openmetadata.catalog.type.Include;
|
import org.openmetadata.catalog.type.Include;
|
||||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
|
||||||
import org.openmetadata.catalog.util.RestUtil;
|
import org.openmetadata.catalog.util.RestUtil;
|
||||||
import org.openmetadata.catalog.util.RestUtil.DeleteResponse;
|
import org.openmetadata.catalog.util.RestUtil.DeleteResponse;
|
||||||
import org.openmetadata.catalog.util.RestUtil.PatchResponse;
|
import org.openmetadata.catalog.util.RestUtil.PatchResponse;
|
||||||
@ -101,7 +99,6 @@ public class GlossaryResource extends EntityResource<Glossary, GlossaryRepositor
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final String FIELDS = "owner,tags,reviewers,usageCount";
|
static final String FIELDS = "owner,tags,reviewers,usageCount";
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(Glossary.class);
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Valid
|
@Valid
|
||||||
@ -145,8 +142,7 @@ public class GlossaryResource extends EntityResource<Glossary, GlossaryRepositor
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include);
|
||||||
filter.addQueryParam("include", include.value());
|
|
||||||
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,8 +302,7 @@ public class GlossaryResource extends EntityResource<Glossary, GlossaryRepositor
|
|||||||
}))
|
}))
|
||||||
JsonPatch patch)
|
JsonPatch patch)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, FIELDS);
|
Glossary glossary = dao.get(uriInfo, id, getFields(Entity.FIELD_OWNER));
|
||||||
Glossary glossary = dao.get(uriInfo, id, fields);
|
|
||||||
SecurityUtil.checkAdminRoleOrPermissions(
|
SecurityUtil.checkAdminRoleOrPermissions(
|
||||||
authorizer,
|
authorizer,
|
||||||
securityContext,
|
securityContext,
|
||||||
@ -336,8 +331,7 @@ public class GlossaryResource extends EntityResource<Glossary, GlossaryRepositor
|
|||||||
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreateGlossary create)
|
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreateGlossary create)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Glossary glossary = getGlossary(securityContext, create);
|
Glossary glossary = getGlossary(securityContext, create);
|
||||||
EntityReference owner = dao.getOriginalOwner(glossary);
|
SecurityUtil.checkAdminRoleOrPermissions(authorizer, securityContext, dao.getOriginalOwner(glossary));
|
||||||
SecurityUtil.checkAdminRoleOrPermissions(authorizer, securityContext, owner);
|
|
||||||
PutResponse<Glossary> response = dao.createOrUpdate(uriInfo, glossary);
|
PutResponse<Glossary> response = dao.createOrUpdate(uriInfo, glossary);
|
||||||
addHref(uriInfo, response.getEntity());
|
addHref(uriInfo, response.getEntity());
|
||||||
return response.toResponse();
|
return response.toResponse();
|
||||||
|
@ -63,6 +63,7 @@ import org.openmetadata.catalog.security.SecurityUtil;
|
|||||||
import org.openmetadata.catalog.type.EntityHistory;
|
import org.openmetadata.catalog.type.EntityHistory;
|
||||||
import org.openmetadata.catalog.type.EntityReference;
|
import org.openmetadata.catalog.type.EntityReference;
|
||||||
import org.openmetadata.catalog.type.Include;
|
import org.openmetadata.catalog.type.Include;
|
||||||
|
import org.openmetadata.catalog.util.EntityInterface;
|
||||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||||
import org.openmetadata.catalog.util.RestUtil;
|
import org.openmetadata.catalog.util.RestUtil;
|
||||||
import org.openmetadata.catalog.util.RestUtil.DeleteResponse;
|
import org.openmetadata.catalog.util.RestUtil.DeleteResponse;
|
||||||
@ -106,7 +107,6 @@ public class GlossaryTermResource extends EntityResource<GlossaryTerm, GlossaryT
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final String FIELDS = "children,relatedTerms,reviewers,tags,usageCount";
|
static final String FIELDS = "children,relatedTerms,reviewers,tags,usageCount";
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(GlossaryTerm.class);
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Valid
|
@Valid
|
||||||
@ -165,7 +165,7 @@ public class GlossaryTermResource extends EntityResource<GlossaryTerm, GlossaryT
|
|||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
// TODO make this common implementation
|
// TODO make this common implementation
|
||||||
RestUtil.validateCursors(before, after);
|
RestUtil.validateCursors(before, after);
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, fieldsParam);
|
Fields fields = getFields(fieldsParam);
|
||||||
|
|
||||||
// Filter by glossary
|
// Filter by glossary
|
||||||
String fqn = null;
|
String fqn = null;
|
||||||
@ -186,8 +186,7 @@ public class GlossaryTermResource extends EntityResource<GlossaryTerm, GlossaryT
|
|||||||
CatalogExceptionMessage.glossaryTermMismatch(parentTermParam, glossaryIdParam));
|
CatalogExceptionMessage.glossaryTermMismatch(parentTermParam, glossaryIdParam));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include).addQueryParam("parent", fqn);
|
||||||
filter.addQueryParam("include", include.value()).addQueryParam("parent", fqn);
|
|
||||||
|
|
||||||
ResultList<GlossaryTerm> terms;
|
ResultList<GlossaryTerm> terms;
|
||||||
if (before != null) { // Reverse paging
|
if (before != null) { // Reverse paging
|
||||||
@ -339,7 +338,7 @@ public class GlossaryTermResource extends EntityResource<GlossaryTerm, GlossaryT
|
|||||||
description = "Update an existing glossary using JsonPatch.",
|
description = "Update an existing glossary using JsonPatch.",
|
||||||
externalDocs = @ExternalDocumentation(description = "JsonPatch RFC", url = "https://tools.ietf.org/html/rfc6902"))
|
externalDocs = @ExternalDocumentation(description = "JsonPatch RFC", url = "https://tools.ietf.org/html/rfc6902"))
|
||||||
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
|
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
|
||||||
public Response updateDescription(
|
public Response patch(
|
||||||
@Context UriInfo uriInfo,
|
@Context UriInfo uriInfo,
|
||||||
@Context SecurityContext securityContext,
|
@Context SecurityContext securityContext,
|
||||||
@PathParam("id") String id,
|
@PathParam("id") String id,
|
||||||
@ -353,14 +352,10 @@ public class GlossaryTermResource extends EntityResource<GlossaryTerm, GlossaryT
|
|||||||
}))
|
}))
|
||||||
JsonPatch patch)
|
JsonPatch patch)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, FIELDS);
|
GlossaryTerm term = dao.get(uriInfo, id, Fields.EMPTY_FIELDS);
|
||||||
GlossaryTerm term = dao.get(uriInfo, id, fields);
|
EntityInterface<GlossaryTerm> entityInterface = dao.getEntityInterface(term);
|
||||||
SecurityUtil.checkAdminRoleOrPermissions(
|
SecurityUtil.checkAdminRoleOrPermissions(
|
||||||
authorizer,
|
authorizer, securityContext, entityInterface.getEntityReference(), entityInterface.getOwner(), patch);
|
||||||
securityContext,
|
|
||||||
dao.getEntityInterface(term).getEntityReference(),
|
|
||||||
dao.getOriginalOwner(term),
|
|
||||||
patch);
|
|
||||||
PatchResponse<GlossaryTerm> response =
|
PatchResponse<GlossaryTerm> response =
|
||||||
dao.patch(uriInfo, UUID.fromString(id), securityContext.getUserPrincipal().getName(), patch);
|
dao.patch(uriInfo, UUID.fromString(id), securityContext.getUserPrincipal().getName(), patch);
|
||||||
addHref(uriInfo, response.getEntity());
|
addHref(uriInfo, response.getEntity());
|
||||||
@ -383,8 +378,7 @@ public class GlossaryTermResource extends EntityResource<GlossaryTerm, GlossaryT
|
|||||||
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreateGlossaryTerm create)
|
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreateGlossaryTerm create)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
GlossaryTerm term = getGlossaryTerm(securityContext, create);
|
GlossaryTerm term = getGlossaryTerm(securityContext, create);
|
||||||
EntityReference owner = dao.getOriginalOwner(term);
|
SecurityUtil.checkAdminRoleOrPermissions(authorizer, securityContext, dao.getOriginalOwner(term));
|
||||||
SecurityUtil.checkAdminRoleOrPermissions(authorizer, securityContext, owner);
|
|
||||||
PutResponse<GlossaryTerm> response = dao.createOrUpdate(uriInfo, term);
|
PutResponse<GlossaryTerm> response = dao.createOrUpdate(uriInfo, term);
|
||||||
addHref(uriInfo, response.getEntity());
|
addHref(uriInfo, response.getEntity());
|
||||||
return response.toResponse();
|
return response.toResponse();
|
||||||
|
@ -96,7 +96,6 @@ public class LocationResource extends EntityResource<Location, LocationRepositor
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final String FIELDS = "owner,followers,tags";
|
static final String FIELDS = "owner,followers,tags";
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(Location.class);
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Operation(
|
@Operation(
|
||||||
@ -144,8 +143,7 @@ public class LocationResource extends EntityResource<Location, LocationRepositor
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include).addQueryParam("service", serviceParam);
|
||||||
filter.addQueryParam("include", include.value()).addQueryParam("service", serviceParam);
|
|
||||||
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +241,7 @@ public class LocationResource extends EntityResource<Location, LocationRepositor
|
|||||||
String after)
|
String after)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
RestUtil.validateCursors(before, after);
|
RestUtil.validateCursors(before, after);
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, fieldsParam);
|
Fields fields = getFields(fieldsParam);
|
||||||
|
|
||||||
ResultList<Location> locations;
|
ResultList<Location> locations;
|
||||||
if (before != null) { // Reverse paging
|
if (before != null) { // Reverse paging
|
||||||
@ -383,7 +381,7 @@ public class LocationResource extends EntityResource<Location, LocationRepositor
|
|||||||
}))
|
}))
|
||||||
JsonPatch patch)
|
JsonPatch patch)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, FIELDS);
|
Fields fields = getFields(FIELDS);
|
||||||
Location location = dao.get(uriInfo, id, fields);
|
Location location = dao.get(uriInfo, id, fields);
|
||||||
SecurityUtil.checkAdminRoleOrPermissions(
|
SecurityUtil.checkAdminRoleOrPermissions(
|
||||||
authorizer,
|
authorizer,
|
||||||
|
@ -41,7 +41,6 @@ import javax.ws.rs.core.MediaType;
|
|||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.core.SecurityContext;
|
import javax.ws.rs.core.SecurityContext;
|
||||||
import javax.ws.rs.core.UriInfo;
|
import javax.ws.rs.core.UriInfo;
|
||||||
import org.openmetadata.catalog.Entity;
|
|
||||||
import org.openmetadata.catalog.entity.data.Metrics;
|
import org.openmetadata.catalog.entity.data.Metrics;
|
||||||
import org.openmetadata.catalog.jdbi3.CollectionDAO;
|
import org.openmetadata.catalog.jdbi3.CollectionDAO;
|
||||||
import org.openmetadata.catalog.jdbi3.ListFilter;
|
import org.openmetadata.catalog.jdbi3.ListFilter;
|
||||||
@ -77,7 +76,6 @@ public class MetricsResource extends EntityResource<Metrics, MetricsRepository>
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final String FIELDS = "owner,usageSummary";
|
static final String FIELDS = "owner,usageSummary";
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(Metrics.class);
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Operation(
|
@Operation(
|
||||||
|
@ -99,7 +99,6 @@ public class MlModelResource extends EntityResource<MlModel, MlModelRepository>
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final String FIELDS = "owner,dashboard,followers,tags,usageSummary";
|
static final String FIELDS = "owner,dashboard,followers,tags,usageSummary";
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(MlModel.class);
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Valid
|
@Valid
|
||||||
@ -143,8 +142,7 @@ public class MlModelResource extends EntityResource<MlModel, MlModelRepository>
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include);
|
||||||
filter.addQueryParam("include", include.value());
|
|
||||||
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,7 +253,7 @@ public class MlModelResource extends EntityResource<MlModel, MlModelRepository>
|
|||||||
}))
|
}))
|
||||||
JsonPatch patch)
|
JsonPatch patch)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, FIELDS);
|
Fields fields = getFields(FIELDS);
|
||||||
MlModel mlModel = dao.get(uriInfo, id, fields);
|
MlModel mlModel = dao.get(uriInfo, id, fields);
|
||||||
SecurityUtil.checkAdminRoleOrPermissions(
|
SecurityUtil.checkAdminRoleOrPermissions(
|
||||||
authorizer,
|
authorizer,
|
||||||
|
@ -28,8 +28,6 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.json.JsonPatch;
|
import javax.json.JsonPatch;
|
||||||
@ -67,6 +65,7 @@ import org.openmetadata.catalog.security.Authorizer;
|
|||||||
import org.openmetadata.catalog.security.SecurityUtil;
|
import org.openmetadata.catalog.security.SecurityUtil;
|
||||||
import org.openmetadata.catalog.type.EntityHistory;
|
import org.openmetadata.catalog.type.EntityHistory;
|
||||||
import org.openmetadata.catalog.type.Include;
|
import org.openmetadata.catalog.type.Include;
|
||||||
|
import org.openmetadata.catalog.util.EntityInterface;
|
||||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||||
import org.openmetadata.catalog.util.RestUtil.DeleteResponse;
|
import org.openmetadata.catalog.util.RestUtil.DeleteResponse;
|
||||||
import org.openmetadata.catalog.util.RestUtil.PatchResponse;
|
import org.openmetadata.catalog.util.RestUtil.PatchResponse;
|
||||||
@ -112,15 +111,8 @@ public class AirflowPipelineResource extends EntityResource<AirflowPipeline, Air
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final String FIELDS = FIELD_OWNER;
|
static final String FIELDS = FIELD_OWNER;
|
||||||
public static final List<String> ALLOWED_FIELDS;
|
|
||||||
static final String PIPELINE_STATUSES = "pipelineStatuses";
|
static final String PIPELINE_STATUSES = "pipelineStatuses";
|
||||||
|
|
||||||
static {
|
|
||||||
List<String> list = new ArrayList<>();
|
|
||||||
list.addAll(Entity.getEntityFields(AirflowPipeline.class));
|
|
||||||
ALLOWED_FIELDS = Collections.unmodifiableList(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Valid
|
@Valid
|
||||||
@Operation(
|
@Operation(
|
||||||
@ -169,8 +161,7 @@ public class AirflowPipelineResource extends EntityResource<AirflowPipeline, Air
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include).addQueryParam("service", serviceParam);
|
||||||
filter.addQueryParam("include", include.value()).addQueryParam("service", serviceParam);
|
|
||||||
ResultList<AirflowPipeline> airflowPipelines =
|
ResultList<AirflowPipeline> airflowPipelines =
|
||||||
super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
||||||
if (fieldsParam != null && fieldsParam.contains(PIPELINE_STATUSES)) {
|
if (fieldsParam != null && fieldsParam.contains(PIPELINE_STATUSES)) {
|
||||||
@ -268,7 +259,7 @@ public class AirflowPipelineResource extends EntityResource<AirflowPipeline, Air
|
|||||||
@GET
|
@GET
|
||||||
@Path("/name/{fqn}")
|
@Path("/name/{fqn}")
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "Get a AirlfowPipeline by name",
|
summary = "Get a AirflowPipeline by name",
|
||||||
tags = "airflowPipelines",
|
tags = "airflowPipelines",
|
||||||
description = "Get a ingestion by fully qualified name.",
|
description = "Get a ingestion by fully qualified name.",
|
||||||
responses = {
|
responses = {
|
||||||
@ -349,14 +340,10 @@ public class AirflowPipelineResource extends EntityResource<AirflowPipeline, Air
|
|||||||
}))
|
}))
|
||||||
JsonPatch patch)
|
JsonPatch patch)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, FIELDS);
|
AirflowPipeline airflowPipeline = dao.get(uriInfo, id, getFields(FIELD_OWNER));
|
||||||
AirflowPipeline airflowPipeline = dao.get(uriInfo, id, fields);
|
EntityInterface<AirflowPipeline> entityInterface = dao.getEntityInterface(airflowPipeline);
|
||||||
SecurityUtil.checkAdminRoleOrPermissions(
|
SecurityUtil.checkAdminRoleOrPermissions(
|
||||||
authorizer,
|
authorizer, securityContext, entityInterface.getEntityReference(), entityInterface.getOwner(), patch);
|
||||||
securityContext,
|
|
||||||
dao.getEntityInterface(airflowPipeline).getEntityReference(),
|
|
||||||
dao.getOriginalOwner(airflowPipeline),
|
|
||||||
patch);
|
|
||||||
|
|
||||||
PatchResponse<AirflowPipeline> response =
|
PatchResponse<AirflowPipeline> response =
|
||||||
dao.patch(uriInfo, UUID.fromString(id), securityContext.getUserPrincipal().getName(), patch);
|
dao.patch(uriInfo, UUID.fromString(id), securityContext.getUserPrincipal().getName(), patch);
|
||||||
@ -405,7 +392,7 @@ public class AirflowPipelineResource extends EntityResource<AirflowPipeline, Air
|
|||||||
public AirflowPipeline triggerIngestion(
|
public AirflowPipeline triggerIngestion(
|
||||||
@Context UriInfo uriInfo, @PathParam("id") String id, @Context SecurityContext securityContext)
|
@Context UriInfo uriInfo, @PathParam("id") String id, @Context SecurityContext securityContext)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, FIELD_OWNER);
|
Fields fields = getFields(FIELD_OWNER);
|
||||||
AirflowPipeline pipeline = dao.get(uriInfo, id, fields);
|
AirflowPipeline pipeline = dao.get(uriInfo, id, fields);
|
||||||
airflowRESTClient.runPipeline(pipeline.getName());
|
airflowRESTClient.runPipeline(pipeline.getName());
|
||||||
return addHref(uriInfo, dao.get(uriInfo, id, fields));
|
return addHref(uriInfo, dao.get(uriInfo, id, fields));
|
||||||
@ -424,7 +411,7 @@ public class AirflowPipelineResource extends EntityResource<AirflowPipeline, Air
|
|||||||
public Response delete(@Context UriInfo uriInfo, @Context SecurityContext securityContext, @PathParam("id") String id)
|
public Response delete(@Context UriInfo uriInfo, @Context SecurityContext securityContext, @PathParam("id") String id)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
SecurityUtil.checkAdminOrBotRole(authorizer, securityContext);
|
SecurityUtil.checkAdminOrBotRole(authorizer, securityContext);
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, FIELD_OWNER);
|
Fields fields = getFields(FIELD_OWNER);
|
||||||
AirflowPipeline pipeline = dao.get(uriInfo, id, fields);
|
AirflowPipeline pipeline = dao.get(uriInfo, id, fields);
|
||||||
airflowRESTClient.deletePipeline(pipeline.getName());
|
airflowRESTClient.deletePipeline(pipeline.getName());
|
||||||
DeleteResponse<AirflowPipeline> response = dao.delete(securityContext.getUserPrincipal().getName(), id);
|
DeleteResponse<AirflowPipeline> response = dao.delete(securityContext.getUserPrincipal().getName(), id);
|
||||||
|
@ -100,7 +100,6 @@ public class PipelineResource extends EntityResource<Pipeline, PipelineRepositor
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final String FIELDS = "owner,tasks,pipelineStatus,followers,tags";
|
static final String FIELDS = "owner,tasks,pipelineStatus,followers,tags";
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(Pipeline.class);
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Valid
|
@Valid
|
||||||
@ -149,8 +148,7 @@ public class PipelineResource extends EntityResource<Pipeline, PipelineRepositor
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include).addQueryParam("service", serviceParam);
|
||||||
filter.addQueryParam("include", include.value()).addQueryParam("service", serviceParam);
|
|
||||||
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +308,7 @@ public class PipelineResource extends EntityResource<Pipeline, PipelineRepositor
|
|||||||
}))
|
}))
|
||||||
JsonPatch patch)
|
JsonPatch patch)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, FIELDS);
|
Fields fields = getFields(FIELDS);
|
||||||
Pipeline pipeline = dao.get(uriInfo, id, fields);
|
Pipeline pipeline = dao.get(uriInfo, id, fields);
|
||||||
SecurityUtil.checkAdminRoleOrPermissions(
|
SecurityUtil.checkAdminRoleOrPermissions(
|
||||||
authorizer,
|
authorizer,
|
||||||
|
@ -110,7 +110,6 @@ public class PolicyResource extends EntityResource<Policy, PolicyRepository> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final String FIELDS = "owner,location";
|
public static final String FIELDS = "owner,location";
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(Policy.class);
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Valid
|
@Valid
|
||||||
@ -154,8 +153,7 @@ public class PolicyResource extends EntityResource<Policy, PolicyRepository> {
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include);
|
||||||
filter.addQueryParam("include", include.value());
|
|
||||||
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,7 +311,7 @@ public class PolicyResource extends EntityResource<Policy, PolicyRepository> {
|
|||||||
}))
|
}))
|
||||||
JsonPatch patch)
|
JsonPatch patch)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, FIELD_OWNER);
|
Fields fields = getFields(FIELD_OWNER);
|
||||||
Policy policy = dao.get(uriInfo, id, fields);
|
Policy policy = dao.get(uriInfo, id, fields);
|
||||||
SecurityUtil.checkAdminRoleOrPermissions(authorizer, securityContext, dao.getOwnerReference(policy));
|
SecurityUtil.checkAdminRoleOrPermissions(authorizer, securityContext, dao.getOwnerReference(policy));
|
||||||
|
|
||||||
|
@ -39,7 +39,6 @@ import javax.ws.rs.core.MediaType;
|
|||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.core.SecurityContext;
|
import javax.ws.rs.core.SecurityContext;
|
||||||
import javax.ws.rs.core.UriInfo;
|
import javax.ws.rs.core.UriInfo;
|
||||||
import org.openmetadata.catalog.Entity;
|
|
||||||
import org.openmetadata.catalog.entity.data.Report;
|
import org.openmetadata.catalog.entity.data.Report;
|
||||||
import org.openmetadata.catalog.jdbi3.CollectionDAO;
|
import org.openmetadata.catalog.jdbi3.CollectionDAO;
|
||||||
import org.openmetadata.catalog.jdbi3.ListFilter;
|
import org.openmetadata.catalog.jdbi3.ListFilter;
|
||||||
@ -76,7 +75,6 @@ public class ReportResource extends EntityResource<Report, ReportRepository> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final String FIELDS = "owner,usageSummary";
|
static final String FIELDS = "owner,usageSummary";
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(Report.class);
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Operation(
|
@Operation(
|
||||||
@ -97,7 +95,7 @@ public class ReportResource extends EntityResource<Report, ReportRepository> {
|
|||||||
@QueryParam("fields")
|
@QueryParam("fields")
|
||||||
String fieldsParam)
|
String fieldsParam)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, fieldsParam);
|
Fields fields = getFields(fieldsParam);
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter();
|
||||||
return dao.listAfter(uriInfo, fields, filter, 10000, null);
|
return dao.listAfter(uriInfo, fields, filter, 10000, null);
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,6 @@ public class DashboardServiceResource extends EntityResource<DashboardService, D
|
|||||||
public static final String COLLECTION_PATH = "v1/services/dashboardServices";
|
public static final String COLLECTION_PATH = "v1/services/dashboardServices";
|
||||||
|
|
||||||
static final String FIELDS = FIELD_OWNER;
|
static final String FIELDS = FIELD_OWNER;
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(DashboardService.class);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DashboardService addHref(UriInfo uriInfo, DashboardService service) {
|
public DashboardService addHref(UriInfo uriInfo, DashboardService service) {
|
||||||
@ -130,8 +129,7 @@ public class DashboardServiceResource extends EntityResource<DashboardService, D
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include);
|
||||||
filter.addQueryParam("include", include.value());
|
|
||||||
return super.listInternal(uriInfo, null, fieldsParam, filter, limitParam, before, after);
|
return super.listInternal(uriInfo, null, fieldsParam, filter, limitParam, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,7 +287,7 @@ public class DashboardServiceResource extends EntityResource<DashboardService, D
|
|||||||
schema = @Schema(implementation = CreateDashboardService.class))),
|
schema = @Schema(implementation = CreateDashboardService.class))),
|
||||||
@ApiResponse(responseCode = "400", description = "Bad request")
|
@ApiResponse(responseCode = "400", description = "Bad request")
|
||||||
})
|
})
|
||||||
public Response update(
|
public Response createOrUpdate(
|
||||||
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreateDashboardService update)
|
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreateDashboardService update)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
DashboardService service = getService(update, securityContext);
|
DashboardService service = getService(update, securityContext);
|
||||||
|
@ -79,7 +79,6 @@ public class DatabaseServiceResource extends EntityResource<DatabaseService, Dat
|
|||||||
public static final String COLLECTION_PATH = "v1/services/databaseServices/";
|
public static final String COLLECTION_PATH = "v1/services/databaseServices/";
|
||||||
|
|
||||||
static final String FIELDS = "airflowPipeline,owner";
|
static final String FIELDS = "airflowPipeline,owner";
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(DatabaseService.class);
|
|
||||||
private final Fernet fernet;
|
private final Fernet fernet;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -140,12 +139,10 @@ public class DatabaseServiceResource extends EntityResource<DatabaseService, Dat
|
|||||||
Include include)
|
Include include)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
RestUtil.validateCursors(before, after);
|
RestUtil.validateCursors(before, after);
|
||||||
EntityUtil.Fields fields = new EntityUtil.Fields(ALLOWED_FIELDS, fieldsParam);
|
EntityUtil.Fields fields = getFields(fieldsParam);
|
||||||
ResultList<DatabaseService> dbServices;
|
ResultList<DatabaseService> dbServices;
|
||||||
|
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include);
|
||||||
filter.addQueryParam("include", include.value());
|
|
||||||
|
|
||||||
if (before != null) {
|
if (before != null) {
|
||||||
dbServices = dao.listBefore(uriInfo, fields, filter, limitParam, before);
|
dbServices = dao.listBefore(uriInfo, fields, filter, limitParam, before);
|
||||||
} else {
|
} else {
|
||||||
@ -311,9 +308,9 @@ public class DatabaseServiceResource extends EntityResource<DatabaseService, Dat
|
|||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "Update a database service",
|
summary = "Update database service",
|
||||||
tags = "services",
|
tags = "services",
|
||||||
description = "Update an existing database service identified by `id`.",
|
description = "Update an existing or create a new database service.",
|
||||||
responses = {
|
responses = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
responseCode = "200",
|
responseCode = "200",
|
||||||
@ -324,7 +321,7 @@ public class DatabaseServiceResource extends EntityResource<DatabaseService, Dat
|
|||||||
schema = @Schema(implementation = CreateDatabaseService.class))),
|
schema = @Schema(implementation = CreateDatabaseService.class))),
|
||||||
@ApiResponse(responseCode = "400", description = "Bad request")
|
@ApiResponse(responseCode = "400", description = "Bad request")
|
||||||
})
|
})
|
||||||
public Response update(
|
public Response createOrUpdate(
|
||||||
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreateDatabaseService update)
|
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreateDatabaseService update)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
DatabaseService service = getService(update, securityContext);
|
DatabaseService service = getService(update, securityContext);
|
||||||
|
@ -70,7 +70,6 @@ public class MessagingServiceResource extends EntityResource<MessagingService, M
|
|||||||
public static final String COLLECTION_PATH = "v1/services/messagingServices/";
|
public static final String COLLECTION_PATH = "v1/services/messagingServices/";
|
||||||
|
|
||||||
public static final String FIELDS = FIELD_OWNER;
|
public static final String FIELDS = FIELD_OWNER;
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(MessagingService.class);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MessagingService addHref(UriInfo uriInfo, MessagingService service) {
|
public MessagingService addHref(UriInfo uriInfo, MessagingService service) {
|
||||||
@ -133,8 +132,7 @@ public class MessagingServiceResource extends EntityResource<MessagingService, M
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException, ParseException, GeneralSecurityException {
|
throws IOException, ParseException, GeneralSecurityException {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include);
|
||||||
filter.addQueryParam("include", include.value());
|
|
||||||
return super.listInternal(uriInfo, null, fieldsParam, filter, limitParam, before, after);
|
return super.listInternal(uriInfo, null, fieldsParam, filter, limitParam, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +277,7 @@ public class MessagingServiceResource extends EntityResource<MessagingService, M
|
|||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "Update a messaging service",
|
summary = "Update messaging service",
|
||||||
tags = "services",
|
tags = "services",
|
||||||
description = "Create a new messaging service or Update an existing messaging service identified by `id`.",
|
description = "Create a new messaging service or Update an existing messaging service identified by `id`.",
|
||||||
responses = {
|
responses = {
|
||||||
@ -292,7 +290,7 @@ public class MessagingServiceResource extends EntityResource<MessagingService, M
|
|||||||
schema = @Schema(implementation = CreateMessagingService.class))),
|
schema = @Schema(implementation = CreateMessagingService.class))),
|
||||||
@ApiResponse(responseCode = "400", description = "Bad request")
|
@ApiResponse(responseCode = "400", description = "Bad request")
|
||||||
})
|
})
|
||||||
public Response update(
|
public Response createOrUpdate(
|
||||||
@Context UriInfo uriInfo,
|
@Context UriInfo uriInfo,
|
||||||
@Context SecurityContext securityContext,
|
@Context SecurityContext securityContext,
|
||||||
@Parameter(description = "Id of the messaging service", schema = @Schema(type = "string")) @PathParam("id")
|
@Parameter(description = "Id of the messaging service", schema = @Schema(type = "string")) @PathParam("id")
|
||||||
|
@ -70,7 +70,6 @@ public class PipelineServiceResource extends EntityResource<PipelineService, Pip
|
|||||||
public static final String COLLECTION_PATH = "v1/services/pipelineServices/";
|
public static final String COLLECTION_PATH = "v1/services/pipelineServices/";
|
||||||
|
|
||||||
static final String FIELDS = FIELD_OWNER;
|
static final String FIELDS = FIELD_OWNER;
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(PipelineService.class);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PipelineService addHref(UriInfo uriInfo, PipelineService service) {
|
public PipelineService addHref(UriInfo uriInfo, PipelineService service) {
|
||||||
@ -133,8 +132,7 @@ public class PipelineServiceResource extends EntityResource<PipelineService, Pip
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include);
|
||||||
filter.addQueryParam("include", include.value());
|
|
||||||
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +277,7 @@ public class PipelineServiceResource extends EntityResource<PipelineService, Pip
|
|||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "Update a pipeline service",
|
summary = "Update pipeline service",
|
||||||
tags = "services",
|
tags = "services",
|
||||||
description = "Create a new pipeline service or update an existing pipeline service identified by `id`.",
|
description = "Create a new pipeline service or update an existing pipeline service identified by `id`.",
|
||||||
responses = {
|
responses = {
|
||||||
@ -292,7 +290,7 @@ public class PipelineServiceResource extends EntityResource<PipelineService, Pip
|
|||||||
schema = @Schema(implementation = CreatePipelineService.class))),
|
schema = @Schema(implementation = CreatePipelineService.class))),
|
||||||
@ApiResponse(responseCode = "400", description = "Bad request")
|
@ApiResponse(responseCode = "400", description = "Bad request")
|
||||||
})
|
})
|
||||||
public Response update(
|
public Response createOrUpdate(
|
||||||
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreatePipelineService update)
|
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreatePipelineService update)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
PipelineService service = getService(update, securityContext);
|
PipelineService service = getService(update, securityContext);
|
||||||
|
@ -70,7 +70,6 @@ public class StorageServiceResource extends EntityResource<StorageService, Stora
|
|||||||
public static final String COLLECTION_PATH = "v1/services/storageServices/";
|
public static final String COLLECTION_PATH = "v1/services/storageServices/";
|
||||||
|
|
||||||
static final String FIELDS = FIELD_OWNER;
|
static final String FIELDS = FIELD_OWNER;
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(StorageService.class);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StorageService addHref(UriInfo uriInfo, StorageService service) {
|
public StorageService addHref(UriInfo uriInfo, StorageService service) {
|
||||||
@ -133,8 +132,7 @@ public class StorageServiceResource extends EntityResource<StorageService, Stora
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include);
|
||||||
filter.addQueryParam("include", include.value());
|
|
||||||
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +275,7 @@ public class StorageServiceResource extends EntityResource<StorageService, Stora
|
|||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "Update a storage service",
|
summary = "Update storage service",
|
||||||
tags = "services",
|
tags = "services",
|
||||||
description = "Update an existing storage service identified by `id`.",
|
description = "Update an existing storage service identified by `id`.",
|
||||||
responses = {
|
responses = {
|
||||||
@ -288,7 +286,7 @@ public class StorageServiceResource extends EntityResource<StorageService, Stora
|
|||||||
@Content(mediaType = "application/json", schema = @Schema(implementation = StorageService.class))),
|
@Content(mediaType = "application/json", schema = @Schema(implementation = StorageService.class))),
|
||||||
@ApiResponse(responseCode = "400", description = "Bad request")
|
@ApiResponse(responseCode = "400", description = "Bad request")
|
||||||
})
|
})
|
||||||
public Response update(
|
public Response createOrUpdate(
|
||||||
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreateStorageService update)
|
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreateStorageService update)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
StorageService service = getService(update, securityContext);
|
StorageService service = getService(update, securityContext);
|
||||||
|
@ -101,7 +101,6 @@ public class RoleResource extends EntityResource<Role, RoleRepository> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final String FIELDS = "policy,teams,users";
|
public static final String FIELDS = "policy,teams,users";
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(Role.class);
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Valid
|
@Valid
|
||||||
@ -148,8 +147,8 @@ public class RoleResource extends EntityResource<Role, RoleRepository> {
|
|||||||
Include include)
|
Include include)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
RestUtil.validateCursors(before, after);
|
RestUtil.validateCursors(before, after);
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, fieldsParam);
|
Fields fields = getFields(fieldsParam);
|
||||||
ListFilter filter = new ListFilter().addQueryParam("include", include.value());
|
ListFilter filter = new ListFilter(include);
|
||||||
|
|
||||||
ResultList<Role> roles;
|
ResultList<Role> roles;
|
||||||
if (defaultParam) {
|
if (defaultParam) {
|
||||||
@ -213,8 +212,7 @@ public class RoleResource extends EntityResource<Role, RoleRepository> {
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, fieldsParam);
|
return getInternal(uriInfo, securityContext, id, fieldsParam, include);
|
||||||
return addHref(uriInfo, dao.get(uriInfo, id, fields, include));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@ -301,7 +299,7 @@ public class RoleResource extends EntityResource<Role, RoleRepository> {
|
|||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "Create or Update a role",
|
summary = "Update role",
|
||||||
tags = "roles",
|
tags = "roles",
|
||||||
description = "Create or Update a role.",
|
description = "Create or Update a role.",
|
||||||
responses = {
|
responses = {
|
||||||
|
@ -59,7 +59,7 @@ import org.openmetadata.catalog.security.Authorizer;
|
|||||||
import org.openmetadata.catalog.security.SecurityUtil;
|
import org.openmetadata.catalog.security.SecurityUtil;
|
||||||
import org.openmetadata.catalog.type.EntityHistory;
|
import org.openmetadata.catalog.type.EntityHistory;
|
||||||
import org.openmetadata.catalog.type.Include;
|
import org.openmetadata.catalog.type.Include;
|
||||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
import org.openmetadata.catalog.util.EntityInterface;
|
||||||
import org.openmetadata.catalog.util.RestUtil;
|
import org.openmetadata.catalog.util.RestUtil;
|
||||||
import org.openmetadata.catalog.util.RestUtil.DeleteResponse;
|
import org.openmetadata.catalog.util.RestUtil.DeleteResponse;
|
||||||
import org.openmetadata.catalog.util.RestUtil.PatchResponse;
|
import org.openmetadata.catalog.util.RestUtil.PatchResponse;
|
||||||
@ -96,7 +96,6 @@ public class TeamResource extends EntityResource<Team, TeamRepository> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final String FIELDS = "owner,profile,users,owns,defaultRoles";
|
static final String FIELDS = "owner,profile,users,owns,defaultRoles";
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(Team.class);
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Valid
|
@Valid
|
||||||
@ -140,8 +139,7 @@ public class TeamResource extends EntityResource<Team, TeamRepository> {
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include);
|
||||||
filter.addQueryParam("include", include.value());
|
|
||||||
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +279,7 @@ public class TeamResource extends EntityResource<Team, TeamRepository> {
|
|||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "Create or Update a team",
|
summary = "Update team",
|
||||||
tags = "teams",
|
tags = "teams",
|
||||||
description = "Create or Update a team.",
|
description = "Create or Update a team.",
|
||||||
responses = {
|
responses = {
|
||||||
@ -291,7 +289,7 @@ public class TeamResource extends EntityResource<Team, TeamRepository> {
|
|||||||
content = @Content(mediaType = "application/json", schema = @Schema(implementation = CreateTeam.class))),
|
content = @Content(mediaType = "application/json", schema = @Schema(implementation = CreateTeam.class))),
|
||||||
@ApiResponse(responseCode = "400", description = "Bad request")
|
@ApiResponse(responseCode = "400", description = "Bad request")
|
||||||
})
|
})
|
||||||
public Response createOrUpdateTeam(
|
public Response createOrUpdate(
|
||||||
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreateTeam ct)
|
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreateTeam ct)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Team team = getTeam(ct, securityContext);
|
Team team = getTeam(ct, securityContext);
|
||||||
@ -323,14 +321,10 @@ public class TeamResource extends EntityResource<Team, TeamRepository> {
|
|||||||
}))
|
}))
|
||||||
JsonPatch patch)
|
JsonPatch patch)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, FIELDS);
|
Team team = dao.get(uriInfo, id, getFields(Entity.FIELD_OWNER));
|
||||||
Team team = dao.get(uriInfo, id, fields);
|
EntityInterface<Team> entityInterface = dao.getEntityInterface(team);
|
||||||
SecurityUtil.checkAdminRoleOrPermissions(
|
SecurityUtil.checkAdminRoleOrPermissions(
|
||||||
authorizer,
|
authorizer, securityContext, entityInterface.getEntityReference(), entityInterface.getOwner(), patch);
|
||||||
securityContext,
|
|
||||||
dao.getEntityInterface(team).getEntityReference(),
|
|
||||||
dao.getOriginalOwner(team),
|
|
||||||
patch);
|
|
||||||
PatchResponse<Team> response =
|
PatchResponse<Team> response =
|
||||||
dao.patch(uriInfo, UUID.fromString(id), securityContext.getUserPrincipal().getName(), patch);
|
dao.patch(uriInfo, UUID.fromString(id), securityContext.getUserPrincipal().getName(), patch);
|
||||||
addHref(uriInfo, response.getEntity());
|
addHref(uriInfo, response.getEntity());
|
||||||
|
@ -101,7 +101,6 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final String FIELDS = "profile,roles,teams,follows,owns";
|
static final String FIELDS = "profile,roles,teams,follows,owns";
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(User.class);
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Valid
|
@Valid
|
||||||
@ -148,8 +147,7 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include).addQueryParam("team", teamParam);
|
||||||
filter.addQueryParam("include", include.value()).addQueryParam("team", teamParam);
|
|
||||||
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
return super.listInternal(uriInfo, securityContext, fieldsParam, filter, limitParam, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +260,7 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
|||||||
@QueryParam("fields")
|
@QueryParam("fields")
|
||||||
String fieldsParam)
|
String fieldsParam)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, fieldsParam);
|
Fields fields = getFields(fieldsParam);
|
||||||
String currentUserName = securityContext.getUserPrincipal().getName();
|
String currentUserName = securityContext.getUserPrincipal().getName();
|
||||||
User user = dao.getByName(uriInfo, currentUserName, fields);
|
User user = dao.getByName(uriInfo, currentUserName, fields);
|
||||||
return addHref(uriInfo, user);
|
return addHref(uriInfo, user);
|
||||||
@ -321,7 +319,7 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
|||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "Create or Update a user",
|
summary = "Update user",
|
||||||
tags = "users",
|
tags = "users",
|
||||||
description = "Create or Update a user.",
|
description = "Create or Update a user.",
|
||||||
responses = {
|
responses = {
|
||||||
@ -376,7 +374,7 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
User user = dao.get(uriInfo, id, new Fields(ALLOWED_FIELDS, null));
|
User user = dao.get(uriInfo, id, Fields.EMPTY_FIELDS);
|
||||||
SecurityUtil.checkAdminRoleOrPermissions(
|
SecurityUtil.checkAdminRoleOrPermissions(
|
||||||
authorizer, securityContext, new UserEntityInterface(user).getEntityReference());
|
authorizer, securityContext, new UserEntityInterface(user).getEntityReference());
|
||||||
PatchResponse<User> response =
|
PatchResponse<User> response =
|
||||||
|
@ -101,7 +101,6 @@ public class TopicResource extends EntityResource<Topic, TopicRepository> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final String FIELDS = "owner,followers,tags";
|
static final String FIELDS = "owner,followers,tags";
|
||||||
public static final List<String> ALLOWED_FIELDS = Entity.getEntityFields(Topic.class);
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Operation(
|
@Operation(
|
||||||
@ -149,8 +148,7 @@ public class TopicResource extends EntityResource<Topic, TopicRepository> {
|
|||||||
@DefaultValue("non-deleted")
|
@DefaultValue("non-deleted")
|
||||||
Include include)
|
Include include)
|
||||||
throws IOException, GeneralSecurityException, ParseException {
|
throws IOException, GeneralSecurityException, ParseException {
|
||||||
ListFilter filter = new ListFilter();
|
ListFilter filter = new ListFilter(include).addQueryParam("service", serviceParam);
|
||||||
filter.addQueryParam("include", include.value()).addQueryParam("service", serviceParam);
|
|
||||||
return super.listInternal(uriInfo, null, fieldsParam, filter, limitParam, before, after);
|
return super.listInternal(uriInfo, null, fieldsParam, filter, limitParam, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,7 +307,7 @@ public class TopicResource extends EntityResource<Topic, TopicRepository> {
|
|||||||
}))
|
}))
|
||||||
JsonPatch patch)
|
JsonPatch patch)
|
||||||
throws IOException, ParseException {
|
throws IOException, ParseException {
|
||||||
Fields fields = new Fields(ALLOWED_FIELDS, FIELD_OWNER);
|
Fields fields = getFields(FIELD_OWNER);
|
||||||
Topic topic = dao.get(uriInfo, id, fields);
|
Topic topic = dao.get(uriInfo, id, fields);
|
||||||
SecurityUtil.checkAdminRoleOrPermissions(
|
SecurityUtil.checkAdminRoleOrPermissions(
|
||||||
authorizer,
|
authorizer,
|
||||||
@ -326,7 +324,7 @@ public class TopicResource extends EntityResource<Topic, TopicRepository> {
|
|||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "Create or update topic",
|
summary = "Update topic",
|
||||||
tags = "topics",
|
tags = "topics",
|
||||||
description = "Create a topic, it it does not exist or update an existing topic.",
|
description = "Create a topic, it it does not exist or update an existing topic.",
|
||||||
responses = {
|
responses = {
|
||||||
|
@ -34,11 +34,12 @@ import org.openmetadata.catalog.jdbi3.CollectionDAO;
|
|||||||
import org.openmetadata.catalog.jdbi3.RoleRepository;
|
import org.openmetadata.catalog.jdbi3.RoleRepository;
|
||||||
import org.openmetadata.catalog.jdbi3.TeamRepository;
|
import org.openmetadata.catalog.jdbi3.TeamRepository;
|
||||||
import org.openmetadata.catalog.jdbi3.UserRepository;
|
import org.openmetadata.catalog.jdbi3.UserRepository;
|
||||||
import org.openmetadata.catalog.resources.teams.UserResource;
|
|
||||||
import org.openmetadata.catalog.security.policyevaluator.PolicyEvaluator;
|
import org.openmetadata.catalog.security.policyevaluator.PolicyEvaluator;
|
||||||
import org.openmetadata.catalog.type.EntityReference;
|
import org.openmetadata.catalog.type.EntityReference;
|
||||||
|
import org.openmetadata.catalog.type.Include;
|
||||||
import org.openmetadata.catalog.type.MetadataOperation;
|
import org.openmetadata.catalog.type.MetadataOperation;
|
||||||
import org.openmetadata.catalog.util.EntityUtil;
|
import org.openmetadata.catalog.util.EntityUtil;
|
||||||
|
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||||
import org.openmetadata.catalog.util.RestUtil;
|
import org.openmetadata.catalog.util.RestUtil;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -74,10 +75,9 @@ public class DefaultAuthorizer implements Authorizer {
|
|||||||
|
|
||||||
private void mayBeAddAdminUsers() {
|
private void mayBeAddAdminUsers() {
|
||||||
LOG.debug("Checking user entries for admin users");
|
LOG.debug("Checking user entries for admin users");
|
||||||
EntityUtil.Fields fields = new EntityUtil.Fields(UserResource.ALLOWED_FIELDS, FIELDS_PARAM);
|
|
||||||
for (String adminUser : adminUsers) {
|
for (String adminUser : adminUsers) {
|
||||||
try {
|
try {
|
||||||
User user = userRepository.getByName(null, adminUser, fields);
|
User user = userRepository.getByName(null, adminUser, Fields.EMPTY_FIELDS);
|
||||||
if (user != null && (user.getIsAdmin() == null || !user.getIsAdmin())) {
|
if (user != null && (user.getIsAdmin() == null || !user.getIsAdmin())) {
|
||||||
user.setIsAdmin(true);
|
user.setIsAdmin(true);
|
||||||
}
|
}
|
||||||
@ -100,10 +100,9 @@ public class DefaultAuthorizer implements Authorizer {
|
|||||||
|
|
||||||
private void mayBeAddBotUsers() {
|
private void mayBeAddBotUsers() {
|
||||||
LOG.debug("Checking user entries for bot users");
|
LOG.debug("Checking user entries for bot users");
|
||||||
EntityUtil.Fields fields = new EntityUtil.Fields(UserResource.ALLOWED_FIELDS, FIELDS_PARAM);
|
|
||||||
for (String botUser : botUsers) {
|
for (String botUser : botUsers) {
|
||||||
try {
|
try {
|
||||||
User user = userRepository.getByName(null, botUser, fields);
|
User user = userRepository.getByName(null, botUser, Fields.EMPTY_FIELDS);
|
||||||
if (user != null && (user.getIsBot() == null || !user.getIsBot())) {
|
if (user != null && (user.getIsBot() == null || !user.getIsBot())) {
|
||||||
user.setIsBot(true);
|
user.setIsBot(true);
|
||||||
}
|
}
|
||||||
@ -153,7 +152,8 @@ public class DefaultAuthorizer implements Authorizer {
|
|||||||
return policyEvaluator.hasPermission(user, null, operation);
|
return policyEvaluator.hasPermission(user, null, operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
Object entity = Entity.getEntity(entityReference, new EntityUtil.Fields(List.of("tags", FIELD_OWNER)));
|
Object entity =
|
||||||
|
Entity.getEntity(entityReference, new EntityUtil.Fields(List.of("tags", FIELD_OWNER)), Include.NON_DELETED);
|
||||||
EntityReference owner = Entity.getEntityInterface(entity).getOwner();
|
EntityReference owner = Entity.getEntityInterface(entity).getOwner();
|
||||||
|
|
||||||
if (Entity.shouldHaveOwner(entityReference.getType()) && owner != null && isOwnedByUser(user, owner)) {
|
if (Entity.shouldHaveOwner(entityReference.getType()) && owner != null && isOwnedByUser(user, owner)) {
|
||||||
@ -180,7 +180,8 @@ public class DefaultAuthorizer implements Authorizer {
|
|||||||
if (entityReference == null) {
|
if (entityReference == null) {
|
||||||
return policyEvaluator.getAllowedOperations(user, null);
|
return policyEvaluator.getAllowedOperations(user, null);
|
||||||
}
|
}
|
||||||
Object entity = Entity.getEntity(entityReference, new EntityUtil.Fields(List.of("tags", FIELD_OWNER)));
|
Object entity =
|
||||||
|
Entity.getEntity(entityReference, new EntityUtil.Fields(List.of("tags", FIELD_OWNER)), Include.NON_DELETED);
|
||||||
EntityReference owner = Entity.getEntityInterface(entity).getOwner();
|
EntityReference owner = Entity.getEntityInterface(entity).getOwner();
|
||||||
if (owner == null || isOwnedByUser(user, owner)) {
|
if (owner == null || isOwnedByUser(user, owner)) {
|
||||||
// Entity does not have an owner or is owned by the user - allow all operations.
|
// Entity does not have an owner or is owned by the user - allow all operations.
|
||||||
@ -213,9 +214,8 @@ public class DefaultAuthorizer implements Authorizer {
|
|||||||
public boolean isAdmin(AuthenticationContext ctx) {
|
public boolean isAdmin(AuthenticationContext ctx) {
|
||||||
validateAuthenticationContext(ctx);
|
validateAuthenticationContext(ctx);
|
||||||
String userName = SecurityUtil.getUserName(ctx);
|
String userName = SecurityUtil.getUserName(ctx);
|
||||||
EntityUtil.Fields fields = new EntityUtil.Fields(UserResource.ALLOWED_FIELDS, FIELDS_PARAM);
|
|
||||||
try {
|
try {
|
||||||
User user = userRepository.getByName(null, userName, fields);
|
User user = userRepository.getByName(null, userName, Fields.EMPTY_FIELDS);
|
||||||
if (user.getIsAdmin() == null) {
|
if (user.getIsAdmin() == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -229,9 +229,8 @@ public class DefaultAuthorizer implements Authorizer {
|
|||||||
public boolean isBot(AuthenticationContext ctx) {
|
public boolean isBot(AuthenticationContext ctx) {
|
||||||
validateAuthenticationContext(ctx);
|
validateAuthenticationContext(ctx);
|
||||||
String userName = SecurityUtil.getUserName(ctx);
|
String userName = SecurityUtil.getUserName(ctx);
|
||||||
EntityUtil.Fields fields = new EntityUtil.Fields(UserResource.ALLOWED_FIELDS, FIELDS_PARAM);
|
|
||||||
try {
|
try {
|
||||||
User user = userRepository.getByName(null, userName, fields);
|
User user = userRepository.getByName(null, userName, Fields.EMPTY_FIELDS);
|
||||||
if (user.getIsBot() == null) {
|
if (user.getIsBot() == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -245,9 +244,8 @@ public class DefaultAuthorizer implements Authorizer {
|
|||||||
public boolean isOwner(AuthenticationContext ctx, EntityReference owner) {
|
public boolean isOwner(AuthenticationContext ctx, EntityReference owner) {
|
||||||
validateAuthenticationContext(ctx);
|
validateAuthenticationContext(ctx);
|
||||||
String userName = SecurityUtil.getUserName(ctx);
|
String userName = SecurityUtil.getUserName(ctx);
|
||||||
EntityUtil.Fields fields = new EntityUtil.Fields(UserResource.ALLOWED_FIELDS, FIELDS_PARAM);
|
|
||||||
try {
|
try {
|
||||||
User user = userRepository.getByName(null, userName, fields);
|
User user = userRepository.getByName(null, userName, Fields.EMPTY_FIELDS);
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -265,7 +263,7 @@ public class DefaultAuthorizer implements Authorizer {
|
|||||||
|
|
||||||
private User getUserFromAuthenticationContext(AuthenticationContext ctx) throws IOException, ParseException {
|
private User getUserFromAuthenticationContext(AuthenticationContext ctx) throws IOException, ParseException {
|
||||||
String userName = SecurityUtil.getUserName(ctx);
|
String userName = SecurityUtil.getUserName(ctx);
|
||||||
EntityUtil.Fields fields = new EntityUtil.Fields(UserResource.ALLOWED_FIELDS, FIELDS_PARAM);
|
EntityUtil.Fields fields = userRepository.getFields(FIELDS_PARAM);
|
||||||
return userRepository.getByName(null, userName, fields);
|
return userRepository.getByName(null, userName, fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,21 +28,20 @@ import org.openmetadata.catalog.jdbi3.CollectionDAO;
|
|||||||
import org.openmetadata.catalog.jdbi3.RoleRepository;
|
import org.openmetadata.catalog.jdbi3.RoleRepository;
|
||||||
import org.openmetadata.catalog.jdbi3.TeamRepository;
|
import org.openmetadata.catalog.jdbi3.TeamRepository;
|
||||||
import org.openmetadata.catalog.jdbi3.UserRepository;
|
import org.openmetadata.catalog.jdbi3.UserRepository;
|
||||||
import org.openmetadata.catalog.resources.teams.UserResource;
|
|
||||||
import org.openmetadata.catalog.type.EntityReference;
|
import org.openmetadata.catalog.type.EntityReference;
|
||||||
import org.openmetadata.catalog.type.MetadataOperation;
|
import org.openmetadata.catalog.type.MetadataOperation;
|
||||||
import org.openmetadata.catalog.util.EntityUtil;
|
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||||
import org.openmetadata.catalog.util.RestUtil;
|
import org.openmetadata.catalog.util.RestUtil;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NoopAuthorizer implements Authorizer {
|
public class NoopAuthorizer implements Authorizer {
|
||||||
private static final String FIELDS_PARAM = "roles,teams";
|
|
||||||
private UserRepository userRepository;
|
private UserRepository userRepository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(AuthorizerConfiguration config, Jdbi jdbi) {
|
public void init(AuthorizerConfiguration config, Jdbi jdbi) {
|
||||||
CollectionDAO collectionDAO = jdbi.onDemand(CollectionDAO.class);
|
CollectionDAO collectionDAO = jdbi.onDemand(CollectionDAO.class);
|
||||||
this.userRepository = new UserRepository(collectionDAO);
|
this.userRepository = new UserRepository(collectionDAO);
|
||||||
|
// TODO: fixme
|
||||||
// RoleRepository and TeamRepository needs to be instantiated for Entity.DAO_MAP to populated.
|
// RoleRepository and TeamRepository needs to be instantiated for Entity.DAO_MAP to populated.
|
||||||
// As we create default admin/bots we need to have RoleRepository and TeamRepository available in DAO_MAP.
|
// As we create default admin/bots we need to have RoleRepository and TeamRepository available in DAO_MAP.
|
||||||
// This needs to be handled better in future releases.
|
// This needs to be handled better in future releases.
|
||||||
@ -84,10 +83,9 @@ public class NoopAuthorizer implements Authorizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addAnonymousUser() {
|
private void addAnonymousUser() {
|
||||||
EntityUtil.Fields fields = new EntityUtil.Fields(UserResource.ALLOWED_FIELDS, FIELDS_PARAM);
|
|
||||||
String username = "anonymous";
|
String username = "anonymous";
|
||||||
try {
|
try {
|
||||||
userRepository.getByName(null, username, fields);
|
userRepository.getByName(null, username, Fields.EMPTY_FIELDS);
|
||||||
} catch (EntityNotFoundException ex) {
|
} catch (EntityNotFoundException ex) {
|
||||||
User user =
|
User user =
|
||||||
new User()
|
new User()
|
||||||
|
@ -885,7 +885,7 @@ public abstract class EntityResourceTest<T, K> extends CatalogApplicationTest {
|
|||||||
final K request = createRequest(name, null, null, null);
|
final K request = createRequest(name, null, null, null);
|
||||||
T entity = createEntity(request, ADMIN_AUTH_HEADERS);
|
T entity = createEntity(request, ADMIN_AUTH_HEADERS);
|
||||||
EntityInterface<T> entityInterface = getEntityInterface(entity);
|
EntityInterface<T> entityInterface = getEntityInterface(entity);
|
||||||
String[] split = entityInterface.getFullyQualifiedName().split("\\/");
|
String[] split = entityInterface.getFullyQualifiedName().split("/");
|
||||||
String actualName = split[split.length - 1];
|
String actualName = split[split.length - 1];
|
||||||
assertTrue(actualName.contains("foo.bar"));
|
assertTrue(actualName.contains("foo.bar"));
|
||||||
}
|
}
|
||||||
|
@ -1603,7 +1603,8 @@ public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void assertFields(Table table, String fieldsParam) {
|
void assertFields(Table table, String fieldsParam) {
|
||||||
Fields fields = new Fields(TableResource.ALLOWED_FIELDS, fieldsParam);
|
// TODO cleanup
|
||||||
|
Fields fields = new Fields(Entity.getEntityFields(Table.class), fieldsParam);
|
||||||
|
|
||||||
if (fields.contains("usageSummary")) {
|
if (fields.contains("usageSummary")) {
|
||||||
assertNotNull(table.getUsageSummary());
|
assertNotNull(table.getUsageSummary());
|
||||||
|
@ -69,7 +69,7 @@ class PermissionsResourceTest extends CatalogApplicationTest {
|
|||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("getPermissionsTestParams")
|
@MethodSource("getPermissionsTestParams")
|
||||||
void get_permissiofns(String username, Map<MetadataOperation, Boolean> expectedOperations)
|
void get_permissions(String username, Map<MetadataOperation, Boolean> expectedOperations)
|
||||||
throws HttpResponseException {
|
throws HttpResponseException {
|
||||||
WebTarget target = getResource("permissions");
|
WebTarget target = getResource("permissions");
|
||||||
Map<String, String> authHeaders = SecurityUtil.authHeaders(username + "@open-metadata.org");
|
Map<String, String> authHeaders = SecurityUtil.authHeaders(username + "@open-metadata.org");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user