DATAMONGO-1695 - Polishing.
Javadoc. Variable names. Move off deprecated methods. Removed obsolete private method.
This commit is contained in:
@@ -46,6 +46,12 @@ public class GridFsResource extends InputStreamResource {
|
||||
this(file, new ByteArrayInputStream(new byte[] {}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link GridFsResource} from the given {@link GridFSDBFile} and {@link InputStream}.
|
||||
*
|
||||
* @param file must not be {@literal null}.
|
||||
* @param inputStream must not be {@literal null}.
|
||||
*/
|
||||
public GridFsResource(GridFSFile file, InputStream inputStream) {
|
||||
|
||||
super(inputStream);
|
||||
|
||||
@@ -162,9 +162,10 @@ public class GridFsTemplate implements GridFsOperations, ResourcePatternResolver
|
||||
|
||||
Assert.notNull(content, "InputStream must not be null!");
|
||||
|
||||
GridFSUploadOptions opts = new GridFSUploadOptions();
|
||||
GridFSUploadOptions options = new GridFSUploadOptions();
|
||||
|
||||
Document mData = new Document();
|
||||
|
||||
if (StringUtils.hasText(contentType)) {
|
||||
mData.put(GridFsResource.CONTENT_TYPE_FIELD, contentType);
|
||||
}
|
||||
@@ -173,9 +174,9 @@ public class GridFsTemplate implements GridFsOperations, ResourcePatternResolver
|
||||
mData.putAll(metadata);
|
||||
}
|
||||
|
||||
opts.metadata(mData);
|
||||
options.metadata(mData);
|
||||
|
||||
return getGridFs().uploadFromStream(filename, content, opts);
|
||||
return getGridFs().uploadFromStream(filename, content, options);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -228,7 +229,7 @@ public class GridFsTemplate implements GridFsOperations, ResourcePatternResolver
|
||||
public GridFsResource getResource(String location) {
|
||||
|
||||
GridFSFile file = findOne(query(whereFilename().is(location)));
|
||||
return file != null ? new GridFsResource(file, getGridFs().openDownloadStreamByName(location)) : null;
|
||||
return file != null ? new GridFsResource(file, getGridFs().openDownloadStream(location)) : null;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -249,7 +250,7 @@ public class GridFsTemplate implements GridFsOperations, ResourcePatternResolver
|
||||
List<GridFsResource> resources = new ArrayList<GridFsResource>();
|
||||
|
||||
for (GridFSFile file : files) {
|
||||
resources.add(new GridFsResource(file, getGridFs().openDownloadStreamByName(file.getFilename())));
|
||||
resources.add(new GridFsResource(file, getGridFs().openDownloadStream(file.getFilename())));
|
||||
}
|
||||
|
||||
return resources.toArray(new GridFsResource[resources.size()]);
|
||||
@@ -258,10 +259,6 @@ public class GridFsTemplate implements GridFsOperations, ResourcePatternResolver
|
||||
return new GridFsResource[] { getResource(locationPattern) };
|
||||
}
|
||||
|
||||
private Document getMappedQuery(Query query) {
|
||||
return query == null ? new Query().getQueryObject() : getMappedQuery(query.getQueryObject());
|
||||
}
|
||||
|
||||
private Document getMappedQuery(Document query) {
|
||||
return query == null ? null : queryMapper.getMappedObject(query, Optional.empty());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user