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.setup.for3_5;
35
36 import info.magnolia.cms.beans.config.ContentRepository;
37 import info.magnolia.cms.core.Content;
38 import info.magnolia.module.InstallContext;
39 import info.magnolia.module.delta.AllChildrenNodesOperation;
40 import info.magnolia.module.delta.TaskExecutionException;
41 import org.apache.commons.lang.StringUtils;
42
43 import javax.jcr.RepositoryException;
44 import java.util.Iterator;
45 import java.util.Set;
46 import java.util.TreeSet;
47
48
49
50
51
52
53 public class IPConfigRulesUpdate extends AllChildrenNodesOperation {
54
55 public IPConfigRulesUpdate() {
56 super("IPConfig rules changed", "Updates the existing ip access rules to match the new configuration structure.",
57 ContentRepository.CONFIG, "/server/IPConfig");
58 }
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 protected void operateOnChildNode(Content node, InstallContext ctx) throws RepositoryException, TaskExecutionException {
74 if (node.hasContent("Access")) {
75 final Content accessNode = node.getContent("Access");
76 final Set methods = new TreeSet(String.CASE_INSENSITIVE_ORDER);
77 final Iterator it = accessNode.getChildren().iterator();
78 while (it.hasNext()) {
79 final Content methodNode = (Content) it.next();
80 if (methodNode.hasNodeData("Method")) {
81 final String method = methodNode.getNodeData("Method").getString();
82 methods.add(method.toUpperCase());
83 }
84 }
85 final String methodsStr = StringUtils.join(methods, ',');
86 node.createNodeData("methods", methodsStr);
87 accessNode.delete();
88 }
89 }
90
91 }