Move copy method to create entity from createEntity request to Entity Repository class (#13531)

This commit is contained in:
Suresh Srinivas 2023-10-11 12:25:36 -07:00 committed by GitHub
parent 0ede37f942
commit 26e3be5455
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
46 changed files with 121 additions and 78 deletions

View File

@ -48,6 +48,7 @@ import static org.openmetadata.service.util.EntityUtil.fieldAdded;
import static org.openmetadata.service.util.EntityUtil.fieldDeleted;
import static org.openmetadata.service.util.EntityUtil.fieldUpdated;
import static org.openmetadata.service.util.EntityUtil.getColumnField;
import static org.openmetadata.service.util.EntityUtil.getEntityReferences;
import static org.openmetadata.service.util.EntityUtil.getExtensionField;
import static org.openmetadata.service.util.EntityUtil.nextMajorVersion;
import static org.openmetadata.service.util.EntityUtil.nextVersion;
@ -81,16 +82,17 @@ import java.util.concurrent.TimeUnit;
import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.json.JsonPatch;
import javax.validation.constraints.NotNull;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
import lombok.Getter;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.openmetadata.common.utils.CommonUtil;
import org.openmetadata.schema.CreateEntity;
import org.openmetadata.schema.EntityInterface;
import org.openmetadata.schema.api.VoteRequest;
import org.openmetadata.schema.api.feed.ResolveTask;
@ -428,6 +430,23 @@ public abstract class EntityRepository<T extends EntityInterface> {
LOG.info("Created a new {} {}", entityType, entity.getFullyQualifiedName());
}
public final T copy(T entity, CreateEntity request, String updatedBy) {
EntityReference owner = validateOwner(request.getOwner());
EntityReference domain = validateDomain(request.getDomain());
entity.setId(UUID.randomUUID());
entity.setName(request.getName());
entity.setDisplayName(request.getDisplayName());
entity.setDescription(request.getDescription());
entity.setOwner(owner);
entity.setDomain(domain);
entity.setDataProducts(getEntityReferences(Entity.DATA_PRODUCT, request.getDataProducts()));
entity.setLifeCycle(request.getLifeCycle());
entity.setExtension(request.getExtension());
entity.setUpdatedBy(updatedBy);
entity.setUpdatedAt(System.currentTimeMillis());
return entity;
}
public EntityUpdater getUpdater(T original, T updated, Operation operation) {
return new EntityUpdater(original, updated, operation);
}
@ -1370,7 +1389,7 @@ public abstract class EntityRepository<T extends EntityInterface> {
public List<EntityReference> findFrom(
UUID toId, String toEntityType, Relationship relationship, String fromEntityType) {
List<EntityRelationshipRecord> records = findFromRecords(toId, toEntityType, relationship, fromEntityType);
return EntityUtil.getEntityReferences(records);
return getEntityReferences(records);
}
public List<EntityRelationshipRecord> findFromRecords(
@ -1431,7 +1450,7 @@ public abstract class EntityRepository<T extends EntityInterface> {
UUID fromId, String fromEntityType, Relationship relationship, String toEntityType) {
// When toEntityType is null, all the relationships to any entity is returned
List<EntityRelationshipRecord> records = findToRecords(fromId, fromEntityType, relationship, toEntityType);
return EntityUtil.getEntityReferences(records);
return getEntityReferences(records);
}
public final List<EntityRelationshipRecord> findToRecords(
@ -2387,7 +2406,7 @@ public abstract class EntityRepository<T extends EntityInterface> {
static class EntityLoaderWithName extends CacheLoader<Pair<String, String>, EntityInterface> {
@Override
public EntityInterface load(@CheckForNull Pair<String, String> fqnPair) {
public @NonNull EntityInterface load(@NotNull Pair<String, String> fqnPair) {
String entityType = fqnPair.getLeft();
String fqn = fqnPair.getRight();
EntityRepository<? extends EntityInterface> repository = Entity.getEntityRepository(entityType);
@ -2397,7 +2416,7 @@ public abstract class EntityRepository<T extends EntityInterface> {
static class EntityLoaderWithId extends CacheLoader<Pair<String, UUID>, EntityInterface> {
@Override
public EntityInterface load(@NotNull Pair<String, UUID> idPair) {
public @NonNull EntityInterface load(@NotNull Pair<String, UUID> idPair) {
String entityType = idPair.getLeft();
UUID id = idPair.getRight();
EntityRepository<? extends EntityInterface> repository = Entity.getEntityRepository(entityType);

View File

@ -19,7 +19,6 @@ import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.core.UriInfo;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.openmetadata.schema.CreateEntity;
import org.openmetadata.schema.EntityInterface;
import org.openmetadata.schema.type.EntityHistory;
import org.openmetadata.schema.type.EntityReference;
@ -289,23 +288,6 @@ public abstract class EntityResource<T extends EntityInterface, K extends Entity
return repository.importFromCsv(name, csv, dryRun, securityContext.getUserPrincipal().getName());
}
public T copy(T entity, CreateEntity request, String updatedBy) {
EntityReference owner = repository.validateOwner(request.getOwner());
EntityReference domain = repository.validateDomain(request.getDomain());
entity.setId(UUID.randomUUID());
entity.setName(request.getName());
entity.setDisplayName(request.getDisplayName());
entity.setDescription(request.getDescription());
entity.setOwner(owner);
entity.setDomain(domain);
entity.setDataProducts(getEntityReferences(Entity.DATA_PRODUCT, request.getDataProducts()));
entity.setLifeCycle(request.getLifeCycle());
entity.setExtension(request.getExtension());
entity.setUpdatedBy(updatedBy);
entity.setUpdatedAt(System.currentTimeMillis());
return entity;
}
protected ResourceContext<T> getResourceContext() {
return new ResourceContext<>(entityType);
}

View File

@ -463,7 +463,8 @@ public class WebAnalyticEventResource extends EntityResource<WebAnalyticEvent, W
}
private WebAnalyticEvent getWebAnalyticEvent(CreateWebAnalyticEvent create, String user) {
return copy(new WebAnalyticEvent(), create, user)
return repository
.copy(new WebAnalyticEvent(), create, user)
.withName(create.getName())
.withDisplayName(create.getDisplayName())
.withDescription(create.getDescription())

View File

@ -354,7 +354,8 @@ public class AppMarketPlaceResource extends EntityResource<AppMarketPlaceDefinit
private AppMarketPlaceDefinition getApplicationDefinition(
CreateAppMarketPlaceDefinitionReq create, String updatedBy) {
AppMarketPlaceDefinition app =
copy(new AppMarketPlaceDefinition(), create, updatedBy)
repository
.copy(new AppMarketPlaceDefinition(), create, updatedBy)
.withDeveloper(create.getDeveloper())
.withDeveloperUrl(create.getDeveloperUrl())
.withSupportEmail(create.getSupportEmail())

View File

@ -444,7 +444,8 @@ public class WorkflowResource extends EntityResource<Workflow, WorkflowRepositor
private Workflow getWorkflow(CreateWorkflow create, String user) {
OpenMetadataConnection openMetadataServerConnection =
new OpenMetadataConnectionBuilder(openMetadataApplicationConfig).build();
return copy(new Workflow(), create, user)
return repository
.copy(new Workflow(), create, user)
.withDescription(create.getDescription())
.withRequest(create.getRequest())
.withWorkflowType(create.getWorkflowType())

View File

@ -378,7 +378,8 @@ public class BotResource extends EntityResource<Bot, BotRepository> {
}
private Bot getBot(CreateBot create, String user) {
return copy(new Bot(), create, user)
return repository
.copy(new Bot(), create, user)
.withBotUser(getEntityReference(Entity.USER, create.getBotUser()))
.withProvider(create.getProvider())
.withFullyQualifiedName(create.getName());

View File

@ -426,7 +426,8 @@ public class ChartResource extends EntityResource<Chart, ChartRepository> {
}
private Chart getChart(CreateChart create, String user) {
return copy(new Chart(), create, user)
return repository
.copy(new Chart(), create, user)
.withService(EntityUtil.getEntityReference(Entity.DASHBOARD_SERVICE, create.getService()))
.withChartType(create.getChartType())
.withSourceUrl(create.getSourceUrl())

View File

@ -437,7 +437,8 @@ public class DashboardResource extends EntityResource<Dashboard, DashboardReposi
}
private Dashboard getDashboard(CreateDashboard create, String user) {
return copy(new Dashboard(), create, user)
return repository
.copy(new Dashboard(), create, user)
.withService(getEntityReference(Entity.DASHBOARD_SERVICE, create.getService()))
.withCharts(getEntityReferences(Entity.CHART, create.getCharts()))
.withDataModels(getEntityReferences(Entity.DASHBOARD_DATA_MODEL, create.getDataModels()))

View File

@ -402,7 +402,8 @@ public class DatabaseResource extends EntityResource<Database, DatabaseRepositor
}
private Database getDatabase(CreateDatabase create, String user) {
return copy(new Database(), create, user)
return repository
.copy(new Database(), create, user)
.withService(getEntityReference(Entity.DATABASE_SERVICE, create.getService()))
.withSourceUrl(create.getSourceUrl())
.withRetentionPeriod(create.getRetentionPeriod());

View File

@ -406,7 +406,8 @@ public class DatabaseSchemaResource extends EntityResource<DatabaseSchema, Datab
}
private DatabaseSchema getDatabaseSchema(CreateDatabaseSchema create, String user) {
return copy(new DatabaseSchema(), create, user)
return repository
.copy(new DatabaseSchema(), create, user)
.withDatabase(getEntityReference(Entity.DATABASE, create.getDatabase()))
.withTags(create.getTags())
.withSourceUrl(create.getSourceUrl())

View File

@ -414,7 +414,8 @@ public class StoredProcedureResource extends EntityResource<StoredProcedure, Sto
}
private StoredProcedure getStoredProcedure(CreateStoredProcedure create, String user) {
return copy(new StoredProcedure(), create, user)
return repository
.copy(new StoredProcedure(), create, user)
.withDatabaseSchema(getEntityReference(Entity.DATABASE_SCHEMA, create.getDatabaseSchema()))
.withTags(create.getTags())
.withStoredProcedureCode(create.getStoredProcedureCode())

View File

@ -937,7 +937,8 @@ public class TableResource extends EntityResource<Table, TableRepository> {
private Table getTable(CreateTable create, String user) {
return validateNewTable(
copy(new Table(), create, user)
repository
.copy(new Table(), create, user)
.withColumns(create.getColumns())
.withSourceUrl(create.getSourceUrl())
.withTableConstraints(create.getTableConstraints())

View File

@ -442,7 +442,8 @@ public class DataInsightChartResource extends EntityResource<DataInsightChart, D
}
private DataInsightChart getDataInsightChart(CreateDataInsightChart create, String user) {
return copy(new DataInsightChart(), create, user)
return repository
.copy(new DataInsightChart(), create, user)
.withName(create.getName())
.withDescription(create.getDescription())
.withDataIndexType(create.getDataIndexType())

View File

@ -439,7 +439,8 @@ public class DashboardDataModelResource extends EntityResource<DashboardDataMode
private DashboardDataModel getDataModel(CreateDashboardDataModel create, String user) {
DatabaseUtil.validateColumns(create.getColumns());
return copy(new DashboardDataModel(), create, user)
return repository
.copy(new DashboardDataModel(), create, user)
.withService(EntityUtil.getEntityReference(Entity.DASHBOARD_SERVICE, create.getService()))
.withDataModelType(create.getDataModelType())
.withSql(create.getSql())

View File

@ -340,7 +340,8 @@ public class DocStoreResource extends EntityResource<Document, DocumentRepositor
}
private Document getDocument(CreateDocument cd, String user) {
return copy(new Document(), cd, user)
return repository
.copy(new Document(), cd, user)
.withFullyQualifiedName(cd.getFullyQualifiedName())
.withData(cd.getData())
.withEntityType(cd.getEntityType());

View File

@ -331,7 +331,8 @@ public class DataProductResource extends EntityResource<DataProduct, DataProduct
private DataProduct getDataProduct(CreateDataProduct create, String user) {
List<String> experts = create.getExperts();
DataProduct dataProduct =
copy(new DataProduct(), create, user)
repository
.copy(new DataProduct(), create, user)
.withFullyQualifiedName(create.getName())
.withStyle(create.getStyle())
.withExperts(EntityUtil.populateEntityReferences(getEntityReferences(Entity.USER, experts)));

View File

@ -311,7 +311,8 @@ public class DomainResource extends EntityResource<Domain, DomainRepository> {
private Domain getDomain(CreateDomain create, String user) {
List<String> experts = create.getExperts();
return copy(new Domain(), create, user)
return repository
.copy(new Domain(), create, user)
.withStyle(create.getStyle())
.withDomainType(create.getDomainType())
.withFullyQualifiedName(create.getName())

View File

@ -648,7 +648,8 @@ public class TestCaseResource extends EntityResource<TestCase, TestCaseRepositor
}
private TestCase getTestCase(CreateTestCase create, String user, EntityLink entityLink) {
return copy(new TestCase(), create, user)
return repository
.copy(new TestCase(), create, user)
.withDescription(create.getDescription())
.withName(create.getName())
.withDisplayName(create.getDisplayName())

View File

@ -382,7 +382,8 @@ public class TestDefinitionResource extends EntityResource<TestDefinition, TestD
}
private TestDefinition getTestDefinition(CreateTestDefinition create, String user) {
return copy(new TestDefinition(), create, user)
return repository
.copy(new TestDefinition(), create, user)
.withDescription(create.getDescription())
.withEntityType(create.getEntityType())
.withTestPlatforms(create.getTestPlatforms())

View File

@ -533,7 +533,8 @@ public class TestSuiteResource extends EntityResource<TestSuite, TestSuiteReposi
private TestSuite getTestSuite(CreateTestSuite create, String user) {
TestSuite testSuite =
copy(new TestSuite(), create, user)
repository
.copy(new TestSuite(), create, user)
.withDescription(create.getDescription())
.withDisplayName(create.getDisplayName())
.withName(create.getName());

View File

@ -540,7 +540,8 @@ public class EventSubscriptionResource extends EntityResource<EventSubscription,
}
public EventSubscription getEventSubscription(CreateEventSubscription create, String user) {
return copy(new EventSubscription(), create, user)
return repository
.copy(new EventSubscription(), create, user)
.withAlertType(create.getAlertType())
.withTrigger(create.getTrigger())
.withEnabled(create.getEnabled())

View File

@ -449,7 +449,8 @@ public class GlossaryResource extends EntityResource<Glossary, GlossaryRepositor
}
private Glossary getGlossary(CreateGlossary create, String user) {
return copy(new Glossary(), create, user)
return repository
.copy(new Glossary(), create, user)
.withReviewers(getEntityReferences(Entity.USER, create.getReviewers()))
.withTags(create.getTags())
.withProvider(create.getProvider())

View File

@ -441,7 +441,8 @@ public class GlossaryTermResource extends EntityResource<GlossaryTerm, GlossaryT
}
private GlossaryTerm getGlossaryTerm(CreateGlossaryTerm create, String user) {
return copy(new GlossaryTerm(), create, user)
return repository
.copy(new GlossaryTerm(), create, user)
.withSynonyms(create.getSynonyms())
.withStyle(create.getStyle())
.withGlossary(getEntityReference(Entity.GLOSSARY, create.getGlossary()))

View File

@ -461,7 +461,8 @@ public class KpiResource extends EntityResource<Kpi, KpiRepository> {
}
private Kpi getKpi(CreateKpiRequest create, String user) {
return copy(new Kpi(), create, user)
return repository
.copy(new Kpi(), create, user)
.withStartDate(create.getStartDate())
.withEndDate(create.getEndDate())
.withTargetDefinition(create.getTargetDefinition())

View File

@ -440,7 +440,8 @@ public class MlModelResource extends EntityResource<MlModel, MlModelRepository>
}
private MlModel getMlModel(CreateMlModel create, String user) {
return copy(new MlModel(), create, user)
return repository
.copy(new MlModel(), create, user)
.withService(getEntityReference(Entity.MLMODEL_SERVICE, create.getService()))
.withDashboard(getEntityReference(Entity.DASHBOARD, create.getDashboard()))
.withAlgorithm(create.getAlgorithm())

View File

@ -542,7 +542,8 @@ public class PipelineResource extends EntityResource<Pipeline, PipelineRepositor
}
private Pipeline getPipeline(CreatePipeline create, String user) {
return copy(new Pipeline(), create, user)
return repository
.copy(new Pipeline(), create, user)
.withService(getEntityReference(Entity.PIPELINE_SERVICE, create.getService()))
.withTasks(create.getTasks())
.withSourceUrl(create.getSourceUrl())

View File

@ -453,7 +453,8 @@ public class PolicyResource extends EntityResource<Policy, PolicyRepository> {
}
private Policy getPolicy(CreatePolicy create, String user) {
Policy policy = copy(new Policy(), create, user).withRules(create.getRules()).withEnabled(create.getEnabled());
Policy policy =
repository.copy(new Policy(), create, user).withRules(create.getRules()).withEnabled(create.getEnabled());
if (create.getLocation() != null) {
policy = policy.withLocation(new EntityReference().withId(create.getLocation()));
}

View File

@ -509,7 +509,8 @@ public class QueryResource extends EntityResource<Query, QueryRepository> {
}
private Query getQuery(CreateQuery create, String user) {
return copy(new Query(), create, user)
return repository
.copy(new Query(), create, user)
.withTags(create.getTags())
.withQuery(create.getQuery())
.withService(getEntityReference(Entity.DATABASE_SERVICE, create.getService()))

View File

@ -490,7 +490,8 @@ public class SearchIndexResource extends EntityResource<SearchIndex, SearchIndex
}
private SearchIndex getSearchIndex(CreateSearchIndex create, String user) {
return copy(new SearchIndex(), create, user)
return repository
.copy(new SearchIndex(), create, user)
.withService(getEntityReference(Entity.SEARCH_SERVICE, create.getService()))
.withFields(create.getFields())
.withSearchIndexSettings(create.getSearchIndexSettings())

View File

@ -419,7 +419,8 @@ public class DashboardServiceResource
}
private DashboardService getService(CreateDashboardService create, String user) {
return copy(new DashboardService(), create, user)
return repository
.copy(new DashboardService(), create, user)
.withServiceType(create.getServiceType())
.withConnection(create.getConnection());
}

View File

@ -434,7 +434,8 @@ public class DatabaseServiceResource
}
private DatabaseService getService(CreateDatabaseService create, String user) {
return copy(new DatabaseService(), create, user)
return repository
.copy(new DatabaseService(), create, user)
.withServiceType(create.getServiceType())
.withConnection(create.getConnection());
}

View File

@ -780,7 +780,8 @@ public class IngestionPipelineResource extends EntityResource<IngestionPipeline,
private IngestionPipeline getIngestionPipeline(CreateIngestionPipeline create, String user) {
OpenMetadataConnection openMetadataServerConnection =
new OpenMetadataConnectionBuilder(openMetadataApplicationConfig).build();
return copy(new IngestionPipeline(), create, user)
return repository
.copy(new IngestionPipeline(), create, user)
.withPipelineType(create.getPipelineType())
.withAirflowConfig(create.getAirflowConfig())
.withOpenMetadataServerConnection(openMetadataServerConnection)

View File

@ -418,7 +418,8 @@ public class MessagingServiceResource
}
private MessagingService getService(CreateMessagingService create, String user) {
return copy(new MessagingService(), create, user)
return repository
.copy(new MessagingService(), create, user)
.withConnection(create.getConnection())
.withServiceType(create.getServiceType());
}

View File

@ -461,7 +461,8 @@ public class MetadataServiceResource
}
private MetadataService getMetadataService(CreateMetadataService create, String user) {
return copy(new MetadataService(), create, user)
return repository
.copy(new MetadataService(), create, user)
.withServiceType(create.getServiceType())
.withConnection(create.getConnection());
}

View File

@ -433,7 +433,8 @@ public class MlModelServiceResource
}
private MlModelService getService(CreateMlModelService create, String user) {
return copy(new MlModelService(), create, user)
return repository
.copy(new MlModelService(), create, user)
.withServiceType(create.getServiceType())
.withConnection(create.getConnection());
}

View File

@ -434,7 +434,8 @@ public class PipelineServiceResource
}
private PipelineService getService(CreatePipelineService create, String user) {
return copy(new PipelineService(), create, user)
return repository
.copy(new PipelineService(), create, user)
.withServiceType(create.getServiceType())
.withConnection(create.getConnection());
}

View File

@ -407,7 +407,8 @@ public class SearchServiceResource
}
private SearchService getService(CreateSearchService create, String user) {
return copy(new SearchService(), create, user)
return repository
.copy(new SearchService(), create, user)
.withServiceType(create.getServiceType())
.withConnection(create.getConnection());
}

View File

@ -412,7 +412,8 @@ public class StorageServiceResource
}
private StorageService getService(CreateStorageService create, String user) {
return copy(new StorageService(), create, user)
return repository
.copy(new StorageService(), create, user)
.withServiceType(create.getServiceType())
.withConnection(create.getConnection());
}

View File

@ -440,7 +440,8 @@ public class ContainerResource extends EntityResource<Container, ContainerReposi
}
private Container getContainer(CreateContainer create, String user) {
return copy(new Container(), create, user)
return repository
.copy(new Container(), create, user)
.withService(getEntityReference(Entity.STORAGE_SERVICE, create.getService()))
.withParent(create.getParent())
.withDataModel(create.getDataModel())

View File

@ -364,20 +364,16 @@ public class ClassificationResource extends EntityResource<Classification, Class
return restoreEntity(uriInfo, securityContext, restore.getId());
}
public static Classification getClassification(CreateClassification create, SecurityContext securityContext) {
return getClassification(create, securityContext.getUserPrincipal().getName());
private Classification getClassification(CreateClassification create, SecurityContext securityContext) {
return getClassification(repository, create, securityContext.getUserPrincipal().getName());
}
public static Classification getClassification(CreateClassification create, String updatedBy) {
return new Classification()
.withId(UUID.randomUUID())
.withName(create.getName())
.withDisplayName(create.getDisplayName())
public static Classification getClassification(
ClassificationRepository repository, CreateClassification create, String updatedBy) {
return repository
.copy(new Classification(), create, updatedBy)
.withFullyQualifiedName(create.getName())
.withProvider(create.getProvider())
.withMutuallyExclusive(create.getMutuallyExclusive())
.withDescription(create.getDescription())
.withUpdatedBy(updatedBy)
.withUpdatedAt(System.currentTimeMillis());
.withMutuallyExclusive(create.getMutuallyExclusive());
}
}

View File

@ -173,7 +173,8 @@ public class TagResource extends EntityResource<Tag, TagRepository> {
EntityRepository.getEntitiesFromSeedData(CLASSIFICATION, ".*json/data/tags/.*\\.json$", LoadTags.class);
for (LoadTags loadTags : loadTagsList) {
Classification classification =
ClassificationResource.getClassification(loadTags.getCreateClassification(), ADMIN_USER_NAME);
ClassificationResource.getClassification(
classificationRepository, loadTags.getCreateClassification(), ADMIN_USER_NAME);
classificationRepository.initializeEntity(classification);
List<Tag> tagsToCreate = new ArrayList<>();
@ -497,7 +498,8 @@ public class TagResource extends EntityResource<Tag, TagRepository> {
String parentFQN = create.getParent() != null ? create.getParent() : create.getClassification();
EntityReference classification = getEntityReference(CLASSIFICATION, create.getClassification());
EntityReference parent = create.getParent() == null ? null : getEntityReference(TAG, create.getParent());
return copy(new Tag(), create, updateBy)
return repository
.copy(new Tag(), create, updateBy)
.withFullyQualifiedName(FullyQualifiedName.add(parentFQN, create.getName()))
.withStyle(create.getStyle())
.withParent(parent)

View File

@ -326,6 +326,8 @@ public class PersonaResource extends EntityResource<Persona, PersonaRepository>
}
private Persona getPersona(CreatePersona cp, String user) {
return copy(new Persona(), cp, user).withUsers(EntityUtil.toEntityReferences(cp.getUsers(), Entity.USER));
return repository
.copy(new Persona(), cp, user)
.withUsers(EntityUtil.toEntityReferences(cp.getUsers(), Entity.USER));
}
}

View File

@ -408,7 +408,9 @@ public class RoleResource extends EntityResource<Role, RoleRepository> {
if (nullOrEmpty(create.getPolicies())) {
throw new IllegalArgumentException("At least one policy is required to create a role");
}
return copy(new Role(), create, user).withPolicies(getEntityReferences(Entity.POLICY, create.getPolicies()));
return repository
.copy(new Role(), create, user)
.withPolicies(getEntityReferences(Entity.POLICY, create.getPolicies()));
}
public static EntityReference getRole(String roleName) {

View File

@ -502,7 +502,8 @@ public class TeamResource extends EntityResource<Team, TeamRepository> {
if (ct.getTeamType().equals(TeamType.GROUP) && ct.getChildren() != null) {
throw new IllegalArgumentException(CREATE_GROUP);
}
return copy(new Team(), ct, user)
return repository
.copy(new Team(), ct, user)
.withProfile(ct.getProfile())
.withIsJoinable(ct.getIsJoinable())
.withUsers(EntityUtil.toEntityReferences(ct.getUsers(), Entity.USER))

View File

@ -489,7 +489,8 @@ public class TopicResource extends EntityResource<Topic, TopicRepository> {
}
private Topic getTopic(CreateTopic create, String user) {
return copy(new Topic(), create, user)
return repository
.copy(new Topic(), create, user)
.withService(getEntityReference(Entity.MESSAGING_SERVICE, create.getService()))
.withPartitions(create.getPartitions())
.withMessageSchema(create.getMessageSchema())

View File

@ -393,7 +393,8 @@ public class TypeResource extends EntityResource<Type, TypeRepository> {
}
private Type getType(CreateType create, String user) {
return copy(new Type(), create, user)
return repository
.copy(new Type(), create, user)
.withFullyQualifiedName(create.getName())
.withCategory(create.getCategory())
.withSchema(create.getSchema());