Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Release 1.0.7.4

Minor bugfix / tweak release.

+ Fixed some issues w/ GridFS libraries attempting to call toMap in iteration, which isn't implemented on the Java side; added custom toString methods on the GridFS files [BWM]
+ Cleaned up log spam [BWM / MA]
+ Added serialization hook for MongoDBObject to help catch any nested instances [MA]
+ Cleaned up some stray references to java.lang.Object, replaced with AnyRef for good Scala coding practices [BWM]
  • Loading branch information...
commit ed57a77f6e5dd07738618b41c1cb17d56c2382a6 1 parent 7842043
Brendan W. McAdams bwmcadams authored
6 notes/1.0.7.4.markdown
Source Rendered
... ... @@ -0,0 +1,6 @@
  1 +Minor bugfix / tweak release.
  2 +
  3 ++ Fixed some issues w/ GridFS libraries attempting to call toMap in iteration, which isn't implemented on the Java side; added custom toString methods on the GridFS files [BWM]
  4 ++ Cleaned up log spam [BWM / MA]
  5 ++ Added serialization hook for MongoDBObject to help catch any nested instances [MA]
  6 ++ Cleaned up some stray references to java.lang.Object, replaced with AnyRef for good Scala coding practices [BWM]
2  project/build.properties
@@ -3,7 +3,7 @@
3 3 project.organization=com.novus
4 4 project.name=casbah
5 5 sbt.version=0.7.4
6   -project.version=1.0.7.3
  6 +project.version=1.0.7.4
7 7 def.scala.version=2.7.7
8 8 build.scala.versions=2.8.0
9 9 project.initialize=false
23 src/main/scala/mongodb/GridFS.scala
@@ -63,7 +63,7 @@ object GridFS extends Logging {
63 63
64 64 }
65 65
66   -class GridFS protected[mongodb](val underlying: MongoGridFS) extends Iterable[GridFSFile] with Logging {
  66 +class GridFS protected[mongodb](val underlying: MongoGridFS) extends Iterable[GridFSDBFile] with Logging {
67 67 log.info("Instantiated a new GridFS instance against '%s'", underlying)
68 68
69 69 type FileOp = GridFSFile => Unit
@@ -72,7 +72,7 @@ class GridFS protected[mongodb](val underlying: MongoGridFS) extends Iterable[Gr
72 72
73 73 implicit val db = underlying.getDB().asScala
74 74
75   - def iterator = new Iterator[GridFSFile] {
  75 + def iterator = new Iterator[GridFSDBFile] {
76 76 val fileSet = files
77 77 def count() = fileSet.count
78 78 def itcount() = fileSet.itcount()
@@ -187,15 +187,15 @@ class GridFS protected[mongodb](val underlying: MongoGridFS) extends Iterable[Gr
187 187 */
188 188 def sansJodaTime[T](op: => T) = org.bson.BSONDecoders(classOf[java.util.Date]) match {
189 189 case Some(transformer) => {
190   - log.info("DateTime Decoder was loaded; unloading before continuing.")
  190 + log.trace("DateTime Decoder was loaded; unloading before continuing.")
191 191 new conversions.scala.JodaDateTimeDeserializer { unregister() }
192 192 val ret = op
193   - log.info("Retrieval finished. Re-registering decoder.")
  193 + log.trace("Retrieval finished. Re-registering decoder.")
194 194 new conversions.scala.JodaDateTimeDeserializer { register() }
195 195 ret
196 196 }
197 197 case None => {
198   - log.info("Didn't find a registration for JodaTime: %s", org.bson.BSONDecoders())
  198 + log.trace("Didn't find a registration for JodaTime: %s", org.bson.BSONDecoders())
199 199 op
200 200 }
201 201 }
@@ -225,12 +225,14 @@ class GridFS protected[mongodb](val underlying: MongoGridFS) extends Iterable[Gr
225 225 def remove(filename: String) = underlying.remove(filename)
226 226 }
227 227
228   -// Todo - use this as basis for a new DBOBject wrapper object... (One that can take and return arbitrary json esp.)
229 228 @BeanInfo
230 229 trait GridFSFile extends MongoDBObject with Logging {
231 230 val underlying: MongoGridFSFile
232 231 def save = underlying.save
233 232
  233 + override def iterator = underlying.keySet.asScala.map { k =>
  234 + k -> underlying.get(k)
  235 + }.toMap.iterator.asInstanceOf[Iterator[(String, AnyRef)]]
234 236 /**
235 237 * validate the object.
236 238 * Throws an exception if it fails
@@ -251,12 +253,17 @@ trait GridFSFile extends MongoDBObject with Logging {
251 253 def metaData: DBObject = underlying.getMetaData
252 254 def md5: String = underlying.getMD5
253 255
254   - override def toString = underlying.toString
  256 + override def toString = "{ GridFSFile(id=%s, filename=%s, contentType=%s) }".
  257 + format(id, filename, contentType)
255 258
256 259 }
257 260
258 261 @BeanInfo
259   -class GridFSDBFile protected[mongodb](override val underlying: MongoGridFSDBFile) extends GridFSFile
  262 +class GridFSDBFile protected[mongodb](override val underlying: MongoGridFSDBFile) extends GridFSFile {
  263 + override def toString = "{ GridFSDBFile(id=%s, filename=%s, contentType=%s) }".
  264 + format(id, filename, contentType)
  265 +}
  266 +
260 267 @BeanInfo
261 268 class GridFSInputFile protected[mongodb](override val underlying: MongoGridFSInputFile) extends GridFSFile {
262 269 def filename_=(name: String) = underlying.setFilename(name)
6 src/main/scala/mongodb/MongoDBObject.scala
@@ -49,13 +49,13 @@ import scala.reflect._
49 49 * @tparam Object
50 50 */
51 51 @BeanInfo
52   -trait MongoDBObject extends Map[String, Object] with Logging {
  52 +trait MongoDBObject extends Map[String, AnyRef] with Logging {
53 53 val underlying: DBObject
54 54
55 55 def iterator = underlying.toMap.iterator.asInstanceOf[Iterator[(String, Object)]]
56 56
57 57
58   - override def get(key: String): Option[Object] = underlying.get(key) match {
  58 + override def get(key: String): Option[AnyRef] = underlying.get(key) match {
59 59 case null => None
60 60 case value => Some(value)
61 61 }
@@ -70,7 +70,7 @@ trait MongoDBObject extends Map[String, Object] with Logging {
70 70 }
71 71 }
72 72
73   - def +=(kv: (String, Object)) = {
  73 + def +=(kv: (String, AnyRef)) = {
74 74 put(kv._1, kv._2)
75 75 this
76 76 }

0 comments on commit ed57a77

Please sign in to comment.
Something went wrong with that request. Please try again.