def process()

in app/model/commands/CreateWorkflowAtomCommand.scala [24:87]


  def process(): MediaAtom = {
    val atomId = randomUUID().toString
    log.info(s"Request to create new atom $atomId [${workflowMediaAtom.title}] from Workflow")

    val createdChangeRecord = Some(ChangeRecord.now(user).asThrift)

    val atom = ThriftAtom(
      id = atomId,
      atomType = AtomType.Media,
      labels = Nil,
      defaultHtml = "<div></div>", // No content set so empty div
      data = AtomData.Media(ThriftMediaAtom(
        title = workflowMediaAtom.title,
        assets = Nil,
        activeVersion = None,
        category = ThriftCategory.News,
        plutoProjectId = None,
        source = None,
        posterImage= None,
        duration = None,
        description = None,
        metadata = Some(ThriftMetadata(
          categoryId = None,
          channelId = None,
          privacyStatus = None,
          expiryDate = None
        ))
      )),
      contentChangeDetails = ContentChangeDetails(
        lastModified = createdChangeRecord,
        created = createdChangeRecord,
        published = None,
        revision = 1L
      )
    )

    AuditMessage(atomId, "Workflow Create", getUsername(user)).logMessage()

    previewDataStore.createAtom(atom).fold({
        case IDConflictError =>
          log.error(s"Cannot create new atom $atomId. The id is already in use")
          AtomIdConflict

        case other =>
          log.error(s"Cannot create new atom $atomId. $other")
          UnknownFailure
      },
      _ => {
        log.info(s"Successfully created new atom $atomId [${workflowMediaAtom.title}]")

        val event = ContentAtomEvent(atom, EventType.Update, new Date().getTime)

        previewPublisher.publishAtomEvent(event) match {
          case Success(_)  =>
            log.info(s"New atom published to preview $atomId [${workflowMediaAtom.title}]")
            MediaAtom.fromThrift(atom)

          case Failure(err) =>
            log.error(s"Unable to published new atom to preview $atomId [${workflowMediaAtom.title}]", err)
            AtomPublishFailed(err.toString)
        }
      }
    )
  }