Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/1693 api v3 delete recreate #2055

Merged
merged 90 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
f1798b2
#1693 API v3: VersionedModel v3 init - VersionedModelControllerV3 bas…
dk1844 Mar 7, 2022
0f62851
#1693 API v3: some basic VersionedModelControllerV3 integration test
dk1844 Mar 7, 2022
c01cfda
#1693 API v3: VersionedModelControllerV3 integration test cont'd - te…
dk1844 Mar 8, 2022
4fd08e2
#1693 API v3: VersionedModelControllerV3 - post to yield location hea…
dk1844 Mar 21, 2022
5c8e005
#1693 API v3: VersionedModelControllerV3 - put to yield no content ->…
dk1844 Mar 23, 2022
458bfed
#1693 API v3: VersionedModelControllerV3 - IT for /ds/export (latest …
dk1844 Mar 23, 2022
a7a6cf9
#1693 API v3: VersionedModelControllerV3 - location header for put/po…
dk1844 Mar 23, 2022
af489b1
#1693 API v3: VersionedModelControllerV3 - location header for post-i…
dk1844 Mar 24, 2022
21f8008
#1693 API v3: VersionedModelControllerV3 -IT for GET datasets/{name},…
dk1844 Mar 24, 2022
6f63117
#1693 API v3: VersionedModelControllerV3 - IT for GET datasets/{name}…
dk1844 Mar 24, 2022
76e87ce
#1693 API v3: VersionedModelControllerV3 - GET /datasets/{name}/{vers…
dk1844 Mar 24, 2022
d62cd90
#1693 API v3: VersionedModelControllerV3 - common implementation of /…
dk1844 Mar 24, 2022
fc4c359
#1693 API v3: VersionedModelControllerV3 - /{name}/{version}/used-in …
dk1844 Mar 24, 2022
e6c8d8c
#1693 API v3: VersionedModelControllerV3 - GET/PUT /{name}/{version}/…
dk1844 Mar 29, 2022
3566df5
#1693 API v3: VersionedModelControllerV3 - GET/PUT /{name}/{version}/…
dk1844 Mar 30, 2022
219360a
#1693 Fix: (v2) VersionedModelController.getLatestVersionNumber(): Fu…
dk1844 Mar 30, 2022
112ac1e
#1693 VersionedModelControllerV3: `/{name}/{version}/validation` impl…
dk1844 Mar 30, 2022
101b37a
#1693 VersionedModelControllerV3 - IT extended for `POST /{name}/{ver…
dk1844 Mar 31, 2022
b934958
#1693 VersionedModelControllerV3 - conformance rule mgmt GET+POST dat…
dk1844 Apr 1, 2022
51ad013
#1693 PR review update - typos etc
dk1844 Apr 6, 2022
ba5edce
#1693 Validation-warnings as payload to caller in V3
dk1844 Apr 6, 2022
662119b
#1693 Validation-warnings as payload to caller in V3 - IT covered
dk1844 Apr 7, 2022
b0fd955
#1693 API v3 impl for MTs, no tests yet
dk1844 Apr 7, 2022
d480445
#1693 import validation check added to IT.
dk1844 Apr 7, 2022
bffbf55
Merge branch 'feature/1693-api-v3-versioned-model' into feature/1693-…
dk1844 Apr 7, 2022
3542a43
Merge branch 'develop-ver-3.0' into feature/1693-api-v3-versioned-model
dk1844 Apr 7, 2022
51d68a8
Merge branch 'feature/1693-api-v3-versioned-model' into feature/1693-…
dk1844 Apr 7, 2022
e1c904e
#1693 api-v3 mapping table specific - IntegTest for GET/POST/PUT .../…
dk1844 Apr 11, 2022
489ae12
#1693 api-v3 mapping table specific - MT now validates if schema exis…
dk1844 Apr 11, 2022
d6ef401
#1693 schema validation for DSs + IntegTest update
dk1844 Apr 11, 2022
a75ab85
#1693 Mt existence check for DS rules + reflecting in integTest
dk1844 Apr 11, 2022
6a16696
Merge branch 'feature/1693-api-v3-versioned-model' into feature/1693-…
dk1844 Apr 11, 2022
65b9f21
#1693 Mt existence check for DS rules + reflecting in integTest 2
dk1844 Apr 12, 2022
4426ff7
#1693 schema controller v3 - todo IT (original IT v2 works)
dk1844 Apr 14, 2022
fe6246c
#1693 schema controller v3 - partial IT - POST, .../json, .../origina…
dk1844 Apr 14, 2022
9241eb1
Merge branch 'develop-ver-3.0' into feature/1693-api-v3-versioned-model
dk1844 Apr 14, 2022
373bf1d
#1693 PropertyDefinitionControllerV3 - impl + IT for create;
dk1844 Apr 20, 2022
73bb8fd
#1693 admin rights required in VersionedModelControllerV3 -> reflecte…
dk1844 Apr 20, 2022
a2c5f40
#1693 admin rights required in VersionedModelControllerV3 -> ITs with…
dk1844 Apr 20, 2022
4d9f623
#1693 schema api v3: GET ... /json 400 with validation errors on empt…
dk1844 Apr 22, 2022
f410702
#1693 dataset v2 delete IT asserted to make sure there are regression…
dk1844 Apr 25, 2022
27b2e62
#1693 VersionedModelControllerV3 disable (DELETE .../{name}) + enable…
dk1844 Apr 25, 2022
1787692
#1693 Dataset V3 API enable/disable ITs + impl fix
dk1844 Apr 26, 2022
e4559b1
#1693 Schema V3 API enable/disable simple cases - no usedIn checks, yet
dk1844 Apr 26, 2022
cdbe7ae
#1693 VersionedModelControllerV3 - 2 levels of .../used-in exist ( /{…
dk1844 Apr 27, 2022
be02b5d
#1693 usedIn + delete for propertyDefinitions ref'd in Datasets + ITs…
dk1844 Apr 28, 2022
09c326e
#1693 PR review update 1
dk1844 Apr 28, 2022
5df526d
Merge branch 'feature/1693-api-v3-versioned-model' into feature/1693-…
dk1844 Apr 28, 2022
fd87e11
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 Apr 28, 2022
8baf2d3
#1693 PR review update: SchemaService(V3) update/create behavior is e…
dk1844 Apr 29, 2022
0677bef
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 Apr 29, 2022
a474054
#1693 cleanup
dk1844 Apr 29, 2022
c50a024
#1693 MT in MCR check - usedIn fix (originally from JS). IT test-case…
dk1844 Apr 29, 2022
32e48d0
#1693 UsedIn - empty/nonEmpty normalization + UnitTest. V2 alternated…
dk1844 Apr 29, 2022
1c241d1
#1693 DatasetService.updateProperties[V3] -> split between DatasetSer…
dk1844 May 3, 2022
bf15425
Merge branch 'feature/1693-api-v3-versioned-model' into feature/1693-…
dk1844 May 3, 2022
06e5c5f
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 May 3, 2022
7fe2a93
#1693 PR review update: VersionedModelControllerV3 - GET /{name}/expo…
dk1844 May 4, 2022
56a9f0c
#1693 VersionedMongoRepository - unused method `getAllVersionsValues`…
dk1844 May 4, 2022
a4aac70
#1693 for V3 API: VersionedSummary -> NamedLatestVersion: impl + IT
dk1844 May 4, 2022
5d24819
#1693 PR review update: VersionedModelControllerV3 - GET /{name}/expo…
dk1844 May 4, 2022
7040694
#1693 VersionedMongoRepository - unused method `getAllVersionsValues`…
dk1844 May 4, 2022
e0fda73
#1693 for V3 API: VersionedSummary -> NamedLatestVersion: impl + IT
dk1844 May 4, 2022
2bfd751
Merge branch 'feature/1693-api-v3-versioned-model' into feature/1693-…
dk1844 May 4, 2022
a401024
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 May 4, 2022
1da8e8c
#1693 PR review updates: renamings, comments, removed unused, formatt…
dk1844 May 5, 2022
7ae4acb
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 May 5, 2022
9c3f663
#1693 PR review updates: `@PreAuthorize("@authConstants.hasAdminRole(…
dk1844 May 5, 2022
c72e559
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 May 5, 2022
99ee67b
#1693 mergefix: admin-auth for PropDefs only.
dk1844 May 5, 2022
a80d9ac
#1693 Swagger differs in paths based on `spring.profiles.active` bein…
dk1844 May 6, 2022
f851bce
Merge branch 'feature/1693-api-v3-versioned-model' into feature/1693-…
dk1844 May 6, 2022
9679d56
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 May 6, 2022
562da60
#1693 Swagger API: dev-profile: full v2+v3 API, non-dev: full v3 API
dk1844 May 9, 2022
fb0dd93
Merge branch 'feature/1693-api-v3-versioned-model' into feature/1693-…
dk1844 May 9, 2022
1a9c18b
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 May 9, 2022
eac77dd
#1693 unused import cleanup
dk1844 May 9, 2022
db1227b
#1693 `NamedLatestVersion` generalized into a multipurpose `NamedVers…
dk1844 May 9, 2022
56ba9ed
#1693 PRReview `/{name}/{version}/defaults` processing generalization…
dk1844 May 9, 2022
28c7334
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 May 9, 2022
619da37
Merge branch 'develop-ver-3.0' into feature/1693-api-v3-schema-etc
dk1844 May 9, 2022
67f163e
Merge branch 'feature/1693-api-v3-schema-etc' into feature/1693-api-v…
dk1844 May 9, 2022
9769f8d
Merge branch 'develop-ver-3.0' into feature/1693-api-v3-delete-recreate
dk1844 May 10, 2022
0ff6851
#1692 Review update: API v3 summary (NamedVersion) now contains `disa…
dk1844 May 12, 2022
4574b09
#1692 Review update: UsedIn.{isEmpty|nonEmpty} omitted from serializa…
dk1844 May 12, 2022
982e813
Merge branch 'develop-ver-3.0' into feature/1693-api-v3-delete-recreate
dk1844 May 16, 2022
006feb0
#1693 VersionedSummaryV2 Bson support fix
dk1844 May 17, 2022
2905892
#1693 VersionedSummaryV2 support fix - tests & impl
dk1844 May 17, 2022
e593df1
#1693 disable fail due to nonEmpty used in now carries a wrapper with…
dk1844 May 17, 2022
34292c4
#1693 `Future {throw x}` replaced with `Future.failed(x)` in rest_api…
dk1844 May 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,44 @@

