001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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 Group disableTrash(Group group) throws SystemException {
101                    return getTrash().disableTrash(group);
102            }
103    
104            public static List<TrashEntry> getEntries(Hits hits)
105                    throws PortalException, SystemException {
106    
107                    return getTrash().getEntries(hits);
108            }
109    
110            public static OrderByComparator getEntryOrderByComparator(
111                    String orderByCol, String orderByType) {
112    
113                    return getTrash().getEntryOrderByComparator(orderByCol, orderByType);
114            }
115    
116            public static int getMaxAge(Group group)
117                    throws PortalException, SystemException {
118    
119                    return getTrash().getMaxAge(group);
120            }
121    
122            public static String getNewName(String oldName, String token) {
123                    return getTrash().getNewName(oldName, token);
124            }
125    
126            public static String getNewName(
127                            ThemeDisplay themeDisplay, String className, long classPK,
128                            String oldName)
129                    throws PortalException, SystemException {
130    
131                    return getTrash().getNewName(themeDisplay, className, classPK, oldName);
132            }
133    
134            public static String getOriginalTitle(String title) {
135                    return getTrash().getOriginalTitle(title);
136            }
137    
138            public static Trash getTrash() {
139                    PortalRuntimePermission.checkGetBeanProperty(TrashUtil.class);
140    
141                    return _trash;
142            }
143    
144            public static String getTrashTime(String title, String separator) {
145                    return getTrash().getTrashTime(title, separator);
146            }
147    
148            public static String getTrashTitle(long trashEntryId) {
149                    return getTrash().getTrashTitle(trashEntryId);
150            }
151    
152            public static PortletURL getViewContentURL(
153                            HttpServletRequest request, String className, long classPK)
154                    throws PortalException, SystemException {
155    
156                    return getTrash().getViewContentURL(request, className, classPK);
157            }
158    
159            public static boolean isInTrash(String className, long classPK)
160                    throws PortalException, SystemException {
161    
162                    return getTrash().isInTrash(className, classPK);
163            }
164    
165            public static boolean isTrashEnabled(long groupId)
166                    throws PortalException, SystemException {
167    
168                    return getTrash().isTrashEnabled(groupId);
169            }
170    
171            public void setTrash(Trash trash) {
172                    PortalRuntimePermission.checkSetBeanProperty(getClass());
173    
174                    _trash = trash;
175            }
176    
177            private static Trash _trash;
178    
179    }