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.portal.portletfilerepository;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.repository.model.FileEntry;
020    import com.liferay.portal.kernel.repository.model.Folder;
021    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
022    import com.liferay.portal.kernel.util.ObjectValuePair;
023    import com.liferay.portal.kernel.util.OrderByComparator;
024    import com.liferay.portal.service.ServiceContext;
025    
026    import java.io.File;
027    import java.io.InputStream;
028    
029    import java.util.List;
030    
031    /**
032     * @author Eudaldo Alonso
033     */
034    public class PortletFileRepositoryUtil {
035    
036            public static void addPortletFileEntries(
037                            long groupId, long userId, String portletId, long folderId,
038                            List<ObjectValuePair<String, InputStream>> inputStreamOVPs)
039                    throws PortalException, SystemException {
040    
041                    getPortletFileRepository().addPortletFileEntries(
042                            groupId, userId, portletId, folderId, inputStreamOVPs);
043            }
044    
045            public static FileEntry addPortletFileEntry(
046                            long groupId, long userId, String portletId, long folderId,
047                            File file, String fileName)
048                    throws PortalException, SystemException {
049    
050                    return getPortletFileRepository().addPortletFileEntry(
051                            groupId, userId, portletId, folderId, file, fileName);
052            }
053    
054            public static FileEntry addPortletFileEntry(
055                            long groupId, long userId, String portletId, long folderId,
056                            InputStream inputStream, String fileName)
057                    throws PortalException, SystemException {
058    
059                    return getPortletFileRepository().addPortletFileEntry(
060                            groupId, userId, portletId, folderId, inputStream, fileName);
061            }
062    
063            public static void deleteFolder(long folderId)
064                    throws PortalException, SystemException {
065    
066                    getPortletFileRepository().deleteFolder(folderId);
067            }
068    
069            public static void deletePortletFileEntries(long groupId, long folderId)
070                    throws PortalException, SystemException {
071    
072                    getPortletFileRepository().deletePortletFileEntries(groupId, folderId);
073            }
074    
075            public static void deletePortletFileEntries(
076                            long groupId, long folderId, int status)
077                    throws PortalException, SystemException {
078    
079                    getPortletFileRepository().deletePortletFileEntries(
080                            groupId, folderId, status);
081            }
082    
083            public static void deletePortletFileEntry(long fileEntryId)
084                    throws PortalException, SystemException {
085    
086                    getPortletFileRepository().deletePortletFileEntry(fileEntryId);
087            }
088    
089            public static void deletePortletFileEntry(
090                            long groupId, long folderId, String fileName)
091                    throws PortalException, SystemException {
092    
093                    getPortletFileRepository().deletePortletFileEntry(
094                            groupId, folderId, fileName);
095            }
096    
097            public static List<FileEntry> getPortletFileEntries(
098                            long groupId, long folderId)
099                    throws SystemException {
100    
101                    return getPortletFileRepository().getPortletFileEntries(
102                            groupId, folderId);
103            }
104    
105            public static List<FileEntry> getPortletFileEntries(
106                            long groupId, long folderId, int status)
107                    throws SystemException {
108    
109                    return getPortletFileRepository().getPortletFileEntries(
110                            groupId, folderId, status);
111            }
112    
113            public static List<FileEntry> getPortletFileEntries(
114                            long groupId, long folderId, int status, int start, int end,
115                            OrderByComparator obc)
116                    throws SystemException {
117    
118                    return getPortletFileRepository().getPortletFileEntries(
119                            groupId, folderId, status, start, end, obc);
120            }
121    
122            public static int getPortletFileEntriesCount(long groupId, long folderId)
123                    throws SystemException {
124    
125                    return getPortletFileRepository().getPortletFileEntriesCount(
126                            groupId, folderId);
127            }
128    
129            public static int getPortletFileEntriesCount(
130                            long groupId, long folderId, int status)
131                    throws SystemException {
132    
133                    return getPortletFileRepository().getPortletFileEntriesCount(
134                            groupId, folderId, status);
135            }
136    
137            public static FileEntry getPortletFileEntry(long fileEntryId)
138                    throws PortalException, SystemException {
139    
140                    return getPortletFileRepository().getPortletFileEntry(fileEntryId);
141            }
142    
143            public static FileEntry getPortletFileEntry(
144                            long groupId, long folderId, String fileName)
145                    throws PortalException, SystemException {
146    
147                    return getPortletFileRepository().getPortletFileEntry(
148                            groupId, folderId, fileName);
149            }
150    
151            public static PortletFileRepository getPortletFileRepository() {
152                    PortalRuntimePermission.checkGetBeanProperty(
153                            PortletFileRepositoryUtil.class);
154    
155                    return _portletFileRepository;
156            }
157    
158            public static Folder getPortletFolder(long folderId)
159                    throws PortalException, SystemException {
160    
161                    return getPortletFileRepository().getPortletFolder(folderId);
162            }
163    
164            public static Folder getPortletFolder(
165                            long userId, long repositoryId, long parentFolderId,
166                            String folderName, ServiceContext serviceContext)
167                    throws PortalException, SystemException {
168    
169                    return getPortletFileRepository().getPortletFolder(
170                            userId, repositoryId, parentFolderId, folderName, serviceContext);
171            }
172    
173            public static long getPortletRepository(
174                            long groupId, String portletId, ServiceContext serviceContext)
175                    throws PortalException, SystemException {
176    
177                    return getPortletFileRepository().getPortletRepository(
178                            groupId, portletId, serviceContext);
179            }
180    
181            public static void movePortletFileEntryToTrash(
182                            long userId, long fileEntryId)
183                    throws PortalException, SystemException {
184    
185                    getPortletFileRepository().movePortletFileEntryToTrash(
186                            userId, fileEntryId);
187            }
188    
189            public static void movePortletFileEntryToTrash(
190                            long groupId, long userId, long folderId, String fileName)
191                    throws PortalException, SystemException {
192    
193                    getPortletFileRepository().movePortletFileEntryToTrash(
194                            groupId, userId, folderId, fileName);
195            }
196    
197            public static void restorePortletFileEntryFromTrash(
198                            long userId, long fileEntryId)
199                    throws PortalException, SystemException {
200    
201                    getPortletFileRepository().restorePortletFileEntryFromTrash(
202                            userId, fileEntryId);
203            }
204    
205            public static void restorePortletFileEntryFromTrash(
206                            long groupId, long userId, long folderId, String fileName)
207                    throws PortalException, SystemException {
208    
209                    getPortletFileRepository().restorePortletFileEntryFromTrash(
210                            groupId, userId, folderId, fileName);
211            }
212    
213            public void setPortletFileRepository(
214                    PortletFileRepository portletFileRepository) {
215    
216                    PortalRuntimePermission.checkSetBeanProperty(getClass());
217    
218                    _portletFileRepository = portletFileRepository;
219            }
220    
221            private static PortletFileRepository _portletFileRepository;
222    
223    }