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.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.json.JSONArray;
020    import com.liferay.portal.kernel.json.JSONObject;
021    import com.liferay.portal.kernel.upload.UploadPortletRequest;
022    import com.liferay.portal.kernel.xml.Element;
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    import com.liferay.portlet.dynamicdatamapping.storage.Fields;
028    
029    import java.io.InputStream;
030    
031    import java.util.List;
032    import java.util.Map;
033    
034    import javax.portlet.RenderRequest;
035    import javax.portlet.RenderResponse;
036    
037    import javax.servlet.http.HttpServletRequest;
038    import javax.servlet.http.HttpServletResponse;
039    
040    /**
041     * @author Eduardo Lundgren
042     */
043    public interface DDL {
044    
045            public void addAllReservedEls(
046                    Element rootElement, Map<String, String> tokens,
047                    DDLRecordSet recordSet);
048    
049            public Fields getFields(
050                            UploadPortletRequest uploadPortletRequest, long ddmStructureId)
051                    throws PortalException, SystemException;
052    
053            public Fields getFields(
054                            UploadPortletRequest uploadPortletRequest, long ddmStructureId,
055                            long ddmTemplateId)
056                    throws PortalException, SystemException;
057    
058            public String getRecordFileUploadPath(DDLRecord record);
059    
060            public JSONObject getRecordJSONObject(DDLRecord record) throws Exception;
061    
062            public JSONObject getRecordJSONObject(
063                            DDLRecord record, boolean latestRecordVersion)
064                    throws Exception;
065    
066            public JSONArray getRecordSetJSONArray(DDLRecordSet recordSet)
067                    throws Exception;
068    
069            public JSONArray getRecordsJSONArray(DDLRecordSet recordSet)
070                    throws Exception;
071    
072            public JSONArray getRecordsJSONArray(List<DDLRecord> records)
073                    throws Exception;
074    
075            public JSONArray getRecordsJSONArray(
076                            List<DDLRecord> records, boolean latestRecordVersion)
077                    throws Exception;
078    
079            public String getTemplateContent(
080                            long ddmTemplateId, DDLRecordSet recordSet,
081                            ThemeDisplay themeDisplay, RenderRequest renderRequest,
082                            RenderResponse renderResponse)
083                    throws Exception;
084    
085            public void sendRecordFileUpload(
086                            HttpServletRequest request, HttpServletResponse response,
087                            DDLRecord record, String fieldName)
088                    throws Exception;
089    
090            public void sendRecordFileUpload(
091                            HttpServletRequest request, HttpServletResponse response,
092                            long recordId, String fieldName)
093                    throws Exception;
094    
095            public String storeRecordFieldFile(
096                            DDLRecord record, String fieldName, InputStream inputStream)
097                    throws Exception;
098    
099            public DDLRecord updateRecord(
100                            UploadPortletRequest uploadPortletRequest, long recordId,
101                            long recordSetId, boolean mergeFields)
102                    throws Exception;
103    
104            public DDLRecord updateRecord(
105                            UploadPortletRequest uploadPortletRequest, long recordId,
106                            long recordSetId, boolean mergeFields, boolean checkPermission)
107                    throws Exception;
108    
109            public void uploadRecordFieldFile(
110                            DDLRecord record, String fieldName,
111                            UploadPortletRequest uploadPortletRequest,
112                            ServiceContext serviceContext)
113                    throws Exception;
114    
115            public void uploadRecordFieldFiles(
116                            DDLRecord record, UploadPortletRequest uploadPortletRequest,
117                            ServiceContext serviceContext)
118                    throws Exception;
119    
120    }