001
014
015 package com.liferay.portlet.dynamicdatalists.util;
016
017 import com.liferay.portal.kernel.json.JSONArray;
018 import com.liferay.portal.kernel.json.JSONObject;
019 import com.liferay.portal.kernel.search.Hits;
020 import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
021 import com.liferay.portal.service.ServiceContext;
022 import com.liferay.portal.theme.ThemeDisplay;
023 import com.liferay.portlet.dynamicdatalists.model.DDLRecord;
024 import com.liferay.portlet.dynamicdatalists.model.DDLRecordSet;
025
026 import java.util.List;
027
028 import javax.portlet.PortletPreferences;
029 import javax.portlet.RenderRequest;
030 import javax.portlet.RenderResponse;
031
032 import javax.servlet.http.HttpServletRequest;
033
034
038 public class DDLUtil {
039
040 public static DDL getDDL() {
041 PortalRuntimePermission.checkGetBeanProperty(DDLUtil.class);
042
043 return _ddl;
044 }
045
046 public static JSONObject getRecordJSONObject(DDLRecord record)
047 throws Exception {
048
049 return getDDL().getRecordJSONObject(record);
050 }
051
052 public static JSONObject getRecordJSONObject(
053 DDLRecord record, boolean latestRecordVersion)
054 throws Exception {
055
056 return getDDL().getRecordJSONObject(record, latestRecordVersion);
057 }
058
059 public static List<DDLRecord> getRecords(Hits hits) throws Exception {
060 return getDDL().getRecords(hits);
061 }
062
063 public static JSONArray getRecordSetJSONArray(DDLRecordSet recordSet)
064 throws Exception {
065
066 return getDDL().getRecordSetJSONArray(recordSet);
067 }
068
069 public static JSONArray getRecordsJSONArray(List<DDLRecord> records)
070 throws Exception {
071
072 return getDDL().getRecordsJSONArray(records);
073 }
074
075 public static JSONArray getRecordsJSONArray(
076 List<DDLRecord> records, boolean latestRecordVersion)
077 throws Exception {
078
079 return getDDL().getRecordsJSONArray(records, latestRecordVersion);
080 }
081
082 public static String getTemplateContent(
083 long ddmTemplateId, DDLRecordSet recordSet,
084 ThemeDisplay themeDisplay, RenderRequest renderRequest,
085 RenderResponse renderResponse)
086 throws Exception {
087
088 return getDDL().getTemplateContent(
089 ddmTemplateId, recordSet, themeDisplay, renderRequest,
090 renderResponse);
091 }
092
093 public static boolean isEditable(
094 HttpServletRequest request, String portletId, long groupId)
095 throws Exception {
096
097 return getDDL().isEditable(request, portletId, groupId);
098 }
099
100 public static boolean isEditable(
101 PortletPreferences preferences, String portletId, long groupId)
102 throws Exception {
103
104 return getDDL().isEditable(preferences, portletId, groupId);
105 }
106
107 public static DDLRecord updateRecord(
108 long recordId, long recordSetId, boolean mergeFields,
109 boolean checkPermission, ServiceContext serviceContext)
110 throws Exception {
111
112 return getDDL().updateRecord(
113 recordId, recordSetId, mergeFields, checkPermission,
114 serviceContext);
115 }
116
117 public static DDLRecord updateRecord(
118 long recordId, long recordSetId, boolean mergeFields,
119 ServiceContext serviceContext)
120 throws Exception {
121
122 return getDDL().updateRecord(
123 recordId, recordSetId, mergeFields, serviceContext);
124 }
125
126 public void setDDL(DDL ddl) {
127 PortalRuntimePermission.checkSetBeanProperty(getClass());
128
129 _ddl = ddl;
130 }
131
132 private static DDL _ddl;
133
134 }