in app/db/AtomWorkshopDB.scala [58:70]
def publishAtom(datastore: DynamoDataStore, user: User, newAtom: Atom): Either[AtomAPIError, Atom] = {
def checkAtomExistsInDatastore(datastore: DynamoDataStore, atomType: AtomType, id: String): Either[AtomAPIError, Boolean] =
datastore.getAtom(buildKey(atomType, id)).fold({
case IDNotFound => Right(false)
case e => Left(AtomWorkshopDynamoDatastoreError(e.msg))
}, _ => Right(true))
checkAtomExistsInDatastore(datastore, newAtom.atomType, newAtom.id).fold(err => Left(err), result => {
if (result) updateAtom(datastore, newAtom)
else createAtom(datastore, newAtom.atomType, user, newAtom)
})
}