2 * Copyright (C) 2021 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.cdm
.api
.service
.media
;
11 import java
.io
.IOException
;
12 import java
.util
.ArrayList
;
13 import java
.util
.List
;
15 import org
.apache
.http
.HttpException
;
16 import org
.springframework
.stereotype
.Component
;
18 import eu
.etaxonomy
.cdm
.common
.URI
;
19 import eu
.etaxonomy
.cdm
.common
.media
.CdmImageInfo
;
22 * @author a.kohlbecker
26 public class MediaInfoFactory
implements IMediaInfoFactory
{
29 * TODO needs to be managed in CDM PREFERENCES
31 private List
<MediaUriTransformation
> uriTransformations
= new ArrayList
<>();
34 public MediaInfoFactory() {
35 uriTransformations
.add(DefaultMediaTransformations
.bgbmMediaMetadataService());
39 * This method only exists due to performance issues for cases when
40 * the {@link MediaMetadataFileReader} to reduce the overhead imposed by reading
41 * the image metadata from the file itself.
47 * @throws HttpException
49 public CdmImageInfo
cdmImageInfoWithMetaData(eu
.etaxonomy
.cdm
.common
.URI imageUri
) throws IOException
, HttpException
{
50 return cdmImageInfoWithMetaData(imageUri
.getJavaUri());
54 * This method only exists due to performance issues for cases when
55 * the {@link MediaMetadataFileReader} to reduce the overhead imposed by reading
56 * the image metadata from the file itself.
62 * @throws HttpException
64 public CdmImageInfo
cdmImageInfoWithMetaData(URI imageUri
) throws IOException
, HttpException
{
66 // :-) Hooray, we can get the metadata from the web service, this is going to be snappy
67 MediaUriTransformationProcessor processor
= new MediaUriTransformationProcessor();
68 processor
.addAll(uriTransformations
);
69 processor
.applyTo(imageUri
);
71 // :-( need to use the files reader
72 return new MediaMetadataFileReader(imageUri
)
79 public CdmImageInfo
cdmImageInfo(eu
.etaxonomy
.cdm
.common
.URI imageUri
) throws IOException
, HttpException
{
80 return cdmImageInfo(imageUri
.getJavaUri());
83 public CdmImageInfo
cdmImageInfo(URI imageUri
) throws IOException
, HttpException
{
85 // :-) Hooray, we can get the metadata from the web service, this is going to be snappy
87 // :-( need to use the files reader
88 return new MediaMetadataFileReader(imageUri
)