in app/model/commands/CreateAtomCommand.scala [27:74]
def process() = {
val atomId = randomUUID().toString
val createdChangeRecord = Some(ChangeRecord.now(user))
val scheduledLaunchDate: Option[DateTime] = data.contentChangeDetails.scheduledLaunch.map(scheduledLaunch => new DateTime(scheduledLaunch.date))
val embargo: Option[DateTime] = data.contentChangeDetails.embargo.map(embargo => new DateTime(embargo.date))
val expiry: Option[DateTime] = data.expiryDate.map(expiry => new DateTime(expiry))
val details = media.model.ContentChangeDetails(
lastModified = createdChangeRecord,
created = createdChangeRecord,
published = None,
revision = 1L,
scheduledLaunch = scheduledLaunchDate.map(ChangeRecord.build(_, user)),
embargo = embargo.map(ChangeRecord.build(_, user)),
expiry = expiry.map(ChangeRecord.build(_, user))
)
log.info(s"Request to create new atom $atomId [${data.title}]")
val atom = data.asThrift(atomId, details)
AuditMessage(atom.id, "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 [${data.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 [${data.title}]")
MediaAtom.fromThrift(atom)
case Failure(err) =>
log.error(s"Unable to published new atom to preview $atomId [${data.title}]", err)
AtomPublishFailed(err.toString)
}
}
)
}