Revision 31840
Added by Sandro La Bruzzo over 9 years ago
GridFSObjectStore.java | ||
---|---|---|
353 | 353 |
@Override |
354 | 354 |
public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException { |
355 | 355 |
if ((record == null) || (record.getFileMetadata() == null)) throw new ObjectStoreServiceException("Empty input Record"); |
356 |
ObjectStoreFile obj = deliverObject(record.getFileMetadata().getObjectID()); |
|
357 |
if ((obj != null) && (obj.getObjectID() == record.getFileMetadata().getObjectID())) {
|
|
356 |
|
|
357 |
if (existIDStartsWith(record.getFileMetadata().getObjectID())) {
|
|
358 | 358 |
log.debug("Object already exist "); |
359 | 359 |
if (record.getInputStream() != null) { |
360 | 360 |
try { |
... | ... | |
364 | 364 |
throw new ObjectStoreServiceException(e); |
365 | 365 |
} |
366 | 366 |
} |
367 |
ObjectStoreFile obj = deliverObject(record.getFileMetadata().getObjectID()); |
|
367 | 368 |
return obj.getURI(); |
368 | 369 |
} |
369 | 370 |
long timestamp = System.currentTimeMillis(); |
... | ... | |
405 | 406 |
*/ |
406 | 407 |
@Override |
407 | 408 |
public boolean existIDStartsWith(final String startId) { |
408 |
GridFSDBFile out = collection.findOne(new BasicDBObject("_id", Pattern.compile(startId))); |
|
409 |
return out != null; |
|
409 |
BasicDBObject query = new BasicDBObject("_id", startId); |
|
410 |
List<GridFSDBFile> file = collection.find(query); |
|
411 |
return file.size() > 0; |
|
410 | 412 |
} |
411 |
|
|
412 | 413 |
} |
Also available in: Unified diff
fixed case of wrong excpetion raised