AbstractSiteCatalystService.java
1.58 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.sling.commons.json.JSONArray
* org.apache.sling.commons.json.JSONException
* org.apache.sling.commons.json.JSONObject
*/
package com.day.cq.analytics.sitecatalyst.common;
import com.day.cq.analytics.sitecatalyst.SitecatalystException;
import com.day.cq.analytics.sitecatalyst.impl.util.AnalyticsAPICallsUtils;
import org.apache.sling.commons.json.JSONArray;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
public abstract class AbstractSiteCatalystService {
protected JSONObject toJSONObject(String result) throws SitecatalystException {
try {
JSONObject o = new JSONObject(result);
if (o.has("error")) {
throw new SitecatalystException(o.getString("error"));
}
return o;
}
catch (JSONException e) {
throw new SitecatalystException(e.getMessage(), (Throwable)e);
}
}
protected JSONArray toJSONArray(String result) throws SitecatalystException {
try {
String error = this.getError(result);
if (error != null) {
throw new SitecatalystException(error);
}
return new JSONArray(result);
}
catch (JSONException e) {
throw new SitecatalystException(e.getMessage(), (Throwable)e);
}
}
protected String getError(String result) throws JSONException {
return AnalyticsAPICallsUtils.getErrorMessageFromResponse(result);
}
}