DoRDocumentFragmentElement.java
2.89 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.aemds.guide.addon.dor.DoRThreadLocal
* com.adobe.aemds.guide.addon.dor.DoRUtils
* com.adobe.forms.foundation.util.ContentConverterUtils
* com.adobe.xfa.Element
* com.adobe.xfa.Node
* com.adobe.xfa.content.Content
* com.adobe.xfa.template.Value
* org.apache.commons.lang3.StringUtils
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ValueMap
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemds.guide.addon.dor.elements;
import com.adobe.aemds.guide.addon.dor.DoRThreadLocal;
import com.adobe.aemds.guide.addon.dor.DoRUtils;
import com.adobe.aemds.guide.addon.dor.elements.DoRTextDrawElement;
import com.adobe.forms.foundation.util.ContentConverterUtils;
import com.adobe.xfa.Element;
import com.adobe.xfa.Node;
import com.adobe.xfa.content.Content;
import com.adobe.xfa.template.Value;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DoRDocumentFragmentElement
extends DoRTextDrawElement {
private static Logger logger = LoggerFactory.getLogger(DoRDocumentFragmentElement.class);
public DoRDocumentFragmentElement(Element xfaElement) throws Exception {
super(xfaElement);
}
@Override
public void applyProperties(Properties properties) throws Exception {
String data = "";
if (!properties.containsKey("_value")) {
if (properties.containsKey("assetRef")) {
String assetRef = properties.getProperty("assetRef");
Resource resource = DoRThreadLocal.getResourceResolver().getResource(assetRef);
data = (String)resource.getValueMap().get((Object)"jcr:data");
}
properties.put("_value", data);
}
Value valueNode = (Value)this.xfaElement.resolveNode("#value");
DoRUtils.enableRichText((Value)valueNode);
if (properties.containsKey("_value")) {
String text = properties.getProperty("_value");
text = this.massageText(text);
DoRUtils.setValue((Content)((Content)valueNode.getOneOfChild()), (String)text, (String)"text/html");
properties.remove("_value");
}
super.applyProperties(properties, true);
}
@Override
protected String massageText(String text) {
String result = "";
try {
if (StringUtils.isNotBlank((CharSequence)text)) {
result = ContentConverterUtils.convertToXFAHTML((String)text);
}
}
catch (Exception e) {
logger.error("Unable to convert HTML rich text to XFA compliant rich text for document fragment\n" + e.getMessage(), (Throwable)e);
}
return result;
}
}