BaseActionFactory.java
2.07 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.day.cq.wcm.api.WCMException
* com.day.cq.wcm.msm.api.LiveAction
* com.day.cq.wcm.msm.api.LiveActionFactory
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ValueMap
* org.apache.sling.api.wrappers.ValueMapDecorator
*/
package com.day.cq.wcm.msm.commons;
import com.day.cq.wcm.api.WCMException;
import com.day.cq.wcm.msm.api.LiveAction;
import com.day.cq.wcm.msm.api.LiveActionFactory;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.api.wrappers.ValueMapDecorator;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public abstract class BaseActionFactory<ActionType extends LiveAction>
implements LiveActionFactory<ActionType> {
protected abstract ActionType newActionInstance(ValueMap var1) throws WCMException;
public ActionType createAction(Resource resource) throws WCMException {
ValueMap resourceMap = null;
if (resource != null) {
resourceMap = (ValueMap)resource.adaptTo(ValueMap.class);
}
Map<String, Object> result = this.mergeConfigs(this.getFactoryConfig(), (Map<String, Object>)resourceMap);
return this.newActionInstance((ValueMap)new ValueMapDecorator(result));
}
protected Dictionary getFactoryConfig() {
return null;
}
private Map<String, Object> mergeConfigs(Dictionary base, Map<String, Object> overrides) {
HashMap<String, Object> result = new HashMap<String, Object>();
if (base != null) {
Enumeration<K> enumeration = base.keys();
while (enumeration.hasMoreElements()) {
K key = enumeration.nextElement();
result.put(key.toString(), base.get(key));
}
}
if (overrides != null) {
result.putAll(overrides);
}
return result;
}
}