Fix #315: Allow Editing of fields in Messaging service

This commit is contained in:
Suresh Srinivas 2021-08-26 20:50:01 -07:00
parent 31a4e7a2cb
commit f31b0fe1c7
4 changed files with 16 additions and 3 deletions

View File

@ -34,6 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.net.URI;
import java.util.List; import java.util.List;
import static org.openmetadata.catalog.exception.CatalogExceptionMessage.entityNotFound; import static org.openmetadata.catalog.exception.CatalogExceptionMessage.entityNotFound;
@ -71,12 +72,14 @@ public abstract class MessagingServiceRepository {
return messagingService; return messagingService;
} }
public MessagingService update(String id, String description, Schedule ingestionSchedule) public MessagingService update(String id, String description, List<String> brokers, URI schemaRegistry,
Schedule ingestionSchedule)
throws IOException { throws IOException {
validateIngestionSchedule(ingestionSchedule); validateIngestionSchedule(ingestionSchedule);
MessagingService dbService = EntityUtil.validate(id, messagingServiceDOA().findById(id), MessagingService.class); MessagingService dbService = EntityUtil.validate(id, messagingServiceDOA().findById(id), MessagingService.class);
// Update fields // Update fields
dbService.withDescription(description).withIngestionSchedule(ingestionSchedule); dbService.withDescription(description).withIngestionSchedule(ingestionSchedule)
.withSchemaRegistry(schemaRegistry).withBrokers(brokers);
messagingServiceDOA().update(id, JsonUtils.pojoToJson(dbService)); messagingServiceDOA().update(id, JsonUtils.pojoToJson(dbService));
return dbService; return dbService;
} }

View File

@ -177,7 +177,8 @@ public class MessagingServiceResource {
@Valid UpdateMessagingService update) throws IOException { @Valid UpdateMessagingService update) throws IOException {
SecurityUtil.checkAdminOrBotRole(authorizer, securityContext); SecurityUtil.checkAdminOrBotRole(authorizer, securityContext);
MessagingService service = addHref(uriInfo, MessagingService service = addHref(uriInfo,
dao.update(id, update.getDescription(), update.getIngestionSchedule())); dao.update(id, update.getDescription(), update.getBrokers(), update.getSchemaRegistry(),
update.getIngestionSchedule()));
return Response.ok(service).build(); return Response.ok(service).build();
} }

View File

@ -10,6 +10,14 @@
"description": "Description of Messaging service entity.", "description": "Description of Messaging service entity.",
"type": "string" "type": "string"
}, },
"brokers": {
"$ref" : "../../entity/services/messagingService.json#/definitions/brokers"
},
"schemaRegistry" : {
"description": "Schema registry URL.",
"type": "string",
"format": "uri"
},
"ingestionSchedule" : { "ingestionSchedule" : {
"description": "Schedule for running metadata ingestion jobs", "description": "Schedule for running metadata ingestion jobs",
"$ref" : "../../type/schedule.json" "$ref" : "../../type/schedule.json"

View File

@ -199,6 +199,7 @@ public class MessagingServiceResourceTest extends CatalogApplicationTest {
// Update description and ingestion schedule again // Update description and ingestion schedule again
update.withDescription("description1").withIngestionSchedule(schedule.withRepeatFrequency("PT1H")); update.withDescription("description1").withIngestionSchedule(schedule.withRepeatFrequency("PT1H"));
updateAndCheckService(id, update, OK, adminAuthHeaders()); updateAndCheckService(id, update, OK, adminAuthHeaders());
} }
@Test @Test