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.portlet.LiferayPortletResponse;
020    import com.liferay.portal.kernel.search.Hits;
021    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
022    import com.liferay.portal.kernel.util.OrderByComparator;
023    import com.liferay.portal.model.Group;
024    import com.liferay.portal.theme.ThemeDisplay;
025    import com.liferay.portlet.trash.model.TrashEntry;
026    
027    import java.util.Date;
028    import java.util.List;
029    
030    import javax.portlet.PortletURL;
031    
032    import javax.servlet.http.HttpServletRequest;
033    
034    /**
035     * @author Julio Camarero
036     */
037    public class TrashUtil {
038    
039            public static void addBaseModelBreadcrumbEntries(
040                            HttpServletRequest request,
041                            LiferayPortletResponse liferayPortletResponse, String className,
042                            long classPK, PortletURL containerModelURL)
043                    throws PortalException, SystemException {
044    
045                    getTrash().addBaseModelBreadcrumbEntries(
046                            request, liferayPortletResponse, className, classPK,
047                            containerModelURL);
048            }
049    
050            /**
051             * @deprecated As of 7.0.0, replaced by {@link
052             *             #addBaseModelBreadcrumbEntries(HttpServletRequest,
053             *             LiferayPortletResponse, String, long, PortletURL}
054             */
055            @Deprecated
056            public static void addBaseModelBreadcrumbEntries(
057                            HttpServletRequest request, String className, long classPK,
058                            PortletURL containerModelURL)
059                    throws PortalException, SystemException {
060    
061                    getTrash().addBaseModelBreadcrumbEntries(
062                            request, className, classPK, containerModelURL);
063            }
064    
065            public static void addContainerModelBreadcrumbEntries(
066                            HttpServletRequest request,
067                            LiferayPortletResponse liferayPortletResponse, String className,
068                            long classPK, PortletURL containerModelURL)
069                    throws PortalException, SystemException {
070    
071                    getTrash().addContainerModelBreadcrumbEntries(
072                            request, liferayPortletResponse, className, classPK,
073                            containerModelURL);
074            }
075    
076            /**
077             * @deprecated As of 7.0.0, replaced by {@link
078             *             #addContainerModelBreadcrumbEntries(HttpServletRequest,
079             *             LiferayPortletResponse, String, long, PortletURL}
080             */
081            @Deprecated
082            public static void addContainerModelBreadcrumbEntries(
083                            HttpServletRequest request, String className, long classPK,
084                            PortletURL containerModelURL)
085                    throws PortalException, SystemException {
086    
087                    getTrash().addContainerModelBreadcrumbEntries(
088                            request, className, classPK, containerModelURL);
089            }
090    
091            public static void deleteEntriesAttachments(
092                            long companyId, long repositoryId, Date date,
093                            String[] attachmentFileNames)
094                    throws PortalException, SystemException {
095    
096                    getTrash().deleteEntriesAttachments(
097                            companyId, repositoryId, date, attachmentFileNames);
098            }
099    
100            public static List<TrashEntry> getEntries(Hits hits)
101                    throws PortalException, SystemException {
102    
103                    return getTrash().getEntries(hits);
104            }
105    
106            public static OrderByComparator getEntryOrderByComparator(
107                    String orderByCol, String orderByType) {
108    
109                    return getTrash().getEntryOrderByComparator(orderByCol, orderByType);
110            }
111    
112            public static int getMaxAge(Group group)
113                    throws PortalException, SystemException {
114    
115                    return getTrash().getMaxAge(group);
116            }
117    
118            public static String getNewName(String oldName, String token) {
119                    return getTrash().getNewName(oldName, token);
120            }
121    
122            public static String getNewName(
123                            ThemeDisplay themeDisplay, String className, long classPK,
124                            String oldName)
125                    throws PortalException, SystemException {
126    
127                    return getTrash().getNewName(themeDisplay, className, classPK, oldName);
128            }
129    
130            public static String getOriginalTitle(String title) {
131                    return getTrash().getOriginalTitle(title);
132            }
133    
134            public static Trash getTrash() {
135                    PortalRuntimePermission.checkGetBeanProperty(TrashUtil.class);
136    
137                    return _trash;
138            }
139    
140            public static String getTrashTime(String title, String separator) {
141                    return getTrash().getTrashTime(title, separator);
142            }
143    
144            public static String getTrashTitle(long trashEntryId) {
145                    return getTrash().getTrashTitle(trashEntryId);
146            }
147    
148            public static PortletURL getViewContentURL(
149                            HttpServletRequest request, String className, long classPK)
150                    throws PortalException, SystemException {
151    
152                    return getTrash().getViewContentURL(request, className, classPK);
153            }
154    
155            public static boolean isInTrash(String className, long classPK)
156                    throws PortalException, SystemException {
157    
158                    return getTrash().isInTrash(className, classPK);
159            }
160    
161            public static boolean isTrashEnabled(long groupId)
162                    throws PortalException, SystemException {
163    
164                    return getTrash().isTrashEnabled(groupId);
165            }
166    
167            public void setTrash(Trash trash) {
168                    PortalRuntimePermission.checkSetBeanProperty(getClass());
169    
170                    _trash = trash;
171            }
172    
173            private static Trash _trash;
174    
175    }