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    
095                    getTrash().deleteEntriesAttachments(
096                            companyId, repositoryId, date, attachmentFileNames);
097            }
098    
099            public static Group disableTrash(Group group) {
100                    return getTrash().disableTrash(group);
101            }
102    
103            public static List<TrashEntry> getEntries(Hits hits)
104                    throws PortalException {
105    
106                    return getTrash().getEntries(hits);
107            }
108    
109            public static OrderByComparator<TrashEntry> getEntryOrderByComparator(
110                    String orderByCol, String orderByType) {
111    
112                    return getTrash().getEntryOrderByComparator(orderByCol, orderByType);
113            }
114    
115            public static int getMaxAge(Group group) throws PortalException {
116                    return getTrash().getMaxAge(group);
117            }
118    
119            public static String getNewName(String oldName, String token) {
120                    return getTrash().getNewName(oldName, token);
121            }
122    
123            public static String getNewName(
124                            ThemeDisplay themeDisplay, String className, long classPK,
125                            String oldName)
126                    throws PortalException {
127    
128                    return getTrash().getNewName(themeDisplay, className, classPK, oldName);
129            }
130    
131            public static String getOriginalTitle(String title) {
132                    return getTrash().getOriginalTitle(title);
133            }
134    
135            public static String getOriginalTitle(String title, String paramName) {
136                    return getTrash().getOriginalTitle(title, paramName);
137            }
138    
139            public static Trash getTrash() {
140                    PortalRuntimePermission.checkGetBeanProperty(TrashUtil.class);
141    
142                    return _trash;
143            }
144    
145            public static String getTrashTime(String title, String separator) {
146                    return getTrash().getTrashTime(title, separator);
147            }
148    
149            public static String getTrashTitle(long trashEntryId) {
150                    return getTrash().getTrashTitle(trashEntryId);
151            }
152    
153            public static PortletURL getViewContentURL(
154                            HttpServletRequest request, long trashEntryId)
155                    throws PortalException {
156    
157                    return getTrash().getViewContentURL(request, trashEntryId);
158            }
159    
160            public static PortletURL getViewContentURL(
161                            HttpServletRequest request, String className, long classPK)
162                    throws PortalException {
163    
164                    return getTrash().getViewContentURL(request, className, classPK);
165            }
166    
167            public static PortletURL getViewURL(HttpServletRequest request)
168                    throws PortalException {
169    
170                    return getTrash().getViewURL(request);
171            }
172    
173            public static boolean isInTrash(String className, long classPK)
174                    throws PortalException {
175    
176                    return getTrash().isInTrash(className, classPK);
177            }
178    
179            public static boolean isTrashEnabled(Group group) {
180                    return getTrash().isTrashEnabled(group);
181            }
182    
183            public static boolean isTrashEnabled(long groupId) throws PortalException {
184                    return getTrash().isTrashEnabled(groupId);
185            }
186    
187            public static boolean isValidTrashTitle(String title) {
188                    return getTrash().isValidTrashTitle(title);
189            }
190    
191            public void setTrash(Trash trash) {
192                    PortalRuntimePermission.checkSetBeanProperty(getClass());
193    
194                    _trash = trash;
195            }
196    
197            private static Trash _trash;
198    
199    }