From 5370fd532a8e019ef8e383724c9e46fca1b39e77 Mon Sep 17 00:00:00 2001 From: Erik Janssen Date: Tue, 2 Dec 2014 16:54:28 +0100 Subject: [PATCH 1/2] updated scala 2.11.4 play 2.3.6 reactivemongo 0.10.5.0.akka23 --- app/controllers/Application.scala | 12 ++++++------ app/models/articles.scala | 2 +- project/Build.scala | 13 +++++++------ project/build.properties | 2 +- project/plugins.sbt | 2 +- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/app/controllers/Application.scala b/app/controllers/Application.scala index 99dcc0f..8192e1e 100644 --- a/app/controllers/Application.scala +++ b/app/controllers/Application.scala @@ -57,7 +57,7 @@ object Articles extends Controller with MongoController { } def showEditForm(id: String) = Action.async { - val objectId = new BSONObjectID(id) + val objectId = BSONObjectID(id) // get the documents having this id (there will be 0 or 1 result) val futureArticle = collection.find(BSONDocument("_id" -> objectId)).one[Article] // ... so we get optionally the matching article, if any @@ -94,7 +94,7 @@ object Articles extends Controller with MongoController { Article.form.bindFromRequest.fold( errors => Future.successful(Ok(views.html.editArticle(Some(id), errors, None))), article => { - val objectId = new BSONObjectID(id) + val objectId = BSONObjectID(id) // create a modifier document, ie a document that contains the update operations to run onto the documents matching the query val modifier = BSONDocument( // this modifier will set the fields 'updateDate', 'title', 'content', and 'publisher' @@ -112,7 +112,7 @@ object Articles extends Controller with MongoController { def delete(id: String) = Action.async { // let's collect all the attachments matching that match the article to delete - gridFS.find(BSONDocument("article" -> new BSONObjectID(id))).collect[List]().flatMap { files => + gridFS.find(BSONDocument("article" -> BSONObjectID(id))).collect[List]().flatMap { files => // for each attachment, delete their chunks and then their file entry val deletions = files.map { file => gridFS.remove(file) @@ -120,7 +120,7 @@ object Articles extends Controller with MongoController { Future.sequence(deletions) }.flatMap { _ => // now, the last operation: remove the article - collection.remove(BSONDocument("_id" -> new BSONObjectID(id))) + collection.remove(BSONDocument("_id" -> BSONObjectID(id))) }.map(_ => Ok).recover { case _ => InternalServerError } } @@ -148,7 +148,7 @@ object Articles extends Controller with MongoController { def getAttachment(id: String) = Action.async { request => // find the matching attachment, if any, and streams it to the client - val file = gridFS.find(BSONDocument("_id" -> new BSONObjectID(id))) + val file = gridFS.find(BSONDocument("_id" -> BSONObjectID(id))) request.getQueryString("inline") match { case Some("true") => serve(gridFS, file, CONTENT_DISPOSITION_INLINE) case _ => serve(gridFS, file) @@ -156,7 +156,7 @@ object Articles extends Controller with MongoController { } def removeAttachment(id: String) = Action.async { - gridFS.remove(new BSONObjectID(id)).map(_ => Ok).recover { case _ => InternalServerError } + gridFS.remove(BSONObjectID(id)).map(_ => Ok).recover { case _ => InternalServerError } } private def getSort(request: Request[_]) = { diff --git a/app/models/articles.scala b/app/models/articles.scala index ca3966c..026981f 100644 --- a/app/models/articles.scala +++ b/app/models/articles.scala @@ -51,7 +51,7 @@ object Article { "creationDate" -> optional(of[Long]), "updateDate" -> optional(of[Long])) { (id, title, content, publisher, creationDate, updateDate) => Article( - id.map(new BSONObjectID(_)), + id.map(BSONObjectID(_)), title, content, publisher, diff --git a/project/Build.scala b/project/Build.scala index 845a57c..cbeb4c4 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1,19 +1,20 @@ import sbt._ import Keys._ +import play.Play.autoImport._ +import PlayKeys._ object ApplicationBuild extends Build { val appName = "mongo-app" val appVersion = "1.0-SNAPSHOT" - scalaVersion := "2.10.2" - val appDependencies = Seq( - "org.reactivemongo" %% "play2-reactivemongo" % "0.10.2") + "org.reactivemongo" %% "play2-reactivemongo" % "0.10.5.0.akka23") - val main = play.Project(appName, appVersion, appDependencies).settings( - resolvers += "Sonatype OSS Releases" at "http://oss.sonatype.org/content/repositories/releases" - // settings + val main = Project(appName, file(".")).enablePlugins(play.PlayScala).settings( + version := appVersion, + scalaVersion := "2.11.4", + libraryDependencies ++= appDependencies ) } diff --git a/project/build.properties b/project/build.properties index 0974fce..64abd37 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.0 +sbt.version=0.13.6 diff --git a/project/plugins.sbt b/project/plugins.sbt index 0dcc6cf..763b8b3 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -7,4 +7,4 @@ resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/release resolvers += "Typesafe Snapshots repository" at "http://repo.typesafe.com/typesafe/snapshots/" // Use the Play sbt plugin for Play projects -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.1") +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.6") From 33aaadf8dc7458cecc1b58f8bd6e05b8a628db64 Mon Sep 17 00:00:00 2001 From: Erik Janssen Date: Wed, 3 Dec 2014 06:49:06 +0100 Subject: [PATCH 2/2] resolver added again --- project/Build.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/project/Build.scala b/project/Build.scala index cbeb4c4..556f71c 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -12,9 +12,11 @@ object ApplicationBuild extends Build { "org.reactivemongo" %% "play2-reactivemongo" % "0.10.5.0.akka23") val main = Project(appName, file(".")).enablePlugins(play.PlayScala).settings( + resolvers += Resolver.sonatypeRepo("releases"), version := appVersion, scalaVersion := "2.11.4", libraryDependencies ++= appDependencies ) } +