diff --git a/controllers/src/main/scala/cromwell/pipeline/controller/ProjectConfigurationController.scala b/controllers/src/main/scala/cromwell/pipeline/controller/ProjectConfigurationController.scala index fcf0baa9b..f32dc3edd 100644 --- a/controllers/src/main/scala/cromwell/pipeline/controller/ProjectConfigurationController.scala +++ b/controllers/src/main/scala/cromwell/pipeline/controller/ProjectConfigurationController.scala @@ -6,7 +6,7 @@ import akka.http.scaladsl.server.{ ExceptionHandler, Route } import cromwell.pipeline.controller.ProjectConfigurationController._ import cromwell.pipeline.controller.utils.FromStringUnmarshallers._ import cromwell.pipeline.controller.utils.FromUnitMarshaller._ -import cromwell.pipeline.controller.utils.PathMatchers.{ Path, ProjectId } +import cromwell.pipeline.controller.utils.PathMatchers.{ Path, ProjectId => ProjectIdPM } import cromwell.pipeline.datastorage.dto._ import cromwell.pipeline.datastorage.dto.auth.AccessTokenContent import cromwell.pipeline.model.wrapper.ProjectId @@ -62,7 +62,7 @@ class ProjectConfigurationController(projectConfigurationService: ProjectConfigu val route: AccessTokenContent => Route = implicit accessToken => handleExceptions(projectConfigurationServiceExceptionHandler) { - pathPrefix("projects" / ProjectId / "configurations") { projectId => + pathPrefix("projects" / ProjectIdPM / "configurations") { projectId => buildConfiguration(projectId) ~ addConfiguration(projectId) ~ getConfiguration(projectId) ~ diff --git a/controllers/src/main/scala/cromwell/pipeline/controller/ProjectFileController.scala b/controllers/src/main/scala/cromwell/pipeline/controller/ProjectFileController.scala index 8467c2af4..f3ee33083 100644 --- a/controllers/src/main/scala/cromwell/pipeline/controller/ProjectFileController.scala +++ b/controllers/src/main/scala/cromwell/pipeline/controller/ProjectFileController.scala @@ -6,9 +6,10 @@ import akka.http.scaladsl.server.Route import akka.stream.Materializer import cromwell.pipeline.controller.utils.FieldUnmarshallers._ import cromwell.pipeline.controller.utils.FromStringUnmarshallers._ -import cromwell.pipeline.controller.utils.PathMatchers.{ Path, ProjectId } +import cromwell.pipeline.controller.utils.PathMatchers.{ Path, ProjectId => ProjectIdPM } import cromwell.pipeline.datastorage.dto._ import cromwell.pipeline.datastorage.dto.auth.AccessTokenContent +import cromwell.pipeline.model.wrapper.ProjectId import cromwell.pipeline.service.ProjectFileService import de.heikoseeberger.akkahttpplayjson.PlayJsonSupport._ @@ -99,10 +100,14 @@ class ProjectFileController(wdlService: ProjectFileService)( val route: AccessTokenContent => Route = implicit accessToken => validateFile ~ - pathPrefix("projects" / ProjectId / "files") { projectId => - getFile(projectId) ~ - getFiles(projectId) ~ - uploadFile(projectId) ~ - deleteFile(projectId) + pathPrefix("projects") { + path(ProjectIdPM / "files") { projectId => + { + getFile(projectId) ~ + getFiles(projectId) ~ + uploadFile(projectId) ~ + deleteFile(projectId) + } + } } } diff --git a/controllers/src/main/scala/cromwell/pipeline/controller/RunController.scala b/controllers/src/main/scala/cromwell/pipeline/controller/RunController.scala index e9c72eb73..879f8275d 100644 --- a/controllers/src/main/scala/cromwell/pipeline/controller/RunController.scala +++ b/controllers/src/main/scala/cromwell/pipeline/controller/RunController.scala @@ -4,9 +4,10 @@ import akka.http.scaladsl.model.{ StatusCode, StatusCodes } import akka.http.scaladsl.server.Directives.{ entity, _ } import akka.http.scaladsl.server.{ ExceptionHandler, Route } import cromwell.pipeline.controller.RunController.runServiceExceptionHandler -import cromwell.pipeline.controller.utils.PathMatchers.{ ProjectId, RunId } +import cromwell.pipeline.controller.utils.PathMatchers.{ RunId, ProjectId => ProjectIdPM } import cromwell.pipeline.datastorage.dto._ import cromwell.pipeline.datastorage.dto.auth.AccessTokenContent +import cromwell.pipeline.model.wrapper.ProjectId import cromwell.pipeline.service.RunService import cromwell.pipeline.service.RunService.Exceptions.RunServiceException import de.heikoseeberger.akkahttpplayjson.PlayJsonSupport._ @@ -46,12 +47,16 @@ class RunController(runService: RunService) { val route: AccessTokenContent => Route = implicit accessToken => handleExceptions(runServiceExceptionHandler) { - pathPrefix("projects" / ProjectId / "runs") { projectId => - getRun(projectId) ~ - getRunsByProject(projectId) ~ - deleteRun(projectId) ~ - updateRun(projectId) ~ - addRun(projectId) + pathPrefix("projects") { + path(ProjectIdPM / "runs") { projectId => + { + getRun(projectId) ~ + getRunsByProject(projectId) ~ + deleteRun(projectId) ~ + updateRun(projectId) ~ + addRun(projectId) + } + } } } } diff --git a/controllers/src/main/scala/cromwell/pipeline/controller/utils/FromStringUnmarshallers.scala b/controllers/src/main/scala/cromwell/pipeline/controller/utils/FromStringUnmarshallers.scala index e2748276a..9e2d1fc4e 100644 --- a/controllers/src/main/scala/cromwell/pipeline/controller/utils/FromStringUnmarshallers.scala +++ b/controllers/src/main/scala/cromwell/pipeline/controller/utils/FromStringUnmarshallers.scala @@ -2,8 +2,8 @@ package cromwell.pipeline.controller.utils import akka.http.scaladsl.unmarshalling.Unmarshaller import cats.data.Validated -import cromwell.pipeline.datastorage.dto.{ PipelineVersion, ProjectId } -import cromwell.pipeline.model.wrapper.RunId +import cromwell.pipeline.datastorage.dto.PipelineVersion +import cromwell.pipeline.model.wrapper.{ ProjectId, RunId } import java.nio.file.{ Path, Paths } @@ -17,7 +17,10 @@ object FromStringUnmarshallers { } implicit val stringToProjectId: Unmarshaller[String, ProjectId] = Unmarshaller.strict[String, ProjectId] { projectId => - ProjectId(projectId) + ProjectId.from(projectId) match { + case Validated.Valid(content) => content + case Validated.Invalid(errors) => throw new RuntimeException(errors.head) + } } implicit val stringToPath: Unmarshaller[String, Path] = Unmarshaller.strict[String, Path] { path => Paths.get(path) diff --git a/controllers/src/main/scala/cromwell/pipeline/controller/utils/PathMatchers.scala b/controllers/src/main/scala/cromwell/pipeline/controller/utils/PathMatchers.scala index 476c3abad..aab92d402 100644 --- a/controllers/src/main/scala/cromwell/pipeline/controller/utils/PathMatchers.scala +++ b/controllers/src/main/scala/cromwell/pipeline/controller/utils/PathMatchers.scala @@ -2,13 +2,12 @@ package cromwell.pipeline.controller.utils import akka.http.scaladsl.server.PathMatcher1 import akka.http.scaladsl.server.PathMatchers.Segment -import cromwell.pipeline.datastorage.dto import cromwell.pipeline.model.wrapper import java.nio.file.{ Path, Paths } object PathMatchers { - val ProjectId: PathMatcher1[dto.ProjectId] = Segment.map(dto.ProjectId(_)) + val ProjectId: PathMatcher1[wrapper.ProjectId] = Segment.flatMap(wrapper.ProjectId.from(_).toOption) val Path: PathMatcher1[Path] = Segment.map(Paths.get(_)) val RunId: PathMatcher1[wrapper.RunId] = Segment.flatMap(wrapper.RunId.from(_).toOption) val ProjectSearchFilterId: PathMatcher1[wrapper.ProjectSearchFilterId] = diff --git a/controllers/src/test/scala/cromwell/pipeline/controller/ProjectConfigurationControllerTest.scala b/controllers/src/test/scala/cromwell/pipeline/controller/ProjectConfigurationControllerTest.scala index ce5445fd1..61c52d3bf 100644 --- a/controllers/src/test/scala/cromwell/pipeline/controller/ProjectConfigurationControllerTest.scala +++ b/controllers/src/test/scala/cromwell/pipeline/controller/ProjectConfigurationControllerTest.scala @@ -47,7 +47,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit "return success for update configuration" in { when(configurationService.addConfiguration(configuration, accessToken.userId)).thenReturn(Future.unit) - Put(s"/projects/${projectId}/configurations", configurationAdditionRequest) ~> configurationController.route( + Put(s"/projects/$projectId/configurations", configurationAdditionRequest) ~> configurationController.route( accessToken ) ~> check { status shouldBe StatusCodes.NoContent @@ -57,7 +57,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit "return InternalServerError when failure update configuration" in { val error = InternalError("Something went wrong") when(configurationService.addConfiguration(configuration, accessToken.userId)).thenReturn(Future.failed(error)) - Put(s"/projects/${projectId}/configurations", configurationAdditionRequest) ~> configurationController.route( + Put(s"/projects/$projectId/configurations", configurationAdditionRequest) ~> configurationController.route( accessToken ) ~> check { status shouldBe StatusCodes.InternalServerError @@ -68,7 +68,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit "return NotFound when failure find project to update configuration" in { when(configurationService.addConfiguration(configuration, accessToken.userId)) .thenReturn(Future.failed(NotFound())) - Put(s"/projects/${projectId}/configurations", configurationAdditionRequest) ~> configurationController.route( + Put(s"/projects/$projectId/configurations", configurationAdditionRequest) ~> configurationController.route( accessToken ) ~> check { status shouldBe StatusCodes.NotFound @@ -80,7 +80,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit "return configuration by existing project id" in { when(configurationService.getLastByProjectId(projectId, accessToken.userId)) .thenReturn(Future.successful(configuration)) - Get(s"/projects/${projectId}/configurations") ~> configurationController.route(accessToken) ~> check { + Get(s"/projects/$projectId/configurations") ~> configurationController.route(accessToken) ~> check { status shouldBe StatusCodes.OK entityAs[ProjectConfiguration] shouldBe configuration } @@ -89,7 +89,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit "return Configuration not found message" in { when(configurationService.getLastByProjectId(projectId, accessToken.userId)) .thenReturn(Future.failed(NotFound(s"There is no configuration with project_id: ${projectId.value}"))) - Get(s"/projects/${projectId.value}/configurations") ~> configurationController.route(accessToken) ~> check { + Get(s"/projects/$projectId/configurations") ~> configurationController.route(accessToken) ~> check { status shouldBe StatusCodes.NotFound entityAs[String] shouldBe s"There is no configuration with project_id: ${projectId.value}" } @@ -101,7 +101,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit "return success for deactivate configuration" in { when(configurationService.deactivateLastByProjectId(projectId, accessToken.userId)).thenReturn(Future.unit) - Delete(s"/projects/${projectId.value}/configurations") ~> configurationController.route(accessToken) ~> check { + Delete(s"/projects/$projectId/configurations") ~> configurationController.route(accessToken) ~> check { status shouldBe StatusCodes.NoContent } } @@ -109,7 +109,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit "return InternalServerError when failure deactivate configuration" in { when(configurationService.deactivateLastByProjectId(projectId, accessToken.userId)) .thenReturn(Future.failed(error)) - Delete(s"/projects/${projectId.value}/configurations") ~> configurationController.route(accessToken) ~> check { + Delete(s"/projects/$projectId/configurations") ~> configurationController.route(accessToken) ~> check { status shouldBe StatusCodes.InternalServerError entityAs[String] shouldBe "Something went wrong" } @@ -118,7 +118,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit "return NotFound when failure find project to deactivate configuration" in { when(configurationService.deactivateLastByProjectId(projectId, accessToken.userId)) .thenReturn(Future.failed(NotFound())) - Delete(s"/projects/${projectId.value}/configurations") ~> configurationController.route(accessToken) ~> check { + Delete(s"/projects/$projectId/configurations") ~> configurationController.route(accessToken) ~> check { status shouldBe StatusCodes.NotFound } } @@ -129,7 +129,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit "return configuration for file" in { when(configurationService.buildConfiguration(projectId, path, versionOption, accessToken.userId)) .thenReturn(Future.successful(configuration)) - Get(s"/projects/${projectId.value}/configurations/files/$pathString?version=$versionString") ~> + Get(s"/projects/$projectId/configurations/files/$pathString?version=$versionString") ~> configurationController.route(accessToken) ~> check { status shouldBe StatusCodes.OK entityAs[ProjectConfiguration] shouldBe configuration @@ -139,7 +139,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit "return failed for Bad request" in { when(configurationService.buildConfiguration(projectId, path, versionOption, accessToken.userId)) .thenReturn(Future.failed(VersioningException.HttpException("Bad request"))) - Get(s"/projects/${projectId.value}/configurations/files/$pathString?version=$versionString") ~> + Get(s"/projects/$projectId/configurations/files/$pathString?version=$versionString") ~> configurationController.route(accessToken) ~> check { status shouldBe StatusCodes.InternalServerError entityAs[String] shouldBe "Bad request" @@ -149,7 +149,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit "return failed for invalid file" in { when(configurationService.buildConfiguration(projectId, path, versionOption, accessToken.userId)) .thenReturn(Future.failed(ValidationError(List("invalid some field").mkString(",")))) - Get(s"/projects/${projectId.value}/configurations/files/$pathString?version=$versionString") ~> + Get(s"/projects/$projectId/configurations/files/$pathString?version=$versionString") ~> configurationController.route(accessToken) ~> check { status shouldBe StatusCodes.UnprocessableEntity entityAs[String] shouldBe "invalid some field" diff --git a/repositories/src/main/scala/cromwell/pipeline/datastorage/DatastorageModule.scala b/repositories/src/main/scala/cromwell/pipeline/datastorage/DatastorageModule.scala index 3be12a3e0..25ea4800e 100644 --- a/repositories/src/main/scala/cromwell/pipeline/datastorage/DatastorageModule.scala +++ b/repositories/src/main/scala/cromwell/pipeline/datastorage/DatastorageModule.scala @@ -44,6 +44,12 @@ trait Profile { implicit def uuidIso: Isomorphism[UserId, String] = iso[UserId, String](_.unwrap, UserId(_, Enable.Unsafe)) implicit def runidIso: Isomorphism[RunId, String] = iso[RunId, String](_.unwrap, RunId(_, Enable.Unsafe)) + implicit def projectidIso: Isomorphism[ProjectId, String] = + iso[ProjectId, String](_.unwrap, ProjectId(_, Enable.Unsafe)) + implicit def projectConfigurationIdIso: Isomorphism[ProjectConfigurationId, String] = + iso[ProjectConfigurationId, String](_.unwrap, ProjectConfigurationId(_, Enable.Unsafe)) + implicit def repositoryId: Isomorphism[RepositoryId, Int] = + iso[RepositoryId, Int](_.unwrap, RepositoryId(_, Enable.Unsafe)) implicit def filteridIso: Isomorphism[ProjectSearchFilterId, String] = iso[ProjectSearchFilterId, String](_.unwrap, ProjectSearchFilterId(_, Enable.Unsafe)) implicit def searchQueryIso: Isomorphism[ProjectSearchQuery, JsValue] = diff --git a/repositories/src/main/scala/cromwell/pipeline/datastorage/dao/entry/ProjectEntry.scala b/repositories/src/main/scala/cromwell/pipeline/datastorage/dao/entry/ProjectEntry.scala index c274f6fda..c0bc77903 100644 --- a/repositories/src/main/scala/cromwell/pipeline/datastorage/dao/entry/ProjectEntry.scala +++ b/repositories/src/main/scala/cromwell/pipeline/datastorage/dao/entry/ProjectEntry.scala @@ -3,7 +3,6 @@ package cromwell.pipeline.datastorage.dao.entry import cromwell.pipeline.datastorage.Profile import cromwell.pipeline.datastorage.dto._ import cromwell.pipeline.model.wrapper.{ ProjectId, RepositoryId, UserId } -import slick.lifted.MappedToBase.mappedToIsomorphism import slick.lifted.{ ForeignKeyQuery, ProvenShape } trait ProjectEntry { this: Profile with UserEntry with MyPostgresProfile with AliasesSupport => diff --git a/repositories/src/main/scala/cromwell/pipeline/datastorage/dto/Project.scala b/repositories/src/main/scala/cromwell/pipeline/datastorage/dto/Project.scala index d45d6030f..e376194cb 100644 --- a/repositories/src/main/scala/cromwell/pipeline/datastorage/dto/Project.scala +++ b/repositories/src/main/scala/cromwell/pipeline/datastorage/dto/Project.scala @@ -42,7 +42,7 @@ final case class LocalProject( ) } -final case class PostProject(name: String) +final case class PostProject(name: ProjectId) object PostProject { implicit lazy val postProject: OFormat[PostProject] = Json.format[PostProject] diff --git a/repositories/src/main/scala/cromwell/pipeline/datastorage/dto/ProjectConfiguration.scala b/repositories/src/main/scala/cromwell/pipeline/datastorage/dto/ProjectConfiguration.scala index c9bd871f5..77bfff138 100644 --- a/repositories/src/main/scala/cromwell/pipeline/datastorage/dto/ProjectConfiguration.scala +++ b/repositories/src/main/scala/cromwell/pipeline/datastorage/dto/ProjectConfiguration.scala @@ -2,6 +2,7 @@ package cromwell.pipeline.datastorage.dto import cats.data.Validated import cromwell.pipeline.model.wrapper.{ ProjectConfigurationId, ProjectId, VersionValue } +import ProjectFile.pathFormat import play.api.libs.functional.syntax.toInvariantFunctorOps import play.api.libs.json.{ Format, Json, OFormat } @@ -52,7 +53,6 @@ object ProjectConfigurationVersion { implicitly[Format[String]].inmap(ProjectConfigurationVersion.apply, _.name) } - final case class ProjectConfigurationAdditionRequest( id: ProjectConfigurationId, active: Boolean, diff --git a/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/repository/impls/ProjectConfigurationRepositoryTestImpl.scala b/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/repository/impls/ProjectConfigurationRepositoryTestImpl.scala index 4da4bd128..c36d6f22e 100644 --- a/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/repository/impls/ProjectConfigurationRepositoryTestImpl.scala +++ b/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/repository/impls/ProjectConfigurationRepositoryTestImpl.scala @@ -1,7 +1,8 @@ package cromwell.pipeline.datastorage.dao.repository.impls import cromwell.pipeline.datastorage.dao.repository.ProjectConfigurationRepository -import cromwell.pipeline.datastorage.dto.{ ProjectConfiguration, ProjectConfigurationId, ProjectId } +import cromwell.pipeline.datastorage.dto.ProjectConfiguration +import cromwell.pipeline.model.wrapper.{ ProjectConfigurationId, ProjectId } import scala.collection.mutable import scala.concurrent.Future diff --git a/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/repository/impls/ProjectRepositoryTestImpl.scala b/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/repository/impls/ProjectRepositoryTestImpl.scala index c21dffd46..265dd0d07 100644 --- a/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/repository/impls/ProjectRepositoryTestImpl.scala +++ b/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/repository/impls/ProjectRepositoryTestImpl.scala @@ -1,8 +1,8 @@ package cromwell.pipeline.datastorage.dao.repository.impls import cromwell.pipeline.datastorage.dao.repository.ProjectRepository -import cromwell.pipeline.datastorage.dto.{ Project, ProjectId } -import cromwell.pipeline.model.wrapper.UserId +import cromwell.pipeline.datastorage.dto.Project +import cromwell.pipeline.model.wrapper.{ ProjectId, UserId } import scala.collection.mutable import scala.concurrent.Future diff --git a/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/repository/impls/RunRepositoryTestImpl.scala b/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/repository/impls/RunRepositoryTestImpl.scala index ecc73a539..b5f03bcfb 100644 --- a/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/repository/impls/RunRepositoryTestImpl.scala +++ b/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/repository/impls/RunRepositoryTestImpl.scala @@ -1,8 +1,8 @@ package cromwell.pipeline.datastorage.dao.repository.impls import cromwell.pipeline.datastorage.dao.repository.RunRepository -import cromwell.pipeline.datastorage.dto.{ ProjectId, Run } -import cromwell.pipeline.model.wrapper.{ RunId, UserId } +import cromwell.pipeline.datastorage.dto.Run +import cromwell.pipeline.model.wrapper.{ ProjectId, RunId, UserId } import scala.collection.mutable import scala.concurrent.Future diff --git a/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/utils/GeneratorUtils.scala b/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/utils/GeneratorUtils.scala index 9b6fd8e4d..b14187017 100644 --- a/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/utils/GeneratorUtils.scala +++ b/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/utils/GeneratorUtils.scala @@ -20,10 +20,10 @@ object GeneratorUtils { private def listOfN[T](gen: Gen[T], maxLength: Int = defaultListMaxLength): Gen[List[T]] = Gen.chooseNum(0, maxLength).flatMap(length => Gen.listOfN(length, gen)) - private lazy val projectIdGen: Gen[ProjectId] = Gen.uuid.map(id => ProjectId(id.toString)) + private lazy val projectIdGen: Gen[ProjectId] = Gen.uuid.map(id => ProjectId(id.toString, Enable.Unsafe)) private lazy val projectConfigurationIdGen: Gen[ProjectConfigurationId] = - Gen.uuid.map(id => ProjectConfigurationId(id.toString)) + Gen.uuid.map(id => ProjectConfigurationId(id.toString, Enable.Unsafe)) private lazy val emailGen: Gen[UserEmail] = for { name <- stringGen() diff --git a/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/utils/TestProjectUtils.scala b/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/utils/TestProjectUtils.scala index 8abaed639..202eda464 100644 --- a/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/utils/TestProjectUtils.scala +++ b/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/utils/TestProjectUtils.scala @@ -1,6 +1,7 @@ package cromwell.pipeline.datastorage.dao.utils import cromwell.pipeline.datastorage.dto._ +import cromwell.pipeline.model.validator.Enable import cromwell.pipeline.model.wrapper.{ ProjectConfigurationId, ProjectId, RepositoryId, UserId } import java.nio.file.Paths @@ -12,8 +13,8 @@ object TestProjectUtils { private val defaultRange: Int = 100 private def randomInt(range: Int = defaultRange): Int = Random.nextInt(range) private def randomUuidStr: String = UUID.randomUUID().toString - def getDummyProjectId: ProjectId = ProjectId.random - def getDummyRepositoryId: RepositoryId = RepositoryId(randomInt()) + def getDummyProjectId: ProjectId = ProjectId(randomUuidStr, Enable.Unsafe) + def getDummyRepositoryId: RepositoryId = RepositoryId(randomInt(), Enable.Unsafe) def getDummyProject( projectId: ProjectId = getDummyProjectId, ownerId: UserId = TestUserUtils.getDummyUserId, diff --git a/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/utils/TestRunUtils.scala b/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/utils/TestRunUtils.scala index 9d1077e82..52d079a1d 100644 --- a/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/utils/TestRunUtils.scala +++ b/repositories/src/test/scala/cromwell/pipeline/datastorage/dao/utils/TestRunUtils.scala @@ -8,7 +8,7 @@ import cromwell.pipeline.model.wrapper.{ ProjectId, RunId, UserId } object TestRunUtils { private def randomUuidStr: String = UUID.randomUUID().toString - def getDummyProjectId: ProjectId = ProjectId(randomUuidStr) + def getDummyProjectId: ProjectId = ProjectId.random def getDummyRunId: RunId = RunId.random def getDummyTimeStart: Instant = Instant.now() def getDummyTimeEnd(isEmpty: Boolean): Option[Instant] = diff --git a/services/src/main/scala/cromwell/pipeline/service/GitLabProjectVersioning.scala b/services/src/main/scala/cromwell/pipeline/service/GitLabProjectVersioning.scala index 2f5beb501..82db295ee 100644 --- a/services/src/main/scala/cromwell/pipeline/service/GitLabProjectVersioning.scala +++ b/services/src/main/scala/cromwell/pipeline/service/GitLabProjectVersioning.scala @@ -20,7 +20,7 @@ class GitLabProjectVersioning(httpClient: HttpClient, config: GitLabConfig)(impl Future.failed(RepositoryException("Could not create a repository for deleted project.")) } else { val createRepoUrl: String = s"${config.url}projects" - val postProject = PostProject(name = localProject.projectId.unwrap) + val postProject = PostProject(name = localProject.projectId) httpClient .post[GitLabRepositoryResponse, PostProject](url = createRepoUrl, headers = config.token, payload = postProject) .map { diff --git a/services/src/main/scala/cromwell/pipeline/service/ProjectService.scala b/services/src/main/scala/cromwell/pipeline/service/ProjectService.scala index 0c09a706c..bba0d9b74 100644 --- a/services/src/main/scala/cromwell/pipeline/service/ProjectService.scala +++ b/services/src/main/scala/cromwell/pipeline/service/ProjectService.scala @@ -6,7 +6,6 @@ import cromwell.pipeline.model.wrapper.{ ProjectId, UserId } import cromwell.pipeline.service.ProjectService.Exceptions._ import cromwell.pipeline.service.exceptions.ServiceException -import java.util.UUID import scala.concurrent.{ ExecutionContext, Future } trait ProjectService { @@ -74,7 +73,7 @@ object ProjectService { def addProject(request: ProjectAdditionRequest, userId: UserId): Future[Project] = { val localProject = LocalProject( - projectId = ProjectId(UUID.randomUUID().toString), + projectId = ProjectId.random, ownerId = userId, name = request.name, active = true diff --git a/services/src/test/scala/cromwell/pipeline/service/ProjectConfigurationServiceTest.scala b/services/src/test/scala/cromwell/pipeline/service/ProjectConfigurationServiceTest.scala index b11d417b6..e86464cd2 100644 --- a/services/src/test/scala/cromwell/pipeline/service/ProjectConfigurationServiceTest.scala +++ b/services/src/test/scala/cromwell/pipeline/service/ProjectConfigurationServiceTest.scala @@ -4,7 +4,7 @@ import cromwell.pipeline.datastorage.dao.repository.ProjectConfigurationReposito import cromwell.pipeline.datastorage.dao.repository.impls.ProjectConfigurationRepositoryTestImpl import cromwell.pipeline.datastorage.dao.utils.{ TestProjectUtils, TestUserUtils } import cromwell.pipeline.datastorage.dto._ -import cromwell.pipeline.model.wrapper.UserId +import cromwell.pipeline.model.wrapper.{ ProjectConfigurationId, ProjectId, UserId } import cromwell.pipeline.service.ProjectConfigurationService.Exceptions._ import cromwell.pipeline.service.impls.{ ProjectServiceTestImpl, ProjectVersioningTestImpl, WomToolTestImpl } import cromwell.pipeline.womtool.WomToolAPI diff --git a/services/src/test/scala/cromwell/pipeline/service/ProjectSearchEngineTest.scala b/services/src/test/scala/cromwell/pipeline/service/ProjectSearchEngineTest.scala index 3638c4902..6feedbc54 100644 --- a/services/src/test/scala/cromwell/pipeline/service/ProjectSearchEngineTest.scala +++ b/services/src/test/scala/cromwell/pipeline/service/ProjectSearchEngineTest.scala @@ -2,7 +2,7 @@ package cromwell.pipeline.service import cromwell.pipeline.datastorage.dao.utils.TestProjectUtils import cromwell.pipeline.datastorage.dto._ -import cromwell.pipeline.model.wrapper.UserId +import cromwell.pipeline.model.wrapper.{ ProjectConfigurationId, ProjectId, UserId } import cromwell.pipeline.service.ProjectSearchEngine.Exceptions.InternalError import cromwell.pipeline.service.impls.{ ProjectConfigurationServiceTestImpl, diff --git a/services/src/test/scala/cromwell/pipeline/service/impls/ProjectConfigurationServiceTestImpl.scala b/services/src/test/scala/cromwell/pipeline/service/impls/ProjectConfigurationServiceTestImpl.scala index 880d7aebf..f29bc1ed4 100644 --- a/services/src/test/scala/cromwell/pipeline/service/impls/ProjectConfigurationServiceTestImpl.scala +++ b/services/src/test/scala/cromwell/pipeline/service/impls/ProjectConfigurationServiceTestImpl.scala @@ -1,7 +1,7 @@ package cromwell.pipeline.service.impls import cromwell.pipeline.datastorage.dto._ -import cromwell.pipeline.model.wrapper.UserId +import cromwell.pipeline.model.wrapper.{ ProjectConfigurationId, ProjectId, UserId } import cromwell.pipeline.service.ProjectConfigurationService import java.nio.file.Path diff --git a/services/src/test/scala/cromwell/pipeline/service/impls/ProjectFileServiceTestImpl.scala b/services/src/test/scala/cromwell/pipeline/service/impls/ProjectFileServiceTestImpl.scala index 8436e8ae5..f87bdcfd4 100644 --- a/services/src/test/scala/cromwell/pipeline/service/impls/ProjectFileServiceTestImpl.scala +++ b/services/src/test/scala/cromwell/pipeline/service/impls/ProjectFileServiceTestImpl.scala @@ -1,7 +1,7 @@ package cromwell.pipeline.service.impls import cromwell.pipeline.datastorage.dto._ -import cromwell.pipeline.model.wrapper.UserId +import cromwell.pipeline.model.wrapper.{ ProjectId, UserId } import cromwell.pipeline.service.{ ProjectFileService, VersioningException } import java.nio.file.Path diff --git a/services/src/test/scala/cromwell/pipeline/service/impls/ProjectServiceTestImpl.scala b/services/src/test/scala/cromwell/pipeline/service/impls/ProjectServiceTestImpl.scala index eeb27db5f..c92ed5328 100644 --- a/services/src/test/scala/cromwell/pipeline/service/impls/ProjectServiceTestImpl.scala +++ b/services/src/test/scala/cromwell/pipeline/service/impls/ProjectServiceTestImpl.scala @@ -2,7 +2,7 @@ package cromwell.pipeline.service.impls import cromwell.pipeline.datastorage.dao.utils.TestProjectUtils import cromwell.pipeline.datastorage.dto._ -import cromwell.pipeline.model.wrapper.UserId +import cromwell.pipeline.model.wrapper.{ ProjectId, UserId } import cromwell.pipeline.service.ProjectService import scala.concurrent.Future diff --git a/services/src/test/scala/cromwell/pipeline/service/impls/RunServiceTestImpl.scala b/services/src/test/scala/cromwell/pipeline/service/impls/RunServiceTestImpl.scala index f53281355..c1985ad67 100644 --- a/services/src/test/scala/cromwell/pipeline/service/impls/RunServiceTestImpl.scala +++ b/services/src/test/scala/cromwell/pipeline/service/impls/RunServiceTestImpl.scala @@ -1,7 +1,7 @@ package cromwell.pipeline.service.impls -import cromwell.pipeline.datastorage.dto.{ ProjectId, Run, RunCreateRequest, RunUpdateRequest } -import cromwell.pipeline.model.wrapper.{ RunId, UserId } +import cromwell.pipeline.datastorage.dto.{ Run, RunCreateRequest, RunUpdateRequest } +import cromwell.pipeline.model.wrapper.{ ProjectId, RunId, UserId } import cromwell.pipeline.service.RunService import scala.concurrent.Future