From 96d81a36286e41035ff4068859a3b0f9da924fbc Mon Sep 17 00:00:00 2001 From: vlad Date: Fri, 30 Jun 2017 19:38:37 -0700 Subject: Latest PDS UI utils including all the domain stuff --- .../pdsuidomain/services/QueueUploadService.scala | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/main/scala/xyz/driver/pdsuidomain/services/QueueUploadService.scala (limited to 'src/main/scala/xyz/driver/pdsuidomain/services/QueueUploadService.scala') diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/QueueUploadService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/QueueUploadService.scala new file mode 100644 index 0000000..55a408f --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/services/QueueUploadService.scala @@ -0,0 +1,78 @@ +package xyz.driver.pdsuidomain.services + +import xyz.driver.pdsuicommon.auth.AuthenticatedRequestContext +import xyz.driver.pdsuicommon.concurrent.BridgeUploadQueue +import xyz.driver.pdsuicommon.db.{Pagination, SearchFilterExpr, Sorting} +import xyz.driver.pdsuicommon.error.DomainError + +import scala.concurrent.Future + +object QueueUploadService { + trait DefaultNotFoundError { + def userMessage: String = "Message not found" + } + + trait DefaultAccessDeniedError { + def userMessage: String = "Access denied" + } + + sealed trait CreateReply + object CreateReply { + type Error = CreateReply with DomainError + + case class Created(x: BridgeUploadQueue.Item) extends CreateReply + case object AuthorizationError extends CreateReply with DomainError.AuthorizationError with DefaultAccessDeniedError + case class CommonError(userMessage: String) extends CreateReply with DomainError + } + + sealed trait GetByIdReply + object GetByIdReply { + type Error = GetByIdReply with DomainError + + case class Entity(x: BridgeUploadQueue.Item) extends GetByIdReply + case object AuthorizationError extends GetByIdReply with DomainError.AuthorizationError with DefaultAccessDeniedError + case object NotFoundError extends GetByIdReply with DomainError.NotFoundError with DefaultNotFoundError + case class CommonError(userMessage: String) extends GetByIdReply with DomainError + } + + sealed trait GetListReply + object GetListReply { + type Error = GetListReply with DomainError + + case class EntityList(xs: Seq[BridgeUploadQueue.Item], + totalFound: Int) extends GetListReply + + case object AuthorizationError + extends GetListReply with DomainError.AuthorizationError with DefaultAccessDeniedError + } + + sealed trait ResetReply + object ResetReply { + type Error = ResetReply with DomainError + + case class Updated(updated: BridgeUploadQueue.Item) extends ResetReply + case object AuthorizationError extends ResetReply with DomainError.AuthorizationError with DefaultAccessDeniedError + case object NotFoundError extends ResetReply with DefaultNotFoundError with DomainError.NotFoundError + case class CommonError(userMessage: String) extends ResetReply with DomainError + } +} + +trait QueueUploadService { + + import QueueUploadService._ + + def create(kind: String, tag: String) + (implicit requestContext: AuthenticatedRequestContext): Future[CreateReply] + + def getById(kind: String, tag: String) + (implicit requestContext: AuthenticatedRequestContext): Future[GetByIdReply] + + def getAll(filter: SearchFilterExpr = SearchFilterExpr.Empty, + sorting: Option[Sorting] = None, + pagination: Option[Pagination] = None) + (implicit requestContext: AuthenticatedRequestContext): Future[GetListReply] + + def reset(kind: String, tag: String) + (implicit requestContext: AuthenticatedRequestContext): Future[ResetReply] + +} -- cgit v1.2.3