Spring Data Document

org.springframework.data.mongodb.gridfs
Class GridFsTemplate

java.lang.Object
  extended by org.springframework.data.mongodb.gridfs.GridFsTemplate
All Implemented Interfaces:
ResourceLoader, ResourcePatternResolver, GridFsOperations

public class GridFsTemplate
extends Object
implements GridFsOperations, ResourcePatternResolver

GridFsOperations implementation to store content into MongoDB GridFS.

Author:
Oliver Gierke

Field Summary
 
Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver
CLASSPATH_ALL_URL_PREFIX
 
Fields inherited from interface org.springframework.core.io.ResourceLoader
CLASSPATH_URL_PREFIX
 
Constructor Summary
GridFsTemplate(MongoDbFactory dbFactory, MongoConverter converter)
          Creates a new GridFsTemplate using the given MongoDbFactory and MongoConverter.
GridFsTemplate(MongoDbFactory dbFactory, MongoConverter converter, String bucket)
          Creates a new GridFsTemplate using the given MongoDbFactory and MongoConverter.
 
Method Summary
 void delete(Query query)
          Deletes all files matching the given Query.
 List<GridFSDBFile> find(Query query)
          Returns all files matching the given query.
 GridFSDBFile findOne(Query query)
          Returns a single file matching the given query or null in case no file matches.
 ClassLoader getClassLoader()
           
 GridFsResource getResource(String location)
          Returns all GridFsResource with the given file name.
 GridFsResource[] getResources(String locationPattern)
          Returns all GridFsResources matching the given file name pattern.
 GridFSFile store(InputStream content, String filename)
          Stores the given content into a file with the given name.
 GridFSFile store(InputStream content, String filename, DBObject metadata)
          Stores the given content into a file with the given name using the given metadata.
 GridFSFile store(InputStream content, String filename, Object metadata)
          Stores the given content into a file with the given name using the given metadata.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GridFsTemplate

public GridFsTemplate(MongoDbFactory dbFactory,
                      MongoConverter converter)
Creates a new GridFsTemplate using the given MongoDbFactory and MongoConverter.

Parameters:
dbFactory - must not be null.
converter - must not be null.

GridFsTemplate

public GridFsTemplate(MongoDbFactory dbFactory,
                      MongoConverter converter,
                      String bucket)
Creates a new GridFsTemplate using the given MongoDbFactory and MongoConverter.

Parameters:
dbFactory - must not be null.
converter - must not be null.
bucket -
Method Detail

store

public GridFSFile store(InputStream content,
                        String filename)
Description copied from interface: GridFsOperations
Stores the given content into a file with the given name.

Specified by:
store in interface GridFsOperations
Parameters:
content - must not be null.
filename - must not be null or empty.
Returns:
the GridFSFile just created

store

public GridFSFile store(InputStream content,
                        String filename,
                        Object metadata)
Description copied from interface: GridFsOperations
Stores the given content into a file with the given name using the given metadata. The metadata object will be marshalled before writing.

Specified by:
store in interface GridFsOperations
Parameters:
content - must not be null.
filename - must not be null or empty.
Returns:
the GridFSFile just created

store

public GridFSFile store(InputStream content,
                        String filename,
                        DBObject metadata)
Description copied from interface: GridFsOperations
Stores the given content into a file with the given name using the given metadata.

Specified by:
store in interface GridFsOperations
Parameters:
content - must not be null.
filename - must not be null or empty.
metadata - must not be null.
Returns:
the GridFSFile just created

find

public List<GridFSDBFile> find(Query query)
Description copied from interface: GridFsOperations
Returns all files matching the given query.

Specified by:
find in interface GridFsOperations
Returns:

findOne

public GridFSDBFile findOne(Query query)
Description copied from interface: GridFsOperations
Returns a single file matching the given query or null in case no file matches.

Specified by:
findOne in interface GridFsOperations
Returns:

delete

public void delete(Query query)
Description copied from interface: GridFsOperations
Deletes all files matching the given Query.

Specified by:
delete in interface GridFsOperations

getClassLoader

public ClassLoader getClassLoader()
Specified by:
getClassLoader in interface ResourceLoader

getResource

public GridFsResource getResource(String location)
Description copied from interface: GridFsOperations
Returns all GridFsResource with the given file name.

Specified by:
getResource in interface ResourceLoader
Specified by:
getResource in interface GridFsOperations
See Also:
ResourceLoader.getResource(String)

getResources

public GridFsResource[] getResources(String locationPattern)
Description copied from interface: GridFsOperations
Returns all GridFsResources matching the given file name pattern.

Specified by:
getResources in interface ResourcePatternResolver
Specified by:
getResources in interface GridFsOperations
See Also:
ResourcePatternResolver.getResources(String)

Spring Data Document

Copyright © 2012. All Rights Reserved.