001    /**
002     * Copyright (c) 2000-2013 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.trash.util;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.search.Hits;
020    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
021    import com.liferay.portal.kernel.util.OrderByComparator;
022    import com.liferay.portal.model.Group;
023    import com.liferay.portal.theme.ThemeDisplay;
024    import com.liferay.portlet.trash.model.TrashEntry;
025    
026    import java.util.Date;
027    import java.util.List;
028    
029    import javax.portlet.PortletURL;
030    
031    import javax.servlet.http.HttpServletRequest;
032    
033    /**
034     * @author Julio Camarero
035     */
036    public class TrashUtil {
037    
038            public static void addBaseModelBreadcrumbEntries(
039                            HttpServletRequest request, String className, long classPK,
040                            PortletURL containerModelURL)
041                    throws PortalException, SystemException {
042    
043                    getTrash().addBaseModelBreadcrumbEntries(
044                            request, className, classPK, containerModelURL);
045            }
046    
047            public static void addContainerModelBreadcrumbEntries(
048                            HttpServletRequest request, String className, long classPK,
049                            PortletURL containerModelURL)
050                    throws PortalException, SystemException {
051    
052                    getTrash().addContainerModelBreadcrumbEntries(
053                            request, className, classPK, containerModelURL);
054            }
055    
056            public static void deleteEntriesAttachments(
057                            long companyId, long repositoryId, Date date,
058                            String[] attachmentFileNames)
059                    throws PortalException, SystemException {
060    
061                    getTrash().deleteEntriesAttachments(
062                            companyId, repositoryId, date, attachmentFileNames);
063            }
064    
065            public static List<TrashEntry> getEntries(Hits hits)
066                    throws PortalException, SystemException {
067    
068                    return getTrash().getEntries(hits);
069            }
070    
071            public static OrderByComparator getEntryOrderByComparator(
072                    String orderByCol, String orderByType) {
073    
074                    return getTrash().getEntryOrderByComparator(orderByCol, orderByType);
075            }
076    
077            public static int getMaxAge(Group group)
078                    throws PortalException, SystemException {
079    
080                    return getTrash().getMaxAge(group);
081            }
082    
083            public static String getNewName(String oldName, String token) {
084                    return getTrash().getNewName(oldName, token);
085            }
086    
087            public static String getNewName(
088                            ThemeDisplay themeDisplay, String className, long classPK,
089                            String oldName)
090                    throws PortalException, SystemException {
091    
092                    return getTrash().getNewName(themeDisplay, className, classPK, oldName);
093            }
094    
095            public static String getOriginalTitle(String title) {
096                    return getTrash().getOriginalTitle(title);
097            }
098    
099            public static Trash getTrash() {
100                    PortalRuntimePermission.checkGetBeanProperty(TrashUtil.class);
101    
102                    return _trash;
103            }
104    
105            public static String getTrashTime(String title, String separator) {
106                    return getTrash().getTrashTime(title, separator);
107            }
108    
109            public static String getTrashTitle(long trashEntryId) {
110                    return getTrash().getTrashTitle(trashEntryId);
111            }
112    
113            public static PortletURL getViewContentURL(
114                            HttpServletRequest request, String className, long classPK)
115                    throws PortalException, SystemException {
116    
117                    return getTrash().getViewContentURL(request, className, classPK);
118            }
119    
120            public static boolean isInTrash(String className, long classPK)
121                    throws PortalException, SystemException {
122    
123                    return getTrash().isInTrash(className, classPK);
124            }
125    
126            public static boolean isTrashEnabled(long groupId)
127                    throws PortalException, SystemException {
128    
129                    return getTrash().isTrashEnabled(groupId);
130            }
131    
132            public void setTrash(Trash trash) {
133                    PortalRuntimePermission.checkSetBeanProperty(getClass());
134    
135                    _trash = trash;
136            }
137    
138            private static Trash _trash;
139    
140    }