001
014
015 package com.liferay.portal.kernel.editor.configuration;
016
017 import com.liferay.portal.kernel.json.JSONArray;
018 import com.liferay.portal.kernel.json.JSONException;
019 import com.liferay.portal.kernel.json.JSONFactoryUtil;
020 import com.liferay.portal.kernel.json.JSONObject;
021 import com.liferay.portal.kernel.log.Log;
022 import com.liferay.portal.kernel.log.LogFactoryUtil;
023
024
027 public abstract class BaseEditorConfigContributor
028 implements EditorConfigContributor {
029
030 protected JSONArray toJSONArray(String json) {
031 try {
032 return JSONFactoryUtil.createJSONArray(json);
033 }
034 catch (JSONException jsone) {
035 _log.error("Unable to create a JSON array from: " + json, jsone);
036 }
037
038 return JSONFactoryUtil.createJSONArray();
039 }
040
041 protected JSONObject toJSONObject(String json) {
042 try {
043 return JSONFactoryUtil.createJSONObject(json);
044 }
045 catch (JSONException jsone) {
046 _log.error("Unable to create a JSON object from: " + json, jsone);
047 }
048
049 return JSONFactoryUtil.createJSONObject();
050 }
051
052 private static final Log _log = LogFactoryUtil.getLog(
053 BaseEditorConfigContributor.class);
054
055 }