001
014
015 package com.liferay.portlet.dynamicdatalists.util;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.json.JSONArray;
020 import com.liferay.portal.kernel.json.JSONObject;
021 import com.liferay.portal.kernel.search.Hits;
022 import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
023 import com.liferay.portal.service.ServiceContext;
024 import com.liferay.portal.theme.ThemeDisplay;
025 import com.liferay.portlet.dynamicdatalists.model.DDLRecord;
026 import com.liferay.portlet.dynamicdatalists.model.DDLRecordSet;
027
028 import java.util.List;
029
030 import javax.portlet.PortletPreferences;
031 import javax.portlet.RenderRequest;
032 import javax.portlet.RenderResponse;
033
034 import javax.servlet.http.HttpServletRequest;
035 import javax.servlet.jsp.PageContext;
036
037
041 @ProviderType
042 public class DDLUtil {
043
044 public static DDL getDDL() {
045 PortalRuntimePermission.checkGetBeanProperty(DDLUtil.class);
046
047 return _ddl;
048 }
049
050 public static JSONObject getRecordJSONObject(DDLRecord record)
051 throws Exception {
052
053 return getDDL().getRecordJSONObject(record);
054 }
055
056 public static JSONObject getRecordJSONObject(
057 DDLRecord record, boolean latestRecordVersion)
058 throws Exception {
059
060 return getDDL().getRecordJSONObject(record, latestRecordVersion);
061 }
062
063 public static List<DDLRecord> getRecords(Hits hits) throws Exception {
064 return getDDL().getRecords(hits);
065 }
066
067 public static JSONArray getRecordSetJSONArray(DDLRecordSet recordSet)
068 throws Exception {
069
070 return getDDL().getRecordSetJSONArray(recordSet);
071 }
072
073 public static JSONArray getRecordsJSONArray(List<DDLRecord> records)
074 throws Exception {
075
076 return getDDL().getRecordsJSONArray(records);
077 }
078
079 public static JSONArray getRecordsJSONArray(
080 List<DDLRecord> records, boolean latestRecordVersion)
081 throws Exception {
082
083 return getDDL().getRecordsJSONArray(records, latestRecordVersion);
084 }
085
086 public static String getTemplateContent(
087 long ddmTemplateId, DDLRecordSet recordSet,
088 ThemeDisplay themeDisplay, RenderRequest renderRequest,
089 RenderResponse renderResponse)
090 throws Exception {
091
092 return getDDL().getTemplateContent(
093 ddmTemplateId, recordSet, themeDisplay, renderRequest,
094 renderResponse);
095 }
096
097
102 public static String getTemplateContent(
103 PageContext pageContext, long ddmTemplateId, DDLRecordSet recordSet,
104 ThemeDisplay themeDisplay, RenderRequest renderRequest,
105 RenderResponse renderResponse)
106 throws Exception {
107
108 return getDDL().getTemplateContent(
109 pageContext, ddmTemplateId, recordSet, themeDisplay, renderRequest,
110 renderResponse);
111 }
112
113
116 @Deprecated
117 public static boolean isEditable(
118 HttpServletRequest request, String portletId, long groupId)
119 throws Exception {
120
121 return getDDL().isEditable(request, portletId, groupId);
122 }
123
124
127 @Deprecated
128 public static boolean isEditable(
129 PortletPreferences preferences, String portletId, long groupId)
130 throws Exception {
131
132 return getDDL().isEditable(preferences, portletId, groupId);
133 }
134
135 public static DDLRecord updateRecord(
136 long recordId, long recordSetId, boolean mergeFields,
137 boolean checkPermission, ServiceContext serviceContext)
138 throws Exception {
139
140 return getDDL().updateRecord(
141 recordId, recordSetId, mergeFields, checkPermission,
142 serviceContext);
143 }
144
145 public static DDLRecord updateRecord(
146 long recordId, long recordSetId, boolean mergeFields,
147 ServiceContext serviceContext)
148 throws Exception {
149
150 return getDDL().updateRecord(
151 recordId, recordSetId, mergeFields, serviceContext);
152 }
153
154 public void setDDL(DDL ddl) {
155 PortalRuntimePermission.checkSetBeanProperty(getClass());
156
157 _ddl = ddl;
158 }
159
160 private static DDL _ddl;
161
162 }