FrameworkComponentPostProcessor.java
2.63 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Service
* org.apache.sling.api.SlingHttpServletRequest
* org.apache.sling.api.resource.ModifiableValueMap
* org.apache.sling.api.resource.Resource
* org.apache.sling.servlets.post.Modification
* org.apache.sling.servlets.post.SlingPostProcessor
*/
package com.day.cq.analytics.sitecatalyst.impl;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.ModifiableValueMap;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.servlets.post.Modification;
import org.apache.sling.servlets.post.SlingPostProcessor;
@Component
@Service
public class FrameworkComponentPostProcessor
implements SlingPostProcessor {
private static final String PN_DEFAULTSTORE = "cq:defaultStore";
private static final String RP_DEFAULTSTORE = "./cq:defaultStore";
private static final String RT_CBCONTEXTHUBMAPPINGS = "cq/analytics/components/mappings/cbcontexthubmappings";
public void process(SlingHttpServletRequest request, List<Modification> changes) throws Exception {
if (this.isCBContextHubMappingRequest(request)) {
this.handleCBContextHubMappings(request);
}
}
private boolean isCBContextHubMappingRequest(SlingHttpServletRequest request) {
Resource resource = request.getResource();
String defaultStore = request.getParameter("./cq:defaultStore");
return resource != null && resource.isResourceType("cq/analytics/components/mappings/cbcontexthubmappings") && defaultStore != null;
}
private void handleCBContextHubMappings(SlingHttpServletRequest request) {
String store;
ModifiableValueMap valueMap;
Resource resource = request.getResource();
String defaultStore = request.getParameter("./cq:defaultStore");
if (resource != null && defaultStore != null && (store = (String)(valueMap = (ModifiableValueMap)resource.adaptTo(ModifiableValueMap.class)).get("cq:defaultStore", String.class)) != null && !store.equals(defaultStore)) {
HashSet<String> keysToRemove = new HashSet<String>();
for (String key2 : valueMap.keySet()) {
if (key2.indexOf(":") != -1) continue;
keysToRemove.add(key2);
}
for (String key2 : keysToRemove) {
valueMap.remove((Object)key2);
}
}
}
}