Skip to content

Commit

Permalink
#1693 PR review updates: renamings, comments, removed unused, formatt…
Browse files Browse the repository at this point in the history
…ing,
  • Loading branch information
dk1844 committed May 5, 2022
1 parent 2bfd751 commit 1da8e8c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ class MappingTableControllerV3 @Autowired()(mappingTableService: MappingTableSer
@PutMapping(path = Array("/{name}/{version}/defaults"))
@ResponseStatus(HttpStatus.CREATED)
@PreAuthorize("@authConstants.hasAdminRole(authentication)")
def updateDefault(@AuthenticationPrincipal user: UserDetails,
@PathVariable name: String,
@PathVariable version: String,
@RequestBody newDefaults: Array[DefaultValue],
request: HttpServletRequest
def updateDefaults(@AuthenticationPrincipal user: UserDetails,
@PathVariable name: String,
@PathVariable version: String,
@RequestBody newDefaults: Array[DefaultValue],
request: HttpServletRequest
): CompletableFuture[ResponseEntity[Validation]] = {
for {
existingMtOpt <- forVersionExpression(name, version)(mappingTableService.getVersion)
Expand All @@ -75,6 +75,7 @@ class MappingTableControllerV3 @Autowired()(mappingTableService: MappingTableSer
@RequestBody newDefault: DefaultValue,
request: HttpServletRequest
): CompletableFuture[ResponseEntity[Validation]] = {
// request processing as above in PUT except for: mappingTableService.{updateDefaults -> addDefault} being used
for {
existingMtOpt <- forVersionExpression(name, version)(mappingTableService.getVersion)
existingMt = existingMtOpt.getOrElse(throw notFound())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import za.co.absa.enceladus.rest_api.exceptions.ValidationException
import za.co.absa.enceladus.rest_api.models.rest.exceptions.SchemaParsingException
import za.co.absa.enceladus.rest_api.repositories.RefCollection
import za.co.absa.enceladus.rest_api.services.v3.SchemaServiceV3
import za.co.absa.enceladus.rest_api.services.{AttachmentService, SchemaRegistryService, SchemaService}
import za.co.absa.enceladus.rest_api.services.{AttachmentService, SchemaRegistryService}
import za.co.absa.enceladus.rest_api.utils.SchemaType
import za.co.absa.enceladus.rest_api.utils.converters.SparkMenasSchemaConvertor
import za.co.absa.enceladus.rest_api.utils.parsers.SchemaParser
Expand Down Expand Up @@ -60,7 +60,7 @@ class SchemaControllerV3 @Autowired()(
def getJson(@PathVariable name: String,
@PathVariable version: String,
@RequestParam(defaultValue = "false") pretty: Boolean): CompletableFuture[String] = {
forVersionExpression(name, version) (schemaService.getVersion).map {
forVersionExpression(name, version)(schemaService.getVersion).map {
case Some(schema) =>
if (schema.fields.isEmpty) throw ValidationException(
Validation.empty.withError("schema-fields", s"Schema $name v$version exists, but has no fields!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ class SchemaService @Autowired() (schemaMongoRepository: SchemaMongoRepository,
current.setDescription(update.description).asInstanceOf[Schema]
}

/** final - override `updateWithFields` if needed */
/** final - override `updateFields` if needed */
final override def update(username: String, update: Schema): Future[Option[(Schema, Validation)]] = {
super.update(username, update.name, update.version) { latest =>
updateFields(latest, update)
}
}

/** final - override `updateWithFields` if needed */
/** final - override `updateFields` if needed */
final override def create(newSchema: Schema, username: String): Future[Option[(Schema, Validation)]] = {
val initSchema = Schema(name = newSchema.name, description = newSchema.description)

Expand Down

0 comments on commit 1da8e8c

Please sign in to comment.