From 22b93af823c899fa52289c561389ddab5032eab9 Mon Sep 17 00:00:00 2001 From: Leon Radley Date: Mon, 30 Sep 2013 22:19:38 +0200 Subject: [PATCH 1/5] Working towards 1.4.0 --- .travis.yml | 2 +- notes/1.4.0.markdown | 4 + project/Build.scala | 21 ++-- project/build.properties | 2 +- project/plugins.sbt | 7 +- sample/project/Build.scala | 2 +- sample/project/build.properties | 2 +- sample/project/plugins.sbt | 2 +- .../plugin/salat/OptionsFromConfig.scala | 67 +++++----- .../se/radley/plugin/salat/SalatPlugin.scala | 21 ++-- .../se/radley/plugin/salat/package.scala | 2 +- .../plugin/salat/OptionsFromConfigSpec.scala | 119 +++++------------- 12 files changed, 104 insertions(+), 147 deletions(-) create mode 100644 notes/1.4.0.markdown diff --git a/.travis.yml b/.travis.yml index 320e17d..563a36d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: scala scala: - - 2.10.0 + - 2.10.2 branches: only: diff --git a/notes/1.4.0.markdown b/notes/1.4.0.markdown new file mode 100644 index 0000000..47775df --- /dev/null +++ b/notes/1.4.0.markdown @@ -0,0 +1,4 @@ +- Salat 1.9.3 +- Play 2.2.0 +- Possible breaking change, cappedCollection size and max is now `Long` instead of `Int` #46 +- Change to MongoClient and use MongoClientOptions instead of the now depricated MongoOptions #51 \ No newline at end of file diff --git a/project/Build.scala b/project/Build.scala index d22a4fb..3fb4f7d 100755 --- a/project/Build.scala +++ b/project/Build.scala @@ -3,13 +3,14 @@ import sbt.Keys._ object ProjectBuild extends Build { - lazy val buildVersion = "1.3.0" + lazy val buildVersion = "1.4.0-SNAPSHOT" lazy val root = Project(id = "play-plugins-salat", base = file("."), settings = Project.defaultSettings ++ Publish.settings ++ Ls.settings).settings( organization := "se.radley", description := "MongoDB Salat plugin for PlayFramework 2", version := buildVersion, - scalaVersion := "2.10.0", + scalaVersion := "2.10.2", + scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature"), parallelExecution in Test := false, testFrameworks += TestFrameworks.Specs2, @@ -18,11 +19,11 @@ object ProjectBuild extends Build { resolvers += "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/", libraryDependencies ++= Seq( - "play" %% "play" % "2.1.3" % "provided", - "play" % "play-exceptions" % "2.1.3" % "provided", - "play" %% "play-test" % "2.1.0" % "test", - "com.novus" %% "salat" % "1.9.2", - "org.mongodb" %% "casbah-gridfs" % "2.6.2" + "com.typesafe.play" %% "play" % "2.2.0" % "provided", + "com.typesafe.play" % "play-exceptions" % "2.2.0" % "provided", + "com.typesafe.play" %% "play-test" % "2.2.0" % "test", + "com.novus" %% "salat" % "1.9.3", + "org.mongodb" %% "casbah-gridfs" % "2.6.3" ) ) } @@ -33,9 +34,9 @@ object Publish { publishTo <<= version { (v: String) => val nexus = "https://oss.sonatype.org/" if (v.trim.endsWith("SNAPSHOT")) - Some("snapshots" at nexus + "content/repositories/snapshots") + Some("sonatype snapshots" at nexus + "content/repositories/snapshots") else - Some("releases" at nexus + "service/local/staging/deploy/maven2") + Some("sonatype releases" at nexus + "service/local/staging/deploy/maven2") }, publishArtifact in Test := false, pomIncludeRepository := { _ => false }, @@ -61,7 +62,7 @@ object Ls { import _root_.ls.Plugin.LsKeys._ lazy val settings = _root_.ls.Plugin.lsSettings ++ Seq( - (description in lsync) := "MongoDB Salat plugin for Play Framework 2.", + (description in lsync) := "MongoDB Salat plugin for Play Framework 2.x", licenses in lsync <<= licenses, (tags in lsync) := Seq("play", "playframework", "salat", "mongo", "casbah", "object document mapping", "ODM", "mapper"), (docsUrl in lsync) := Some(new URL("https://github.com/leon/play-salat")) diff --git a/project/build.properties b/project/build.properties index 5e96e96..0974fce 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.12.4 +sbt.version=0.13.0 diff --git a/project/plugins.sbt b/project/plugins.sbt index e56a4e5..4c7daa1 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,11 +1,10 @@ resolvers ++= Seq( "less is" at "http://repo.lessis.me", - "coda" at "http://repo.codahale.com", - Resolver.url("sbt-plugin-releases", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns) + "coda" at "http://repo.codahale.com" ) addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.1") -addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.7") +addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.1") -addSbtPlugin("me.lessis" % "ls-sbt" % "0.1.2") +addSbtPlugin("me.lessis" % "ls-sbt" % "0.1.3") diff --git a/sample/project/Build.scala b/sample/project/Build.scala index 0a62f20..6942745 100755 --- a/sample/project/Build.scala +++ b/sample/project/Build.scala @@ -8,7 +8,7 @@ object ApplicationBuild extends Build { val appVersion = "1.0" val appDependencies = Seq( - "se.radley" %% "play-plugins-salat" % "1.3.0" + "se.radley" %% "play-plugins-salat" % "1.4.0" ) val main = play.Project(appName, appVersion, appDependencies).settings( diff --git a/sample/project/build.properties b/sample/project/build.properties index 5e96e96..0974fce 100755 --- a/sample/project/build.properties +++ b/sample/project/build.properties @@ -1 +1 @@ -sbt.version=0.12.4 +sbt.version=0.13.0 diff --git a/sample/project/plugins.sbt b/sample/project/plugins.sbt index eb84a24..2665433 100755 --- a/sample/project/plugins.sbt +++ b/sample/project/plugins.sbt @@ -9,4 +9,4 @@ resolvers ++= Seq( ) // Use the Play sbt plugin for Play projects -addSbtPlugin("play" % "sbt-plugin" % "2.1.3") +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.0") diff --git a/src/main/scala/se/radley/plugin/salat/OptionsFromConfig.scala b/src/main/scala/se/radley/plugin/salat/OptionsFromConfig.scala index fc1ec63..84e2f91 100644 --- a/src/main/scala/se/radley/plugin/salat/OptionsFromConfig.scala +++ b/src/main/scala/se/radley/plugin/salat/OptionsFromConfig.scala @@ -2,41 +2,48 @@ package se.radley.plugin.salat import play.api.Configuration import com.mongodb.casbah.MongoOptions +import com.mongodb._ +import scala.Some object OptionsFromConfig { - def apply(config: Option[Configuration]): Option[com.mongodb.MongoOptions] = { - if (config.isDefined && config.get.keys.isEmpty) None - else config.map { implicit conf => - val defaults = new com.mongodb.MongoOptions - MongoOptions( - autoConnectRetry = ("autoConnectRetry", defaults.autoConnectRetry), - connectionsPerHost = ("connectionsPerHost", defaults.connectionsPerHost), - threadsAllowedToBlockForConnectionMultiplier = ("threadsAllowedToBlockForConnectionMultiplier", defaults.threadsAllowedToBlockForConnectionMultiplier), - maxWaitTime = ("maxWaitTime", defaults.maxWaitTime), - connectTimeout = ("connectTimeout", defaults.connectTimeout), - socketTimeout = ("socketTimeout", defaults.socketTimeout), - socketKeepAlive = ("socketKeepAlive", defaults.socketKeepAlive), - maxAutoConnectRetryTime = ("maxAutoConnectRetryTime", defaults.maxAutoConnectRetryTime), - slaveOk = ("slaveOk", defaults.slaveOk), - safe = ("safe", defaults.safe), - w = ("w", defaults.w), - wTimeout = ("wtimeout", defaults.wtimeout), - fsync = ("fsync", defaults.fsync), - j = ("j", defaults.j), - dbDecoderFactory = ("dbDecoderFactory", defaults.dbDecoderFactory), - dbEncoderFactory = ("dbEncoderFactory", defaults.dbEncoderFactory), - //socketFactory = ("socketFactory", defaults.socketFactory), FIXME Dependency problem - description = ("description", defaults.description)) + private def getInstanceFromName[T](name: String): Option[T] = { + try { + Some(Class.forName(name).newInstance().asInstanceOf[T]) + } catch { + case ex: ClassNotFoundException => None } } - implicit def getBoolean(prop: (String, Boolean))(implicit conf: Configuration): Boolean = conf.getBoolean(prop._1) getOrElse prop._2 - implicit def getString(prop: (String, String))(implicit conf: Configuration): String = conf.getString(prop._1) getOrElse prop._2 - implicit def getInt(prop: (String, Int))(implicit conf: Configuration): Int = conf.getInt(prop._1) getOrElse prop._2 - implicit def getLong(prop: (String, Long))(implicit conf: Configuration): Long = conf.getMilliseconds(prop._1) getOrElse prop._2 - implicit def getFactory[F](prop: (String, F))(implicit conf: Configuration): F = { - conf.getString(prop._1).map { name => Class.forName(name).newInstance().asInstanceOf[F] } getOrElse prop._2 - } + def apply(config: Configuration): Option[com.mongodb.MongoClientOptions] = { + if (config.keys.isEmpty) { + return None + } + + val builder = new MongoClientOptions.Builder() + config.getBoolean("autoConnectRetry").map(v => builder.autoConnectRetry(v)) + config.getInt("connectionsPerHost").map(v => builder.connectionsPerHost(v)) + config.getInt("connectTimeout").map(v => builder.connectTimeout(v)) + config.getBoolean("cursorFinalizerEnabled").map(v => builder.cursorFinalizerEnabled(v)) + config.getString("dbDecoderFactory").flatMap(className => getInstanceFromName[DBDecoderFactory](className)).map(v => builder.dbDecoderFactory(v)) + config.getString("dbEncoderFactory").flatMap(className => getInstanceFromName[DBEncoderFactory](className)).map(v => builder.dbEncoderFactory(v)) + config.getString("description").map(v => builder.description(v)) + config.getLong("maxAutoConnectRetryTime").map(v => builder.maxAutoConnectRetryTime(v)) + config.getInt("maxWaitTime").map(v => builder.maxWaitTime(v)) + config.getString("readPreference").flatMap { name => + try { + Some(ReadPreference.valueOf(name)) + } catch { + case ex: IllegalArgumentException => None + } + }.map(v => builder.readPreference(v)) + //config.getBoolean("socketFactory").map(v => builder.socketFactory(v)) + config.getBoolean("socketKeepAlive").map(v => builder.socketKeepAlive(v)) + config.getInt("socketTimeout").map(v => builder.socketTimeout(v)) + config.getInt("threadsAllowedToBlockForConnectionMultiplier").map(v => builder.threadsAllowedToBlockForConnectionMultiplier(v)) + config.getString("writeConcern").map(name => WriteConcern.valueOf(name)).map(v => builder.writeConcern(v)) + + Some(builder.build()) + } } \ No newline at end of file diff --git a/src/main/scala/se/radley/plugin/salat/SalatPlugin.scala b/src/main/scala/se/radley/plugin/salat/SalatPlugin.scala index b447bd0..9ff697d 100644 --- a/src/main/scala/se/radley/plugin/salat/SalatPlugin.scala +++ b/src/main/scala/se/radley/plugin/salat/SalatPlugin.scala @@ -4,10 +4,10 @@ import play.api._ import play.api.mvc._ import play.api.Play.current import com.mongodb.casbah._ -import com.mongodb.{MongoException, ServerAddress} +import com.mongodb.{MongoClientOptions, MongoException, ServerAddress, MongoOptions} import com.mongodb.casbah.gridfs.GridFS import commons.MongoDBObject -import com.mongodb.MongoOptions +import com.mongodb.casbah.MongoClientOptions class SalatPlugin(app: Application) extends Plugin { @@ -19,13 +19,13 @@ class SalatPlugin(app: Application) extends Plugin { val writeConcern: com.mongodb.WriteConcern, val user: Option[String] = None, val password: Option[String] = None, - val options: Option[MongoOptions], - private var conn: MongoConnection = null + val options: Option[MongoClientOptions], + private var conn: MongoClient = null ){ - def connection: MongoConnection = { + def connection: MongoClient = { if (conn == null) { - conn = options.map(opts => MongoConnection(hosts, opts)).getOrElse(MongoConnection(hosts)) + conn = options.map(opts => MongoClient(hosts, opts)).getOrElse(MongoClient(hosts)) val authOpt = for { u <- user @@ -50,17 +50,16 @@ class SalatPlugin(app: Application) extends Plugin { def collection(name: String): MongoCollection = db(name) - def cappedCollection(name: String, size: Int, max: Option[Int] = None) = { + def cappedCollection(name: String, size: Long, max: Option[Long] = None): MongoCollection = { val coll = if (db.collectionExists(name)) { db(name) } else { - import com.mongodb.casbah.Implicits.mongoCollAsScala val options = MongoDBObject.newBuilder options += "capped" -> true options += "size" -> size if (max.isDefined) options += "max" -> max.get - db.createCollection(name, options.result()).asScala + new MongoCollection(db.createCollection(name, options.result())) } coll } @@ -76,7 +75,7 @@ class SalatPlugin(app: Application) extends Plugin { lazy val sources: Map[String, MongoSource] = configuration.subKeys.map { sourceKey => val source = configuration.getConfig(sourceKey).getOrElse(Configuration.empty) - val options = OptionsFromConfig(source.getConfig("options")) + val options: Option[MongoClientOptions] = source.getConfig("options").flatMap(opts => OptionsFromConfig(opts)) source.getString("uri").map { str => // MongoURI config - http://www.mongodb.org/display/DOCS/Connections @@ -182,7 +181,7 @@ class SalatPlugin(app: Application) extends Plugin { * @param sourceName The source name ex. default * @return A MongoCollection */ - def cappedCollection(collectionName:String, size: Int, max: Option[Int] = None, sourceName:String = "default"): MongoCollection = source(sourceName).cappedCollection(collectionName, size, max) + def cappedCollection(collectionName:String, size: Long, max: Option[Long] = None, sourceName:String = "default"): MongoCollection = source(sourceName).cappedCollection(collectionName, size, max) /** * Returns GridFS for configured source diff --git a/src/main/scala/se/radley/plugin/salat/package.scala b/src/main/scala/se/radley/plugin/salat/package.scala index 31af55d..1c1df5b 100644 --- a/src/main/scala/se/radley/plugin/salat/package.scala +++ b/src/main/scala/se/radley/plugin/salat/package.scala @@ -25,7 +25,7 @@ package object salat { * @param sourceName The configured source name * @return MongoCollection */ - def mongoCappedCollection(collectionName: String, size: Int, max: Option[Int] = None, sourceName:String = "default")(implicit app: Application): MongoCollection = { + def mongoCappedCollection(collectionName: String, size: Long, max: Option[Long] = None, sourceName:String = "default")(implicit app: Application): MongoCollection = { app.plugin[SalatPlugin].map(_.cappedCollection(collectionName, size, max, sourceName)).getOrElse(throw new PlayException("SalatPlugin is not registered.", "You need to register the plugin with \"500:se.radley.plugin.salat.SalatPlugin\" in conf/play.plugins")) } diff --git a/src/test/scala/se/radley/plugin/salat/OptionsFromConfigSpec.scala b/src/test/scala/se/radley/plugin/salat/OptionsFromConfigSpec.scala index 390b9fd..6af4afd 100644 --- a/src/test/scala/se/radley/plugin/salat/OptionsFromConfigSpec.scala +++ b/src/test/scala/se/radley/plugin/salat/OptionsFromConfigSpec.scala @@ -1,110 +1,57 @@ package se.radley.plugin.salat import org.specs2.mutable.Specification -import com.mongodb.MongoOptions +import com.mongodb._ import play.api.Configuration -import com.mongodb.DBDecoderFactory -import com.mongodb.DBEncoderFactory import javax.net.SocketFactory -import com.mongodb.DBDecoder -import org.specs2.mutable.SpecificationWithJUnit import org.specs2.specification.AllExpectations -import scala.reflect.ClassManifest -class OptionsFromConfigSpec extends SpecificationWithJUnit with AllExpectations { +class OptionsFromConfigSpec extends Specification with AllExpectations { "OptionsFromConfig" should { "Override all defaults when all props are present" in { val allNonDefaultConfiguration = Map( ("mongodb.default.options.autoConnectRetry" -> "true"), ("mongodb.default.options.connectionsPerHost" -> "333"), - ("mongodb.default.options.threadsAllowedToBlockForConnectionMultiplier" -> "22"), - ("mongodb.default.options.maxWaitTime" -> "68000"), ("mongodb.default.options.connectTimeout" -> "34000"), - ("mongodb.default.options.socketTimeout" -> "21000"), - ("mongodb.default.options.socketKeepAlive" -> "true"), - ("mongodb.default.options.maxAutoConnectRetryTime" -> "20"), - ("mongodb.default.options.slaveOk" -> "true"), - ("mongodb.default.options.safe" -> "true"), - ("mongodb.default.options.w" -> "1"), - ("mongodb.default.options.wtimeout" -> "10"), - ("mongodb.default.options.fsync" -> "true"), - ("mongodb.default.options.j" -> "true"), + ("mongodb.default.options.cursorFinalizerEnabled" -> "true"), ("mongodb.default.options.dbDecoderFactory" -> "se.radley.plugin.salat.NonDefaultDBDecoderFactory"), ("mongodb.default.options.dbEncoderFactory" -> "se.radley.plugin.salat.NonDefaultDBEncoderFactory"), + ("mongodb.default.options.description" -> "Some Description"), + ("mongodb.default.options.maxAutoConnectRetryTime" -> "20"), + ("mongodb.default.options.maxWaitTime" -> "68000"), + ("mongodb.default.options.readPreference" -> "PRIMARY"), ("mongodb.default.options.socketFactory" -> "se.radley.plugin.salat.NonDefaultDBSocketFactory"), - ("mongodb.default.options.description" -> "Some Description")) + ("mongodb.default.options.socketKeepAlive" -> "true"), + ("mongodb.default.options.socketTimeout" -> "21000"), + ("mongodb.default.options.threadsAllowedToBlockForConnectionMultiplier" -> "22"), + ("mongodb.default.options.writeConcern" -> "SAFE") + ) - val sourceConfig = Configuration.from(allNonDefaultConfiguration).getConfig("mongodb.default").get - val optionsConfig = sourceConfig.getConfig("options") - val optionsOpt = OptionsFromConfig(optionsConfig) + val configuration = Configuration.from(allNonDefaultConfiguration).getConfig("mongodb.default.options").get + val optionsOpt = OptionsFromConfig(configuration) optionsOpt must beSome val options = optionsOpt.get // All Overridden - options.autoConnectRetry must beTrue - options.connectionsPerHost must be equalTo(333) - options.threadsAllowedToBlockForConnectionMultiplier must be equalTo(22) - options.maxWaitTime must be equalTo(68000) - options.connectTimeout must be equalTo(34000) - options.socketTimeout must be equalTo(21000) - options.socketKeepAlive must beTrue - options.maxAutoConnectRetryTime must be equalTo(20) - options.slaveOk must beTrue - options.safe must beTrue - options.w must be equalTo(1) - options.wtimeout must be equalTo(10) - options.fsync must beTrue - options.j must beTrue - options.description must be equalTo("Some Description") - options.dbDecoderFactory must haveClass[NonDefaultDBDecoderFactory] - options.dbEncoderFactory must haveClass[NonDefaultDBEncoderFactory] - //options.socketFactory must haveClass[NonDefaultSocketFactory] FIXME Dependency problem - } - - "Override some defaults for present props" in { - val someNonDefaultConfiguration = Map( - ("mongodb.default.options.connectionsPerHost" -> "255"), - ("mongodb.default.options.threadsAllowedToBlockForConnectionMultiplier" -> "24"), - ("mongodb.default.options.connectTimeout" -> "60000")) - - val defaultOptions = new MongoOptions - - val sourceConfig = Configuration.from(someNonDefaultConfiguration).getConfig("mongodb.default").get - val optionsConfig = sourceConfig.getConfig("options") - val optionsOpt = OptionsFromConfig(optionsConfig) - optionsOpt must beSome - val options = optionsOpt.get - // Overridden - options.connectionsPerHost must be equalTo(255) - options.threadsAllowedToBlockForConnectionMultiplier must be equalTo(24) - options.connectTimeout must be equalTo(60000) - // Remain defaults - options.autoConnectRetry must beFalse - options.maxWaitTime must be equalTo(1000 * 60 * 2) - options.socketTimeout must be equalTo(0) - options.socketKeepAlive must beFalse - options.maxAutoConnectRetryTime must be equalTo(0) - options.slaveOk must beFalse - options.safe must beFalse - options.w must be equalTo(0) - options.wtimeout must be equalTo(0) - options.fsync must beFalse - options.j must beFalse - options.description must beNull - options.dbDecoderFactory must be(defaultOptions.dbDecoderFactory) - options.dbEncoderFactory must be(defaultOptions.dbEncoderFactory) - options.socketFactory must be(defaultOptions.socketFactory) - } - - "Return none options if config is not defined" in { - val undefinedConfig = None - val options = OptionsFromConfig(undefinedConfig) - options must beNone + options.isAutoConnectRetry must beTrue + options.getConnectionsPerHost must be equalTo(333) + options.getConnectTimeout must be equalTo(34000) + options.isCursorFinalizerEnabled must beTrue + options.getDbDecoderFactory must haveClass[NonDefaultDBDecoderFactory] + options.getDbEncoderFactory must haveClass[NonDefaultDBEncoderFactory] + options.getDescription must be equalTo("Some Description") + options.getMaxAutoConnectRetryTime must be equalTo(20) + options.getMaxWaitTime must be equalTo(68000) + options.getReadPreference must be equalTo(ReadPreference.primary()) + options.getSocketFactory must haveClass[NonDefaultSocketFactory] + options.isSocketKeepAlive must beTrue + options.getSocketTimeout must be equalTo(21000) + options.getThreadsAllowedToBlockForConnectionMultiplier must be equalTo(22) + options.getWriteConcern must be equalTo(WriteConcern.SAFE) } "Return none options if config is empty" in { - val emptyConfig = Some(Configuration.empty) - val options = OptionsFromConfig(emptyConfig) + val options = OptionsFromConfig(Configuration.empty) options must beNone } } @@ -119,7 +66,7 @@ class NonDefaultDBEncoderFactory extends DBEncoderFactory { } class NonDefaultSocketFactory extends SocketFactory { def createSocket(host: String, port: Int) = null - def createSocket(address: java.net.InetAddress, port: Int) = null - def createSocket(host: String, port: Int, clientAddress: java.net.InetAddress, clientPort: Int) = null - def createSocket(address: java.net.InetAddress, port: Int, clientAddress: java.net.InetAddress, clientPort: Int) = null + def createSocket(address: java.net.InetAddress, port: Int) = null + def createSocket(host: String, port: Int, clientAddress: java.net.InetAddress, clientPort: Int) = null + def createSocket(address: java.net.InetAddress, port: Int, clientAddress: java.net.InetAddress, clientPort: Int) = null } \ No newline at end of file From 6fcdb60d58d6725ab8bdc3ffd91e4c297500d231 Mon Sep 17 00:00:00 2001 From: Leon Radley Date: Mon, 18 Nov 2013 13:34:08 +0100 Subject: [PATCH 2/5] Removed lessis --- build.sbt | 1 - project/Build.scala | 14 +------------- project/plugins.sbt | 9 +-------- src/main/ls/1.0.2.json | 26 -------------------------- src/main/ls/1.0.3.json | 25 ------------------------- src/main/ls/1.0.4.json | 25 ------------------------- src/main/ls/1.0.5.json | 25 ------------------------- src/main/ls/1.0.6.json | 25 ------------------------- src/main/ls/1.0.7.json | 25 ------------------------- src/main/ls/1.0.8.json | 25 ------------------------- src/main/ls/1.0.9.json | 25 ------------------------- src/main/ls/1.1.json | 25 ------------------------- src/main/ls/1.2.json | 25 ------------------------- 13 files changed, 2 insertions(+), 273 deletions(-) delete mode 100644 build.sbt delete mode 100644 src/main/ls/1.0.2.json delete mode 100644 src/main/ls/1.0.3.json delete mode 100644 src/main/ls/1.0.4.json delete mode 100644 src/main/ls/1.0.5.json delete mode 100644 src/main/ls/1.0.6.json delete mode 100644 src/main/ls/1.0.7.json delete mode 100644 src/main/ls/1.0.8.json delete mode 100644 src/main/ls/1.0.9.json delete mode 100644 src/main/ls/1.1.json delete mode 100644 src/main/ls/1.2.json diff --git a/build.sbt b/build.sbt deleted file mode 100644 index 6b3dcde..0000000 --- a/build.sbt +++ /dev/null @@ -1 +0,0 @@ -seq(lsSettings:_*) \ No newline at end of file diff --git a/project/Build.scala b/project/Build.scala index 3fb4f7d..828ce3e 100755 --- a/project/Build.scala +++ b/project/Build.scala @@ -5,7 +5,7 @@ object ProjectBuild extends Build { lazy val buildVersion = "1.4.0-SNAPSHOT" - lazy val root = Project(id = "play-plugins-salat", base = file("."), settings = Project.defaultSettings ++ Publish.settings ++ Ls.settings).settings( + lazy val root = Project(id = "play-plugins-salat", base = file("."), settings = Project.defaultSettings ++ Publish.settings).settings( organization := "se.radley", description := "MongoDB Salat plugin for PlayFramework 2", version := buildVersion, @@ -56,15 +56,3 @@ object Publish { ) ) } - -object Ls { - - import _root_.ls.Plugin.LsKeys._ - - lazy val settings = _root_.ls.Plugin.lsSettings ++ Seq( - (description in lsync) := "MongoDB Salat plugin for Play Framework 2.x", - licenses in lsync <<= licenses, - (tags in lsync) := Seq("play", "playframework", "salat", "mongo", "casbah", "object document mapping", "ODM", "mapper"), - (docsUrl in lsync) := Some(new URL("https://github.com/leon/play-salat")) - ) -} diff --git a/project/plugins.sbt b/project/plugins.sbt index 4c7daa1..4ff68b4 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,10 +1,3 @@ -resolvers ++= Seq( - "less is" at "http://repo.lessis.me", - "coda" at "http://repo.codahale.com" -) - -addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.1") +addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.2") addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.1") - -addSbtPlugin("me.lessis" % "ls-sbt" % "0.1.3") diff --git a/src/main/ls/1.0.2.json b/src/main/ls/1.0.2.json deleted file mode 100644 index 77118cf..0000000 --- a/src/main/ls/1.0.2.json +++ /dev/null @@ -1,26 +0,0 @@ - -{ - "organization":"se.radley", - "name":"play-plugins-salat", - "version":"1.0.2", - "description":"MongoDB Salat plugin for PlayFramework 2", - "site":"http://github.com/leon/play-salat", - "tags":["mongodb", "casbah", "salat", "play"], - "docs":"http://github.com/leon/play-salat", - "licenses": [{ - "name": "Apache 2.0", - "url": "http://www.opensource.org/licenses/Apache-2.0" - }], - "resolvers": ["https://oss.sonatype.org/content/groups/public/"], - "dependencies": [{ - "organization":"play", - "name": "play", - "version": "[2.0,)" - },{ - "organization":"com.novus", - "name": "salat-core", - "version": "0.0.8-SNAPSHOT" - }], - "scalas": ["2.9.1"], - "sbt": false -} \ No newline at end of file diff --git a/src/main/ls/1.0.3.json b/src/main/ls/1.0.3.json deleted file mode 100644 index 764f10e..0000000 --- a/src/main/ls/1.0.3.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "organization":"se.radley", - "name":"play-plugins-salat", - "version":"1.0.3", - "description":"MongoDB Salat plugin for PlayFramework 2", - "site":"http://github.com/leon/play-salat", - "tags":["mongodb", "casbah", "salat", "play"], - "docs":"http://github.com/leon/play-salat", - "licenses": [{ - "name": "Apache 2.0", - "url": "http://www.opensource.org/licenses/Apache-2.0" - }], - "resolvers": ["https://oss.sonatype.org/content/groups/public/"], - "dependencies": [{ - "organization":"play", - "name": "play", - "version": "2.0.1" - },{ - "organization":"com.novus", - "name": "salat-core", - "version": "0.0.8-SNAPSHOT" - }], - "scalas": ["2.9.1"], - "sbt": false -} diff --git a/src/main/ls/1.0.4.json b/src/main/ls/1.0.4.json deleted file mode 100644 index b240827..0000000 --- a/src/main/ls/1.0.4.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "organization":"se.radley", - "name":"play-plugins-salat", - "version":"1.0.4", - "description":"MongoDB Salat plugin for PlayFramework 2", - "site":"http://github.com/leon/play-salat", - "tags":["mongodb", "casbah", "salat", "play"], - "docs":"http://github.com/leon/play-salat", - "licenses": [{ - "name": "Apache 2.0", - "url": "http://www.opensource.org/licenses/Apache-2.0" - }], - "resolvers": ["https://oss.sonatype.org/content/groups/public/"], - "dependencies": [{ - "organization":"play", - "name": "play", - "version": "2.0.1" - },{ - "organization":"com.novus", - "name": "salat-core", - "version": "0.0.8-SNAPSHOT" - }], - "scalas": ["2.9.1"], - "sbt": false -} diff --git a/src/main/ls/1.0.5.json b/src/main/ls/1.0.5.json deleted file mode 100644 index bb05b44..0000000 --- a/src/main/ls/1.0.5.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "organization":"se.radley", - "name":"play-plugins-salat", - "version":"1.0.5", - "description":"MongoDB Salat plugin for PlayFramework 2", - "site":"http://github.com/leon/play-salat", - "tags":["mongodb", "casbah", "salat", "play"], - "docs":"http://github.com/leon/play-salat", - "licenses": [{ - "name": "Apache 2.0", - "url": "http://www.opensource.org/licenses/Apache-2.0" - }], - "resolvers": ["https://oss.sonatype.org/content/groups/public/"], - "dependencies": [{ - "organization":"play", - "name": "play", - "version": "2.0.1" - },{ - "organization":"com.novus", - "name": "salat", - "version": "0.0.8" - }], - "scalas": ["2.9.1"], - "sbt": false -} diff --git a/src/main/ls/1.0.6.json b/src/main/ls/1.0.6.json deleted file mode 100644 index f35810b..0000000 --- a/src/main/ls/1.0.6.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "organization":"se.radley", - "name":"play-plugins-salat", - "version":"1.0.6", - "description":"MongoDB Salat plugin for PlayFramework 2", - "site":"http://github.com/leon/play-salat", - "tags":["mongodb", "casbah", "salat", "play"], - "docs":"http://github.com/leon/play-salat", - "licenses": [{ - "name": "Apache 2.0", - "url": "http://www.opensource.org/licenses/Apache-2.0" - }], - "resolvers": ["https://oss.sonatype.org/content/groups/public/"], - "dependencies": [{ - "organization":"play", - "name": "play", - "version": "2.0.2" - },{ - "organization":"com.novus", - "name": "salat", - "version": "0.0.8" - }], - "scalas": ["2.9.1"], - "sbt": false -} diff --git a/src/main/ls/1.0.7.json b/src/main/ls/1.0.7.json deleted file mode 100644 index d699a9a..0000000 --- a/src/main/ls/1.0.7.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "organization":"se.radley", - "name":"play-plugins-salat", - "version":"1.0.7", - "description":"MongoDB Salat plugin for PlayFramework 2", - "site":"http://github.com/leon/play-salat", - "tags":["mongodb", "casbah", "salat", "play"], - "docs":"http://github.com/leon/play-salat", - "licenses": [{ - "name": "Apache 2.0", - "url": "http://www.opensource.org/licenses/Apache-2.0" - }], - "resolvers": ["https://oss.sonatype.org/content/groups/public/"], - "dependencies": [{ - "organization":"play", - "name": "play", - "version": "2.0.2" - },{ - "organization":"com.novus", - "name": "salat", - "version": "1.9.0" - }], - "scalas": ["2.9.1"], - "sbt": false -} diff --git a/src/main/ls/1.0.8.json b/src/main/ls/1.0.8.json deleted file mode 100644 index 7eb890d..0000000 --- a/src/main/ls/1.0.8.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "organization":"se.radley", - "name":"play-plugins-salat", - "version":"1.0.8", - "description":"MongoDB Salat plugin for PlayFramework 2", - "site":"http://github.com/leon/play-salat", - "tags":["mongodb", "casbah", "salat", "play"], - "docs":"http://github.com/leon/play-salat", - "licenses": [{ - "name": "Apache 2.0", - "url": "http://www.opensource.org/licenses/Apache-2.0" - }], - "resolvers": ["https://oss.sonatype.org/content/groups/public/"], - "dependencies": [{ - "organization":"play", - "name": "play", - "version": "2.0.3" - },{ - "organization":"com.novus", - "name": "salat", - "version": "1.9.0" - }], - "scalas": ["2.9.1"], - "sbt": false -} \ No newline at end of file diff --git a/src/main/ls/1.0.9.json b/src/main/ls/1.0.9.json deleted file mode 100644 index e5354ee..0000000 --- a/src/main/ls/1.0.9.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "organization":"se.radley", - "name":"play-plugins-salat", - "version":"1.0.9", - "description":"MongoDB Salat plugin for PlayFramework 2", - "site":"http://github.com/leon/play-salat", - "tags":["mongodb", "casbah", "salat", "play"], - "docs":"http://github.com/leon/play-salat", - "licenses": [{ - "name": "Apache 2.0", - "url": "http://www.opensource.org/licenses/Apache-2.0" - }], - "resolvers": ["https://oss.sonatype.org/content/groups/public/"], - "dependencies": [{ - "organization":"play", - "name": "play", - "version": "2.0.3" - },{ - "organization":"com.novus", - "name": "salat", - "version": "1.9.0" - }], - "scalas": ["2.9.1"], - "sbt": false -} \ No newline at end of file diff --git a/src/main/ls/1.1.json b/src/main/ls/1.1.json deleted file mode 100644 index 78e0b54..0000000 --- a/src/main/ls/1.1.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "organization":"se.radley", - "name":"play-plugins-salat", - "version":"1.1", - "description":"MongoDB Salat plugin for PlayFramework 2", - "site":"http://github.com/leon/play-salat", - "tags":["mongodb", "casbah", "salat", "play"], - "docs":"http://github.com/leon/play-salat", - "licenses": [{ - "name": "Apache 2.0", - "url": "http://www.apache.org/licenses/LICENSE-2.0" - }], - "resolvers": ["https://oss.sonatype.org/content/groups/public/"], - "dependencies": [{ - "organization":"play", - "name": "play", - "version": "2.0.3" - },{ - "organization":"com.novus", - "name": "salat", - "version": "1.9.1" - }], - "scalas": ["2.9.1"], - "sbt": false -} \ No newline at end of file diff --git a/src/main/ls/1.2.json b/src/main/ls/1.2.json deleted file mode 100644 index bd90852..0000000 --- a/src/main/ls/1.2.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "organization":"se.radley", - "name":"play-plugins-salat", - "version":"1.2", - "description":"MongoDB Salat plugin for PlayFramework 2", - "site":"http://github.com/leon/play-salat", - "tags":["mongodb", "casbah", "salat", "play"], - "docs":"http://github.com/leon/play-salat", - "licenses": [{ - "name": "Apache 2.0", - "url": "http://www.apache.org/licenses/LICENSE-2.0" - }], - "resolvers": ["https://oss.sonatype.org/content/groups/public/"], - "dependencies": [{ - "organization":"play", - "name": "play", - "version": "2.1" - },{ - "organization":"com.novus", - "name": "salat", - "version": "1.9.2" - }], - "scalas": ["2.10.0"], - "sbt": false -} \ No newline at end of file From 501d77fc5ca576e56fc1ec07640427e7f5bd1868 Mon Sep 17 00:00:00 2001 From: Leon Radley Date: Mon, 18 Nov 2013 13:34:28 +0100 Subject: [PATCH 3/5] Updated project --- .travis.yml | 2 +- notes/1.4.0.markdown | 4 ++-- project/Build.scala | 18 ++++++++++-------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 563a36d..0e0aa23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: scala scala: - - 2.10.2 + - 2.10.3 branches: only: diff --git a/notes/1.4.0.markdown b/notes/1.4.0.markdown index 47775df..1298c4d 100644 --- a/notes/1.4.0.markdown +++ b/notes/1.4.0.markdown @@ -1,4 +1,4 @@ -- Salat 1.9.3 -- Play 2.2.0 +- Salat 1.9.4 +- Play 2.2.1 - Possible breaking change, cappedCollection size and max is now `Long` instead of `Int` #46 - Change to MongoClient and use MongoClientOptions instead of the now depricated MongoOptions #51 \ No newline at end of file diff --git a/project/Build.scala b/project/Build.scala index 828ce3e..3f265dd 100755 --- a/project/Build.scala +++ b/project/Build.scala @@ -9,20 +9,22 @@ object ProjectBuild extends Build { organization := "se.radley", description := "MongoDB Salat plugin for PlayFramework 2", version := buildVersion, - scalaVersion := "2.10.2", + scalaVersion := "2.10.3", scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature"), parallelExecution in Test := false, testFrameworks += TestFrameworks.Specs2, - resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/", - resolvers += "Typesafe Snapshots" at "http://repo.typesafe.com/typesafe/snapshots/", - resolvers += "Sonatype Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/", + resolvers ++= Seq( + "play Repository" at "http://repo.typesafe.com/typesafe/simple/maven-releases/", + Resolver.sonatypeRepo("releases"), + Resolver.sonatypeRepo("snapshots") + ), libraryDependencies ++= Seq( - "com.typesafe.play" %% "play" % "2.2.0" % "provided", - "com.typesafe.play" % "play-exceptions" % "2.2.0" % "provided", - "com.typesafe.play" %% "play-test" % "2.2.0" % "test", - "com.novus" %% "salat" % "1.9.3", + "com.typesafe.play" %% "play" % "2.2.1" % "provided", + "com.typesafe.play" % "play-exceptions" % "2.2.1" % "provided", + "com.typesafe.play" %% "play-test" % "2.2.1" % "test", + "com.novus" %% "salat" % "1.9.4", "org.mongodb" %% "casbah-gridfs" % "2.6.3" ) ) From 6f117fcfd8e071ba851d5fd9402c43c6fe1a777f Mon Sep 17 00:00:00 2001 From: Leon Radley Date: Mon, 18 Nov 2013 13:35:28 +0100 Subject: [PATCH 4/5] Implemented ssl setting #52 The ssl setting works by setting the socket factory to javax.net.ssl.SSLSocketFactory --- .../radley/plugin/salat/OptionsFromConfig.scala | 2 ++ .../plugin/salat/OptionsFromConfigSpec.scala | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/main/scala/se/radley/plugin/salat/OptionsFromConfig.scala b/src/main/scala/se/radley/plugin/salat/OptionsFromConfig.scala index 84e2f91..0272a83 100644 --- a/src/main/scala/se/radley/plugin/salat/OptionsFromConfig.scala +++ b/src/main/scala/se/radley/plugin/salat/OptionsFromConfig.scala @@ -3,6 +3,7 @@ package se.radley.plugin.salat import play.api.Configuration import com.mongodb.casbah.MongoOptions import com.mongodb._ +import javax.net.ssl.SSLSocketFactory import scala.Some object OptionsFromConfig { @@ -43,6 +44,7 @@ object OptionsFromConfig { config.getInt("socketTimeout").map(v => builder.socketTimeout(v)) config.getInt("threadsAllowedToBlockForConnectionMultiplier").map(v => builder.threadsAllowedToBlockForConnectionMultiplier(v)) config.getString("writeConcern").map(name => WriteConcern.valueOf(name)).map(v => builder.writeConcern(v)) + config.getBoolean("ssl").map(v => if (v) builder.socketFactory(SSLSocketFactory.getDefault())) Some(builder.build()) } diff --git a/src/test/scala/se/radley/plugin/salat/OptionsFromConfigSpec.scala b/src/test/scala/se/radley/plugin/salat/OptionsFromConfigSpec.scala index 6af4afd..58d6e75 100644 --- a/src/test/scala/se/radley/plugin/salat/OptionsFromConfigSpec.scala +++ b/src/test/scala/se/radley/plugin/salat/OptionsFromConfigSpec.scala @@ -5,6 +5,7 @@ import com.mongodb._ import play.api.Configuration import javax.net.SocketFactory import org.specs2.specification.AllExpectations +import javax.net.ssl.SSLSocketFactory class OptionsFromConfigSpec extends Specification with AllExpectations { @@ -54,6 +55,20 @@ class OptionsFromConfigSpec extends Specification with AllExpectations { val options = OptionsFromConfig(Configuration.empty) options must beNone } + + "Set SSL factory is ssl = true" in { + val conf = Map( + ("mongodb.default.options.ssl" -> "true") + ) + + val configuration = Configuration.from(conf).getConfig("mongodb.default.options").get + val optionsOpt = OptionsFromConfig(configuration) + + optionsOpt must beSome + val options = optionsOpt.get + + options.getSocketFactory must haveClass[SSLSocketFactory] + } } } From 652e23feb9b801408c76810ac7810f59e845c8de Mon Sep 17 00:00:00 2001 From: Leon Radley Date: Mon, 18 Nov 2013 13:43:21 +0100 Subject: [PATCH 5/5] 1.4.0 #50 #51 #52 --- project/Build.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Build.scala b/project/Build.scala index 3f265dd..ff479b9 100755 --- a/project/Build.scala +++ b/project/Build.scala @@ -3,7 +3,7 @@ import sbt.Keys._ object ProjectBuild extends Build { - lazy val buildVersion = "1.4.0-SNAPSHOT" + lazy val buildVersion = "1.4.0" lazy val root = Project(id = "play-plugins-salat", base = file("."), settings = Project.defaultSettings ++ Publish.settings).settings( organization := "se.radley",