001
014
015 package com.liferay.portal.json.jabsorb.serializer;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019
020 import org.jabsorb.serializer.ProcessedObject;
021 import org.jabsorb.serializer.SerializerState;
022
023 import org.json.JSONException;
024 import org.json.JSONObject;
025
026
029 public class LiferaySerializerState extends SerializerState {
030
031 @Override
032 public ProcessedObject store(Object object) {
033 if (!(object instanceof JSONObject)) {
034 return super.store(object);
035 }
036
037 JSONObject jsonObject = (JSONObject)object;
038
039 if (jsonObject.has("javaClass")) {
040 try {
041 String javaClass = jsonObject.getString("javaClass");
042
043 if (javaClass.contains("com.liferay") &&
044 javaClass.contains("Util")) {
045
046 throw new RuntimeException(
047 "Not instantiating " + javaClass);
048 }
049 }
050 catch (JSONException jsone) {
051 _log.error("Unable to parse object", jsone);
052 }
053 }
054
055 return super.store(object);
056 }
057
058 private static Log _log = LogFactoryUtil.getLog(
059 LiferaySerializerState.class);
060
061 }