001
014
015 package com.liferay.portlet.expando.service.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.json.JSONFactoryUtil;
020 import com.liferay.portal.kernel.json.JSONObject;
021 import com.liferay.portal.kernel.util.StringPool;
022 import com.liferay.portal.kernel.util.Validator;
023 import com.liferay.portal.security.permission.ActionKeys;
024 import com.liferay.portlet.expando.model.ExpandoColumn;
025 import com.liferay.portlet.expando.model.ExpandoValue;
026 import com.liferay.portlet.expando.service.base.ExpandoValueServiceBaseImpl;
027 import com.liferay.portlet.expando.service.permission.ExpandoColumnPermission;
028
029 import java.io.Serializable;
030
031
034 public class ExpandoValueServiceImpl extends ExpandoValueServiceBaseImpl {
035
036 public ExpandoValue addValue(
037 long companyId, String className, String tableName,
038 String columnName, long classPK, Object data)
039 throws PortalException, SystemException {
040
041 ExpandoColumn column = expandoColumnLocalService.getColumn(
042 companyId, className, tableName, columnName);
043
044 ExpandoColumnPermission.check(
045 getPermissionChecker(), column, ActionKeys.UPDATE);
046
047 return expandoValueLocalService.addValue(
048 companyId, className, tableName, columnName, classPK, data);
049 }
050
051 public ExpandoValue addValue(
052 long companyId, String className, String tableName,
053 String columnName, long classPK, String data)
054 throws PortalException, SystemException {
055
056 ExpandoColumn column = expandoColumnLocalService.getColumn(
057 companyId, className, tableName, columnName);
058
059 ExpandoColumnPermission.check(
060 getPermissionChecker(), column, ActionKeys.UPDATE);
061
062 return expandoValueLocalService.addValue(
063 companyId, className, tableName, columnName, classPK, data);
064 }
065
066 public Serializable getData(
067 long companyId, String className, String tableName,
068 String columnName, long classPK)
069 throws PortalException, SystemException {
070
071 ExpandoColumn column = expandoColumnLocalService.getColumn(
072 companyId, className, tableName, columnName);
073
074 if (ExpandoColumnPermission.contains(
075 getPermissionChecker(), column, ActionKeys.VIEW)) {
076
077 return expandoValueLocalService.getData(
078 companyId, className, tableName, columnName, classPK);
079 }
080 else {
081 return null;
082 }
083 }
084
085 public JSONObject getJSONData(
086 long companyId, String className, String tableName,
087 String columnName, long classPK)
088 throws PortalException, SystemException {
089
090 ExpandoColumn column = expandoColumnLocalService.getColumn(
091 companyId, className, tableName, columnName);
092
093 if (ExpandoColumnPermission.contains(
094 getPermissionChecker(), column, ActionKeys.VIEW)) {
095
096 String data = expandoValueLocalService.getData(
097 companyId, className, tableName, columnName, classPK,
098 StringPool.BLANK);
099
100 if (Validator.isNotNull(data)) {
101 return JSONFactoryUtil.createJSONObject(data);
102 }
103 else {
104 return null;
105 }
106 }
107 else {
108 return null;
109 }
110 }
111
112 }