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.module.templatingkit.imaging;
35
36 import info.magnolia.context.MgnlContext;
37
38 import javax.jcr.Property;
39 import javax.jcr.RepositoryException;
40
41 import org.slf4j.Logger;
42 import org.slf4j.LoggerFactory;
43
44
45
46
47
48
49
50
51 public class VariationImpl implements Variation {
52
53 private static Logger log = LoggerFactory.getLogger(VariationImpl.class);
54
55 private String name;
56
57 private String generatorName;
58
59 private VariationRule rule;
60
61 public String getGeneratorName() {
62 return this.generatorName;
63 }
64
65 public void setGeneratorName(String generatorName) {
66 this.generatorName = generatorName;
67 }
68
69
70 @Override
71 public String getName() {
72 return this.name;
73 }
74
75 public void setName(String name) {
76 this.name = name;
77 }
78
79
80 @Override
81 public String createLink(Property binaryNodeData){
82 String path = null;
83 String workspaceName = null;
84 try {
85 path = binaryNodeData.getParent().getPath();
86 workspaceName = binaryNodeData.getSession().getWorkspace().getName();
87 } catch (RepositoryException e) {
88 String propertyPath = null;
89 try {
90 propertyPath = binaryNodeData.getPath()+binaryNodeData.getName();
91 } catch (Exception ee) {
92 log.warn("could not create Link for property :" + path, e);
93 }
94 return propertyPath;
95 }
96 return MgnlContext.getContextPath() + "/.imaging/" + getGeneratorName() + "/" + workspaceName + path + ".jpg";
97 }
98
99
100 @Override
101 public boolean matches(String cssSelector) {
102 if(rule == null){
103 return false;
104 }
105 return rule.matches(cssSelector);
106 }
107
108 public VariationRule getRule() {
109 return this.rule;
110 }
111
112 public void setRule(VariationRule rule) {
113 this.rule = rule;
114 }
115 }