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.delta;
35
36 import info.magnolia.module.InstallContext;
37 import info.magnolia.repository.RepositoryConstants;
38
39 import javax.jcr.Node;
40 import javax.jcr.RepositoryException;
41
42
43
44
45 public class HasPropertyDelegateTask extends CheckNodeDelegateTask {
46
47 public HasPropertyDelegateTask(String taskName, String parentPath, String propertyName, Task ifTrue) {
48 this(taskName, parentPath, propertyName, ifTrue, null);
49 }
50
51 public HasPropertyDelegateTask(String taskName, String parentPath, String propertyName, Task ifTrue, Task ifFalse) {
52 this(taskName, String.format("Execute task [%s] if property '%s' exists or [%s] if not.",
53 ifTrue == null ? DO_NOTHING : ifTrue.getDescription(),
54 parentPath + "/" + propertyName,
55 ifFalse == null ? DO_NOTHING : ifFalse.getDescription()),
56 RepositoryConstants.CONFIG, parentPath, propertyName, ifTrue, ifFalse);
57 }
58
59 public HasPropertyDelegateTask(String taskName, String taskDescription, String workspaceName, String parentPath, String propertyName, Task ifTrue) {
60 this(taskName, taskDescription, workspaceName, parentPath, propertyName, ifTrue, null);
61 }
62
63 public HasPropertyDelegateTask(String taskName, String taskDescription, String workspaceName, String parentPath, String propertyName, Task ifTrue, Task ifFalse) {
64 super(taskName, taskDescription, workspaceName, parentPath, propertyName, ifTrue, ifFalse);
65 }
66
67 @Override
68 protected boolean checkNode(Node node, InstallContext ctx) throws RepositoryException {
69 return node.hasProperty(propertyName);
70 }
71 }