diff options
author | vlad <vlad@driver.xyz> | 2017-06-30 19:38:37 -0700 |
---|---|---|
committer | vlad <vlad@driver.xyz> | 2017-06-30 19:38:37 -0700 |
commit | 96d81a36286e41035ff4068859a3b0f9da924fbc (patch) | |
tree | 8d9f0014140d1f07ca449b56adaba8ccb3d2fc59 /src/main/scala/xyz/driver/pdsuidomain/services/QueueUploadService.scala | |
parent | a997aa6539d1f0af4ab4fc395ff2033335da312a (diff) | |
download | rest-query-96d81a36286e41035ff4068859a3b0f9da924fbc.tar.gz rest-query-96d81a36286e41035ff4068859a3b0f9da924fbc.tar.bz2 rest-query-96d81a36286e41035ff4068859a3b0f9da924fbc.zip |
Latest PDS UI utils including all the domain stuffv0.1.12
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/services/QueueUploadService.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/services/QueueUploadService.scala | 78 |
1 files changed, 78 insertions, 0 deletions
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] + +} |