Project

General

Profile

« Previous | Next » 

Revision 72e2be95

Added by Andreas Müller 5 months ago

ref #9607 try metadata reading client side if error occurs server side

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/media/MediaInfoFactory.java
13 13
import java.util.List;
14 14

  
15 15
import org.apache.http.HttpException;
16
import org.apache.log4j.Logger;
16 17
import org.springframework.stereotype.Component;
17 18

  
18 19
import eu.etaxonomy.cdm.common.URI;
......
25 26
@Component
26 27
public class MediaInfoFactory implements IMediaInfoFactory {
27 28

  
29
    private static final Logger logger = Logger.getLogger(MediaInfoFactory.class);
30

  
28 31
    /**
29 32
     * TODO needs to be managed in CDM PREFERENCES per service and version.
30 33
     *
......
47 50
        List<URI> metadataServiceURIs = applyURITransformations(imageUri);
48 51
        if(!metadataServiceURIs.isEmpty()) {
49 52
            // :-) Hooray, we can get the metadata from the web service, this is going to be snappy
50
            return new MediaInfoServiceReader(imageUri, metadataServiceURIs.get(0))
51
                    .read()
52
                    .getCdmImageInfo();
53
        } else {
54
            // :-( need to use the files reader
55
            MediaInfoFileReader mediaReader = new MediaInfoFileReader(imageUri)
56
                   .readBaseInfo();
57
            AbstactMediaMetadataReader reader = forceMetaData ? mediaReader.readMetaData() : mediaReader;
58
            return reader.getCdmImageInfo();
53
            try {
54
                return new MediaInfoServiceReader(imageUri, metadataServiceURIs.get(0))
55
                        .read()
56
                        .getCdmImageInfo();
57
            } catch (Exception e) {
58
                logger.warn("Meta data could not be read from meta data service: " + imageUri.toString());
59
                //if an exception occurs read data from original file
60
            }
59 61
        }
62

  
63
        // :-( need to use the files reader
64
        MediaInfoFileReader mediaReader = new MediaInfoFileReader(imageUri).readBaseInfo();
65
        AbstactMediaMetadataReader reader = forceMetaData ? mediaReader.readMetaData() : mediaReader;
66
        return reader.getCdmImageInfo();
67

  
60 68
    }
61 69

  
62 70
    protected List<URI> applyURITransformations(URI imageUri) {

Also available in: Unified diff