def shouldCreateEntry()

in app/controllers/GenericDatabaseObjectController.scala [179:215]


  def shouldCreateEntry(newEntry:M):Either[String,Boolean] = Right(true)

  /**
    * perform the actual create operation. this is because some classes of objects you must be an admin to create,
    * but others need to be creatable by any user
    * @param uid user id
    * @param request full request object
    * @return an async play response
    */
  private def internalCreate(uid:String, request:Request[JsValue]) = {
    this.validate(request).fold(
      errors => {
        logger.error(s"errors parsing content: $errors")
        Future(BadRequest(Json.obj("status"->"error","detail"->JsError.toJson(errors))))
      },
      newEntry => {
        shouldCreateEntry(newEntry) match {
          case Right(_)=>
            this.insert(newEntry, uid).map({
              case Success(result) => Ok(Json.obj("status" -> "ok", "detail" -> "added", "id" -> result.asInstanceOf[Int]))
              case Failure(error) =>
                logger.error(error.toString)
                error match {
                  case e: BadDataException =>
                    Conflict(Json.obj("status" -> "error", "detail" -> e.toString))
                  case e: AlreadyExistsException =>
                    Conflict(Json.obj("status" -> "error", "detail" -> e.toString, "nextAvailableVersion"->e.getNextAvailableVersion))
                  case _ =>
                    handleConflictErrors(error, "object", isInsert = true)
                }
            })
          case Left(errDetail)=>
            Future(BadRequest(Json.obj("status"->"error", "detail"->errDetail)))
        }
      }
    )
  }