AggregationRule.java
1.5 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.sling.api.resource.PersistenceException
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceResolver
*/
package com.adobe.cq.mobile.index.impl.builder;
import com.adobe.cq.mobile.index.impl.builder.AggregationRuleEntry;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
public class AggregationRule {
private String primaryType;
private List<AggregationRuleEntry> ruleEntryList;
public AggregationRule(String primaryType, List<AggregationRuleEntry> ruleEntryList) {
this.primaryType = primaryType;
this.ruleEntryList = ruleEntryList;
}
public void build(Resource resource) throws PersistenceException {
ResourceResolver resolver = resource.getResourceResolver();
Resource aggregateNode = resolver.create(resource, this.primaryType, new HashMap());
int i = 0;
for (AggregationRuleEntry entry : this.ruleEntryList) {
HashMap<String, Object> properties = new HashMap<String, Object>();
properties.put(entry.getName(), entry.getValue());
if (entry.isRelative()) {
properties.put("relativeNode", true);
}
resolver.create(aggregateNode, "include" + i++, properties);
}
}
}