}
// Check whether this is really an image file
ODMGXAWrapper txw = new ODMGXAWrapper();
ImageInstance instance = null;
try {
instance = ImageInstance.create( volume, f );
} catch ( Exception e ) {
currentEvent.setResult( ExtVolIndexerEvent.RESULT_ERROR );
return null;
}
if ( instance == null ) {
currentEvent.setResult( ExtVolIndexerEvent.RESULT_NOT_IMAGE );
/*
ImageInstance already aborts transaction if reading image file
was unsuccessfull.
*/
return null;
}
byte[] hash = instance.getHash();
// Check whether there is already an image instance with the same hash
PhotoInfo matchingPhotos[] = PhotoInfo.retrieveByOrigHash( hash );
PhotoInfo photo = null;
if ( matchingPhotos != null && matchingPhotos.length > 0 ) {
// If yes then get the PhotoInfo and add this file as an instance with
// the same type as the one with same hash. If only PhotoInfo with no
// instances add as original for that
photo = matchingPhotos[0];
photo.addInstance( instance );
currentEvent.setResult( ExtVolIndexerEvent.RESULT_NEW_INSTANCE );
newInstanceCount++;
} else {
photo = PhotoInfo.create();
photo.addInstance( instance );
photo.updateFromOriginalFile();
txw.flush();
// Create a thumbnail for this photo
photo.getThumbnail();
currentEvent.setResult( ExtVolIndexerEvent.RESULT_NEW_PHOTO );
newInstanceCount++;
newPhotoCount++;
}
currentEvent.setPhoto( photo );
txw.commit();
log.debug( "exit: indexFile " + f.getAbsolutePath() );
return photo;
}