Project

General

Profile

« Previous | Next » 

Revision 64cd247e

Added by Andreas Müller over 6 years ago

ref #6684 handle casting and null for preferred media part

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/media/MediaUtils.java
14 14

  
15 15
import org.apache.log4j.Logger;
16 16

  
17
import eu.etaxonomy.cdm.model.common.CdmBase;
18

  
17 19
public class MediaUtils {
18 20

  
19 21
    private static final Logger logger = Logger.getLogger(MediaUtils.class);
......
307 309
                    if (height != 0 && widthOrDuration != 0){
308 310
                        int durationWidthWeight = 0;
309 311

  
310
                        if (part instanceof ImageFile) {
311
                            ImageFile image = (ImageFile) part;
312
                            durationWidthWeight = image.getWidth() * image.getHeight() - height * widthOrDuration;
312
                        if (part.isInstanceOf(ImageFile.class)) {
313
                            ImageFile image = CdmBase.deproxy(part, ImageFile.class);
314
                            if (image.getWidth() != null && image.getHeight() != null){
315
                                durationWidthWeight = image.getWidth() * image.getHeight() - height * widthOrDuration;
316
                            }
313 317
                        }
314
                        else if (part instanceof MovieFile){
315
                            MovieFile movie = (MovieFile) part;
318
                        else if (part.isInstanceOf(MovieFile.class)){
319
                            MovieFile movie = CdmBase.deproxy(part, MovieFile.class);
316 320
                            durationWidthWeight = movie.getDuration() - widthOrDuration;
317

  
318
                        }else if (part instanceof AudioFile){
319
                            AudioFile audio = (AudioFile) part;
321
                        }else if (part.isInstanceOf(AudioFile.class)){
322
                            AudioFile audio = CdmBase.deproxy(part, AudioFile.class);
320 323
                            durationWidthWeight = audio.getDuration() - widthOrDuration;
321

  
322 324
                        }
323 325
                        if (durationWidthWeight < 0) {
324 326
                            durationWidthWeight *= -1;

Also available in: Unified diff