def registerAlias()

in path-manager/app/services/PathStore.scala [106:130]


  def registerAlias(proposedAliasPathRecord: PathRecord) = {

    val id = proposedAliasPathRecord.identifier

    logger.debug(s"Registering path [${proposedAliasPathRecord.path }] for [$id]")

    if (PathValidator.isInvalid(proposedAliasPathRecord.path)) {
      Left(s"invalid path [${proposedAliasPathRecord.path}]")
    } else {
      val existingPath = Option(Dynamo.pathsTable.getItem("path", proposedAliasPathRecord.path)).map(PathRecord(_))

      existingPath match {
        case Some(pr) if (pr.identifier != id) => {
          logger.warn(s"Failed to register existing path [${proposedAliasPathRecord.path}], already claimed by id [${pr.identifier}], submitting id [$id]")
          Left("path already in use")
        }
        case _ => {
          putPathItemAndAwaitIndexUpdate(proposedAliasPathRecord)

          logger.debug(s"Registered new $ALIAS_PATH_TYPE path [${proposedAliasPathRecord.path}] for id [$id] successfully")
          Right(List(proposedAliasPathRecord).groupBy(_.`type`))
        }
      }
    }
  }