MCMConfiguration.java
4.06 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.felix.scr.annotations.Activate
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Modified
* org.apache.felix.scr.annotations.Properties
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.PropertyUnbounded
* org.apache.felix.scr.annotations.Service
* org.apache.sling.commons.osgi.OsgiUtil
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.day.cq.mcm.impl;
import java.util.Arrays;
import java.util.Map;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Modified;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.PropertyUnbounded;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.commons.osgi.OsgiUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(configurationFactory=1, metatype=1)
@Service(value={MCMConfiguration.class})
@Properties(value={@Property(name="experience.indirection", unbounded=PropertyUnbounded.ARRAY), @Property(name="touchpoint.indirection", unbounded=PropertyUnbounded.ARRAY)})
public class MCMConfiguration
implements Cloneable {
private static final Logger log = LoggerFactory.getLogger(MCMConfiguration.class);
private String[] experienceIndirectionConfig;
private String[] touchpointIndirectionConfig;
@Activate
protected void activate(Map<String, Object> params) {
this.readParams(params);
}
private void readParams(Map<String, Object> params) {
String[] touchpointIndConfig;
Object servicePid = params.get("service.pid");
String[] experienceIndConfig = OsgiUtil.toStringArray((Object)params.get("experience.indirection"));
if (experienceIndConfig != null) {
if (experienceIndConfig.length == 2 && experienceIndConfig[0].length() != 0 && experienceIndConfig[1].length() != 0) {
this.experienceIndirectionConfig = experienceIndConfig;
} else {
experienceIndConfig = null;
log.error("Wrong configuration for {} in {}, need exactly 2 non-empty strings in array!", (Object)"experience.indirection", servicePid);
}
}
if (experienceIndConfig == null) {
this.experienceIndirectionConfig = null;
}
if ((touchpointIndConfig = OsgiUtil.toStringArray((Object)params.get("touchpoint.indirection"))) != null) {
if (touchpointIndConfig.length == 2 && touchpointIndConfig[0].length() != 0 && touchpointIndConfig[1].length() != 0) {
this.touchpointIndirectionConfig = touchpointIndConfig;
} else {
log.error("Wrong configuration for {} in {}, need exactly 2 non-empty strings in array!", (Object)"touchpoint.indirection", servicePid);
}
}
if (touchpointIndConfig == null) {
this.touchpointIndirectionConfig = null;
}
}
@Modified
protected void modified(Map<String, Object> params) {
this.readParams(params);
}
public String[] getExperienceIndirectionConfig() {
return this.experienceIndirectionConfig;
}
public String[] getTouchpointIndirectionConfig() {
return this.touchpointIndirectionConfig;
}
protected Object clone() throws CloneNotSupportedException {
return super.clone();
}
public boolean equals(Object obj) {
if (obj != null && obj instanceof MCMConfiguration) {
MCMConfiguration other = (MCMConfiguration)obj;
return (this.experienceIndirectionConfig == null && other.experienceIndirectionConfig == null || Arrays.equals(this.experienceIndirectionConfig, other.experienceIndirectionConfig)) && (this.touchpointIndirectionConfig == null && other.touchpointIndirectionConfig == null || Arrays.equals(this.touchpointIndirectionConfig, other.touchpointIndirectionConfig));
}
return false;
}
}