2 * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
4 * This file is part of GSS.
6 * GSS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
19 package gr.ebs.gss.server.ejb;
21 import gr.ebs.gss.client.exceptions.DuplicateNameException;
22 import gr.ebs.gss.client.exceptions.GSSIOException;
23 import gr.ebs.gss.client.exceptions.InsufficientPermissionsException;
24 import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
25 import gr.ebs.gss.client.exceptions.QuotaExceededException;
26 import gr.ebs.gss.server.domain.FileUploadStatus;
27 import gr.ebs.gss.server.domain.Nonce;
28 import gr.ebs.gss.server.domain.User;
29 import gr.ebs.gss.server.domain.dto.FileBodyDTO;
30 import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
31 import gr.ebs.gss.server.domain.dto.FolderDTO;
32 import gr.ebs.gss.server.domain.dto.GroupDTO;
33 import gr.ebs.gss.server.domain.dto.PermissionDTO;
34 import gr.ebs.gss.server.domain.dto.StatsDTO;
35 import gr.ebs.gss.server.domain.dto.UserDTO;
38 import java.io.IOException;
39 import java.io.InputStream;
40 import java.util.Date;
41 import java.util.List;
44 import javax.ejb.Local;
45 import javax.ejb.TransactionAttribute;
46 import javax.ejb.TransactionAttributeType;
49 * The External API for GSS clients.
54 public interface ExternalAPI {
57 * Retrieves the root folder for the specified user. The caller must ensure
58 * that the userId exists.
62 * @throws ObjectNotFoundException if no Folder or user was found
64 public FolderDTO getRootFolder(Long userId) throws ObjectNotFoundException;
67 * Retrieve the folder with the specified ID.
69 * @param userId the ID of the current user
70 * @param folderId the ID of the folder to retrieve
71 * @return the folder found
72 * @throws ObjectNotFoundException if the folder or the user was not found
73 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
75 public FolderDTO getFolder(Long userId, Long folderId) throws ObjectNotFoundException,
76 InsufficientPermissionsException;
79 * Returns the user with the specified ID.
81 * @param userId The ID of the User to be found
82 * @return The User object
83 * @throws ObjectNotFoundException if the user cannot be found
85 public User getUser(Long userId) throws ObjectNotFoundException;
88 * Returns the user with the specified ID.
90 * @param userId The ID of the User to be found
91 * @return The User object
92 * @throws ObjectNotFoundException if the user cannot be found
94 public UserDTO getUserDTO(Long userId) throws ObjectNotFoundException;
97 * Returns the group with the specified ID.
99 * @param groupId The ID of the Group to be found
100 * @return The Group object
101 * @throws ObjectNotFoundException if the group cannot be found
103 public GroupDTO getGroup(Long groupId) throws ObjectNotFoundException;
106 * Returns the group with the specified name that belongs to the
109 * @param userId the ID of the user
110 * @param name the name of the group
111 * @return The Group object
112 * @throws ObjectNotFoundException if the group cannot be found
114 public GroupDTO getGroup(Long userId, String name) throws ObjectNotFoundException;
117 * Retrieve the list of groups for a particular user.
119 * @param userId the ID of the User
120 * @return a List of Groups that belong to the specified User
121 * @throws ObjectNotFoundException if the user was not found
123 public List<GroupDTO> getGroups(Long userId) throws ObjectNotFoundException;
126 * Returns a list of files contained in the folder specified by its id.
128 * @param userId the ID of the User
129 * @param folderId the ID of the folder containing the files
130 * @param ignoreDeleted
131 * @return the list of file header objects
132 * @throws ObjectNotFoundException if the user or the folder cannot be found
133 * @throws InsufficientPermissionsException
135 public List<FileHeaderDTO> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException,
136 InsufficientPermissionsException;
139 * Returns a list of users for the specified group
141 * @param userId the ID of the User
142 * @param groupId the ID of the requested group
143 * @return List<UserDTO>
144 * @throws ObjectNotFoundException if the user or group was not found, with
145 * the exception message mentioning the precise problem
147 public List<UserDTO> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
150 * Returns a list of users matching the specified username
152 * @param username the username of the User
153 * @return List<UserDTO>
155 public List<UserDTO> getUsersByUserNameLike(String username);
158 * Creates a new folder with the specified owner, parent folder and name.
159 * New folder has the same permissions as its parent
164 * @throws DuplicateNameException if the specified name already exists in
165 * the parent folder, as either a folder or file
166 * @throws ObjectNotFoundException if the user or parent folder was not
167 * found, with the exception message mentioning the precise
169 * @throws InsufficientPermissionsException
171 public void createFolder(Long userId, Long parentId, String name) throws DuplicateNameException,
172 ObjectNotFoundException, InsufficientPermissionsException;
175 * Deletes the specified folder, if the specified user has the appropriate
178 * @param userId the ID of the current user
179 * @param folderId the ID of the folder to delete
180 * @throws InsufficientPermissionsException if the user does not have the
181 * appropriate privileges
182 * @throws ObjectNotFoundException if the user or folder was not found, with
183 * the exception message mentioning the precise problem
185 public void deleteFolder(Long userId, Long folderId)
186 throws InsufficientPermissionsException, ObjectNotFoundException;
189 * Retrieve the subfolders of the specified folder.
191 * @param userId the ID of the current user
192 * @param folderId the ID of the folder to retrieve
193 * @return the list of subfolders found
194 * @throws ObjectNotFoundException if the folder or user was not found
195 * @throws InsufficientPermissionsException
197 public List<FolderDTO> getSubfolders(Long userId, Long folderId)
198 throws ObjectNotFoundException, InsufficientPermissionsException;
201 * Retrieve the folder with the specified ID with subfolders.
203 * @param userId the ID of the current user
204 * @param folderId the ID of the folder to retrieve
205 * @return the folder found
206 * @throws ObjectNotFoundException if the folder or the user was not found
207 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
209 public FolderDTO getFolderWithSubfolders(Long userId, Long folderId)
210 throws ObjectNotFoundException, InsufficientPermissionsException;
213 * Retrieve the folder with the specified ID with subfolders.
215 * @param userId the ID of the current user
216 * @param callingUserId the ID of the user requesting this operation
217 * @param folderId the ID of the folder to retrieve
218 * @return the folder found
219 * @throws ObjectNotFoundException if the folder or the user was not found
220 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
222 public FolderDTO getFolderWithSubfolders(Long userId, Long callingUserId, Long folderId)
223 throws ObjectNotFoundException, InsufficientPermissionsException;
225 * Retrieve the subfolders of the specified folder that are shared to others.
227 * @param userId the ID of the current user
228 * @param folderId the ID of the folder to retrieve
229 * @return the list of subfolders found
230 * @throws ObjectNotFoundException if the folder or user was not found
232 public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
235 * Retrieve the subfolders of the specified folder that are shared to others.
237 * @param userId the ID of the current user
238 * @param callingUserId the id of the user requesting this operation
239 * @param folderId the ID of the folder to retrieve
240 * @return the list of subfolders found
241 * @throws ObjectNotFoundException if the folder or user was not found
243 public List<FolderDTO> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException;
245 * Modifies the specified folder if the specified user has the appropriate
248 * @param userId the ID of the current user
249 * @param folderId the ID of the folder to retrieve
251 * @throws InsufficientPermissionsException if the user does not have the
252 * appropriate privileges
253 * @throws ObjectNotFoundException if the user or folder was not found, with
254 * the exception message mentioning the precise problem
255 * @throws DuplicateNameException if the specified name already exists in
256 * the parent folder, as either a folder or file
258 public void modifyFolder(Long userId, Long folderId, String folderName)
259 throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
262 * Adds a user to the specified group
264 * @param userId the ID of the current user
265 * @param groupId the id of the new group
266 * @param userToAddId the id of the user to add
267 * @throws DuplicateNameException if the user already exists in group
268 * @throws ObjectNotFoundException if the user or group was not found, with
269 * the exception message mentioning the precise problem
270 * @throws InsufficientPermissionsException
272 public void addUserToGroup(Long userId, Long groupId, Long userToAddId)
273 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
276 * Creates a new group with the specified owner and name.
278 * @param userId the ID of the current user
279 * @param name the name of the new group
280 * @throws DuplicateNameException if the new group name already exists
281 * @throws ObjectNotFoundException if the user or group was not found, with
282 * the exception message mentioning the precise problem
284 public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
287 * Deletes the specified group in the specified user's namespace.
289 * @param userId the ID of the current user
290 * @param groupId the ID of the group to delete
291 * @throws ObjectNotFoundException if the user or group was not found, with
292 * the exception message mentioning the precise problem
293 * @throws InsufficientPermissionsException
295 public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
298 * Creates a new file with the specified owner, parent folder and name. The
299 * new file has the same permissions as its parent folder. The file contents
300 * are read from the input stream to a new File object.
302 * @param userId the ID of the current user
303 * @param folderId the ID of the parent folder
304 * @param name the name of the new file
305 * @param mimeType the MIME type of the file
306 * @param stream the input stream with the file contents
307 * @return The FileHeaderDTO created
308 * @throws DuplicateNameException if the specified name already exists in
309 * the parent folder, as either a folder or file
310 * @throws ObjectNotFoundException if the user or parent folder was not
311 * found, with the exception message mentioning the precise
313 * @throws GSSIOException if there was an error while storing the file contents
314 * @throws InsufficientPermissionsException
315 * @throws QuotaExceededException
317 public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType,
318 InputStream stream) throws DuplicateNameException, ObjectNotFoundException,
319 GSSIOException, InsufficientPermissionsException, QuotaExceededException;
322 * Deletes the specified file, provided the specified user has
323 * the necessary permissions.
325 * @param userId the ID of the current user
326 * @param fileId the ID of the file to delete
327 * @throws ObjectNotFoundException if the user or file was not found, with
328 * the exception message mentioning the precise problem
329 * @throws InsufficientPermissionsException if the user does not have the
330 * appropriate privileges
332 public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
335 * Deletes the specified file in the specified user's namespace.
337 * @param userId the ID of the current user
338 * @param fileIds the IDs of the files to delete
339 * @throws ObjectNotFoundException if the user or file was not found, with
340 * the exception message mentioning the precise problem
341 * @throws InsufficientPermissionsException if the user does not have the
342 * appropriate privileges
344 public void deleteFiles(Long userId, List<Long> fileIds)
345 throws ObjectNotFoundException, InsufficientPermissionsException;
348 * Creates a new tag for the specified user and file.
350 * @param userId the creator of the tag
351 * @param fileHeaderId the file that is tagged
353 * @throws ObjectNotFoundException if the user or the file was not found
355 public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
358 * Returns all tags defined by the specified user
361 * @return Set<String>
362 * @throws ObjectNotFoundException if the user was null
364 public Set<String> getUserTags(final Long userId) throws ObjectNotFoundException;
367 * Updates name and tags for the specified file
372 * @param tagSet a String that contains tags separated by comma
373 * @throws ObjectNotFoundException
374 * @throws InsufficientPermissionsException
376 public void updateFile(Long userId, Long fileId, String name, String tagSet)
377 throws ObjectNotFoundException, InsufficientPermissionsException;
380 * Retrieve the contents of the current body for the file
381 * with the specified FileHeader ID. The file contents
382 * are provided as an InputStream from which the caller can
383 * retrieve the raw bytes.
385 * @param userId the ID of the current user
386 * @param fileId the ID of the file to retrieve
387 * @return an InputStream from the current file body contents
388 * @throws ObjectNotFoundException if the file or the user was not found
389 * @throws InsufficientPermissionsException if the user does not have the
390 * appropriate privileges
392 public InputStream getFileContents(Long userId, Long fileId)
393 throws ObjectNotFoundException, InsufficientPermissionsException;
396 * Retrieve the contents of the body identified by bodyId for the file
397 * with the specified FileHeader ID. The file contents
398 * are provided as an InputStream from which the caller can
399 * retrieve the raw bytes.
401 * @param userId the ID of the current user
402 * @param fileId the ID of the file to retrieve
403 * @param bodyId the body ID
404 * @return an InputStream from the current file body contents
405 * @throws ObjectNotFoundException if the file or the user was not found
406 * @throws InsufficientPermissionsException if the user does not have the
407 * appropriate privileges
409 public InputStream getFileContents(Long userId, Long fileId, Long bodyId)
410 throws ObjectNotFoundException, InsufficientPermissionsException;
413 * Retrieve the file with the specified ID.
415 * @param userId the ID of the current user
416 * @param fileId the ID of the file to retrieve
417 * @return the file found
418 * @throws ObjectNotFoundException if the file or the user was not found, with
419 * the exception message mentioning the precise problem
420 * @throws InsufficientPermissionsException
422 public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException,
423 InsufficientPermissionsException;
426 * Retrieve the filebody with the specified ID.
428 * @param userId the ID of the current user
429 * @param fileId the ID of the file to retrieve
430 * @param bodyId the ID of the body
431 * @return the file found
432 * @throws ObjectNotFoundException if the file or the user was not found, with
433 * the exception message mentioning the precise problem
434 * @throws InsufficientPermissionsException
436 public FileBodyDTO getFileBody(Long userId, Long fileId, Long bodyId)
437 throws ObjectNotFoundException, InsufficientPermissionsException;
440 * Get the resource (file or folder) at the specified path in
441 * the specified user's namespace. The returned object will be of type
442 * FileHeaderDTO or FolderDTO.<p><strong>Note:</strong> this method does not
443 * receive the current user as a parameter, therefore it is unable to perform
444 * the necessary permission checks and should <strong>NOT</strong> be directly
445 * exposed to remote clients. It is the caller's responsibility to verify that
446 * the calling user has the required privileges for performing any subsequent
447 * action on the resource through one of the other ExternalAPI methods.
449 * @param ownerId the ID of the user owning the namespace
450 * @param path the absolute path in the user's namespace
451 * @param ignoreDeleted if true, resources that have been moved to the trash
453 * @throws ObjectNotFoundException if the user or resource was not found, with
454 * the exception message mentioning the precise problem
455 * @return the resource found
457 public Object getResourceAtPath(Long ownerId, String path, boolean ignoreDeleted)
458 throws ObjectNotFoundException;
461 * Copy the provided file to the specified destination.
463 * @param userId the ID of the current user
464 * @param fileId the IF of the provided file
465 * @param dest the path of the new resource
466 * @throws ObjectNotFoundException if the user, file or destination was not
467 * found, with the exception message mentioning the precise problem
468 * @throws DuplicateNameException if the specified name already exists in
469 * the destination folder, as either a folder or file
470 * @throws GSSIOException if there was an error while accessing the file contents
471 * @throws InsufficientPermissionsException
472 * @throws QuotaExceededException
474 public void copyFile(Long userId, Long fileId, String dest) throws ObjectNotFoundException,
475 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
478 * Copy the provided file to the specified destination.
480 * @param userId the ID of the current user
481 * @param ownerId the ID of the owner of the destination namespace
482 * @param fileId the IF of the provided file
483 * @param dest the path of the new resource
484 * @throws ObjectNotFoundException if the user, file or destination was not
485 * found, with the exception message mentioning the precise problem
486 * @throws DuplicateNameException if the specified name already exists in
487 * the destination folder, as either a folder or file
488 * @throws GSSIOException if there was an error while accessing the file contents
489 * @throws InsufficientPermissionsException
490 * @throws QuotaExceededException
492 public void copyFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException,
493 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
496 * Copy the provided file to the specified destination.
498 * @param userId the ID of the current user
499 * @param fileIds the IDs of the provided files
500 * @param destId the ID of the destination folder
501 * @throws ObjectNotFoundException if the user, file or destination was not
502 * found, with the exception message mentioning the precise problem
503 * @throws GSSIOException if there was an error while accessing the file contents
504 * @throws DuplicateNameException if the specified name already exists in
505 * the destination folder, as either a folder or file
506 * @throws InsufficientPermissionsException
507 * @throws QuotaExceededException
509 public void copyFiles(Long userId, List<Long> fileIds, Long destId)
510 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
511 InsufficientPermissionsException, QuotaExceededException;
514 * Copy the provided file to the specified destination.
516 * @param userId the ID of the current user
517 * @param fileId the IF of the provided file
518 * @param destId the ID of the destination folder
519 * @param destName the name of the new file
520 * @throws ObjectNotFoundException if the user, file or destination was not
521 * found, with the exception message mentioning the precise problem
522 * @throws GSSIOException if there was an error while accessing the file contents
523 * @throws DuplicateNameException if the specified name already exists in
524 * the destination folder, as either a folder or file
525 * @throws InsufficientPermissionsException
526 * @throws QuotaExceededException
528 public void copyFile(Long userId, Long fileId, Long destId, String destName)
529 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
530 InsufficientPermissionsException, QuotaExceededException;
533 * Copy the provided folder to the specified destination.
535 * @param userId the ID of the current user
536 * @param folderId the IF of the provided folder
537 * @param dest the path of the new folder
538 * @throws ObjectNotFoundException if the user, folder or destination was not
539 * found, with the exception message mentioning the precise problem
540 * @throws DuplicateNameException if the specified name already exists in
541 * the destination folder, as either a folder or file
542 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
543 * appropriate privileges
545 public void copyFolder(Long userId, Long folderId, String dest) throws ObjectNotFoundException,
546 DuplicateNameException, InsufficientPermissionsException;
549 * Copy the provided folder to the specified destination.
551 * @param userId the ID of the current user
552 * @param folderId the IF of the provided folder
553 * @param destId the ID of the destination folder
554 * @param destName the name of the new folder
555 * @throws ObjectNotFoundException if the user, folder or destination was not
556 * found, with the exception message mentioning the precise problem
557 * @throws DuplicateNameException if the specified name already exists in
558 * the destination folder, as either a folder or file
559 * @throws InsufficientPermissionsException InsufficientPermissionsException
560 * if the user does not have the appropriate privileges
562 public void copyFolder(Long userId, Long folderId, Long destId, String destName)
563 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
566 * Copy the provided folder and all its subfolders and files to the specified destination.
568 * @param userId the ID of the current user
569 * @param ownerId the ID of the owner of the destination namespace
570 * @param folderId the IF of the provided folder
571 * @param dest the path of the new folder
572 * @throws ObjectNotFoundException if the user, folder or destination was not
573 * found, with the exception message mentioning the precise problem
574 * @throws DuplicateNameException if the specified name already exists in
575 * the destination folder, as either a folder or file
576 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
577 * appropriate privileges
578 * @throws QuotaExceededException if the user quota limit would be exceeded
579 * @throws GSSIOException if there was an error while accessing the file contents
581 public void copyFolderStructureToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
582 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
585 * Copy the provided folder and all its subfolders and files to the specified destination.
587 * @param userId the ID of the current user
588 * @param folderId the IF of the provided folder
589 * @param destId the ID of the destination folder
590 * @param destName the name of the new folder
591 * @throws ObjectNotFoundException if the user, folder or destination was not
592 * found, with the exception message mentioning the precise problem
593 * @throws DuplicateNameException if the specified name already exists in
594 * the destination folder, as either a folder or file
595 * @throws InsufficientPermissionsException InsufficientPermissionsException
596 * if the user does not have the appropriate privileges
597 * @throws GSSIOException if there was an error while accessing the file contents
598 * @throws QuotaExceededException if the user quota limit would be exceeded
600 public void copyFolderStructure(Long userId, Long folderId, Long destId, String destName)
601 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
602 GSSIOException, QuotaExceededException;
605 * Marks the specified file as deleted in the specified user's namespace.
607 * @param userId the ID of the current user
608 * @param fileId the ID of the file to delete
609 * @throws ObjectNotFoundException if the user or file was not found, with
610 * the exception message mentioning the precise problem
611 * @throws InsufficientPermissionsException if the user does not have the
612 * appropriate privileges
614 public void moveFileToTrash(Long userId, Long fileId) throws ObjectNotFoundException,
615 InsufficientPermissionsException;
618 * Marks the specified deleted file as undeleted in the specified user's namespace.
620 * @param userId the ID of the current user
621 * @param fileId the ID of the file to undelete
622 * @throws ObjectNotFoundException if the user or file was not found, with
623 * the exception message mentioning the precise problem
624 * @throws InsufficientPermissionsException if the user does not have the
625 * appropriate privileges
628 public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
631 * Marks the specified files as deleted in the specified user's namespace.
633 * @param userId the ID of the current user
634 * @param fileIds the IDs of the file to delete
635 * @throws ObjectNotFoundException if the user or file was not found, with
636 * the exception message mentioning the precise problem
637 * @throws InsufficientPermissionsException if the user does not have the
638 * appropriate privileges
640 public void moveFilesToTrash(Long userId, List<Long> fileIds)
641 throws ObjectNotFoundException, InsufficientPermissionsException;
644 * Marks the specified deleted files as undeleted in the specified user's namespace.
646 * @param userId the ID of the current user
647 * @param fileIds the IDs of the file to undelete
648 * @throws ObjectNotFoundException if the user or file was not found, with
649 * the exception message mentioning the precise problem
650 * @throws InsufficientPermissionsException if the user does not have the
651 * appropriate privileges
653 public void removeFilesFromTrash(Long userId, List<Long> fileIds) throws ObjectNotFoundException, InsufficientPermissionsException;
656 * Marks the specified folder as deleted in the specified user's namespace.
658 * @param userId the ID of the current user
659 * @param folderId the ID of the folder to delete
660 * @throws ObjectNotFoundException if the user or file was not found, with
661 * the exception message mentioning the precise problem
662 * @throws InsufficientPermissionsException if the user does not have the
663 * appropriate privileges
665 public void moveFolderToTrash(Long userId, Long folderId)
666 throws ObjectNotFoundException, InsufficientPermissionsException;
669 * Marks the specified deleted folder as undeleted in the specified user's namespace.
671 * @param userId the ID of the current user
672 * @param folderId the ID of the folder to undelete
673 * @throws ObjectNotFoundException if the user or file was not found, with
674 * the exception message mentioning the precise problem
675 * @throws InsufficientPermissionsException if the user does not have the
676 * appropriate privileges
679 public void removeFolderFromTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
682 * Move the provided folder and all its subfolders and files to the specified destination.
684 * @param userId the ID of the current user
685 * @param folderId the IF of the provided folder
686 * @param destId the ID of the destination folder
687 * @param destName the name of the new folder
688 * @throws ObjectNotFoundException if the user, folder or destination was not
689 * found, with the exception message mentioning the precise problem
690 * @throws DuplicateNameException if the specified name already exists in
691 * the destination folder, as either a folder or file
692 * @throws InsufficientPermissionsException if the user does not have the
693 * appropriate privileges
694 * @throws GSSIOException
695 * @throws QuotaExceededException
697 public void moveFolder(Long userId, Long folderId, Long destId, String destName)
698 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
699 GSSIOException, QuotaExceededException;
702 * Move the provided folder and all its subfolders and files to the specified destination.
704 * @param userId the ID of the current user
705 * @param ownerId the owner of the destination namespace
706 * @param folderId the IF of the provided folder
707 * @param dest the path of the new folder
708 * @throws ObjectNotFoundException if the user, folder or destination was not
709 * found, with the exception message mentioning the precise problem
710 * @throws DuplicateNameException if the specified name already exists in
711 * the destination folder, as either a folder or file
712 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
713 * appropriate privileges
714 * @throws GSSIOException
715 * @throws QuotaExceededException
717 public void moveFolderToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
718 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
721 * Move the provided file to the specified destination.
723 * @param userId the ID of the current user
724 * @param fileId the IF of the provided file
725 * @param destId the ID of the destination folder
726 * @param destName the name of the new file
727 * @throws InsufficientPermissionsException
728 * @throws ObjectNotFoundException if the user, file or destination was not
729 * found, with the exception message mentioning the precise problem
730 * @throws GSSIOException if there was an error while accessing the file contents
731 * @throws DuplicateNameException if the specified name already exists in
732 * the destination folder, as either a folder or file
733 * @throws QuotaExceededException
735 public void moveFile(Long userId, Long fileId, Long destId, String destName)
736 throws InsufficientPermissionsException, ObjectNotFoundException,
737 DuplicateNameException, GSSIOException, QuotaExceededException;
740 * Move the provided file to the specified destination.
742 * @param userId the ID of the current user
743 * @param ownerId the owner of the destination namespace
744 * @param fileId the IF of the provided file
745 * @param dest the path of the new file
746 * @throws InsufficientPermissionsException
747 * @throws ObjectNotFoundException if the user, file or destination was not
748 * found, with the exception message mentioning the precise problem
749 * @throws GSSIOException if there was an error while accessing the file contents
750 * @throws DuplicateNameException if the specified name already exists in
751 * the destination folder, as either a folder or file
752 * @throws QuotaExceededException
754 public void moveFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException, InsufficientPermissionsException, DuplicateNameException, GSSIOException, QuotaExceededException;
757 * move the provided file to the specified destination.
759 * @param userId the ID of the current user
760 * @param fileIds the IDs of the provided files
761 * @param destId the ID of the destination folder
762 * @throws InsufficientPermissionsException
763 * @throws ObjectNotFoundException if the user, file or destination was not
764 * found, with the exception message mentioning the precise problem
765 * @throws GSSIOException if there was an error while accessing the file contents
766 * @throws DuplicateNameException if the specified name already exists in
767 * the destination folder, as either a folder or file
768 * @throws QuotaExceededException
770 public void moveFiles(Long userId, List<Long> fileIds, Long destId)
771 throws InsufficientPermissionsException, ObjectNotFoundException,
772 DuplicateNameException, GSSIOException, QuotaExceededException;
775 * Returns a list of All deleted files of a user.
777 * @param userId the ID of the User
778 * * @return the list of deleted file header objects
779 * @throws ObjectNotFoundException if the user cannot be found
781 public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException;
784 * Returns a list of All deleted root folders of a user.
786 * @param userId the ID of the User
787 * * @return the list of deleted file header objects
788 * @throws ObjectNotFoundException if the user cannot be found
790 public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
793 * Empty Trash by deleting all marked as deleted files and folders
795 * @throws ObjectNotFoundException if something goes wrong in the delete process
796 * @throws InsufficientPermissionsException if something goes wrong in the delete process
798 public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
801 * Restores All Trashed Items by undeleting all marked as deleted files and folders
803 * @throws ObjectNotFoundException if something goes wrong in the delete process
804 * @throws InsufficientPermissionsException
806 public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
809 * Search the system for a user with the specified username.
810 * If no such user is found, the method returns null.
812 * @param username the username to search for
813 * @return the User object with the specified username
815 public User findUser(String username);
818 * Create a new user with the specified name, username and e-mail address.
820 * @param username the username of the new user
821 * @param name the full name of the new user
822 * @param mail the e-mail of the new user
823 * @return the newly-created User object
824 * @throws DuplicateNameException if a user with the same username already exists
825 * @throws ObjectNotFoundException if no username was provided
827 public User createUser(String username, String name, String mail)
828 throws DuplicateNameException, ObjectNotFoundException;
831 * Update the user with the specified username with the provoded name
832 * and e-mail address.
834 * @param username the username of the user
835 * @param name the modified full name of the user
836 * @param mail the modified e-mail of the user
837 * @return the updated User object
838 * @throws ObjectNotFoundException if no username was provided
840 public User updateUser(String username, String name, String mail) throws ObjectNotFoundException;
843 * Updates the authentication token for the specified user.
845 * @param userId the ID of the user whose token should be updated
846 * @return the updated user
847 * @throws ObjectNotFoundException if the user could not be found
849 public User updateUserToken(Long userId) throws ObjectNotFoundException;
852 * Updates the policy acceptance flag for the specified user.
854 * @param userId the ID of the user whose flag should be updated
855 * @param isAccepted the new value of the flag
856 * @return the updated user
857 * @throws ObjectNotFoundException if the user could not be found
859 public User updateUserPolicyAcceptance(Long userId, boolean isAccepted) throws ObjectNotFoundException;
862 * Invalidates the authentication token for the specified user.
864 * @param userId the ID of the user whose token should be updated
865 * @throws ObjectNotFoundException if the user could not be found
867 public void invalidateUserToken(Long userId) throws ObjectNotFoundException;
870 * Retrieve folder user and group permissions
872 * @param userId the ID of the user whose token should be updated
873 * @param folderId the ID of the folder
874 * @return the Set of permissions from requested folder
875 * @throws ObjectNotFoundException if the user or folder could not be found
876 * @throws InsufficientPermissionsException
878 public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId)
879 throws ObjectNotFoundException, InsufficientPermissionsException;
882 * update folder permissions
886 * @throws ObjectNotFoundException
887 * @throws InsufficientPermissionsException
889 public void setFolderPermissions(Long userId, Long folderId, Set<PermissionDTO> permissions)
890 throws ObjectNotFoundException, InsufficientPermissionsException;
893 * Retrieve file user and group permissions
895 * @param userId the ID of the user whose token should be updated
896 * @param fileId the ID of the folder
897 * @return the Set of permissions from requested folder
898 * @throws ObjectNotFoundException if the user or folder could not be found
899 * @throws InsufficientPermissionsException
901 public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId)
902 throws ObjectNotFoundException, InsufficientPermissionsException;
906 * update file permissions
911 * @throws ObjectNotFoundException
912 * @throws InsufficientPermissionsException
914 public void setFilePermissions(Long userId, Long fileId, Boolean readForAll,
915 Set<PermissionDTO> permissions)
916 throws ObjectNotFoundException, InsufficientPermissionsException;
919 * Returns a list of all shared root folders of a user.
921 * @param userId the ID of the User
922 * @return the list of shared root folders
923 * @throws ObjectNotFoundException if the user cannot be found
925 public List<FolderDTO> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
928 * Returns a list of all shared files of a user that are not
929 * inside other shared folders.
931 * @param userId the ID of the User
932 * @return the list of shared files
933 * @throws ObjectNotFoundException if the user cannot be found
935 public List<FileHeaderDTO> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
938 * Returns a list of all shared files of a user.
940 * @param userId the ID of the User
941 * @return the list of shared files
942 * @throws ObjectNotFoundException if the user cannot be found
944 public List<FileHeaderDTO> getSharedFiles(Long userId) throws ObjectNotFoundException;
947 * Returns a list of all shared folders of a user.
949 * @param userId the ID of the User
950 * @return the list of shared folders
951 * @throws ObjectNotFoundException if the user cannot be found
953 public List<FolderDTO> getSharedFolders(Long userId) throws ObjectNotFoundException;
956 * Returns a list of all shared root folders of a user that calling
957 * user has at least read permissions.
959 * @param ownerId the ID of the User
960 * @return the list of shared root folders
961 * @param callingUserId
963 * @throws ObjectNotFoundException if the user cannot be found
965 public List<FolderDTO> getSharedRootFolders(Long ownerId, Long callingUserId)
966 throws ObjectNotFoundException;
969 * Returns a list of all shared files of a user that calling user has
970 * at least read permissions..
972 * @param ownerId the ID of the User
973 * @return the list of shared files
974 * @param callingUserId
975 * @throws ObjectNotFoundException if the user cannot be found
977 public List<FileHeaderDTO> getSharedFiles(Long ownerId, Long callingUserId)
978 throws ObjectNotFoundException;
981 * Remove a user member from a group
983 * @param userId the ID of the User owning the group
984 * @param groupId the ID of the requested group
985 * @param memberId the ID of the member to be removed
987 * @throws ObjectNotFoundException if the user or group was not found, with
988 * the exception message mentioning the precise problem
989 * @throws InsufficientPermissionsException
991 public void removeMemberFromGroup(Long userId, Long groupId, Long memberId)
992 throws ObjectNotFoundException, InsufficientPermissionsException;
995 * Retrieves the list of users sharing files to user identified by user id
997 * @return the List of users sharing files to user
998 * @throws ObjectNotFoundException
1000 public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
1007 * @return list of files that match query
1008 * @throws ObjectNotFoundException if no user or query was specified
1010 public List<FileHeaderDTO> searchFiles(Long userId, String query) throws ObjectNotFoundException;
1013 * Creates a nonce for the specified user.
1015 * @param userId the ID of the user
1016 * @return the new nonce
1017 * @throws ObjectNotFoundException if the user could not be found
1019 public Nonce createNonce(Long userId) throws ObjectNotFoundException;
1022 * Find the nonce object for the specified encoded nonce, that should be
1023 * associated with the specified user.
1025 * @param nonce the issued nonce in Base64 encoding
1026 * @param userId the ID of the user for whom this nonce should have been issued
1027 * @return the retrieved nonce object
1028 * @throws ObjectNotFoundException if the nonce or user were not found
1030 public Nonce getNonce(String nonce, Long userId) throws ObjectNotFoundException;
1033 * Remove the specified nonce from the persistent store.
1035 * @param id the ID of the nonce
1036 * @throws ObjectNotFoundException if the specified nonce could not be found
1038 public void removeNonce(Long id) throws ObjectNotFoundException;
1041 * Activate the supplied nonce for the specified user.
1043 * @param userId the ID of the user
1044 * @param nonce the nonce to activate
1045 * @param nonceExpiryDate the expiry date of the nonce
1046 * @throws ObjectNotFoundException
1048 public void activateUserNonce(Long userId, String nonce, Date nonceExpiryDate) throws ObjectNotFoundException;
1051 * Retrieves user statistics.
1053 * @param userId the ID of the user
1054 * @return the statistics
1055 * @throws ObjectNotFoundException
1058 public StatsDTO getUserStatistics(Long userId) throws ObjectNotFoundException;
1061 * Retrieves file versions
1063 * @param userId the ID of the user
1064 * @param fileId the ID of the file
1065 * @return the list of filebodies
1066 * @throws ObjectNotFoundException
1067 * @throws InsufficientPermissionsException
1070 public List<FileBodyDTO> getVersions(Long userId, Long fileId)
1071 throws ObjectNotFoundException, InsufficientPermissionsException;
1074 * Restore the file contents to the specified version.
1076 * @param userId the ID of the user
1077 * @param fileId the ID of the file
1078 * @param version the version number of the desired file contents
1079 * @throws ObjectNotFoundException if the user or file was not
1080 * found, with the exception message mentioning the precise problem
1081 * @throws InsufficientPermissionsException if the user does not have the
1082 * appropriate privileges
1083 * @throws QuotaExceededException if the user quota limit would be exceeded
1084 * @throws GSSIOException if there was an error while accessing the file contents
1086 public void restoreVersion(Long userId, Long fileId, int version)
1087 throws ObjectNotFoundException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
1090 * Remove file version identified by bodyId
1092 * @param userId the ID of the user
1093 * @param fileId the ID of the file
1094 * @param bodyId the ID of the body
1096 * @throws ObjectNotFoundException
1097 * @throws InsufficientPermissionsException
1100 public void removeVersion(Long userId, Long fileId, Long bodyId)
1101 throws ObjectNotFoundException, InsufficientPermissionsException;
1104 * Removes all old file versions for specified file keeping only the current revision
1106 * @param userId the ID of the user
1107 * @param fileId the ID of the file
1109 * @throws ObjectNotFoundException
1110 * @throws InsufficientPermissionsException
1113 public void removeOldVersions(Long userId, Long fileId)
1114 throws ObjectNotFoundException, InsufficientPermissionsException;
1117 * Toggle between file being versioned or not.
1119 * @param userId the ID of the user
1120 * @param fileId the ID of the file
1121 * @param versioned the new value of the flag
1123 * @throws ObjectNotFoundException
1124 * @throws InsufficientPermissionsException
1127 public void toggleFileVersioning(Long userId, Long fileId, boolean versioned)
1128 throws ObjectNotFoundException, InsufficientPermissionsException;
1131 * It is used by the Solr mbean to rebuild the index.
1133 public void rebuildSolrIndex();
1136 * Creates a new file with the specified owner, parent folder and name. The
1137 * new file has the same permissions as its parent folder. The file contents
1138 * are already uploaded outside of externalAPI and the uploaded file is used as a parameter.
1140 * @param userId the ID of the current user
1141 * @param folderId the ID of the parent folder
1142 * @param name the name of the new file
1143 * @param mimeType the MIME type of the file
1144 * @param uploadedFile the uploaded file
1145 * @return The FileHeaderDTO created
1146 * @throws DuplicateNameException if the specified name already exists in
1147 * the parent folder, as either a folder or file
1148 * @throws ObjectNotFoundException if the user or parent folder was not
1149 * found, with the exception message mentioning the precise
1151 * @throws GSSIOException if there was an error while storing the file contents
1152 * @throws InsufficientPermissionsException
1153 * @throws QuotaExceededException
1155 public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, File uploadedFile)
1156 throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
1157 InsufficientPermissionsException, QuotaExceededException;
1160 * Create a new FileBody with the supplied uploaded file as contents and make it the current body
1163 * @param userId the ID of the current user
1164 * @param fileId the ID of the file header object
1165 * @param mimeType the content type of the file
1166 * @param uploadedFile the already uploadedFile
1167 * @return The FileHeaderDTO updated
1168 * @throws ObjectNotFoundException if the user or file was not found, with
1169 * the exception message mentioning the precise problem
1170 * @throws GSSIOException when an IO exception occurs
1171 * @throws InsufficientPermissionsException
1172 * @throws QuotaExceededException
1174 public FileHeaderDTO updateFileContents(Long userId, Long fileId, String mimeType,
1175 File uploadedFile) throws ObjectNotFoundException, GSSIOException,
1176 InsufficientPermissionsException, QuotaExceededException;
1179 * Create a file based on inputstream without using transaction.
1184 * @throws IOException
1185 * @throws ObjectNotFoundException
1187 @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
1188 public File uploadFile(InputStream stream, Long userId)
1189 throws IOException, ObjectNotFoundException;
1191 public void createFileUploadProgress(Long userId, String filename,
1192 Long bytesTransfered, Long fileSize) throws ObjectNotFoundException;
1194 public FileUploadStatus getFileUploadStatus(Long userId, String fileName);
1196 public void removeFileUploadProgress(Long userId, String filename)
1197 throws ObjectNotFoundException;
1200 * Fetch the file body with the specified version number.
1202 * @param userId the ID of the current user
1203 * @param fileId the ID of the file header
1204 * @param version the version number
1205 * @return the file body
1206 * @throws ObjectNotFoundException if the user file or version
1208 * @throws InsufficientPermissionsException if the user does not
1209 * have enough privileges for reading this file
1211 public FileBodyDTO getFileVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException;
1214 * Search the system for a user with the specified email address.
1215 * If no such user is found, the method returns null.
1217 public User findUserByEmail(String email);
1220 * Update the user with the values from the supplied object.
1222 public void updateUser(User user);
1225 * Update accounting information for given user.
1227 * @param user The user to update
1228 * @param date Date of transaction
1229 * @param bandwidthDiff Bandwidth used; positive for addition,
1230 * negative for subtraction (e.g. to rollback)
1232 public void updateAccounting(User user, Date date, long bandwidthDiff);
1235 * Check if the user with the specified ID has permission to read the
1236 * folder with the supplied ID.
1238 public boolean canReadFolder(Long userId, Long folderId) throws ObjectNotFoundException;