001
014
015 package com.liferay.portlet.dynamicdatamapping.storage;
016
017 import com.liferay.portal.kernel.json.JSONException;
018 import com.liferay.portal.kernel.json.JSONFactoryUtil;
019 import com.liferay.portal.kernel.json.JSONObject;
020 import com.liferay.portal.kernel.log.Log;
021 import com.liferay.portal.kernel.log.LogFactoryUtil;
022 import com.liferay.portal.kernel.util.StringPool;
023 import com.liferay.portal.kernel.util.Validator;
024
025 import java.io.Serializable;
026
027 import java.util.Locale;
028
029
032 public class FileUploadFieldRenderer extends BaseFieldRenderer {
033
034 @Override
035 protected String doRender(Field field, Locale locale) {
036 Serializable fieldValue = field.getValue();
037
038 if (Validator.isNull(fieldValue) ||
039 fieldValue.equals(JSONFactoryUtil.getNullJSON())) {
040
041 return StringPool.BLANK;
042 }
043
044 JSONObject fieldValueJSONObject = null;
045
046 try {
047 fieldValueJSONObject = JSONFactoryUtil.createJSONObject(
048 String.valueOf(fieldValue));
049 }
050 catch (JSONException jsone) {
051 if (_log.isDebugEnabled()) {
052 _log.debug("Unable to parse JSON", jsone);
053 }
054
055 return StringPool.BLANK;
056 }
057
058 return fieldValueJSONObject.getString("name");
059 }
060
061 private static Log _log = LogFactoryUtil.getLog(
062 FileUploadFieldRenderer.class);
063
064 }