Package: EmbeddedMediaMetadataProvider$AjcClosure1
EmbeddedMediaMetadataProvider$AjcClosure1
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
EmbeddedMediaMetadataProvider.AjcClosure1(Object[]) |
|
|
|
|
|
||||||||||||||||||||
run(Object[]) |
|
|
|
|
|
Coverage
1: /*
2: * #%L
3: * *********************************************************************************************************************
4: *
5: * NorthernWind - lightweight CMS
6: * http://northernwind.tidalwave.it - git clone https://bitbucket.org/tidalwave/northernwind-src.git
7: * %%
8: * Copyright (C) 2011 - 2023 Tidalwave s.a.s. (http://tidalwave.it)
9: * %%
10: * *********************************************************************************************************************
11: *
12: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
13: * the License. You may obtain a copy of the License at
14: *
15: * http://www.apache.org/licenses/LICENSE-2.0
16: *
17: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
18: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
19: * specific language governing permissions and limitations under the License.
20: *
21: * *********************************************************************************************************************
22: *
23: *
24: * *********************************************************************************************************************
25: * #L%
26: */
27: package it.tidalwave.northernwind.frontend.media.impl;
28:
29: import javax.annotation.Nonnull;
30: import javax.inject.Inject;
31: import java.util.List;
32: import java.io.IOException;
33: import it.tidalwave.util.Id;
34: import it.tidalwave.util.Key;
35: import it.tidalwave.util.NotFoundException;
36: import it.tidalwave.northernwind.aspect.DebugProfiling;
37: import it.tidalwave.northernwind.core.model.ResourceProperties;
38: import it.tidalwave.northernwind.frontend.ui.component.gallery.spi.MediaMetadataProvider;
39: import lombok.extern.slf4j.Slf4j;
40:
41: /***********************************************************************************************************************
42: *
43: * An implementation of {@link MediaMetadataProvider} which retrieves metadata from embedded data inside media files.
44: *
45: * @author Fabrizio Giudici
46: *
47: **********************************************************************************************************************/
48: @Slf4j
49: public class EmbeddedMediaMetadataProvider implements MediaMetadataProvider
50: {
51: public static final Key<List<String>> P_CAMERA_IDS = new Key<>("cameraIds") {};
52:
53: public static final Key<List<String>> P_LENS_IDS = new Key<>("lensIds") {};
54:
55: public static final Key<List<String>> P_MEDIA_PATHS = new Key<>("mediaPaths") {};
56:
57: public static final Id P_GROUP_ID = new Id("EmbeddedMediaMetadataProvider");
58:
59: @Inject
60: private MetadataCache metadataCache;
61:
62: /*******************************************************************************************************************
63: *
64: * {@inheritDoc}
65: *
66: ******************************************************************************************************************/
67: // FIXME: should use the Metadata API of blueMarine, but we have first to make it work with Spring and its DI.
68: @Override @Nonnull @DebugProfiling(message = "metadata retrieved")
69: public String getMetadataString (@Nonnull final Id mediaId,
70: @Nonnull final String template,
71: @Nonnull final ResourceProperties properties)
72: {
73: try
74: {
75: final var metadata = metadataCache.findMetadataById(mediaId, properties);
76: return metadata.interpolateString(template, properties);
77: }
78: catch (NotFoundException e)
79: {
80: log.warn("Cannot find media for id {}: {}", mediaId, e.toString());
81: return "";
82: }
83: catch (IOException e)
84: {
85: log.warn("Unexpected I/O error for id {}: {}", mediaId, e.toString());
86: return "";
87: }
88: }
89: }