package za.co.absa.enceladus.model

import com.fasterxml.jackson.annotation.JsonIgnore
import za.co.absa.enceladus.model.menas.MenasReference

case class UsedIn(
datasets: Option[Seq[MenasReference]] = None,
mappingTables: Option[Seq[MenasReference]] = None
) {
case class UsedIn(datasets: Option[Seq[MenasReference]] = None,
mappingTables: Option[Seq[MenasReference]] = None) {

def nonEmpty: Boolean = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to assess correctness of the rewrite, the unit test for nonEmpty was written first and the implementation was changed after that.

datasets.exists(_.nonEmpty) || mappingTables.exists(_.nonEmpty)
/**
* Should any of the original UsedIn equal to Some(Seq.empty), it will be None after normalization
*/
@JsonIgnore
lazy val normalized: UsedIn = {
def normalizeOne(field: Option[Seq[MenasReference]]) = field match {
case None => None
case Some(x) if x.isEmpty => None
case otherNonEmpty => otherNonEmpty
}

val normalizedDs = normalizeOne(datasets)
val normalizedMt = normalizeOne(mappingTables)

(normalizedDs, normalizedMt) match {
case (`datasets`, `mappingTables`) => this // no normalization needed
case _ => UsedIn(normalizedDs, normalizedMt)
}
}

@JsonIgnore
val isEmpty: Boolean = {
normalized.datasets == None && normalized.mappingTables == None
}

@JsonIgnore
val nonEmpty: Boolean = !isEmpty
}

object UsedIn {
/**
* Normalized
*/
val empty = UsedIn(None, None)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

package za.co.absa.enceladus.model.test.factories

import java.time.ZonedDateTime

import za.co.absa.enceladus.model.Dataset
import za.co.absa.enceladus.model.conformanceRule._
import za.co.absa.enceladus.model.menas.MenasReference
import za.co.absa.enceladus.model.versionedModel.VersionedSummary

import java.time.ZonedDateTime

object DatasetFactory extends EntityFactory[Dataset] {

override val collectionBaseName: String = "dataset"
Expand Down Expand Up @@ -128,7 +128,7 @@ object DatasetFactory extends EntityFactory[Dataset] {
}

def toSummary(dataset: Dataset): VersionedSummary = {
VersionedSummary(dataset.name, dataset.version)
VersionedSummary(dataset.name, dataset.version, Set(dataset.disabled))
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2018 ABSA Group Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package za.co.absa.enceladus.model.versionedModel

/**
* V3 Wrapper for [[za.co.absa.enceladus.model.versionedModel.VersionedSummary]]
*/
case class NamedVersion(name: String, version: Int, disabled: Boolean)
Zejnilovic marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@

package za.co.absa.enceladus.model.versionedModel

case class VersionedSummary(_id: String, latestVersion: Int) {
def toNamedLatestVersion: NamedLatestVersion = NamedLatestVersion(_id, latestVersion)
/**
* V2 Representation of `VersionedSummary` - V2 does not carry disabled information
*/
case class VersionedSummaryV2(_id: String, latestVersion: Int)

case class VersionedSummary(_id: String, latestVersion: Int, disabledSet: Set[Boolean]) {
def toV2: VersionedSummaryV2 = VersionedSummaryV2(_id, latestVersion)

def toNamedVersion: NamedVersion = {
val disabled = disabledSet.contains(true) // legacy mixed state reported as disabled for V3 summary
NamedVersion(_id, latestVersion, disabled)
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright 2018 ABSA Group Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package za.co.absa.enceladus.model

import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import za.co.absa.enceladus.model.menas.MenasReference

class UsedInTest extends AnyFlatSpec with Matchers {

private val exampleRef = MenasReference(Some("collection1"), "entity1", 1)

"UsedIn" should "correctly evaluate .nonEmpty" in {
UsedIn(Some(Seq(exampleRef)), Some(Seq(exampleRef))).nonEmpty shouldBe true
UsedIn(Some(Seq(exampleRef)), Some(Seq.empty)).nonEmpty shouldBe true
UsedIn(Some(Seq(exampleRef)), None).nonEmpty shouldBe true

UsedIn(Some(Seq.empty), Some(Seq(exampleRef))).nonEmpty shouldBe true
UsedIn(None, Some(Seq(exampleRef))).nonEmpty shouldBe true

UsedIn(Some(Seq.empty), Some(Seq.empty)).nonEmpty shouldBe false
UsedIn(None, Some(Seq.empty)).nonEmpty shouldBe false
UsedIn(Some(Seq.empty), None).nonEmpty shouldBe false
UsedIn(None, None).nonEmpty shouldBe false
}

it should "correctly evaluate .empty" in {
UsedIn(Some(Seq(exampleRef)), Some(Seq(exampleRef))).isEmpty shouldBe false
UsedIn(Some(Seq(exampleRef)), Some(Seq.empty)).isEmpty shouldBe false
UsedIn(Some(Seq(exampleRef)), None).isEmpty shouldBe false

UsedIn(Some(Seq.empty), Some(Seq(exampleRef))).isEmpty shouldBe false
UsedIn(None, Some(Seq(exampleRef))).isEmpty shouldBe false

UsedIn(Some(Seq.empty), Some(Seq.empty)).isEmpty shouldBe true
UsedIn(None, Some(Seq.empty)).isEmpty shouldBe true
UsedIn(Some(Seq.empty), None).isEmpty shouldBe true
UsedIn(None, None).isEmpty shouldBe true
}

it should "normalize" in {
UsedIn(Some(Seq(exampleRef)), Some(Seq(exampleRef))).normalized shouldBe UsedIn(Some(Seq(exampleRef)), Some(Seq(exampleRef)))

UsedIn(Some(Seq(exampleRef)), Some(Seq.empty)).normalized shouldBe UsedIn(Some(Seq(exampleRef)), None)
UsedIn(Some(Seq(exampleRef)), None).normalized shouldBe UsedIn(Some(Seq(exampleRef)), None)

UsedIn(Some(Seq.empty), Some(Seq(exampleRef))).normalized shouldBe UsedIn(None, Some(Seq(exampleRef)))
UsedIn(None, Some(Seq(exampleRef))).normalized shouldBe UsedIn(None, Some(Seq(exampleRef)))

UsedIn(Some(Seq.empty), Some(Seq.empty)).normalized shouldBe UsedIn(None, None)
UsedIn(None, None).normalized shouldBe UsedIn(None, None)




}



}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import za.co.absa.enceladus.rest_api.services.DatasetService
import za.co.absa.enceladus.utils.validation.ValidationLevel.ValidationLevel
import za.co.absa.enceladus.model.conformanceRule.ConformanceRule
import za.co.absa.enceladus.model.properties.PropertyDefinition
import za.co.absa.enceladus.model.versionedModel.VersionedSummary
import za.co.absa.enceladus.model.versionedModel.VersionedSummaryV2
import za.co.absa.enceladus.model.{Dataset, Validation}
import za.co.absa.enceladus.utils.validation.ValidationLevel.Constants.DefaultValidationLevelName

Expand All @@ -49,9 +49,9 @@ class DatasetController @Autowired()(datasetService: DatasetService)
@GetMapping(Array("/latest"))
@ResponseStatus(HttpStatus.OK)
def getLatestVersions(@RequestParam(value = "missing_property", required = false)
missingProperty: Optional[String]): CompletableFuture[Seq[VersionedSummary]] = {
missingProperty: Optional[String]): CompletableFuture[Seq[VersionedSummaryV2]] = {
datasetService.getLatestVersions(missingProperty.toScalaOption)
.map(datasets => datasets.map(dataset => VersionedSummary(dataset.name, dataset.version)))
.map(datasets => datasets.map(dataset => VersionedSummaryV2(dataset.name, dataset.version)))
}

@PostMapping(Array("/{datasetName}/rule/create"))
Expand All @@ -67,7 +67,7 @@ class DatasetController @Autowired()(datasetService: DatasetService)
case Some((ds, validation)) => ds // v2 disregarding validation
case _ => throw notFound()
}
case _ => throw notFound()
case _ => Future.failed(notFound())
}
} yield res
}
Expand Down Expand Up @@ -104,7 +104,7 @@ class DatasetController @Autowired()(datasetService: DatasetService)
} else {
datasetService.filterProperties(dsProperties, DatasetController.paramsToPropertyDefinitionFilter(scalaFilterMap))
}
case None => throw notFound()
case None => Future.failed(notFound())
}
}

