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; |
35 |
|
|
36 |
|
import info.magnolia.imaging.operations.ImageOperationChain; |
37 |
|
import info.magnolia.imaging.operations.load.FromBinaryNode; |
38 |
|
import info.magnolia.imaging.parameters.BinaryJcrNodePathParameterProviderFactory; |
39 |
|
import info.magnolia.jcr.util.PropertyUtil; |
40 |
|
|
41 |
|
import javax.jcr.Node; |
42 |
|
|
43 |
|
import org.apache.commons.lang3.StringUtils; |
44 |
|
|
45 |
|
|
46 |
|
@link |
47 |
|
|
48 |
|
@link@link |
49 |
|
|
50 |
|
|
51 |
|
@link@link |
52 |
|
|
53 |
|
@link |
54 |
|
@link |
55 |
|
|
|
|
| 85% |
Uncovered Elements: 3 (20) |
Complexity: 5 |
Complexity Density: 0.33 |
|
56 |
|
public class DefaultImageGenerator extends ImageOperationChain<ParameterProvider<Node>> { |
57 |
|
|
58 |
|
public static final String GENERATOR_NAME = "default"; |
59 |
|
|
60 |
|
private static final BinaryJcrNodePathParameterProviderFactory parameterProviderFactory = new BinaryJcrNodePathParameterProviderFactory(); |
61 |
|
private static final FromBinaryNode fromBinaryNodeOperation = new FromBinaryNode(); |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
62 |
1 |
private static final OutputFormat defaultOutputFormat = new OutputFormat() {{... |
63 |
1 |
setFormatName("jpg"); |
64 |
|
}}; |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
66 |
2 |
public DefaultImageGenerator() {... |
67 |
2 |
setParameterProviderFactory(parameterProviderFactory); |
68 |
2 |
setOutputFormat(defaultOutputFormat); |
69 |
2 |
addOperation(fromBinaryNodeOperation); |
70 |
|
} |
71 |
|
|
|
|
| 76.9% |
Uncovered Elements: 3 (13) |
Complexity: 3 |
Complexity Density: 0.27 |
|
72 |
2 |
@Override... |
73 |
|
public OutputFormat getOutputFormat(final ParameterProvider<Node> params) { |
74 |
2 |
final Node node = params.getParameter(); |
75 |
2 |
OutputFormat format; |
76 |
2 |
try { |
77 |
2 |
format = getOutputFormat().clone(); |
78 |
|
} catch (CloneNotSupportedException e) { |
79 |
0 |
throw new RuntimeException("Can't clone the output format to produce a dynamic format.", e); |
80 |
|
} |
81 |
2 |
String extension = PropertyUtil.getString(node, "extension", "jpg"); |
82 |
2 |
format.setFormatName(extension); |
83 |
|
|
84 |
2 |
if ("gif".equals(StringUtils.lowerCase(extension))) { |
85 |
0 |
format.setCompressionType("lzw"); |
86 |
|
} else { |
87 |
2 |
format.setCompressionType(null); |
88 |
|
} |
89 |
2 |
return format; |
90 |
|
} |
91 |
|
} |