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