Skip to content

Commit

Permalink
PIN-4571 Aliogned to 1.0.,x
Browse files Browse the repository at this point in the history
  • Loading branch information
nttdata-rtorsoli committed Feb 20, 2024
1 parent d28359e commit ce1cb34
Showing 1 changed file with 45 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ final case class ProcessApiServiceImpl(
.find(_.id.toString == descriptorId)
.toRight(EServiceDescriptorNotFound(eService.id.toString, descriptorId))

private def getLatestDescriptor(eService: CatalogItem): Option[CatalogDescriptor] = eService.descriptors
.sortBy(_.version.toInt)(Ordering.Int.reverse)
.headOption

override def getEServices(
name: Option[String],
eServicesIds: String,
Expand Down Expand Up @@ -423,6 +427,22 @@ final case class ProcessApiServiceImpl(
_ <- assertRequesterAllowed(catalogItem.producerId)(organizationId)
_ <- hasNotDraftDescriptor(catalogItem).toFuture
_ <- eServiceDescriptorSeed.attributes.certified.traverse(
_ <- checkDailyCalls(
eServiceDescriptorSeed.dailyCallsPerConsumer,
eServiceDescriptorSeed.dailyCallsTotal
).toFuture
_ <- getLatestDescriptor(catalogItem).fold(Future.unit)(descriptor =>
checkIfDailyCallsIsGreaterThanExisting(
eServiceDescriptorSeed.dailyCallsPerConsumer,
descriptor.dailyCallsPerConsumer
).toFuture
)
_ <- getLatestDescriptor(catalogItem).fold(Future.unit)(descriptor =>
checkIfDailyCallsIsGreaterThanExisting(
eServiceDescriptorSeed.dailyCallsTotal,
descriptor.dailyCallsTotal
).toFuture
)
_.traverse(attr => attributeRegistryManagementService.getAttributeById(attr.id))
)
_ <- eServiceDescriptorSeed.attributes.declared.traverse(
Expand Down Expand Up @@ -462,6 +482,18 @@ final case class ProcessApiServiceImpl(
_ <- assertRequesterAllowed(catalogItem.producerId)(organizationId)
descriptor <- assertDescriptorExists(catalogItem, descriptorUuid)
_ <- isDraftDescriptor(descriptor)
_ <- checkDailyCalls(
updateEServiceDescriptorSeed.dailyCallsPerConsumer,
updateEServiceDescriptorSeed.dailyCallsTotal
).toFuture
_ <- checkIfDailyCallsIsGreaterThanExisting(
updateEServiceDescriptorSeed.dailyCallsPerConsumer,
descriptor.dailyCallsPerConsumer
).toFuture
_ <- checkIfDailyCallsIsGreaterThanExisting(
updateEServiceDescriptorSeed.dailyCallsTotal,
descriptor.dailyCallsTotal
).toFuture
updatedEService <- catalogManagementService.updateDescriptor(
eServiceId,
descriptorId,
Expand All @@ -484,13 +516,19 @@ final case class ProcessApiServiceImpl(
logger.info(operationLabel)

val result: Future[EService] = for {
organizationId <- getOrganizationIdFutureUUID(contexts)
eServiceUuid <- eServiceId.toFutureUUID
descriptorUuid <- descriptorId.toFutureUUID
catalogItem <- catalogManagementService.getEServiceById(eServiceUuid)
_ <- assertRequesterAllowed(catalogItem.producerId)(organizationId)
descriptor <- assertDescriptorExists(catalogItem, descriptorUuid)
_ <- descriptorCanBeUpdated(descriptor)
organizationId <- getOrganizationIdFutureUUID(contexts)
eServiceUuid <- eServiceId.toFutureUUID
descriptorUuid <- descriptorId.toFutureUUID
catalogItem <- catalogManagementService.getEServiceById(eServiceUuid)
_ <- assertRequesterAllowed(catalogItem.producerId)(organizationId)
descriptor <- assertDescriptorExists(catalogItem, descriptorUuid)
_ <- descriptorCanBeUpdated(descriptor)
_ <- checkDailyCalls(seed.dailyCallsPerConsumer, seed.dailyCallsTotal).toFuture
_ <- checkIfDailyCallsIsGreaterThanExisting(
seed.dailyCallsPerConsumer,
descriptor.dailyCallsPerConsumer
).toFuture
_ <- checkIfDailyCallsIsGreaterThanExisting(seed.dailyCallsTotal, descriptor.dailyCallsTotal).toFuture
updatedEService <- catalogManagementService.updateDescriptor(
eServiceId,
descriptorId,
Expand Down

0 comments on commit ce1cb34

Please sign in to comment.