2 * Copyright 2007, 2008, 2009, 2010 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.InvitationUsedException;
25 import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
26 import gr.ebs.gss.client.exceptions.QuotaExceededException;
27 import gr.ebs.gss.server.domain.FileUploadStatus;
28 import gr.ebs.gss.server.domain.Invitation;
29 import gr.ebs.gss.server.domain.Nonce;
30 import gr.ebs.gss.server.domain.User;
31 import gr.ebs.gss.server.domain.UserClass;
32 import gr.ebs.gss.server.domain.dto.FileBodyDTO;
33 import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
34 import gr.ebs.gss.server.domain.dto.FolderDTO;
35 import gr.ebs.gss.server.domain.dto.GroupDTO;
36 import gr.ebs.gss.server.domain.dto.PermissionDTO;
37 import gr.ebs.gss.server.domain.dto.StatsDTO;
38 import gr.ebs.gss.server.domain.dto.UserDTO;
41 import java.io.IOException;
42 import java.io.InputStream;
43 import java.util.Date;
44 import java.util.List;
47 import javax.ejb.Local;
48 import javax.ejb.TransactionAttribute;
49 import javax.ejb.TransactionAttributeType;
52 * The External API for GSS clients.
57 public interface ExternalAPI {
60 * Retrieves the root folder for the specified user. The caller must ensure
61 * that the userId exists.
65 * @throws ObjectNotFoundException if no Folder or user was found
67 public FolderDTO getRootFolder(Long userId) throws ObjectNotFoundException;
70 * Retrieve the folder with the specified ID.
72 * @param userId the ID of the current user
73 * @param folderId the ID of the folder to retrieve
74 * @return the folder found
75 * @throws ObjectNotFoundException if the folder or the user was not found
76 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
78 public FolderDTO getFolder(Long userId, Long folderId) throws ObjectNotFoundException,
79 InsufficientPermissionsException;
82 * Returns the user with the specified ID.
84 * @param userId The ID of the User to be found
85 * @return The User object
86 * @throws ObjectNotFoundException if the user cannot be found
88 public User getUser(Long userId) throws ObjectNotFoundException;
91 * Returns the user with the specified ID.
93 * @param userId The ID of the User to be found
94 * @return The User object
95 * @throws ObjectNotFoundException if the user cannot be found
97 public UserDTO getUserDTO(Long userId) throws ObjectNotFoundException;
100 * Returns the group with the specified ID.
102 * @param groupId The ID of the Group to be found
103 * @return The Group object
104 * @throws ObjectNotFoundException if the group cannot be found
106 public GroupDTO getGroup(Long groupId) throws ObjectNotFoundException;
109 * Returns the group with the specified name that belongs to the
112 * @param userId the ID of the user
113 * @param name the name of the group
114 * @return The Group object
115 * @throws ObjectNotFoundException if the group cannot be found
117 public GroupDTO getGroup(Long userId, String name) throws ObjectNotFoundException;
120 * Retrieve the list of groups for a particular user.
122 * @param userId the ID of the User
123 * @return a List of Groups that belong to the specified User
124 * @throws ObjectNotFoundException if the user was not found
126 public List<GroupDTO> getGroups(Long userId) throws ObjectNotFoundException;
129 * Returns a list of files contained in the folder specified by its id.
131 * @param userId the ID of the User
132 * @param folderId the ID of the folder containing the files
133 * @param ignoreDeleted
134 * @return the list of file header objects
135 * @throws ObjectNotFoundException if the user or the folder cannot be found
136 * @throws InsufficientPermissionsException
138 public List<FileHeaderDTO> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException,
139 InsufficientPermissionsException;
142 * Returns a list of users for the specified group
144 * @param userId the ID of the User
145 * @param groupId the ID of the requested group
146 * @return List<UserDTO>
147 * @throws ObjectNotFoundException if the user or group was not found, with
148 * the exception message mentioning the precise problem
150 public List<UserDTO> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
153 * Returns a list of users matching the specified username
155 * @param username the username of the User
156 * @return List<UserDTO>
158 public List<UserDTO> getUsersByUserNameLike(String username);
161 * Creates a new folder with the specified owner, parent folder and name.
162 * New folder has the same permissions as its parent
167 * @return the new folder
168 * @throws DuplicateNameException if the specified name already exists in
169 * the parent folder, as either a folder or file
170 * @throws ObjectNotFoundException if the user or parent folder was not
171 * found, with the exception message mentioning the precise
173 * @throws InsufficientPermissionsException
175 public FolderDTO createFolder(Long userId, Long parentId, String name) throws DuplicateNameException,
176 ObjectNotFoundException, InsufficientPermissionsException;
179 * Deletes the specified folder, if the specified user has the appropriate
182 * @param userId the ID of the current user
183 * @param folderId the ID of the folder to delete
184 * @throws InsufficientPermissionsException if the user does not have the
185 * appropriate privileges
186 * @throws ObjectNotFoundException if the user or folder was not found, with
187 * the exception message mentioning the precise problem
189 public void deleteFolder(Long userId, Long folderId)
190 throws InsufficientPermissionsException, ObjectNotFoundException;
193 * Retrieve the subfolders of the specified folder.
195 * @param userId the ID of the current user
196 * @param folderId the ID of the folder to retrieve
197 * @return the list of subfolders found
198 * @throws ObjectNotFoundException if the folder or user was not found
199 * @throws InsufficientPermissionsException
201 public List<FolderDTO> getSubfolders(Long userId, Long folderId)
202 throws ObjectNotFoundException, InsufficientPermissionsException;
205 * Retrieve the folder with the specified ID with subfolders.
207 * @param userId the ID of the current user
208 * @param folderId the ID of the folder to retrieve
209 * @return the folder found
210 * @throws ObjectNotFoundException if the folder or the user was not found
211 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
213 public FolderDTO getFolderWithSubfolders(Long userId, Long folderId)
214 throws ObjectNotFoundException, InsufficientPermissionsException;
217 * Retrieve the folder with the specified ID with subfolders.
219 * @param userId the ID of the current user
220 * @param callingUserId the ID of the user requesting this operation
221 * @param folderId the ID of the folder to retrieve
222 * @return the folder found
223 * @throws ObjectNotFoundException if the folder or the user was not found
224 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
226 public FolderDTO getFolderWithSubfolders(Long userId, Long callingUserId, Long folderId)
227 throws ObjectNotFoundException, InsufficientPermissionsException;
229 * Retrieve the subfolders of the specified folder that are shared to others.
231 * @param userId the ID of the current user
232 * @param folderId the ID of the folder to retrieve
233 * @return the list of subfolders found
234 * @throws ObjectNotFoundException if the folder or user was not found
236 public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
239 * Retrieve the subfolders of the specified folder that are shared to others.
241 * @param userId the ID of the current user
242 * @param callingUserId the id of the user requesting this operation
243 * @param folderId the ID of the folder to retrieve
244 * @return the list of subfolders found
245 * @throws ObjectNotFoundException if the folder or user was not found
247 public List<FolderDTO> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException;
249 * Modifies the specified folder if the specified user has the appropriate
252 * @param userId the ID of the current user
253 * @param folderId the ID of the folder to retrieve
256 * @return the updated folder
257 * @throws InsufficientPermissionsException if the user does not have the
258 * appropriate privileges
259 * @throws ObjectNotFoundException if the user or folder was not found, with
260 * the exception message mentioning the precise problem
261 * @throws DuplicateNameException if the specified name already exists in
262 * the parent folder, as either a folder or file
264 public FolderDTO updateFolder(Long userId, Long folderId, String folderName, Set<PermissionDTO> permissions)
265 throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
268 * Adds a user to the specified group
270 * @param userId the ID of the current user
271 * @param groupId the id of the new group
272 * @param userToAddId the id of the user to add
273 * @throws DuplicateNameException if the user already exists in group
274 * @throws ObjectNotFoundException if the user or group was not found, with
275 * the exception message mentioning the precise problem
276 * @throws InsufficientPermissionsException
278 public void addUserToGroup(Long userId, Long groupId, Long userToAddId)
279 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
282 * Creates a new group with the specified owner and name.
284 * @param userId the ID of the current user
285 * @param name the name of the new group
286 * @throws DuplicateNameException if the new group name already exists
287 * @throws ObjectNotFoundException if the user or group was not found, with
288 * the exception message mentioning the precise problem
290 public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
293 * Deletes the specified group in the specified user's namespace.
295 * @param userId the ID of the current user
296 * @param groupId the ID of the group to delete
297 * @throws ObjectNotFoundException if the user or group was not found, with
298 * the exception message mentioning the precise problem
299 * @throws InsufficientPermissionsException
301 public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
304 * Creates a new file with the specified owner, parent folder and name. The
305 * new file has the same permissions as its parent folder. The file contents
306 * are read from the input stream to a new File object.
308 * @param userId the ID of the current user
309 * @param folderId the ID of the parent folder
310 * @param name the name of the new file
311 * @param mimeType the MIME type of the file
312 * @param stream the input stream with the file contents
313 * @return The FileHeaderDTO created
314 * @throws DuplicateNameException if the specified name already exists in
315 * the parent folder, as either a folder or file
316 * @throws ObjectNotFoundException if the user or parent folder was not
317 * found, with the exception message mentioning the precise
319 * @throws GSSIOException if there was an error while storing the file contents
320 * @throws InsufficientPermissionsException
321 * @throws QuotaExceededException
323 public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType,
324 InputStream stream) throws DuplicateNameException, ObjectNotFoundException,
325 GSSIOException, InsufficientPermissionsException, QuotaExceededException;
328 * Deletes the specified file, provided the specified user has
329 * the necessary permissions.
331 * @param userId the ID of the current user
332 * @param fileId the ID of the file to delete
333 * @throws ObjectNotFoundException if the user or file was not found, with
334 * the exception message mentioning the precise problem
335 * @throws InsufficientPermissionsException if the user does not have the
336 * appropriate privileges
338 public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
341 * Deletes the specified file in the specified user's namespace.
343 * @param userId the ID of the current user
344 * @param fileIds the IDs of the files to delete
345 * @throws ObjectNotFoundException if the user or file was not found, with
346 * the exception message mentioning the precise problem
347 * @throws InsufficientPermissionsException if the user does not have the
348 * appropriate privileges
350 public void deleteFiles(Long userId, List<Long> fileIds)
351 throws ObjectNotFoundException, InsufficientPermissionsException;
354 * Creates a new tag for the specified user and file.
356 * @param userId the creator of the tag
357 * @param fileHeaderId the file that is tagged
359 * @throws ObjectNotFoundException if the user or the file was not found
361 public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
364 * Returns all tags defined by the specified user
367 * @return Set<String>
368 * @throws ObjectNotFoundException if the user was null
370 public Set<String> getUserTags(final Long userId) throws ObjectNotFoundException;
373 * Updates the attributes of the specified file.
378 * @param tagSet a String that contains tags separated by comma
379 * @param modificationDate the modification date
380 * @param versioned the new value of the versioned flag
383 * @throws DuplicateNameException
384 * @throws ObjectNotFoundException
385 * @throws InsufficientPermissionsException
387 public void updateFile(Long userId, Long fileId, String name, String tagSet,
388 Date modificationDate, Boolean versioned, Boolean readForAll,
389 Set<PermissionDTO> permissions)
390 throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
393 * Retrieve the contents of the current body for the file
394 * with the specified FileHeader ID. The file contents
395 * are provided as an InputStream from which the caller can
396 * retrieve the raw bytes.
398 * @param userId the ID of the current user
399 * @param fileId the ID of the file to retrieve
400 * @return an InputStream from the current file body contents
401 * @throws ObjectNotFoundException if the file or the user was not found
402 * @throws InsufficientPermissionsException if the user does not have the
403 * appropriate privileges
405 public InputStream getFileContents(Long userId, Long fileId)
406 throws ObjectNotFoundException, InsufficientPermissionsException;
409 * Retrieve the contents of the body identified by bodyId for the file
410 * with the specified FileHeader ID. The file contents
411 * are provided as an InputStream from which the caller can
412 * retrieve the raw bytes.
414 * @param userId the ID of the current user
415 * @param fileId the ID of the file to retrieve
416 * @param bodyId the body ID
417 * @return an InputStream from the current file body contents
418 * @throws ObjectNotFoundException if the file or the user was not found
419 * @throws InsufficientPermissionsException if the user does not have the
420 * appropriate privileges
422 public InputStream getFileContents(Long userId, Long fileId, Long bodyId)
423 throws ObjectNotFoundException, InsufficientPermissionsException;
426 * Retrieve the file with the specified ID.
428 * @param userId the ID of the current user
429 * @param fileId the ID of the file to retrieve
430 * @return the file found
431 * @throws ObjectNotFoundException if the file or the user was not found, with
432 * the exception message mentioning the precise problem
433 * @throws InsufficientPermissionsException
435 public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException,
436 InsufficientPermissionsException;
439 * Retrieve the filebody with the specified ID.
441 * @param userId the ID of the current user
442 * @param fileId the ID of the file to retrieve
443 * @param bodyId the ID of the body
444 * @return the file found
445 * @throws ObjectNotFoundException if the file or the user was not found, with
446 * the exception message mentioning the precise problem
447 * @throws InsufficientPermissionsException
449 public FileBodyDTO getFileBody(Long userId, Long fileId, Long bodyId)
450 throws ObjectNotFoundException, InsufficientPermissionsException;
453 * Get the resource (file or folder) at the specified path in
454 * the specified user's namespace. The returned object will be of type
455 * FileHeaderDTO or FolderDTO.<p><strong>Note:</strong> this method does not
456 * receive the current user as a parameter, therefore it is unable to perform
457 * the necessary permission checks and should <strong>NOT</strong> be directly
458 * exposed to remote clients. It is the caller's responsibility to verify that
459 * the calling user has the required privileges for performing any subsequent
460 * action on the resource through one of the other ExternalAPI methods.
462 * @param ownerId the ID of the user owning the namespace
463 * @param path the absolute path in the user's namespace
464 * @param ignoreDeleted if true, resources that have been moved to the trash
466 * @throws ObjectNotFoundException if the user or resource was not found, with
467 * the exception message mentioning the precise problem
468 * @return the resource found
470 public Object getResourceAtPath(Long ownerId, String path, boolean ignoreDeleted)
471 throws ObjectNotFoundException;
474 * Copy the provided file to the specified destination.
476 * @param userId the ID of the current user
477 * @param fileId the IF of the provided file
478 * @param dest the path of the new resource
479 * @throws ObjectNotFoundException if the user, file or destination was not
480 * found, with the exception message mentioning the precise problem
481 * @throws DuplicateNameException if the specified name already exists in
482 * the destination folder, as either a folder or file
483 * @throws GSSIOException if there was an error while accessing the file contents
484 * @throws InsufficientPermissionsException
485 * @throws QuotaExceededException
487 public void copyFile(Long userId, Long fileId, String dest) throws ObjectNotFoundException,
488 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
491 * Copy the provided file to the specified destination.
493 * @param userId the ID of the current user
494 * @param ownerId the ID of the owner of the destination namespace
495 * @param fileId the IF of the provided file
496 * @param dest the path of the new resource
497 * @throws ObjectNotFoundException if the user, file or destination was not
498 * found, with the exception message mentioning the precise problem
499 * @throws DuplicateNameException if the specified name already exists in
500 * the destination folder, as either a folder or file
501 * @throws GSSIOException if there was an error while accessing the file contents
502 * @throws InsufficientPermissionsException
503 * @throws QuotaExceededException
505 public void copyFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException,
506 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
509 * Copy the provided file to the specified destination.
511 * @param userId the ID of the current user
512 * @param fileIds the IDs of the provided files
513 * @param destId the ID of the destination folder
514 * @throws ObjectNotFoundException if the user, file or destination was not
515 * found, with the exception message mentioning the precise problem
516 * @throws GSSIOException if there was an error while accessing the file contents
517 * @throws DuplicateNameException if the specified name already exists in
518 * the destination folder, as either a folder or file
519 * @throws InsufficientPermissionsException
520 * @throws QuotaExceededException
522 public void copyFiles(Long userId, List<Long> fileIds, Long destId)
523 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
524 InsufficientPermissionsException, QuotaExceededException;
527 * Copy the provided file to the specified destination.
529 * @param userId the ID of the current user
530 * @param fileId the IF of the provided file
531 * @param destId the ID of the destination folder
532 * @param destName the name of the new file
533 * @throws ObjectNotFoundException if the user, file or destination was not
534 * found, with the exception message mentioning the precise problem
535 * @throws GSSIOException if there was an error while accessing the file contents
536 * @throws DuplicateNameException if the specified name already exists in
537 * the destination folder, as either a folder or file
538 * @throws InsufficientPermissionsException
539 * @throws QuotaExceededException
541 public void copyFile(Long userId, Long fileId, Long destId, String destName)
542 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
543 InsufficientPermissionsException, QuotaExceededException;
546 * Copy the provided folder to the specified destination.
548 * @param userId the ID of the current user
549 * @param folderId the IF of the provided folder
550 * @param dest the path of the new folder
551 * @throws ObjectNotFoundException if the user, folder or destination was not
552 * found, with the exception message mentioning the precise problem
553 * @throws DuplicateNameException if the specified name already exists in
554 * the destination folder, as either a folder or file
555 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
556 * appropriate privileges
558 public void copyFolder(Long userId, Long folderId, String dest) throws ObjectNotFoundException,
559 DuplicateNameException, InsufficientPermissionsException;
562 * Copy the provided folder to the specified destination.
564 * @param userId the ID of the current user
565 * @param folderId the IF of the provided folder
566 * @param destId the ID of the destination folder
567 * @param destName the name of the new folder
568 * @throws ObjectNotFoundException if the user, folder or destination was not
569 * found, with the exception message mentioning the precise problem
570 * @throws DuplicateNameException if the specified name already exists in
571 * the destination folder, as either a folder or file
572 * @throws InsufficientPermissionsException InsufficientPermissionsException
573 * if the user does not have the appropriate privileges
575 public void copyFolder(Long userId, Long folderId, Long destId, String destName)
576 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
579 * Copy the provided folder and all its subfolders and files to the specified destination.
581 * @param userId the ID of the current user
582 * @param ownerId the ID of the owner of the destination namespace
583 * @param folderId the IF of the provided folder
584 * @param dest the path of the new folder
585 * @throws ObjectNotFoundException if the user, folder or destination was not
586 * found, with the exception message mentioning the precise problem
587 * @throws DuplicateNameException if the specified name already exists in
588 * the destination folder, as either a folder or file
589 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
590 * appropriate privileges
591 * @throws QuotaExceededException if the user quota limit would be exceeded
592 * @throws GSSIOException if there was an error while accessing the file contents
594 public void copyFolderStructureToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
595 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
598 * Copy the provided folder and all its subfolders and files to the specified destination.
600 * @param userId the ID of the current user
601 * @param folderId the IF of the provided folder
602 * @param destId the ID of the destination folder
603 * @param destName the name of the new folder
604 * @throws ObjectNotFoundException if the user, folder or destination was not
605 * found, with the exception message mentioning the precise problem
606 * @throws DuplicateNameException if the specified name already exists in
607 * the destination folder, as either a folder or file
608 * @throws InsufficientPermissionsException InsufficientPermissionsException
609 * if the user does not have the appropriate privileges
610 * @throws GSSIOException if there was an error while accessing the file contents
611 * @throws QuotaExceededException if the user quota limit would be exceeded
613 public void copyFolderStructure(Long userId, Long folderId, Long destId, String destName)
614 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
615 GSSIOException, QuotaExceededException;
618 * Marks the specified file as deleted in the specified user's namespace.
620 * @param userId the ID of the current user
621 * @param fileId the ID of the file to delete
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
627 public void moveFileToTrash(Long userId, Long fileId) throws ObjectNotFoundException,
628 InsufficientPermissionsException;
631 * Marks the specified deleted file as undeleted in the specified user's namespace.
633 * @param userId the ID of the current user
634 * @param fileId the ID of the file to undelete
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
641 public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
644 * Marks the specified files as deleted in the specified user's namespace.
646 * @param userId the ID of the current user
647 * @param fileIds the IDs of the file to delete
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 moveFilesToTrash(Long userId, List<Long> fileIds)
654 throws ObjectNotFoundException, InsufficientPermissionsException;
657 * Marks the specified deleted files as undeleted in the specified user's namespace.
659 * @param userId the ID of the current user
660 * @param fileIds the IDs of the file to undelete
661 * @throws ObjectNotFoundException if the user or file was not found, with
662 * the exception message mentioning the precise problem
663 * @throws InsufficientPermissionsException if the user does not have the
664 * appropriate privileges
666 public void removeFilesFromTrash(Long userId, List<Long> fileIds) throws ObjectNotFoundException, InsufficientPermissionsException;
669 * Marks the specified folder as deleted in the specified user's namespace.
671 * @param userId the ID of the current user
672 * @param folderId the ID of the folder to delete
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
678 public void moveFolderToTrash(Long userId, Long folderId)
679 throws ObjectNotFoundException, InsufficientPermissionsException;
682 * Marks the specified deleted folder as undeleted in the specified user's namespace.
684 * @param userId the ID of the current user
685 * @param folderId the ID of the folder to undelete
686 * @throws ObjectNotFoundException if the user or file was not found, with
687 * the exception message mentioning the precise problem
688 * @throws InsufficientPermissionsException if the user does not have the
689 * appropriate privileges
692 public void removeFolderFromTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
695 * Move the provided folder and all its subfolders and files to the specified destination.
697 * @param userId the ID of the current user
698 * @param folderId the IF of the provided folder
699 * @param destId the ID of the destination folder
700 * @param destName the name of the new folder
701 * @throws ObjectNotFoundException if the user, folder or destination was not
702 * found, with the exception message mentioning the precise problem
703 * @throws DuplicateNameException if the specified name already exists in
704 * the destination folder, as either a folder or file
705 * @throws InsufficientPermissionsException if the user does not have the
706 * appropriate privileges
707 * @throws GSSIOException
708 * @throws QuotaExceededException
710 public void moveFolder(Long userId, Long folderId, Long destId, String destName)
711 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
712 GSSIOException, QuotaExceededException;
715 * Move the provided folder and all its subfolders and files to the specified destination.
717 * @param userId the ID of the current user
718 * @param ownerId the owner of the destination namespace
719 * @param folderId the IF of the provided folder
720 * @param dest the path of the new folder
721 * @throws ObjectNotFoundException if the user, folder or destination was not
722 * found, with the exception message mentioning the precise problem
723 * @throws DuplicateNameException if the specified name already exists in
724 * the destination folder, as either a folder or file
725 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
726 * appropriate privileges
727 * @throws GSSIOException
728 * @throws QuotaExceededException
730 public void moveFolderToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
731 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
734 * Move the provided file to the specified destination.
736 * @param userId the ID of the current user
737 * @param fileId the IF of the provided file
738 * @param destId the ID of the destination folder
739 * @param destName the name of the new file
740 * @throws InsufficientPermissionsException
741 * @throws ObjectNotFoundException if the user, file or destination was not
742 * found, with the exception message mentioning the precise problem
743 * @throws GSSIOException if there was an error while accessing the file contents
744 * @throws DuplicateNameException if the specified name already exists in
745 * the destination folder, as either a folder or file
746 * @throws QuotaExceededException
748 public void moveFile(Long userId, Long fileId, Long destId, String destName)
749 throws InsufficientPermissionsException, ObjectNotFoundException,
750 DuplicateNameException, GSSIOException, QuotaExceededException;
753 * Move the provided file to the specified destination.
755 * @param userId the ID of the current user
756 * @param ownerId the owner of the destination namespace
757 * @param fileId the IF of the provided file
758 * @param dest the path of the new file
759 * @throws InsufficientPermissionsException
760 * @throws ObjectNotFoundException if the user, file or destination was not
761 * found, with the exception message mentioning the precise problem
762 * @throws GSSIOException if there was an error while accessing the file contents
763 * @throws DuplicateNameException if the specified name already exists in
764 * the destination folder, as either a folder or file
765 * @throws QuotaExceededException
767 public void moveFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException, InsufficientPermissionsException, DuplicateNameException, GSSIOException, QuotaExceededException;
770 * move the provided file to the specified destination.
772 * @param userId the ID of the current user
773 * @param fileIds the IDs of the provided files
774 * @param destId the ID of the destination folder
775 * @throws InsufficientPermissionsException
776 * @throws ObjectNotFoundException if the user, file or destination was not
777 * found, with the exception message mentioning the precise problem
778 * @throws GSSIOException if there was an error while accessing the file contents
779 * @throws DuplicateNameException if the specified name already exists in
780 * the destination folder, as either a folder or file
781 * @throws QuotaExceededException
783 public void moveFiles(Long userId, List<Long> fileIds, Long destId)
784 throws InsufficientPermissionsException, ObjectNotFoundException,
785 DuplicateNameException, GSSIOException, QuotaExceededException;
788 * Returns a list of All deleted files of a user.
790 * @param userId the ID of the User
791 * * @return the list of deleted file header objects
792 * @throws ObjectNotFoundException if the user cannot be found
794 public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException;
797 * Returns a list of All deleted root folders of a user.
799 * @param userId the ID of the User
800 * * @return the list of deleted file header objects
801 * @throws ObjectNotFoundException if the user cannot be found
803 public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
806 * Empty Trash by deleting all marked as deleted files and folders
808 * @throws ObjectNotFoundException if something goes wrong in the delete process
809 * @throws InsufficientPermissionsException if something goes wrong in the delete process
811 public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
814 * Restores All Trashed Items by undeleting all marked as deleted files and folders
816 * @throws ObjectNotFoundException if something goes wrong in the delete process
817 * @throws InsufficientPermissionsException
819 public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
822 * Search the system for a user with the specified username.
823 * If no such user is found, the method returns null.
825 * @param username the username to search for
826 * @return the User object with the specified username
828 public User findUser(String username);
831 * Create a new user with the specified name, username and e-mail address.
833 * @param username the username of the new user
834 * @param name the name of the new user
835 * @param mail the e-mail of the new user
836 * @param idp the IdP of the new user
837 * @param idpid the IdP identifier of the new user
838 * @return the newly-created User object
839 * @throws DuplicateNameException if a user with the same username already exists
840 * @throws ObjectNotFoundException if no username was provided
842 public User createUser(String username, String name, String mail, String idp, String idpid)
843 throws DuplicateNameException, ObjectNotFoundException;
846 * Updates the authentication token for the specified user.
848 * @param userId the ID of the user whose token should be updated
849 * @return the updated user
850 * @throws ObjectNotFoundException if the user could not be found
852 public User updateUserToken(Long userId) throws ObjectNotFoundException;
855 * Updates the policy acceptance flag for the specified user.
857 * @param userId the ID of the user whose flag should be updated
858 * @param isAccepted the new value of the flag
859 * @return the updated user
860 * @throws ObjectNotFoundException if the user could not be found
862 public User updateUserPolicyAcceptance(Long userId, boolean isAccepted) throws ObjectNotFoundException;
865 * Invalidates the authentication token for the specified user.
867 * @param userId the ID of the user whose token should be updated
868 * @throws ObjectNotFoundException if the user could not be found
870 public void invalidateUserToken(Long userId) throws ObjectNotFoundException;
873 * Retrieve folder user and group permissions
875 * @param userId the ID of the user whose token should be updated
876 * @param folderId the ID of the folder
877 * @return the Set of permissions from requested folder
878 * @throws ObjectNotFoundException if the user or folder could not be found
879 * @throws InsufficientPermissionsException
881 public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId)
882 throws ObjectNotFoundException, InsufficientPermissionsException;
885 * Retrieve file user and group permissions
887 * @param userId the ID of the user whose token should be updated
888 * @param fileId the ID of the folder
889 * @return the Set of permissions from requested folder
890 * @throws ObjectNotFoundException if the user or folder could not be found
891 * @throws InsufficientPermissionsException
893 public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId)
894 throws ObjectNotFoundException, InsufficientPermissionsException;
897 * Returns a list of all shared root folders of a user.
899 * @param userId the ID of the User
900 * @return the list of shared root folders
901 * @throws ObjectNotFoundException if the user cannot be found
903 public List<FolderDTO> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
906 * Returns a list of all shared files of a user that are not
907 * inside other shared folders.
909 * @param userId the ID of the User
910 * @return the list of shared files
911 * @throws ObjectNotFoundException if the user cannot be found
913 public List<FileHeaderDTO> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
916 * Returns a list of all shared files of a user.
918 * @param userId the ID of the User
919 * @return the list of shared files
920 * @throws ObjectNotFoundException if the user cannot be found
922 public List<FileHeaderDTO> getSharedFiles(Long userId) throws ObjectNotFoundException;
925 * Returns a list of all shared folders of a user.
927 * @param userId the ID of the User
928 * @return the list of shared folders
929 * @throws ObjectNotFoundException if the user cannot be found
931 public List<FolderDTO> getSharedFolders(Long userId) throws ObjectNotFoundException;
934 * Returns a list of all shared root folders of a user that calling
935 * user has at least read permissions.
937 * @param ownerId the ID of the User
938 * @return the list of shared root folders
939 * @param callingUserId
941 * @throws ObjectNotFoundException if the user cannot be found
943 public List<FolderDTO> getSharedRootFolders(Long ownerId, Long callingUserId)
944 throws ObjectNotFoundException;
947 * Returns a list of all shared files of a user that calling user has
948 * at least read permissions..
950 * @param ownerId the ID of the User
951 * @return the list of shared files
952 * @param callingUserId
953 * @throws ObjectNotFoundException if the user cannot be found
955 public List<FileHeaderDTO> getSharedFiles(Long ownerId, Long callingUserId)
956 throws ObjectNotFoundException;
959 * Remove a user member from a group
961 * @param userId the ID of the User owning the group
962 * @param groupId the ID of the requested group
963 * @param memberId the ID of the member to be removed
965 * @throws ObjectNotFoundException if the user or group was not found, with
966 * the exception message mentioning the precise problem
967 * @throws InsufficientPermissionsException
969 public void removeMemberFromGroup(Long userId, Long groupId, Long memberId)
970 throws ObjectNotFoundException, InsufficientPermissionsException;
973 * Retrieves the list of users sharing files to user identified by user id
975 * @return the List of users sharing files to user
976 * @throws ObjectNotFoundException
978 public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
985 * @return list of files that match query
986 * @throws ObjectNotFoundException if no user or query was specified
988 public List<FileHeaderDTO> searchFiles(Long userId, String query) throws ObjectNotFoundException;
991 * Creates a nonce for the specified user.
993 * @param userId the ID of the user
994 * @return the new nonce
995 * @throws ObjectNotFoundException if the user could not be found
997 public Nonce createNonce(Long userId) throws ObjectNotFoundException;
1000 * Find the nonce object for the specified encoded nonce, that should be
1001 * associated with the specified user.
1003 * @param nonce the issued nonce in Base64 encoding
1004 * @param userId the ID of the user for whom this nonce should have been issued
1005 * @return the retrieved nonce object
1006 * @throws ObjectNotFoundException if the nonce or user were not found
1008 public Nonce getNonce(String nonce, Long userId) throws ObjectNotFoundException;
1011 * Remove the specified nonce from the persistent store.
1013 * @param id the ID of the nonce
1014 * @throws ObjectNotFoundException if the specified nonce could not be found
1016 public void removeNonce(Long id) throws ObjectNotFoundException;
1019 * Activate the supplied nonce for the specified user.
1021 * @param userId the ID of the user
1022 * @param nonce the nonce to activate
1023 * @param nonceExpiryDate the expiry date of the nonce
1024 * @throws ObjectNotFoundException
1026 public void activateUserNonce(Long userId, String nonce, Date nonceExpiryDate) throws ObjectNotFoundException;
1029 * Retrieves user statistics.
1031 * @param userId the ID of the user
1032 * @return the statistics
1033 * @throws ObjectNotFoundException
1036 public StatsDTO getUserStatistics(Long userId) throws ObjectNotFoundException;
1039 * Retrieves file versions
1041 * @param userId the ID of the user
1042 * @param fileId the ID of the file
1043 * @return the list of filebodies
1044 * @throws ObjectNotFoundException
1045 * @throws InsufficientPermissionsException
1048 public List<FileBodyDTO> getVersions(Long userId, Long fileId)
1049 throws ObjectNotFoundException, InsufficientPermissionsException;
1052 * Restore the file contents to the specified version.
1054 * @param userId the ID of the user
1055 * @param fileId the ID of the file
1056 * @param version the version number of the desired file contents
1057 * @throws ObjectNotFoundException if the user or file was not
1058 * found, with the exception message mentioning the precise problem
1059 * @throws InsufficientPermissionsException if the user does not have the
1060 * appropriate privileges
1061 * @throws QuotaExceededException if the user quota limit would be exceeded
1062 * @throws GSSIOException if there was an error while accessing the file contents
1064 public void restoreVersion(Long userId, Long fileId, int version)
1065 throws ObjectNotFoundException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
1068 * Remove file version identified by bodyId
1070 * @param userId the ID of the user
1071 * @param fileId the ID of the file
1072 * @param bodyId the ID of the body
1074 * @throws ObjectNotFoundException
1075 * @throws InsufficientPermissionsException
1078 public void removeVersion(Long userId, Long fileId, Long bodyId)
1079 throws ObjectNotFoundException, InsufficientPermissionsException;
1082 * Removes all old file versions for specified file keeping only the current revision
1084 * @param userId the ID of the user
1085 * @param fileId the ID of the file
1087 * @throws ObjectNotFoundException
1088 * @throws InsufficientPermissionsException
1091 public void removeOldVersions(Long userId, Long fileId)
1092 throws ObjectNotFoundException, InsufficientPermissionsException;
1095 * It is used by the Solr mbean to rebuild the index.
1097 public void rebuildSolrIndex();
1100 * Creates a new file with the specified owner, parent folder and name. The
1101 * new file has the same permissions as its parent folder. The file contents
1102 * are already uploaded outside of externalAPI and the uploaded file is used as a parameter.
1104 * @param userId the ID of the current user
1105 * @param folderId the ID of the parent folder
1106 * @param name the name of the new file
1107 * @param mimeType the MIME type of the file
1108 * @param fileSize the uploaded file size
1109 * @param filePath the uploaded file full path
1110 * @return The FileHeaderDTO created
1111 * @throws DuplicateNameException if the specified name already exists in
1112 * the parent folder, as either a folder or file
1113 * @throws ObjectNotFoundException if the user or parent folder was not
1114 * found, with the exception message mentioning the precise
1116 * @throws GSSIOException if there was an error while storing the file contents
1117 * @throws InsufficientPermissionsException
1118 * @throws QuotaExceededException
1120 public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
1121 throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
1122 InsufficientPermissionsException, QuotaExceededException;
1125 * Create a new FileBody with the supplied uploaded file as contents and make it the current body
1128 * @param userId the ID of the current user
1129 * @param fileId the ID of the file header object
1130 * @param mimeType the content type of the file
1131 * @param fileSize the uploaded file size
1132 * @param filePath the uploaded file full path
1133 * @return The FileHeaderDTO updated
1134 * @throws ObjectNotFoundException if the user or file was not found, with
1135 * the exception message mentioning the precise problem
1136 * @throws GSSIOException when an IO exception occurs
1137 * @throws InsufficientPermissionsException
1138 * @throws QuotaExceededException
1140 public FileHeaderDTO updateFileContents(Long userId, Long fileId, String mimeType,
1141 long fileSize, String filePath) throws ObjectNotFoundException, GSSIOException,
1142 InsufficientPermissionsException, QuotaExceededException;
1145 * Create a file based on inputstream without using transaction.
1150 * @throws IOException
1151 * @throws ObjectNotFoundException
1153 @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
1154 public File uploadFile(InputStream stream, Long userId)
1155 throws IOException, ObjectNotFoundException;
1157 public void createFileUploadProgress(Long userId, String filename,
1158 Long bytesTransfered, Long fileSize) throws ObjectNotFoundException;
1160 public FileUploadStatus getFileUploadStatus(Long userId, String fileName);
1162 public void removeFileUploadProgress(Long userId, String filename)
1163 throws ObjectNotFoundException;
1166 * Fetch the file body with the specified version number.
1168 * @param userId the ID of the current user
1169 * @param fileId the ID of the file header
1170 * @param version the version number
1171 * @return the file body
1172 * @throws ObjectNotFoundException if the user file or version
1174 * @throws InsufficientPermissionsException if the user does not
1175 * have enough privileges for reading this file
1177 public FileBodyDTO getFileVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException;
1180 * Search the system for a user with the specified email address.
1181 * If no such user is found, the method returns null.
1183 public User findUserByEmail(String email);
1186 * Update the user with the values from the supplied object.
1188 public void updateUser(User user);
1191 * Update accounting information for given user.
1193 * @param user The user to update
1194 * @param date Date of transaction
1195 * @param bandwidthDiff Bandwidth used; positive for addition,
1196 * negative for subtraction (e.g. to rollback)
1198 public void updateAccounting(User user, Date date, long bandwidthDiff);
1201 * Check if the user with the specified ID has permission to read the
1202 * folder with the supplied ID.
1204 public boolean canReadFolder(Long userId, Long folderId) throws ObjectNotFoundException;
1207 * Reset WebDAV password for given user.
1210 * @return the new password
1211 * @throws ObjectNotFoundException
1213 public String resetWebDAVPassword(Long userId) throws ObjectNotFoundException;
1216 * Find the invite for the specified invitation code.
1218 * @param code the invitation code
1219 * @return the Invitation or null if not found
1221 public Invitation findInvite(String code);
1224 * Create a new user in the connected IdP.
1226 * @param username the username of the new user
1227 * @param firstname the first name of the new user
1228 * @param lastname the last name of the new user
1229 * @param email the e-mail of the new user
1230 * @param password the password of the new user
1232 public void createLdapUser(String username, String firstname, String lastname, String email, String password);
1235 * Retrieves the available user classes.
1237 public List<UserClass> getUserClasses();
1240 * Upgrades the user class to the default "coupon bearer" class and marks
1241 * the provided coupon as used.
1243 * @param username the username of the user
1244 * @param code the coupon code
1245 * @return the new user class
1246 * @throws InvitationUsedException when trying to reuse an already used invitation
1247 * @throws ObjectNotFoundException if the user was not found
1249 public UserClass upgradeUserClass(String username, String code)
1250 throws ObjectNotFoundException, InvitationUsedException;
1253 * Retrieve the user class for coupon-bearing users.
1255 public UserClass getCouponUserClass();
1258 * Delete the actual file in the specified file system path.
1260 public void deleteActualFile(String path);