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.xml.Element;
020    import com.liferay.portal.service.ServiceContext;
021    import com.liferay.portal.theme.ThemeDisplay;
022    import com.liferay.portlet.dynamicdatalists.model.DDLRecord;
023    import com.liferay.portlet.dynamicdatalists.model.DDLRecordSet;
024    
025    import java.util.List;
026    import java.util.Map;
027    
028    import javax.portlet.PortletPreferences;
029    import javax.portlet.RenderRequest;
030    import javax.portlet.RenderResponse;
031    
032    import javax.servlet.http.HttpServletRequest;
033    import javax.servlet.http.HttpServletResponse;
034    
035    /**
036     * @author Eduardo Lundgren
037     */
038    public interface DDL {
039    
040            public void addAllReservedEls(
041                    Element rootElement, Map<String, String> tokens,
042                    DDLRecordSet recordSet);
043    
044            public JSONObject getRecordJSONObject(DDLRecord record) throws Exception;
045    
046            public JSONObject getRecordJSONObject(
047                            DDLRecord record, boolean latestRecordVersion)
048                    throws Exception;
049    
050            public JSONArray getRecordSetJSONArray(DDLRecordSet recordSet)
051                    throws Exception;
052    
053            public JSONArray getRecordsJSONArray(DDLRecordSet recordSet)
054                    throws Exception;
055    
056            public JSONArray getRecordsJSONArray(List<DDLRecord> records)
057                    throws Exception;
058    
059            public JSONArray getRecordsJSONArray(
060                            List<DDLRecord> records, boolean latestRecordVersion)
061                    throws Exception;
062    
063            public String getTemplateContent(
064                            long ddmTemplateId, DDLRecordSet recordSet,
065                            ThemeDisplay themeDisplay, RenderRequest renderRequest,
066                            RenderResponse renderResponse)
067                    throws Exception;
068    
069            public boolean isEditable(
070                            HttpServletRequest request, String portletId, long groupId)
071                    throws Exception;
072    
073            public boolean isEditable(
074                            PortletPreferences preferences, String portletId, long groupId)
075                    throws Exception;
076    
077            public void sendRecordFileUpload(
078                            HttpServletRequest request, HttpServletResponse response,
079                            DDLRecord record, String fieldName)
080                    throws Exception;
081    
082            public void sendRecordFileUpload(
083                            HttpServletRequest request, HttpServletResponse response,
084                            long recordId, String fieldName)
085                    throws Exception;
086    
087            public DDLRecord updateRecord(
088                            long recordId, long recordSetId, boolean mergeFields,
089                            boolean checkPermission, ServiceContext serviceContext)
090                    throws Exception;
091    
092            public DDLRecord updateRecord(
093                            long recordId, long recordSetId, boolean mergeFields,
094                            ServiceContext serviceContext)
095                    throws Exception;
096    
097            public String uploadRecordFieldFile(
098                            DDLRecord record, String fieldName, ServiceContext serviceContext)
099                    throws Exception;
100    
101    }