GuideTnCElement.java
2.39 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:
* com.adobe.xfa.Element
* org.apache.sling.commons.json.JSONException
* org.apache.sling.commons.json.JSONObject
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemds.guide.addon.dor.elements;
import com.adobe.aemds.guide.addon.dor.elements.DoRElement;
import com.adobe.aemds.guide.addon.dor.elements.DoRTnCElement;
import com.adobe.aemds.guide.addon.dor.elements.GuideElement;
import com.adobe.aemds.guide.addon.dor.elements.GuideElementProperties;
import com.adobe.xfa.Element;
import java.util.Properties;
import java.util.StringTokenizer;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GuideTnCElement
extends GuideElement {
private Logger logger = LoggerFactory.getLogger(GuideTnCElement.class);
public GuideTnCElement(JSONObject jsonObject) {
super(jsonObject);
try {
for (String key : GuideElementProperties.TNC_PROPERTIES) {
this.properties.setProperty(key, jsonObject.getString(key));
}
this.initOtherProperty("items.reviewStatus.name", jsonObject);
this.initOtherProperty("items.reviewDocument.name", jsonObject);
String property = "tncTextContent";
String tncTextContent = this.properties.getProperty(property);
String replacedString = tncTextContent.replaceAll("<[^>]+>", "").replaceAll(" ", " ");
this.properties.put(property, replacedString);
}
catch (JSONException e) {
this.logger.error("Failed to construct", (Throwable)e);
}
}
private void initOtherProperty(String property, JSONObject jsonObject) throws JSONException {
StringTokenizer stringTokenizer = new StringTokenizer(property, ".");
String token = stringTokenizer.nextToken();
JSONObject propertyObject = jsonObject;
while (stringTokenizer.hasMoreTokens()) {
propertyObject = propertyObject.getJSONObject(token);
token = stringTokenizer.nextToken();
}
this.properties.setProperty(property, propertyObject.getString(token));
}
@Override
public DoRElement createDoRElement(Element xfaElement) throws Exception {
return new DoRTnCElement(xfaElement);
}
}