001    /**
002     * Copyright (c) 2000-present 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.documentlibrary.util;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
019    import com.liferay.portal.kernel.repository.model.FileEntry;
020    import com.liferay.portal.kernel.repository.model.FileVersion;
021    import com.liferay.portal.kernel.repository.model.Folder;
022    import com.liferay.portal.kernel.search.Hits;
023    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
024    import com.liferay.portal.kernel.util.OrderByComparator;
025    import com.liferay.portal.service.ServiceContext;
026    import com.liferay.portal.theme.ThemeDisplay;
027    import com.liferay.portlet.documentlibrary.model.DLFileEntryType;
028    import com.liferay.portlet.documentlibrary.model.DLFileShortcut;
029    import com.liferay.portlet.documentlibrary.model.DLFileVersion;
030    
031    import java.util.List;
032    import java.util.Map;
033    import java.util.Set;
034    
035    import javax.portlet.PortletRequest;
036    import javax.portlet.PortletURL;
037    import javax.portlet.RenderRequest;
038    import javax.portlet.RenderResponse;
039    
040    import javax.servlet.http.HttpServletRequest;
041    
042    /**
043     * @author Brian Wing Shun Chan
044     * @author Julio Camarero
045     */
046    public class DLUtil {
047    
048            public static void addPortletBreadcrumbEntries(
049                            DLFileShortcut dlFileShortcut, HttpServletRequest request,
050                            RenderResponse renderResponse)
051                    throws Exception {
052    
053                    getDL().addPortletBreadcrumbEntries(
054                            dlFileShortcut, request, renderResponse);
055            }
056    
057            public static void addPortletBreadcrumbEntries(
058                            FileEntry fileEntry, HttpServletRequest request,
059                            RenderResponse renderResponse)
060                    throws Exception {
061    
062                    getDL().addPortletBreadcrumbEntries(fileEntry, request, renderResponse);
063            }
064    
065            public static void addPortletBreadcrumbEntries(
066                            Folder folder, HttpServletRequest request,
067                            LiferayPortletResponse liferayPortletResponse)
068                    throws Exception {
069    
070                    getDL().addPortletBreadcrumbEntries(
071                            folder, request, liferayPortletResponse);
072            }
073    
074            public static void addPortletBreadcrumbEntries(
075                            Folder folder, HttpServletRequest request, PortletURL portletURL)
076                    throws Exception {
077    
078                    getDL().addPortletBreadcrumbEntries(folder, request, portletURL);
079            }
080    
081            public static void addPortletBreadcrumbEntries(
082                            Folder folder, HttpServletRequest request,
083                            RenderResponse renderResponse)
084                    throws Exception {
085    
086                    getDL().addPortletBreadcrumbEntries(folder, request, renderResponse);
087            }
088    
089            public static void addPortletBreadcrumbEntries(
090                            long folderId, HttpServletRequest request,
091                            RenderResponse renderResponse)
092                    throws Exception {
093    
094                    getDL().addPortletBreadcrumbEntries(folderId, request, renderResponse);
095            }
096    
097            public static int compareVersions(String version1, String version2) {
098                    return getDL().compareVersions(version1, version2);
099            }
100    
101            public static String getAbsolutePath(
102                            PortletRequest portletRequest, long folderId)
103                    throws PortalException {
104    
105                    return getDL().getAbsolutePath(portletRequest, folderId);
106            }
107    
108            public static Set<String> getAllMediaGalleryMimeTypes() {
109                    return getDL().getAllMediaGalleryMimeTypes();
110            }
111    
112            public static String getDDMStructureKey(DLFileEntryType dlFileEntryType) {
113                    return getDL().getDDMStructureKey(dlFileEntryType);
114            }
115    
116            public static String getDDMStructureKey(String fileEntryTypeUuid) {
117                    return getDL().getDDMStructureKey(fileEntryTypeUuid);
118            }
119    
120            public static String getDeprecatedDDMStructureKey(
121                    DLFileEntryType dlFileEntryType) {
122    
123                    return getDL().getDeprecatedDDMStructureKey(dlFileEntryType);
124            }
125    
126            public static String getDeprecatedDDMStructureKey(long fileEntryTypeId) {
127                    return getDL().getDeprecatedDDMStructureKey(fileEntryTypeId);
128            }
129    
130            public static String getDividedPath(long id) {
131                    return getDL().getDividedPath(id);
132            }
133    
134            public static DL getDL() {
135                    PortalRuntimePermission.checkGetBeanProperty(DLUtil.class);
136    
137                    return _dl;
138            }
139    
140            public static String getDLFileEntryControlPanelLink(
141                            PortletRequest portletRequest, long fileEntryId)
142                    throws PortalException {
143    
144                    return getDL().getDLFileEntryControlPanelLink(
145                            portletRequest, fileEntryId);
146            }
147    
148            public static String getDLFolderControlPanelLink(
149                            PortletRequest portletRequest, long folderId)
150                    throws PortalException {
151    
152                    return getDL().getDLFolderControlPanelLink(portletRequest, folderId);
153            }
154    
155            public static String getDownloadURL(
156                    FileEntry fileEntry, FileVersion fileVersion, ThemeDisplay themeDisplay,
157                    String queryString) {
158    
159                    return getDL().getDownloadURL(
160                            fileEntry, fileVersion, themeDisplay, queryString);
161            }
162    
163            public static String getDownloadURL(
164                    FileEntry fileEntry, FileVersion fileVersion, ThemeDisplay themeDisplay,
165                    String queryString, boolean appendVersion, boolean absoluteURL) {
166    
167                    return getDL().getDownloadURL(
168                            fileEntry, fileVersion, themeDisplay, queryString, appendVersion,
169                            absoluteURL);
170            }
171    
172            public static Map<String, String> getEmailDefinitionTerms(
173                    RenderRequest request, String emailFromAddress, String emailFromName) {
174    
175                    return getDL().getEmailDefinitionTerms(
176                            request, emailFromAddress, emailFromName);
177            }
178    
179            public static Map<String, String> getEmailFromDefinitionTerms(
180                    RenderRequest request, String emailFromAddress, String emailFromName) {
181    
182                    return getDL().getEmailFromDefinitionTerms(
183                            request, emailFromAddress, emailFromName);
184            }
185    
186            public static List<Object> getEntries(Hits hits) {
187                    return getDL().getEntries(hits);
188            }
189    
190            public static List<FileEntry> getFileEntries(Hits hits) {
191                    return getDL().getFileEntries(hits);
192            }
193    
194            public static String getFileEntryImage(
195                    FileEntry fileEntry, ThemeDisplay themeDisplay) {
196    
197                    return getDL().getFileEntryImage(fileEntry, themeDisplay);
198            }
199    
200            public static Set<Long> getFileEntryTypeSubscriptionClassPKs(long userId) {
201                    return getDL().getFileEntryTypeSubscriptionClassPKs(userId);
202            }
203    
204            public static String getFileIcon(String extension) {
205                    return getDL().getFileIcon(extension);
206            }
207    
208            public static String getFileIconCssClass(String extension) {
209                    return getDL().getFileIconCssClass(extension);
210            }
211    
212            public static String getFileName(
213                    long groupId, long folderId, String tempFileName) {
214    
215                    return getDL().getFileName(groupId, folderId, tempFileName);
216            }
217    
218            public static String getGenericName(String extension) {
219                    return getDL().getGenericName(extension);
220            }
221    
222            public static String getImagePreviewURL(
223                            FileEntry fileEntry, FileVersion fileVersion,
224                            ThemeDisplay themeDisplay)
225                    throws Exception {
226    
227                    return getDL().getImagePreviewURL(fileEntry, fileVersion, themeDisplay);
228            }
229    
230            public static String getImagePreviewURL(
231                            FileEntry fileEntry, ThemeDisplay themeDisplay)
232                    throws Exception {
233    
234                    return getDL().getImagePreviewURL(fileEntry, themeDisplay);
235            }
236    
237            public static String getPreviewURL(
238                    FileEntry fileEntry, FileVersion fileVersion, ThemeDisplay themeDisplay,
239                    String queryString) {
240    
241                    return getDL().getPreviewURL(
242                            fileEntry, fileVersion, themeDisplay, queryString);
243            }
244    
245            /**
246             * @deprecated As of 6.2.0, replaced by {@link #getPreviewURL(FileEntry,
247             *             FileVersion, ThemeDisplay, String, boolean, boolean)}
248             */
249            @Deprecated
250            public static String getPreviewURL(
251                    FileEntry fileEntry, FileVersion fileVersion, ThemeDisplay themeDisplay,
252                    String queryString, boolean appendToken) {
253    
254                    return getDL().getPreviewURL(
255                            fileEntry, fileVersion, themeDisplay, queryString, appendToken);
256            }
257    
258            public static String getPreviewURL(
259                    FileEntry fileEntry, FileVersion fileVersion, ThemeDisplay themeDisplay,
260                    String queryString, boolean appendVersion, boolean absoluteURL) {
261    
262                    return getDL().getPreviewURL(
263                            fileEntry, fileVersion, themeDisplay, queryString, appendVersion,
264                            absoluteURL);
265            }
266    
267            public static <T> OrderByComparator<T> getRepositoryModelOrderByComparator(
268                    String orderByCol, String orderByType) {
269    
270                    return getDL().getRepositoryModelOrderByComparator(
271                            orderByCol, orderByType);
272            }
273    
274            public static String getSanitizedFileName(String title, String extension) {
275                    return getDL().getSanitizedFileName(title, extension);
276            }
277    
278            public static String getTempFileId(long id, String version) {
279                    return getDL().getTempFileId(id, version);
280            }
281    
282            public static String getTempFileId(
283                    long id, String version, String languageId) {
284    
285                    return getDL().getTempFileId(id, version, languageId);
286            }
287    
288            public static String getThumbnailSrc(
289                            FileEntry fileEntry, DLFileShortcut dlFileShortcut,
290                            ThemeDisplay themeDisplay)
291                    throws Exception {
292    
293                    return getDL().getThumbnailSrc(fileEntry, dlFileShortcut, themeDisplay);
294            }
295    
296            public static String getThumbnailSrc(
297                            FileEntry fileEntry, FileVersion fileVersion,
298                            DLFileShortcut dlFileShortcut, ThemeDisplay themeDisplay)
299                    throws Exception {
300    
301                    return getDL().getThumbnailSrc(
302                            fileEntry, fileVersion, dlFileShortcut, themeDisplay);
303            }
304    
305            public static String getThumbnailStyle() throws Exception {
306                    return getDL().getThumbnailStyle();
307            }
308    
309            public static String getThumbnailStyle(boolean max, int margin)
310                    throws Exception {
311    
312                    return getDL().getThumbnailStyle(max, margin);
313            }
314    
315            public static String getTitleWithExtension(FileEntry fileEntry) {
316                    return getDL().getTitleWithExtension(fileEntry);
317            }
318    
319            public static String getTitleWithExtension(String title, String extension) {
320                    return getDL().getTitleWithExtension(title, extension);
321            }
322    
323            public static String getWebDavURL(
324                            ThemeDisplay themeDisplay, Folder folder, FileEntry fileEntry)
325                    throws PortalException {
326    
327                    return getDL().getWebDavURL(themeDisplay, folder, fileEntry);
328            }
329    
330            public static String getWebDavURL(
331                            ThemeDisplay themeDisplay, Folder folder, FileEntry fileEntry,
332                            boolean manualCheckInRequired)
333                    throws PortalException {
334    
335                    return getDL().getWebDavURL(
336                            themeDisplay, folder, fileEntry, manualCheckInRequired);
337            }
338    
339            public static String getWebDavURL(
340                            ThemeDisplay themeDisplay, Folder folder, FileEntry fileEntry,
341                            boolean manualCheckInRequired, boolean officeExtensionRequired)
342                    throws PortalException {
343    
344                    return getDL().getWebDavURL(
345                            themeDisplay, folder, fileEntry, manualCheckInRequired,
346                            officeExtensionRequired);
347            }
348    
349            public static boolean hasWorkflowDefinitionLink(
350                            long companyId, long groupId, long folderId, long fileEntryTypeId)
351                    throws Exception {
352    
353                    return getDL().hasWorkflowDefinitionLink(
354                            companyId, groupId, folderId, fileEntryTypeId);
355            }
356    
357            public static boolean isAutoGeneratedDLFileEntryTypeDDMStructureKey(
358                    String ddmStructureKey) {
359    
360                    return getDL().isAutoGeneratedDLFileEntryTypeDDMStructureKey(
361                            ddmStructureKey);
362            }
363    
364            public static boolean isOfficeExtension(String extension) {
365                    return getDL().isOfficeExtension(extension);
366            }
367    
368            public static boolean isSubscribedToFileEntryType(
369                    long companyId, long groupId, long userId, long fileEntryTypeId) {
370    
371                    return getDL().isSubscribedToFileEntryType(
372                            companyId, groupId, userId, fileEntryTypeId);
373            }
374    
375            public static boolean isSubscribedToFolder(
376                            long companyId, long groupId, long userId, long folderId)
377                    throws PortalException {
378    
379                    return getDL().isSubscribedToFolder(
380                            companyId, groupId, userId, folderId);
381            }
382    
383            public static boolean isSubscribedToFolder(
384                            long companyId, long groupId, long userId, long folderId,
385                            boolean recursive)
386                    throws PortalException {
387    
388                    return getDL().isSubscribedToFolder(
389                            companyId, groupId, userId, folderId, recursive);
390            }
391    
392            public static boolean isValidVersion(String version) {
393                    return getDL().isValidVersion(version);
394            }
395    
396            public static void startWorkflowInstance(
397                            long userId, DLFileVersion dlFileVersion, String syncEventType,
398                            ServiceContext serviceContext)
399                    throws PortalException {
400    
401                    getDL().startWorkflowInstance(
402                            userId, dlFileVersion, syncEventType, serviceContext);
403            }
404    
405            public void setDL(DL dl) {
406                    PortalRuntimePermission.checkSetBeanProperty(getClass());
407    
408                    _dl = dl;
409            }
410    
411            private static DL _dl;
412    
413    }