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(ThemeDisplay themeDisplay, String oldName) {
084                    return getTrash().getNewName(themeDisplay, oldName);
085            }
086    
087            public static String getOriginalTitle(String title) {
088                    return getTrash().getOriginalTitle(title);
089            }
090    
091            public static Trash getTrash() {
092                    PortalRuntimePermission.checkGetBeanProperty(TrashUtil.class);
093    
094                    return _trash;
095            }
096    
097            public static String getTrashTime(String title, String separator) {
098                    return getTrash().getTrashTime(title, separator);
099            }
100    
101            public static String getTrashTitle(long trashEntryId) {
102                    return getTrash().getTrashTitle(trashEntryId);
103            }
104    
105            public static PortletURL getViewContentURL(
106                            HttpServletRequest request, String className, long classPK)
107                    throws PortalException, SystemException {
108    
109                    return getTrash().getViewContentURL(request, className, classPK);
110            }
111    
112            public static boolean isInTrash(String className, long classPK)
113                    throws PortalException, SystemException {
114    
115                    return getTrash().isInTrash(className, classPK);
116            }
117    
118            public static boolean isTrashEnabled(long groupId)
119                    throws PortalException, SystemException {
120    
121                    return getTrash().isTrashEnabled(groupId);
122            }
123    
124            public void setTrash(Trash trash) {
125                    PortalRuntimePermission.checkSetBeanProperty(getClass());
126    
127                    _trash = trash;
128            }
129    
130            private static Trash _trash;
131    
132    }