AbsoluteBindrefResolver.java
1.51 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.commons.lang3.StringUtils
* org.apache.sling.commons.json.JSONException
* org.apache.sling.commons.json.JSONObject
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemds.guide.utils.guideJson;
import com.adobe.aemds.guide.utils.XMLUtils;
import com.adobe.aemds.guide.utils.guideJson.GuideJsonVisitor;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AbsoluteBindrefResolver
implements GuideJsonVisitor {
private static Logger log = LoggerFactory.getLogger(AbsoluteBindrefResolver.class);
private String xsdRootElem = null;
public AbsoluteBindrefResolver(String xsdRootEl) {
this.xsdRootElem = xsdRootEl;
}
public void visitItem(JSONObject obj) {
try {
String relBindRef;
if (XMLUtils.isXsd(obj) && StringUtils.isNotBlank((CharSequence)(relBindRef = XMLUtils.getRelativeXpath(obj.optString("bindRef"), this.xsdRootElem)))) {
obj.put("bindRef", (Object)("/" + this.xsdRootElem + "/" + relBindRef));
}
}
catch (JSONException e) {
log.debug("Failed to modify absolute bindRef of item : " + obj.toString(), (Throwable)e);
}
}
public void preRecurse(JSONObject obj) {
}
public void postRecurse(JSONObject obj) {
}
}