001
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
032 public class TrashUtil {
033
034 public static final String TRASH_ATTACHMENTS_DIR = ".trashed_";
035
036 public static final int TRASH_DEFAULT_VALUE = -1;
037
038 public static final int TRASH_DISABLED = 0;
039
040 public static final int TRASH_DISABLED_BY_DEFAULT = 1;
041
042 public static final int TRASH_ENABLED = 3;
043
044 public static final int TRASH_ENABLED_BY_DEFAULT = 2;
045
046 public static final String TRASH_TIME_SEPARATOR = "_TRASH_TIME_";
047
048 public static String appendTrashNamespace(String title) {
049 return getTrash().appendTrashNamespace(title);
050 }
051
052 public static String appendTrashNamespace(String title, String separator) {
053 return getTrash().appendTrashNamespace(title, separator);
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 Trash getTrash() {
088 PortalRuntimePermission.checkGetBeanProperty(TrashUtil.class);
089
090 return _trash;
091 }
092
093 public static String getTrashTime(String title, String separator) {
094 return getTrash().getTrashTime(title, separator);
095 }
096
097 public static boolean isInTrash(String className, long classPK)
098 throws PortalException, SystemException {
099
100 return getTrash().isInTrash(className, classPK);
101 }
102
103 public static boolean isTrashEnabled(long groupId)
104 throws PortalException, SystemException {
105
106 return getTrash().isTrashEnabled(groupId);
107 }
108
109 public static void moveAttachmentFromTrash(
110 long companyId, long repositoryId, String deletedFileName,
111 String attachmentsDir)
112 throws PortalException, SystemException {
113
114 getTrash().moveAttachmentFromTrash(
115 companyId, repositoryId, deletedFileName, attachmentsDir);
116 }
117
118 public static void moveAttachmentFromTrash(
119 long companyId, long repositoryId, String deletedFileName,
120 String attachmentsDir, String separator)
121 throws PortalException, SystemException {
122
123 getTrash().moveAttachmentFromTrash(
124 companyId, repositoryId, deletedFileName, attachmentsDir,
125 separator);
126 }
127
128 public static String moveAttachmentToTrash(
129 long companyId, long repositoryId, String fileName,
130 String deletedAttachmentsDir)
131 throws PortalException, SystemException {
132
133 return getTrash().moveAttachmentToTrash(
134 companyId, repositoryId, fileName, deletedAttachmentsDir);
135 }
136
137 public static String moveAttachmentToTrash(
138 long companyId, long repositoryId, String fileName,
139 String deletedAttachmentsDir, String separator)
140 throws PortalException, SystemException {
141
142 return getTrash().moveAttachmentToTrash(
143 companyId, repositoryId, fileName, deletedAttachmentsDir,
144 separator);
145 }
146
147 public static String stripTrashNamespace(String title) {
148 return getTrash().stripTrashNamespace(title);
149 }
150
151 public static String stripTrashNamespace(String title, String separator) {
152 return getTrash().stripTrashNamespace(title, separator);
153 }
154
155 public void setTrash(Trash trash) {
156 PortalRuntimePermission.checkSetBeanProperty(getClass());
157
158 _trash = trash;
159 }
160
161 private static Trash _trash;
162
163 }