Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

updated scala 2.11.4 play 2.3.6 reactivemongo 0.10.5.0.akka23 #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions app/controllers/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand All @@ -112,15 +112,15 @@ 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)
}
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 }
}

Expand Down Expand Up @@ -148,15 +148,15 @@ 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)
}
}

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[_]) = {
Expand Down
2 changes: 1 addition & 1 deletion app/models/articles.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 9 additions & 6 deletions project/Build.scala
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
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(
resolvers += Resolver.sonatypeRepo("releases"),
version := appVersion,
scalaVersion := "2.11.4",
libraryDependencies ++= appDependencies
)

}

2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.0
sbt.version=0.13.6
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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")