Expand All @@ -126,7 +126,7 @@ class DatasetController @Autowired()(datasetService: DatasetService)
def getPropertiesValidation(@PathVariable datasetName: String, @PathVariable datasetVersion: Int): CompletableFuture[Validation] = {
datasetService.getVersion(datasetName, datasetVersion).flatMap {
case Some(entity) => datasetService.validateProperties(entity.propertiesAsMap, forRun = false)
case None => throw notFound()
case None => Future.failed(notFound())
}
}

Expand All @@ -135,7 +135,7 @@ class DatasetController @Autowired()(datasetService: DatasetService)
def getPropertiesValidationForRun(@PathVariable datasetName: String, @PathVariable datasetVersion: Int): CompletableFuture[Validation] = {
datasetService.getVersion(datasetName, datasetVersion).flatMap {
case Some(entity) => datasetService.validateProperties(entity.propertiesAsMap, forRun = true)
case None => throw notFound()
case None => Future.failed(notFound())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
package za.co.absa.enceladus.rest_api.controllers

import java.util.concurrent.CompletableFuture

import org.apache.hadoop.fs.Path
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation._
import za.co.absa.enceladus.model.menas.HDFSFolder
import za.co.absa.enceladus.rest_api.services.HDFSService

import scala.concurrent.Future

@RestController
@RequestMapping(Array("/api/hdfs"))
class HDFSController @Autowired() (hdfsService: HDFSService) extends BaseController {
Expand All @@ -41,7 +42,7 @@ class HDFSController @Autowired() (hdfsService: HDFSService) extends BaseControl
if (exists) {
hdfsService.getFolder(path)
} else {
throw notFound()
Future.failed(notFound())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.security.core.annotation.AuthenticationPrincipal
import org.springframework.security.core.userdetails.UserDetails
import org.springframework.web.bind.annotation._
import za.co.absa.enceladus.rest_api.exceptions.EndpointDisabled
import za.co.absa.enceladus.rest_api.services.PropertyDefinitionService
import za.co.absa.enceladus.model.ExportableObject
import za.co.absa.enceladus.model.properties.PropertyDefinition
Expand All @@ -39,15 +38,15 @@ import scala.concurrent.ExecutionContext.Implicits.global
*/
@RestController
@RequestMapping(path = Array("/api/properties/datasets"), produces = Array("application/json"))
class PropertyDefinitionController @Autowired()(propertyDefService: PropertyDefinitionService)
extends VersionedModelController(propertyDefService) {
class PropertyDefinitionController @Autowired()(propertyDefinitionService: PropertyDefinitionService)
extends VersionedModelController(propertyDefinitionService) {

import za.co.absa.enceladus.rest_api.utils.implicits._

@GetMapping(Array(""))
def getAllDatasetProperties(): CompletableFuture[Seq[PropertyDefinition]] = {
logger.info("retrieving all dataset properties in full")
propertyDefService.getLatestVersions()
propertyDefinitionService.getLatestVersions()
}

@PostMapping(Array(""))
Expand All @@ -63,8 +62,6 @@ class PropertyDefinitionController @Autowired()(propertyDefService: PropertyDefi
val location: URI = new URI(s"/api/properties/datasets/${entity.name}/${entity.version}")
ResponseEntity.created(location).body(entity)
}

// TODO: Location header would make sense for the underlying VersionedModelController.create, too. Issue #1611
}

@GetMapping(Array("/{propertyName}"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,16 @@ class RestExceptionHandler {
ResponseEntity.notFound().build[Any]()
}

@ExceptionHandler(value = Array(classOf[EndpointDisabled]))
def handleEndpointDisabled(exception: EndpointDisabled): ResponseEntity[Any] = {
@ExceptionHandler(value = Array(classOf[EndpointDisabledException]))
def handleEndpointDisabled(exception: EndpointDisabledException): ResponseEntity[Any] = {
ResponseEntity.status(HttpStatus.I_AM_A_TEAPOT).build[Any]() // Could change for LOCKED but I like this more
}

@ExceptionHandler(value = Array(classOf[EntityDisabledException]))
def handleEntityDisabled(exception: EntityDisabledException): ResponseEntity[EntityDisabledException] = {
ResponseEntity.status(HttpStatus.BAD_REQUEST).body(exception)
}

@ExceptionHandler(value = Array(classOf[SchemaParsingException]))
def handleBadRequestException(exception: SchemaParsingException): ResponseEntity[Any] = {
val response = RestResponse(exception.message, Option(SchemaParsingError.fromException(exception)))
Expand Down Expand Up @@ -111,8 +116,8 @@ class RestExceptionHandler {
}

@ExceptionHandler(value = Array(classOf[EntityInUseException]))
def handleValidationException(exception: EntityInUseException): ResponseEntity[UsedIn] = {
ResponseEntity.badRequest().body(exception.usedIn)
def handleValidationException(exception: EntityInUseException): ResponseEntity[EntityInUseException] = {
ResponseEntity.badRequest().body(exception)
}

@ExceptionHandler(value = Array(classOf[MethodArgumentTypeMismatchException]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal
import org.springframework.security.core.userdetails.UserDetails
import org.springframework.web.bind.annotation._
import za.co.absa.enceladus.model.{ExportableObject, UsedIn}
import za.co.absa.enceladus.model.versionedModel._
import za.co.absa.enceladus.model.versionedModel.{VersionedModel, VersionedSummaryV2}
import za.co.absa.enceladus.rest_api.exceptions.NotFoundException
import za.co.absa.enceladus.rest_api.services.VersionedModelService
import za.co.absa.enceladus.model.menas.audit._
Expand All @@ -38,8 +38,9 @@ abstract class VersionedModelController[C <: VersionedModel with Product with Au

@GetMapping(Array("/list", "/list/{searchQuery}"))
@ResponseStatus(HttpStatus.OK)
def getList(@PathVariable searchQuery: Optional[String]): CompletableFuture[Seq[VersionedSummary]] = {
def getList(@PathVariable searchQuery: Optional[String]): CompletableFuture[Seq[VersionedSummaryV2]] = {
versionedModelService.getLatestVersionsSummarySearch(searchQuery.toScalaOption)
.map(_.map(_.toV2))
}

@GetMapping(Array("/searchSuggestions"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import za.co.absa.enceladus.rest_api.utils.implicits._
import java.util.concurrent.CompletableFuture
import javax.servlet.http.HttpServletRequest
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

@RestController
@RequestMapping(path = Array("/api-v3/datasets"))
Expand Down Expand Up @@ -57,14 +58,12 @@ class DatasetControllerV3 @Autowired()(datasetService: DatasetServiceV3)
case Some((entity, validation)) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouln't this endpoint have the same validation?

// stripping last 3 segments (/dsName/dsVersion/properties), instead of /api-v3/dastasets/dsName/dsVersion/properties we want /api-v3/dastasets/dsName/dsVersion/properties
createdWithNameVersionLocationBuilder(entity.name, entity.version, request, stripLastSegments = 3, suffix = "/properties")
.body(validation) // todo include in tests
.body(validation)
case None => throw notFound()
}
}
}

// todo putIntoInfoFile switch needed?

@GetMapping(Array("/{name}/{version}/rules"))
@ResponseStatus(HttpStatus.OK)
def getConformanceRules(@PathVariable name: String,
Expand All @@ -90,7 +89,7 @@ class DatasetControllerV3 @Autowired()(datasetService: DatasetServiceV3)
suffix = s"/rules/$addedRuleOrder").body(validation)
case _ => throw notFound()
}
case None => throw notFound()
case None => Future.failed(notFound())
}
}

Expand Down
Loading