InplaceEditingConfig.java
2.78 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.Node
* javax.jcr.NodeIterator
* javax.jcr.RepositoryException
* org.apache.sling.jcr.resource.JcrPropertyMap
*/
package com.day.cq.wcm.api.components;
import com.day.cq.wcm.api.components.ChildEditor;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
import org.apache.sling.jcr.resource.JcrPropertyMap;
public class InplaceEditingConfig {
public static final String PN_ACTIVE = "active";
public static final String PN_EDITOR_TYPE = "editorType";
public static final String PN_CONFIG_PATH = "configPath";
public static final String NN_CONFIG_DEFAULT = "/config";
static final String NN_CHILD_EDITORS = "cq:childEditors";
private final boolean isActive;
private final String editorType;
private final String configPath;
private Map<String, ChildEditor> childEditors;
public InplaceEditingConfig(Node configNode) throws RepositoryException {
JcrPropertyMap configProps = new JcrPropertyMap(configNode);
this.editorType = (String)configProps.get("editorType", null);
this.isActive = this.editorType != null && (Boolean)configProps.get("active", (Object)false) != false;
String configPath = (String)configProps.get("configPath", (Object)(configProps.getPath() + "/config"));
if (!configPath.startsWith("/")) {
String basePath = configProps.getPath();
configPath = basePath + "/" + configPath;
}
this.configPath = configPath;
LinkedHashMap<String, ChildEditor> myChildEditors = null;
if (configNode.hasNode("cq:childEditors")) {
NodeIterator iter = configNode.getNode("cq:childEditors").getNodes();
while (iter.hasNext()) {
if (myChildEditors == null) {
myChildEditors = new LinkedHashMap<String, ChildEditor>();
}
ChildEditor ce = new ChildEditor(iter.nextNode());
myChildEditors.put(ce.getId(), ce);
}
}
if (myChildEditors != null) {
this.childEditors = myChildEditors;
}
}
public InplaceEditingConfig(InplaceEditingConfig config) {
this.isActive = config.isActive();
this.editorType = config.getEditorType();
this.configPath = config.getConfigPath();
this.childEditors = config.getChildEditors();
}
public boolean isActive() {
return this.isActive;
}
public String getEditorType() {
return this.editorType;
}
public String getConfigPath() {
return this.configPath;
}
public Map<String, ChildEditor> getChildEditors() {
return this.childEditors;
}
}