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