Revision 727e2bb3
Added by Niels Hoffmann almost 13 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelFactsImport.java | ||
---|---|---|
439 | 439 |
TaxonDescription taxonDescription = null; |
440 | 440 |
Reference sourceRef = state.getConfig().getSourceReference(); |
441 | 441 |
Integer size = null; |
442 |
ImageInfo imageMetaData = null;
|
|
442 |
ImageInfo imageInfo = null;
|
|
443 | 443 |
URI uri; |
444 | 444 |
try { |
445 | 445 |
uri = new URI(fact.trim()); |
... | ... | |
448 | 448 |
return null; |
449 | 449 |
} |
450 | 450 |
try { |
451 |
imageMetaData = ImageInfo.NewInstance(uri, 0);
|
|
451 |
imageInfo = ImageInfo.NewInstance(uri, 0);
|
|
452 | 452 |
} catch (IOException e) { |
453 | 453 |
logger.error("IOError reading image metadata." , e); |
454 | 454 |
} catch (HttpException e) { |
455 | 455 |
logger.error("HttpException reading image metadata." , e); |
456 | 456 |
} |
457 |
MediaRepresentation mediaRepresentation = MediaRepresentation.NewInstance(imageMetaData.getMimeType(), null);
|
|
457 |
MediaRepresentation mediaRepresentation = MediaRepresentation.NewInstance(imageInfo.getMimeType(), null);
|
|
458 | 458 |
media.addRepresentation(mediaRepresentation); |
459 |
ImageFile image = ImageFile.NewInstance(uri, size, imageMetaData);
|
|
459 |
ImageFile image = ImageFile.NewInstance(uri, size, imageInfo);
|
|
460 | 460 |
mediaRepresentation.addRepresentationPart(image); |
461 | 461 |
|
462 | 462 |
taxonDescription = taxon.getOrCreateImageGallery(sourceRef == null ? null :sourceRef.getTitleCache()); |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/CdmImportBase.java | ||
---|---|---|
646 | 646 |
if( multimediaObject == null){ |
647 | 647 |
return null; |
648 | 648 |
} else { |
649 |
ImageInfo imd = null;
|
|
649 |
ImageInfo imageInfo = null;
|
|
650 | 650 |
URI uri; |
651 | 651 |
try { |
652 | 652 |
uri = new URI(multimediaObject); |
653 | 653 |
try { |
654 | 654 |
if (readDataFromUrl){ |
655 |
imd = ImageInfo.NewInstance(uri, 0);
|
|
655 |
imageInfo = ImageInfo.NewInstance(uri, 0);
|
|
656 | 656 |
} |
657 | 657 |
} catch (Exception e) { |
658 | 658 |
String message = "An error occurred when trying to read image meta data: " + e.getMessage(); |
659 | 659 |
logger.warn(message); |
660 | 660 |
} |
661 |
ImageFile imf = ImageFile.NewInstance(uri, null, imd);
|
|
661 |
ImageFile imageFile = ImageFile.NewInstance(uri, null, imageInfo);
|
|
662 | 662 |
MediaRepresentation representation = MediaRepresentation.NewInstance(); |
663 |
representation.setMimeType(imd.getMimeType()); |
|
664 |
representation.addRepresentationPart(imf); |
|
663 |
if(imageInfo != null){ |
|
664 |
representation.setMimeType(imageInfo.getMimeType()); |
|
665 |
} |
|
666 |
representation.addRepresentationPart(imageFile); |
|
665 | 667 |
Media media = Media.NewInstance(); |
666 | 668 |
media.addRepresentation(representation); |
667 | 669 |
return media; |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/media/ImageFile.java | ||
---|---|---|
60 | 60 |
return new ImageFile(uri, size, height, width); |
61 | 61 |
} |
62 | 62 |
|
63 |
public static ImageFile NewInstance(URI uri, Integer size, ImageInfo imageMetaData){
|
|
63 |
public static ImageFile NewInstance(URI uri, Integer size, ImageInfo imageInfo){
|
|
64 | 64 |
ImageFile imageFile = NewInstance(uri, size); |
65 | 65 |
|
66 |
if(imageMetaData != null){
|
|
67 |
imageFile.setHeight(imageMetaData.getHeight());
|
|
68 |
imageFile.setWidth(imageMetaData.getWidth());
|
|
66 |
if(imageInfo != null){
|
|
67 |
imageFile.setHeight(imageInfo.getHeight());
|
|
68 |
imageFile.setWidth(imageInfo.getWidth());
|
|
69 | 69 |
} |
70 | 70 |
|
71 | 71 |
return imageFile; |
Also available in: Unified diff
Fixed a failing test