1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.imaging.caching; |
35 |
|
|
36 |
|
import info.magnolia.cms.core.Content; |
37 |
|
import info.magnolia.cms.core.NodeData; |
38 |
|
import info.magnolia.imaging.ImageGenerator; |
39 |
|
import info.magnolia.imaging.ParameterProvider; |
40 |
|
import info.magnolia.jcr.util.NodeTypes; |
41 |
|
|
42 |
|
import java.util.Calendar; |
43 |
|
|
44 |
|
import javax.jcr.Property; |
45 |
|
import javax.jcr.RepositoryException; |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
@link@link |
50 |
|
|
51 |
|
@param |
52 |
|
@deprecated@link |
53 |
|
|
54 |
|
@Deprecated |
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 6 |
Complexity Density: 0.5 |
|
55 |
|
public abstract class AbstractContentBasedCachingStrategy<P> implements CachingStrategy<P> { |
56 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
57 |
0 |
@Override... |
58 |
|
public String getCachePath(ImageGenerator<ParameterProvider<P>> generator, ParameterProvider<P> parameterProvider) { |
59 |
0 |
final P param = parameterProvider.getParameter(); |
60 |
0 |
return "/" + generator.getName() + "/" + getWorkspaceName(param) + getPathOf(param); |
61 |
|
} |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
@return |
67 |
|
|
68 |
|
@deprecated@link |
69 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
70 |
0 |
@Deprecated... |
71 |
|
public boolean shouldRegenerate(NodeData cachedBinary, ParameterProvider<P> parameterProvider) { |
72 |
0 |
try { |
73 |
0 |
return shouldRegenerate(cachedBinary.getJCRProperty(), parameterProvider); |
74 |
|
} catch (RepositoryException e) { |
75 |
0 |
throw new IllegalStateException("Unable to get JCR Property from NodeData " + cachedBinary, e); |
76 |
|
} |
77 |
|
} |
78 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
79 |
0 |
@Override... |
80 |
|
public boolean shouldRegenerate(Property cachedBinary, ParameterProvider<P> parameterProvider) throws RepositoryException { |
81 |
|
|
82 |
0 |
final Calendar cacheLastMod = NodeTypes.LastModified.getLastModified(cachedBinary.getParent()); |
83 |
|
|
84 |
|
|
85 |
0 |
final Calendar srcLastMod = getContent(parameterProvider.getParameter()).getMetaData().getModificationDate(); |
86 |
|
|
87 |
|
|
88 |
0 |
if (srcLastMod == null) { |
89 |
|
|
90 |
0 |
return false; |
91 |
0 |
} else if (cacheLastMod == null) { |
92 |
|
|
93 |
0 |
return true; |
94 |
|
} else { |
95 |
0 |
return cacheLastMod.before(srcLastMod); |
96 |
|
} |
97 |
|
} |
98 |
|
|
99 |
|
abstract protected String getWorkspaceName(P param); |
100 |
|
|
101 |
|
abstract protected Content getContent(P param); |
102 |
|
|
103 |
|
abstract protected String getPathOf(P param); |
104 |
|
} |