001
014
015 package com.liferay.portal.repository;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.repository.DocumentRepository;
019 import com.liferay.portal.kernel.repository.capabilities.Capability;
020 import com.liferay.portal.kernel.repository.model.FileEntry;
021 import com.liferay.portal.kernel.repository.model.FileShortcut;
022 import com.liferay.portal.kernel.repository.model.FileVersion;
023 import com.liferay.portal.kernel.repository.model.Folder;
024 import com.liferay.portal.kernel.repository.model.RepositoryEntry;
025 import com.liferay.portal.kernel.service.ServiceContext;
026 import com.liferay.portal.kernel.util.OrderByComparator;
027
028 import java.io.File;
029 import java.io.InputStream;
030
031 import java.util.List;
032
033
036 public abstract class InitializedDocumentRepository
037 <T extends DocumentRepository> implements DocumentRepository {
038
039 @Override
040 public FileEntry addFileEntry(
041 long userId, long folderId, String sourceFileName, String mimeType,
042 String title, String description, String changeLog, File file,
043 ServiceContext serviceContext)
044 throws PortalException {
045
046 checkDocumentRepository();
047
048 return documentRepository.addFileEntry(
049 userId, folderId, sourceFileName, mimeType, title, description,
050 changeLog, file, serviceContext);
051 }
052
053 @Override
054 public FileEntry addFileEntry(
055 long userId, long folderId, String sourceFileName, String mimeType,
056 String title, String description, String changeLog, InputStream is,
057 long size, ServiceContext serviceContext)
058 throws PortalException {
059
060 checkDocumentRepository();
061
062 return documentRepository.addFileEntry(
063 userId, folderId, sourceFileName, mimeType, title, description,
064 changeLog, is, size, serviceContext);
065 }
066
067 @Override
068 public FileShortcut addFileShortcut(
069 long userId, long folderId, long toFileEntryId,
070 ServiceContext serviceContext)
071 throws PortalException {
072
073 checkDocumentRepository();
074
075 return documentRepository.addFileShortcut(
076 userId, folderId, toFileEntryId, serviceContext);
077 }
078
079 @Override
080 public Folder addFolder(
081 long userId, long parentFolderId, String name, String description,
082 ServiceContext serviceContext)
083 throws PortalException {
084
085 checkDocumentRepository();
086
087 return documentRepository.addFolder(
088 userId, parentFolderId, name, description, serviceContext);
089 }
090
091 @Override
092 public void checkInFileEntry(
093 long userId, long fileEntryId, boolean major, String changeLog,
094 ServiceContext serviceContext)
095 throws PortalException {
096
097 checkDocumentRepository();
098
099 documentRepository.checkInFileEntry(
100 userId, fileEntryId, major, changeLog, serviceContext);
101 }
102
103 @Override
104 public void checkInFileEntry(
105 long userId, long fileEntryId, String lockUuid,
106 ServiceContext serviceContext)
107 throws PortalException {
108
109 checkDocumentRepository();
110
111 documentRepository.checkInFileEntry(
112 userId, fileEntryId, lockUuid, serviceContext);
113 }
114
115 @Override
116 public FileEntry copyFileEntry(
117 long userId, long groupId, long fileEntryId, long destFolderId,
118 ServiceContext serviceContext)
119 throws PortalException {
120
121 checkDocumentRepository();
122
123 return documentRepository.copyFileEntry(
124 userId, groupId, fileEntryId, destFolderId, serviceContext);
125 }
126
127 @Override
128 public void deleteAll() throws PortalException {
129 checkDocumentRepository();
130
131 documentRepository.deleteAll();
132 }
133
134 @Override
135 public void deleteFileEntry(long fileEntryId) throws PortalException {
136 checkDocumentRepository();
137
138 documentRepository.deleteFileEntry(fileEntryId);
139 }
140
141 @Override
142 public void deleteFileShortcut(long fileShortcutId) throws PortalException {
143 checkDocumentRepository();
144
145 documentRepository.deleteFileShortcut(fileShortcutId);
146 }
147
148 @Override
149 public void deleteFileShortcuts(long toFileEntryId) throws PortalException {
150 checkDocumentRepository();
151
152 documentRepository.deleteFileShortcuts(toFileEntryId);
153 }
154
155 @Override
156 public void deleteFolder(long folderId) throws PortalException {
157 checkDocumentRepository();
158
159 documentRepository.deleteFolder(folderId);
160 }
161
162 @Override
163 public <C extends Capability> C getCapability(Class<C> capabilityClass) {
164 checkDocumentRepository();
165
166 return documentRepository.getCapability(capabilityClass);
167 }
168
169 @Override
170 public List<FileEntry> getFileEntries(
171 long folderId, int status, int start, int end,
172 OrderByComparator<FileEntry> obc)
173 throws PortalException {
174
175 checkDocumentRepository();
176
177 return documentRepository.getFileEntries(
178 folderId, status, start, end, obc);
179 }
180
181 @Override
182 public List<FileEntry> getFileEntries(
183 long folderId, int start, int end, OrderByComparator<FileEntry> obc)
184 throws PortalException {
185
186 checkDocumentRepository();
187
188 return documentRepository.getFileEntries(folderId, start, end, obc);
189 }
190
191 @Override
192 public List<RepositoryEntry> getFileEntriesAndFileShortcuts(
193 long folderId, int status, int start, int end)
194 throws PortalException {
195
196 return documentRepository.getFileEntriesAndFileShortcuts(
197 folderId, status, start, end);
198 }
199
200 @Override
201 public int getFileEntriesAndFileShortcutsCount(long folderId, int status)
202 throws PortalException {
203
204 return documentRepository.getFileEntriesAndFileShortcutsCount(
205 folderId, status);
206 }
207
208 @Override
209 public int getFileEntriesCount(long folderId) throws PortalException {
210 checkDocumentRepository();
211
212 return documentRepository.getFileEntriesCount(folderId);
213 }
214
215 @Override
216 public int getFileEntriesCount(long folderId, int status)
217 throws PortalException {
218
219 checkDocumentRepository();
220
221 return documentRepository.getFileEntriesCount(folderId, status);
222 }
223
224 @Override
225 public FileEntry getFileEntry(long fileEntryId) throws PortalException {
226 checkDocumentRepository();
227
228 return documentRepository.getFileEntry(fileEntryId);
229 }
230
231 @Override
232 public FileEntry getFileEntry(long folderId, String title)
233 throws PortalException {
234
235 checkDocumentRepository();
236
237 return documentRepository.getFileEntry(folderId, title);
238 }
239
240 @Override
241 public FileEntry getFileEntryByUuid(String uuid) throws PortalException {
242 checkDocumentRepository();
243
244 return documentRepository.getFileEntryByUuid(uuid);
245 }
246
247 @Override
248 public FileShortcut getFileShortcut(long fileShortcutId)
249 throws PortalException {
250
251 checkDocumentRepository();
252
253 return documentRepository.getFileShortcut(fileShortcutId);
254 }
255
256 @Override
257 public FileVersion getFileVersion(long fileVersionId)
258 throws PortalException {
259
260 checkDocumentRepository();
261
262 return documentRepository.getFileVersion(fileVersionId);
263 }
264
265 @Override
266 public Folder getFolder(long folderId) throws PortalException {
267 checkDocumentRepository();
268
269 return documentRepository.getFolder(folderId);
270 }
271
272 @Override
273 public Folder getFolder(long parentFolderId, String name)
274 throws PortalException {
275
276 checkDocumentRepository();
277
278 return documentRepository.getFolder(parentFolderId, name);
279 }
280
281 @Override
282 public List<Folder> getFolders(
283 long parentFolderId, boolean includeMountFolders, int start,
284 int end, OrderByComparator<Folder> obc)
285 throws PortalException {
286
287 return documentRepository.getFolders(
288 parentFolderId, includeMountFolders, start, end, obc);
289 }
290
291 @Override
292 public List<Folder> getFolders(
293 long parentFolderId, int status, boolean includeMountFolders,
294 int start, int end, OrderByComparator<Folder> obc)
295 throws PortalException {
296
297 return documentRepository.getFolders(
298 parentFolderId, status, includeMountFolders, start, end, obc);
299 }
300
301 @Override
302 public List<RepositoryEntry> getFoldersAndFileEntriesAndFileShortcuts(
303 long folderId, int status, boolean includeMountFolders, int start,
304 int end, OrderByComparator<?> obc)
305 throws PortalException {
306
307 checkDocumentRepository();
308
309 return documentRepository.getFoldersAndFileEntriesAndFileShortcuts(
310 folderId, status, includeMountFolders, start, end, obc);
311 }
312
313 @Override
314 public int getFoldersAndFileEntriesAndFileShortcutsCount(
315 long folderId, int status, boolean includeMountFolders)
316 throws PortalException {
317
318 checkDocumentRepository();
319
320 return documentRepository.getFoldersAndFileEntriesAndFileShortcutsCount(
321 folderId, status, includeMountFolders);
322 }
323
324 @Override
325 public int getFoldersCount(long parentFolderId, boolean includeMountfolders)
326 throws PortalException {
327
328 return documentRepository.getFoldersCount(
329 parentFolderId, includeMountfolders);
330 }
331
332 @Override
333 public int getFoldersCount(
334 long parentFolderId, int status, boolean includeMountfolders)
335 throws PortalException {
336
337 return documentRepository.getFoldersCount(
338 parentFolderId, status, includeMountfolders);
339 }
340
341 @Override
342 public List<FileEntry> getRepositoryFileEntries(
343 long userId, long rootFolderId, int start, int end,
344 OrderByComparator<FileEntry> obc)
345 throws PortalException {
346
347 checkDocumentRepository();
348
349 return documentRepository.getRepositoryFileEntries(
350 userId, rootFolderId, start, end, obc);
351 }
352
353 @Override
354 public long getRepositoryId() {
355 checkDocumentRepository();
356
357 return documentRepository.getRepositoryId();
358 }
359
360 @Override
361 public <C extends Capability> boolean isCapabilityProvided(
362 Class<C> capabilityClass) {
363
364 checkDocumentRepository();
365
366 return documentRepository.isCapabilityProvided(capabilityClass);
367 }
368
369 @Override
370 public FileEntry moveFileEntry(
371 long userId, long fileEntryId, long newFolderId,
372 ServiceContext serviceContext)
373 throws PortalException {
374
375 checkDocumentRepository();
376
377 return documentRepository.moveFileEntry(
378 userId, fileEntryId, newFolderId, serviceContext);
379 }
380
381 @Override
382 public Folder moveFolder(
383 long userId, long folderId, long parentFolderId,
384 ServiceContext serviceContext)
385 throws PortalException {
386
387 checkDocumentRepository();
388
389 return documentRepository.moveFolder(
390 userId, folderId, parentFolderId, serviceContext);
391 }
392
393 @Override
394 public void revertFileEntry(
395 long userId, long fileEntryId, String version,
396 ServiceContext serviceContext)
397 throws PortalException {
398
399 checkDocumentRepository();
400
401 documentRepository.revertFileEntry(
402 userId, fileEntryId, version, serviceContext);
403 }
404
405 public void setDocumentRepository(T documentRepository) {
406 if (this.documentRepository != null) {
407 throw new IllegalStateException(
408 "Unable to initialize an initialized document repository");
409 }
410
411 this.documentRepository = documentRepository;
412 }
413
414 @Override
415 public FileEntry updateFileEntry(
416 long userId, long fileEntryId, String sourceFileName,
417 String mimeType, String title, String description, String changeLog,
418 boolean majorVersion, File file, ServiceContext serviceContext)
419 throws PortalException {
420
421 checkDocumentRepository();
422
423 return documentRepository.updateFileEntry(
424 userId, fileEntryId, sourceFileName, mimeType, title, description,
425 changeLog, majorVersion, file, serviceContext);
426 }
427
428 @Override
429 public FileEntry updateFileEntry(
430 long userId, long fileEntryId, String sourceFileName,
431 String mimeType, String title, String description, String changeLog,
432 boolean majorVersion, InputStream is, long size,
433 ServiceContext serviceContext)
434 throws PortalException {
435
436 checkDocumentRepository();
437
438 return documentRepository.updateFileEntry(
439 userId, fileEntryId, sourceFileName, mimeType, title, description,
440 changeLog, majorVersion, is, size, serviceContext);
441 }
442
443 @Override
444 public FileShortcut updateFileShortcut(
445 long userId, long fileShortcutId, long folderId, long toFileEntryId,
446 ServiceContext serviceContext)
447 throws PortalException {
448
449 checkDocumentRepository();
450
451 return documentRepository.updateFileShortcut(
452 userId, fileShortcutId, folderId, toFileEntryId, serviceContext);
453 }
454
455 @Override
456 public void updateFileShortcuts(
457 long oldToFileEntryId, long newToFileEntryId)
458 throws PortalException {
459
460 checkDocumentRepository();
461
462 documentRepository.updateFileShortcuts(
463 oldToFileEntryId, newToFileEntryId);
464 }
465
466 @Override
467 public Folder updateFolder(
468 long folderId, long parentFolderId, String name, String description,
469 ServiceContext serviceContext)
470 throws PortalException {
471
472 checkDocumentRepository();
473
474 return documentRepository.updateFolder(
475 folderId, parentFolderId, name, description, serviceContext);
476 }
477
478 protected void checkDocumentRepository() {
479 if (documentRepository == null) {
480 throw new IllegalStateException(
481 "Document repositry is not initialized");
482 }
483 }
484
485 protected T documentRepository;
486
487 }