001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
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.xml.Element;
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    import java.util.Map;
028    
029    import javax.portlet.PortletPreferences;
030    import javax.portlet.RenderRequest;
031    import javax.portlet.RenderResponse;
032    
033    import javax.servlet.http.HttpServletRequest;
034    import javax.servlet.http.HttpServletResponse;
035    
036    /**
037     * @author Eduardo Lundgren
038     */
039    public interface DDL {
040    
041            public void addAllReservedEls(
042                    Element rootElement, Map<String, String> tokens,
043                    DDLRecordSet recordSet);
044    
045            public JSONObject getRecordJSONObject(DDLRecord record) throws Exception;
046    
047            public JSONObject getRecordJSONObject(
048                            DDLRecord record, boolean latestRecordVersion)
049                    throws Exception;
050    
051            public List<DDLRecord> getRecords(Hits hits) throws Exception;
052    
053            public JSONArray getRecordSetJSONArray(DDLRecordSet recordSet)
054                    throws Exception;
055    
056            public JSONArray getRecordsJSONArray(DDLRecordSet recordSet)
057                    throws Exception;
058    
059            public JSONArray getRecordsJSONArray(List<DDLRecord> records)
060                    throws Exception;
061    
062            public JSONArray getRecordsJSONArray(
063                            List<DDLRecord> records, boolean latestRecordVersion)
064                    throws Exception;
065    
066            public String getTemplateContent(
067                            long ddmTemplateId, DDLRecordSet recordSet,
068                            ThemeDisplay themeDisplay, RenderRequest renderRequest,
069                            RenderResponse renderResponse)
070                    throws Exception;
071    
072            public boolean isEditable(
073                            HttpServletRequest request, String portletId, long groupId)
074                    throws Exception;
075    
076            public boolean isEditable(
077                            PortletPreferences preferences, String portletId, long groupId)
078                    throws Exception;
079    
080            public void sendRecordFileUpload(
081                            HttpServletRequest request, HttpServletResponse response,
082                            DDLRecord record, String fieldName, int valueIndex)
083                    throws Exception;
084    
085            public void sendRecordFileUpload(
086                            HttpServletRequest request, HttpServletResponse response,
087                            long recordId, String fieldName, int valueIndex)
088                    throws Exception;
089    
090            public DDLRecord updateRecord(
091                            long recordId, long recordSetId, boolean mergeFields,
092                            boolean checkPermission, ServiceContext serviceContext)
093                    throws Exception;
094    
095            public DDLRecord updateRecord(
096                            long recordId, long recordSetId, boolean mergeFields,
097                            ServiceContext serviceContext)
098                    throws Exception;
099    
100            public void uploadRecordFieldFile(
101                            DDLRecord record, String fieldName, ServiceContext serviceContext)
102                    throws Exception;
103    
104    }