26
26
import java .util .ArrayList ;
27
27
import java .util .List ;
28
28
29
+ import com .mongodb .*;
29
30
import org .bson .types .ObjectId ;
30
31
31
- import com .mongodb .BasicDBObject ;
32
- import com .mongodb .BasicDBObjectBuilder ;
33
- import com .mongodb .DB ;
34
- import com .mongodb .DBCollection ;
35
- import com .mongodb .DBCursor ;
36
- import com .mongodb .DBObject ;
37
-
38
32
/**
39
33
* Implementation of GridFS v1.0
40
34
*
@@ -95,14 +89,25 @@ public GridFS(DB db, String bucket) {
95
89
// ------ utils -------
96
90
// --------------------------
97
91
92
+ protected class GridFSCursor extends DBCursor {
93
+ public GridFSCursor (DBCollection collection , DBObject q , DBObject k , ReadPreference preference ){
94
+ super (collection , q , k , preference );
95
+ }
96
+
97
+ @ Override
98
+ public DBObject next () throws MongoException {
99
+ DBObject obj = super .next ();
100
+ return _fix (obj );
101
+ }
102
+ }
98
103
99
104
/**
100
105
* gets the list of files stored in this gridfs, sorted by filename
101
106
*
102
107
* @return cursor of file objects
103
108
*/
104
109
public DBCursor getFileList (){
105
- return _filesCollection . find () .sort (new BasicDBObject ("filename" ,1 ));
110
+ return new GridFSCursor ( _filesCollection , new BasicDBObject (), null , null ) .sort (new BasicDBObject ("filename" , 1 ));
106
111
}
107
112
108
113
/**
@@ -112,7 +117,7 @@ public DBCursor getFileList(){
112
117
* @return cursor of file objects
113
118
*/
114
119
public DBCursor getFileList ( DBObject query ){
115
- return _filesCollection . find ( query ).sort (new BasicDBObject ("filename" ,1 ));
120
+ return new GridFSCursor ( _filesCollection , query , null , null ).sort (new BasicDBObject ("filename" , 1 ));
116
121
}
117
122
118
123
0 commit comments