001    /**
002     * Copyright (c) 2000-2012 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.RenderRequest;
029    import javax.portlet.RenderResponse;
030    
031    import javax.servlet.http.HttpServletRequest;
032    import javax.servlet.http.HttpServletResponse;
033    
034    /**
035     * @author Eduardo Lundgren
036     */
037    public interface DDL {
038    
039            public void addAllReservedEls(
040                    Element rootElement, Map<String, String> tokens,
041                    DDLRecordSet recordSet);
042    
043            public JSONObject getRecordJSONObject(DDLRecord record) throws Exception;
044    
045            public JSONObject getRecordJSONObject(
046                            DDLRecord record, boolean latestRecordVersion)
047                    throws Exception;
048    
049            public JSONArray getRecordSetJSONArray(DDLRecordSet recordSet)
050                    throws Exception;
051    
052            public JSONArray getRecordsJSONArray(DDLRecordSet recordSet)
053                    throws Exception;
054    
055            public JSONArray getRecordsJSONArray(List<DDLRecord> records)
056                    throws Exception;
057    
058            public JSONArray getRecordsJSONArray(
059                            List<DDLRecord> records, boolean latestRecordVersion)
060                    throws Exception;
061    
062            public String getTemplateContent(
063                            long ddmTemplateId, DDLRecordSet recordSet,
064                            ThemeDisplay themeDisplay, RenderRequest renderRequest,
065                            RenderResponse renderResponse)
066                    throws Exception;
067    
068            public void sendRecordFileUpload(
069                            HttpServletRequest request, HttpServletResponse response,
070                            DDLRecord record, String fieldName)
071                    throws Exception;
072    
073            public void sendRecordFileUpload(
074                            HttpServletRequest request, HttpServletResponse response,
075                            long recordId, String fieldName)
076                    throws Exception;
077    
078            public DDLRecord updateRecord(
079                            long recordId, long recordSetId, boolean mergeFields,
080                            boolean checkPermission, ServiceContext serviceContext)
081                    throws Exception;
082    
083            public DDLRecord updateRecord(
084                            long recordId, long recordSetId, boolean mergeFields,
085                            ServiceContext serviceContext)
086                    throws Exception;
087    
088            public String uploadRecordFieldFile(
089                            DDLRecord record, String fieldName, ServiceContext serviceContext)
090                    throws Exception;
091    
092    }