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.ObjectNotFoundException;
25 import gr.ebs.gss.client.exceptions.QuotaExceededException;
26 import gr.ebs.gss.server.domain.FileUploadStatus;
27 import gr.ebs.gss.server.domain.Invitation;
28 import gr.ebs.gss.server.domain.Nonce;
29 import gr.ebs.gss.server.domain.User;
30 import gr.ebs.gss.server.domain.dto.FileBodyDTO;
31 import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
32 import gr.ebs.gss.server.domain.dto.FolderDTO;
33 import gr.ebs.gss.server.domain.dto.GroupDTO;
34 import gr.ebs.gss.server.domain.dto.PermissionDTO;
35 import gr.ebs.gss.server.domain.dto.StatsDTO;
36 import gr.ebs.gss.server.domain.dto.UserDTO;
39 import java.io.IOException;
40 import java.io.InputStream;
41 import java.util.Date;
42 import java.util.List;
45 import javax.ejb.Local;
46 import javax.ejb.TransactionAttribute;
47 import javax.ejb.TransactionAttributeType;
50 * The External API for GSS clients.
55 public interface ExternalAPI {
58 * Retrieves the root folder for the specified user. The caller must ensure
59 * that the userId exists.
63 * @throws ObjectNotFoundException if no Folder or user was found
65 public FolderDTO getRootFolder(Long userId) throws ObjectNotFoundException;
68 * Retrieve the folder with the specified ID.
70 * @param userId the ID of the current user
71 * @param folderId the ID of the folder to retrieve
72 * @return the folder found
73 * @throws ObjectNotFoundException if the folder or the user was not found
74 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
76 public FolderDTO getFolder(Long userId, Long folderId) throws ObjectNotFoundException,
77 InsufficientPermissionsException;
80 * Returns the user with the specified ID.
82 * @param userId The ID of the User to be found
83 * @return The User object
84 * @throws ObjectNotFoundException if the user cannot be found
86 public User getUser(Long userId) throws ObjectNotFoundException;
89 * Returns the user with the specified ID.
91 * @param userId The ID of the User to be found
92 * @return The User object
93 * @throws ObjectNotFoundException if the user cannot be found
95 public UserDTO getUserDTO(Long userId) throws ObjectNotFoundException;
98 * Returns the group with the specified ID.
100 * @param groupId The ID of the Group to be found
101 * @return The Group object
102 * @throws ObjectNotFoundException if the group cannot be found
104 public GroupDTO getGroup(Long groupId) throws ObjectNotFoundException;
107 * Returns the group with the specified name that belongs to the
110 * @param userId the ID of the user
111 * @param name the name of the group
112 * @return The Group object
113 * @throws ObjectNotFoundException if the group cannot be found
115 public GroupDTO getGroup(Long userId, String name) throws ObjectNotFoundException;
118 * Retrieve the list of groups for a particular user.
120 * @param userId the ID of the User
121 * @return a List of Groups that belong to the specified User
122 * @throws ObjectNotFoundException if the user was not found
124 public List<GroupDTO> getGroups(Long userId) throws ObjectNotFoundException;
127 * Returns a list of files contained in the folder specified by its id.
129 * @param userId the ID of the User
130 * @param folderId the ID of the folder containing the files
131 * @param ignoreDeleted
132 * @return the list of file header objects
133 * @throws ObjectNotFoundException if the user or the folder cannot be found
134 * @throws InsufficientPermissionsException
136 public List<FileHeaderDTO> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException,
137 InsufficientPermissionsException;
140 * Returns a list of users for the specified group
142 * @param userId the ID of the User
143 * @param groupId the ID of the requested group
144 * @return List<UserDTO>
145 * @throws ObjectNotFoundException if the user or group was not found, with
146 * the exception message mentioning the precise problem
148 public List<UserDTO> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
151 * Returns a list of users matching the specified username
153 * @param username the username of the User
154 * @return List<UserDTO>
156 public List<UserDTO> getUsersByUserNameLike(String username);
159 * Creates a new folder with the specified owner, parent folder and name.
160 * New folder has the same permissions as its parent
165 * @return the new folder
166 * @throws DuplicateNameException if the specified name already exists in
167 * the parent folder, as either a folder or file
168 * @throws ObjectNotFoundException if the user or parent folder was not
169 * found, with the exception message mentioning the precise
171 * @throws InsufficientPermissionsException
173 public FolderDTO createFolder(Long userId, Long parentId, String name) throws DuplicateNameException,
174 ObjectNotFoundException, InsufficientPermissionsException;
177 * Deletes the specified folder, if the specified user has the appropriate
180 * @param userId the ID of the current user
181 * @param folderId the ID of the folder to delete
182 * @throws InsufficientPermissionsException if the user does not have the
183 * appropriate privileges
184 * @throws ObjectNotFoundException if the user or folder was not found, with
185 * the exception message mentioning the precise problem
187 public void deleteFolder(Long userId, Long folderId)
188 throws InsufficientPermissionsException, ObjectNotFoundException;
191 * Retrieve the subfolders of the specified folder.
193 * @param userId the ID of the current user
194 * @param folderId the ID of the folder to retrieve
195 * @return the list of subfolders found
196 * @throws ObjectNotFoundException if the folder or user was not found
197 * @throws InsufficientPermissionsException
199 public List<FolderDTO> getSubfolders(Long userId, Long folderId)
200 throws ObjectNotFoundException, InsufficientPermissionsException;
203 * Retrieve the folder with the specified ID with subfolders.
205 * @param userId the ID of the current user
206 * @param folderId the ID of the folder to retrieve
207 * @return the folder found
208 * @throws ObjectNotFoundException if the folder or the user was not found
209 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
211 public FolderDTO getFolderWithSubfolders(Long userId, Long folderId)
212 throws ObjectNotFoundException, InsufficientPermissionsException;
215 * Retrieve the folder with the specified ID with subfolders.
217 * @param userId the ID of the current user
218 * @param callingUserId the ID of the user requesting this operation
219 * @param folderId the ID of the folder to retrieve
220 * @return the folder found
221 * @throws ObjectNotFoundException if the folder or the user was not found
222 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
224 public FolderDTO getFolderWithSubfolders(Long userId, Long callingUserId, Long folderId)
225 throws ObjectNotFoundException, InsufficientPermissionsException;
227 * Retrieve the subfolders of the specified folder that are shared to others.
229 * @param userId the ID of the current user
230 * @param folderId the ID of the folder to retrieve
231 * @return the list of subfolders found
232 * @throws ObjectNotFoundException if the folder or user was not found
234 public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
237 * Retrieve the subfolders of the specified folder that are shared to others.
239 * @param userId the ID of the current user
240 * @param callingUserId the id of the user requesting this operation
241 * @param folderId the ID of the folder to retrieve
242 * @return the list of subfolders found
243 * @throws ObjectNotFoundException if the folder or user was not found
245 public List<FolderDTO> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException;
247 * Modifies the specified folder if the specified user has the appropriate
250 * @param userId the ID of the current user
251 * @param folderId the ID of the folder to retrieve
254 * @return the updated folder
255 * @throws InsufficientPermissionsException if the user does not have the
256 * appropriate privileges
257 * @throws ObjectNotFoundException if the user or folder was not found, with
258 * the exception message mentioning the precise problem
259 * @throws DuplicateNameException if the specified name already exists in
260 * the parent folder, as either a folder or file
262 public FolderDTO updateFolder(Long userId, Long folderId, String folderName, Set<PermissionDTO> permissions)
263 throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
266 * Adds a user to the specified group
268 * @param userId the ID of the current user
269 * @param groupId the id of the new group
270 * @param userToAddId the id of the user to add
271 * @throws DuplicateNameException if the user already exists in group
272 * @throws ObjectNotFoundException if the user or group was not found, with
273 * the exception message mentioning the precise problem
274 * @throws InsufficientPermissionsException
276 public void addUserToGroup(Long userId, Long groupId, Long userToAddId)
277 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
280 * Creates a new group with the specified owner and name.
282 * @param userId the ID of the current user
283 * @param name the name of the new group
284 * @throws DuplicateNameException if the new group name already exists
285 * @throws ObjectNotFoundException if the user or group was not found, with
286 * the exception message mentioning the precise problem
288 public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
291 * Deletes the specified group in the specified user's namespace.
293 * @param userId the ID of the current user
294 * @param groupId the ID of the group to delete
295 * @throws ObjectNotFoundException if the user or group was not found, with
296 * the exception message mentioning the precise problem
297 * @throws InsufficientPermissionsException
299 public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
302 * Creates a new file with the specified owner, parent folder and name. The
303 * new file has the same permissions as its parent folder. The file contents
304 * are read from the input stream to a new File object.
306 * @param userId the ID of the current user
307 * @param folderId the ID of the parent folder
308 * @param name the name of the new file
309 * @param mimeType the MIME type of the file
310 * @param stream the input stream with the file contents
311 * @return The FileHeaderDTO created
312 * @throws DuplicateNameException if the specified name already exists in
313 * the parent folder, as either a folder or file
314 * @throws ObjectNotFoundException if the user or parent folder was not
315 * found, with the exception message mentioning the precise
317 * @throws GSSIOException if there was an error while storing the file contents
318 * @throws InsufficientPermissionsException
319 * @throws QuotaExceededException
321 public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType,
322 InputStream stream) throws DuplicateNameException, ObjectNotFoundException,
323 GSSIOException, InsufficientPermissionsException, QuotaExceededException;
326 * Deletes the specified file, provided the specified user has
327 * the necessary permissions.
329 * @param userId the ID of the current user
330 * @param fileId the ID of the file to delete
331 * @throws ObjectNotFoundException if the user or file was not found, with
332 * the exception message mentioning the precise problem
333 * @throws InsufficientPermissionsException if the user does not have the
334 * appropriate privileges
336 public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
339 * Deletes the specified file in the specified user's namespace.
341 * @param userId the ID of the current user
342 * @param fileIds the IDs of the files to delete
343 * @throws ObjectNotFoundException if the user or file was not found, with
344 * the exception message mentioning the precise problem
345 * @throws InsufficientPermissionsException if the user does not have the
346 * appropriate privileges
348 public void deleteFiles(Long userId, List<Long> fileIds)
349 throws ObjectNotFoundException, InsufficientPermissionsException;
352 * Creates a new tag for the specified user and file.
354 * @param userId the creator of the tag
355 * @param fileHeaderId the file that is tagged
357 * @throws ObjectNotFoundException if the user or the file was not found
359 public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
362 * Returns all tags defined by the specified user
365 * @return Set<String>
366 * @throws ObjectNotFoundException if the user was null
368 public Set<String> getUserTags(final Long userId) throws ObjectNotFoundException;
371 * Updates the attributes of the specified file.
376 * @param tagSet a String that contains tags separated by comma
377 * @param modificationDate the modification date
378 * @param versioned the new value of the versioned flag
381 * @throws DuplicateNameException
382 * @throws ObjectNotFoundException
383 * @throws InsufficientPermissionsException
385 public void updateFile(Long userId, Long fileId, String name, String tagSet,
386 Date modificationDate, Boolean versioned, Boolean readForAll,
387 Set<PermissionDTO> permissions)
388 throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
391 * Retrieve the contents of the current body for the file
392 * with the specified FileHeader ID. The file contents
393 * are provided as an InputStream from which the caller can
394 * retrieve the raw bytes.
396 * @param userId the ID of the current user
397 * @param fileId the ID of the file to retrieve
398 * @return an InputStream from the current file body contents
399 * @throws ObjectNotFoundException if the file or the user was not found
400 * @throws InsufficientPermissionsException if the user does not have the
401 * appropriate privileges
403 public InputStream getFileContents(Long userId, Long fileId)
404 throws ObjectNotFoundException, InsufficientPermissionsException;
407 * Retrieve the contents of the body identified by bodyId for the file
408 * with the specified FileHeader ID. The file contents
409 * are provided as an InputStream from which the caller can
410 * retrieve the raw bytes.
412 * @param userId the ID of the current user
413 * @param fileId the ID of the file to retrieve
414 * @param bodyId the body ID
415 * @return an InputStream from the current file body contents
416 * @throws ObjectNotFoundException if the file or the user was not found
417 * @throws InsufficientPermissionsException if the user does not have the
418 * appropriate privileges
420 public InputStream getFileContents(Long userId, Long fileId, Long bodyId)
421 throws ObjectNotFoundException, InsufficientPermissionsException;
424 * Retrieve the file with the specified ID.
426 * @param userId the ID of the current user
427 * @param fileId the ID of the file to retrieve
428 * @return the file found
429 * @throws ObjectNotFoundException if the file or the user was not found, with
430 * the exception message mentioning the precise problem
431 * @throws InsufficientPermissionsException
433 public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException,
434 InsufficientPermissionsException;
437 * Retrieve the filebody with the specified ID.
439 * @param userId the ID of the current user
440 * @param fileId the ID of the file to retrieve
441 * @param bodyId the ID of the body
442 * @return the file found
443 * @throws ObjectNotFoundException if the file or the user was not found, with
444 * the exception message mentioning the precise problem
445 * @throws InsufficientPermissionsException
447 public FileBodyDTO getFileBody(Long userId, Long fileId, Long bodyId)
448 throws ObjectNotFoundException, InsufficientPermissionsException;
451 * Get the resource (file or folder) at the specified path in
452 * the specified user's namespace. The returned object will be of type
453 * FileHeaderDTO or FolderDTO.<p><strong>Note:</strong> this method does not
454 * receive the current user as a parameter, therefore it is unable to perform
455 * the necessary permission checks and should <strong>NOT</strong> be directly
456 * exposed to remote clients. It is the caller's responsibility to verify that
457 * the calling user has the required privileges for performing any subsequent
458 * action on the resource through one of the other ExternalAPI methods.
460 * @param ownerId the ID of the user owning the namespace
461 * @param path the absolute path in the user's namespace
462 * @param ignoreDeleted if true, resources that have been moved to the trash
464 * @throws ObjectNotFoundException if the user or resource was not found, with
465 * the exception message mentioning the precise problem
466 * @return the resource found
468 public Object getResourceAtPath(Long ownerId, String path, boolean ignoreDeleted)
469 throws ObjectNotFoundException;
472 * Copy the provided file to the specified destination.
474 * @param userId the ID of the current user
475 * @param fileId the IF of the provided file
476 * @param dest the path of the new resource
477 * @throws ObjectNotFoundException if the user, file or destination was not
478 * found, with the exception message mentioning the precise problem
479 * @throws DuplicateNameException if the specified name already exists in
480 * the destination folder, as either a folder or file
481 * @throws GSSIOException if there was an error while accessing the file contents
482 * @throws InsufficientPermissionsException
483 * @throws QuotaExceededException
485 public void copyFile(Long userId, Long fileId, String dest) throws ObjectNotFoundException,
486 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
489 * Copy the provided file to the specified destination.
491 * @param userId the ID of the current user
492 * @param ownerId the ID of the owner of the destination namespace
493 * @param fileId the IF of the provided file
494 * @param dest the path of the new resource
495 * @throws ObjectNotFoundException if the user, file or destination was not
496 * found, with the exception message mentioning the precise problem
497 * @throws DuplicateNameException if the specified name already exists in
498 * the destination folder, as either a folder or file
499 * @throws GSSIOException if there was an error while accessing the file contents
500 * @throws InsufficientPermissionsException
501 * @throws QuotaExceededException
503 public void copyFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException,
504 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
507 * Copy the provided file to the specified destination.
509 * @param userId the ID of the current user
510 * @param fileIds the IDs of the provided files
511 * @param destId the ID of the destination folder
512 * @throws ObjectNotFoundException if the user, file or destination was not
513 * found, with the exception message mentioning the precise problem
514 * @throws GSSIOException if there was an error while accessing the file contents
515 * @throws DuplicateNameException if the specified name already exists in
516 * the destination folder, as either a folder or file
517 * @throws InsufficientPermissionsException
518 * @throws QuotaExceededException
520 public void copyFiles(Long userId, List<Long> fileIds, Long destId)
521 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
522 InsufficientPermissionsException, QuotaExceededException;
525 * Copy the provided file to the specified destination.
527 * @param userId the ID of the current user
528 * @param fileId the IF of the provided file
529 * @param destId the ID of the destination folder
530 * @param destName the name of the new file
531 * @throws ObjectNotFoundException if the user, file or destination was not
532 * found, with the exception message mentioning the precise problem
533 * @throws GSSIOException if there was an error while accessing the file contents
534 * @throws DuplicateNameException if the specified name already exists in
535 * the destination folder, as either a folder or file
536 * @throws InsufficientPermissionsException
537 * @throws QuotaExceededException
539 public void copyFile(Long userId, Long fileId, Long destId, String destName)
540 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
541 InsufficientPermissionsException, QuotaExceededException;
544 * Copy the provided folder to the specified destination.
546 * @param userId the ID of the current user
547 * @param folderId the IF of the provided folder
548 * @param dest the path of the new folder
549 * @throws ObjectNotFoundException if the user, folder or destination was not
550 * found, with the exception message mentioning the precise problem
551 * @throws DuplicateNameException if the specified name already exists in
552 * the destination folder, as either a folder or file
553 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
554 * appropriate privileges
556 public void copyFolder(Long userId, Long folderId, String dest) throws ObjectNotFoundException,
557 DuplicateNameException, InsufficientPermissionsException;
560 * Copy the provided folder to the specified destination.
562 * @param userId the ID of the current user
563 * @param folderId the IF of the provided folder
564 * @param destId the ID of the destination folder
565 * @param destName the name of the new folder
566 * @throws ObjectNotFoundException if the user, folder or destination was not
567 * found, with the exception message mentioning the precise problem
568 * @throws DuplicateNameException if the specified name already exists in
569 * the destination folder, as either a folder or file
570 * @throws InsufficientPermissionsException InsufficientPermissionsException
571 * if the user does not have the appropriate privileges
573 public void copyFolder(Long userId, Long folderId, Long destId, String destName)
574 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
577 * Copy the provided folder and all its subfolders and files to the specified destination.
579 * @param userId the ID of the current user
580 * @param ownerId the ID of the owner of the destination namespace
581 * @param folderId the IF of the provided folder
582 * @param dest the path of the new folder
583 * @throws ObjectNotFoundException if the user, folder or destination was not
584 * found, with the exception message mentioning the precise problem
585 * @throws DuplicateNameException if the specified name already exists in
586 * the destination folder, as either a folder or file
587 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
588 * appropriate privileges
589 * @throws QuotaExceededException if the user quota limit would be exceeded
590 * @throws GSSIOException if there was an error while accessing the file contents
592 public void copyFolderStructureToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
593 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
596 * Copy the provided folder and all its subfolders and files to the specified destination.
598 * @param userId the ID of the current user
599 * @param folderId the IF of the provided folder
600 * @param destId the ID of the destination folder
601 * @param destName the name of the new folder
602 * @throws ObjectNotFoundException if the user, folder or destination was not
603 * found, with the exception message mentioning the precise problem
604 * @throws DuplicateNameException if the specified name already exists in
605 * the destination folder, as either a folder or file
606 * @throws InsufficientPermissionsException InsufficientPermissionsException
607 * if the user does not have the appropriate privileges
608 * @throws GSSIOException if there was an error while accessing the file contents
609 * @throws QuotaExceededException if the user quota limit would be exceeded
611 public void copyFolderStructure(Long userId, Long folderId, Long destId, String destName)
612 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
613 GSSIOException, QuotaExceededException;
616 * Marks the specified file as deleted in the specified user's namespace.
618 * @param userId the ID of the current user
619 * @param fileId the ID of the file to delete
620 * @throws ObjectNotFoundException if the user or file was not found, with
621 * the exception message mentioning the precise problem
622 * @throws InsufficientPermissionsException if the user does not have the
623 * appropriate privileges
625 public void moveFileToTrash(Long userId, Long fileId) throws ObjectNotFoundException,
626 InsufficientPermissionsException;
629 * Marks the specified deleted file as undeleted in the specified user's namespace.
631 * @param userId the ID of the current user
632 * @param fileId the ID of the file to undelete
633 * @throws ObjectNotFoundException if the user or file was not found, with
634 * the exception message mentioning the precise problem
635 * @throws InsufficientPermissionsException if the user does not have the
636 * appropriate privileges
639 public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
642 * Marks the specified files as deleted in the specified user's namespace.
644 * @param userId the ID of the current user
645 * @param fileIds the IDs of the file to delete
646 * @throws ObjectNotFoundException if the user or file was not found, with
647 * the exception message mentioning the precise problem
648 * @throws InsufficientPermissionsException if the user does not have the
649 * appropriate privileges
651 public void moveFilesToTrash(Long userId, List<Long> fileIds)
652 throws ObjectNotFoundException, InsufficientPermissionsException;
655 * Marks the specified deleted files as undeleted in the specified user's namespace.
657 * @param userId the ID of the current user
658 * @param fileIds the IDs of the file to undelete
659 * @throws ObjectNotFoundException if the user or file was not found, with
660 * the exception message mentioning the precise problem
661 * @throws InsufficientPermissionsException if the user does not have the
662 * appropriate privileges
664 public void removeFilesFromTrash(Long userId, List<Long> fileIds) throws ObjectNotFoundException, InsufficientPermissionsException;
667 * Marks the specified folder as deleted in the specified user's namespace.
669 * @param userId the ID of the current user
670 * @param folderId the ID of the folder to delete
671 * @throws ObjectNotFoundException if the user or file was not found, with
672 * the exception message mentioning the precise problem
673 * @throws InsufficientPermissionsException if the user does not have the
674 * appropriate privileges
676 public void moveFolderToTrash(Long userId, Long folderId)
677 throws ObjectNotFoundException, InsufficientPermissionsException;
680 * Marks the specified deleted folder as undeleted in the specified user's namespace.
682 * @param userId the ID of the current user
683 * @param folderId the ID of the folder to undelete
684 * @throws ObjectNotFoundException if the user or file was not found, with
685 * the exception message mentioning the precise problem
686 * @throws InsufficientPermissionsException if the user does not have the
687 * appropriate privileges
690 public void removeFolderFromTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
693 * Move the provided folder and all its subfolders and files to the specified destination.
695 * @param userId the ID of the current user
696 * @param folderId the IF of the provided folder
697 * @param destId the ID of the destination folder
698 * @param destName the name of the new folder
699 * @throws ObjectNotFoundException if the user, folder or destination was not
700 * found, with the exception message mentioning the precise problem
701 * @throws DuplicateNameException if the specified name already exists in
702 * the destination folder, as either a folder or file
703 * @throws InsufficientPermissionsException if the user does not have the
704 * appropriate privileges
705 * @throws GSSIOException
706 * @throws QuotaExceededException
708 public void moveFolder(Long userId, Long folderId, Long destId, String destName)
709 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
710 GSSIOException, QuotaExceededException;
713 * Move the provided folder and all its subfolders and files to the specified destination.
715 * @param userId the ID of the current user
716 * @param ownerId the owner of the destination namespace
717 * @param folderId the IF of the provided folder
718 * @param dest the path of the new folder
719 * @throws ObjectNotFoundException if the user, folder or destination was not
720 * found, with the exception message mentioning the precise problem
721 * @throws DuplicateNameException if the specified name already exists in
722 * the destination folder, as either a folder or file
723 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
724 * appropriate privileges
725 * @throws GSSIOException
726 * @throws QuotaExceededException
728 public void moveFolderToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
729 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
732 * Move the provided file to the specified destination.
734 * @param userId the ID of the current user
735 * @param fileId the IF of the provided file
736 * @param destId the ID of the destination folder
737 * @param destName the name of the new file
738 * @throws InsufficientPermissionsException
739 * @throws ObjectNotFoundException if the user, file or destination was not
740 * found, with the exception message mentioning the precise problem
741 * @throws GSSIOException if there was an error while accessing the file contents
742 * @throws DuplicateNameException if the specified name already exists in
743 * the destination folder, as either a folder or file
744 * @throws QuotaExceededException
746 public void moveFile(Long userId, Long fileId, Long destId, String destName)
747 throws InsufficientPermissionsException, ObjectNotFoundException,
748 DuplicateNameException, GSSIOException, QuotaExceededException;
751 * Move the provided file to the specified destination.
753 * @param userId the ID of the current user
754 * @param ownerId the owner of the destination namespace
755 * @param fileId the IF of the provided file
756 * @param dest the path of the new file
757 * @throws InsufficientPermissionsException
758 * @throws ObjectNotFoundException if the user, file or destination was not
759 * found, with the exception message mentioning the precise problem
760 * @throws GSSIOException if there was an error while accessing the file contents
761 * @throws DuplicateNameException if the specified name already exists in
762 * the destination folder, as either a folder or file
763 * @throws QuotaExceededException
765 public void moveFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException, InsufficientPermissionsException, DuplicateNameException, GSSIOException, QuotaExceededException;
768 * move the provided file to the specified destination.
770 * @param userId the ID of the current user
771 * @param fileIds the IDs of the provided files
772 * @param destId the ID of the destination folder
773 * @throws InsufficientPermissionsException
774 * @throws ObjectNotFoundException if the user, file or destination was not
775 * found, with the exception message mentioning the precise problem
776 * @throws GSSIOException if there was an error while accessing the file contents
777 * @throws DuplicateNameException if the specified name already exists in
778 * the destination folder, as either a folder or file
779 * @throws QuotaExceededException
781 public void moveFiles(Long userId, List<Long> fileIds, Long destId)
782 throws InsufficientPermissionsException, ObjectNotFoundException,
783 DuplicateNameException, GSSIOException, QuotaExceededException;
786 * Returns a list of All deleted files of a user.
788 * @param userId the ID of the User
789 * * @return the list of deleted file header objects
790 * @throws ObjectNotFoundException if the user cannot be found
792 public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException;
795 * Returns a list of All deleted root folders of a user.
797 * @param userId the ID of the User
798 * * @return the list of deleted file header objects
799 * @throws ObjectNotFoundException if the user cannot be found
801 public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
804 * Empty Trash by deleting all marked as deleted files and folders
806 * @throws ObjectNotFoundException if something goes wrong in the delete process
807 * @throws InsufficientPermissionsException if something goes wrong in the delete process
809 public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
812 * Restores All Trashed Items by undeleting all marked as deleted files and folders
814 * @throws ObjectNotFoundException if something goes wrong in the delete process
815 * @throws InsufficientPermissionsException
817 public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
820 * Search the system for a user with the specified username.
821 * If no such user is found, the method returns null.
823 * @param username the username to search for
824 * @return the User object with the specified username
826 public User findUser(String username);
829 * Create a new user with the specified name, username and e-mail address.
831 * @param username the username of the new user
832 * @param name the full name of the new user
833 * @param mail the e-mail of the new user
834 * @param idp the IdP of the new user
835 * @param idpid the IdP identifier of the new user
836 * @return the newly-created User object
837 * @throws DuplicateNameException if a user with the same username already exists
838 * @throws ObjectNotFoundException if no username was provided
840 public User createUser(String username, String name, String mail, String idp, String idpid)
841 throws DuplicateNameException, ObjectNotFoundException;
844 * Updates the authentication token for the specified user.
846 * @param userId the ID of the user whose token should be updated
847 * @return the updated user
848 * @throws ObjectNotFoundException if the user could not be found
850 public User updateUserToken(Long userId) throws ObjectNotFoundException;
853 * Updates the policy acceptance flag for the specified user.
855 * @param userId the ID of the user whose flag should be updated
856 * @param isAccepted the new value of the flag
857 * @return the updated user
858 * @throws ObjectNotFoundException if the user could not be found
860 public User updateUserPolicyAcceptance(Long userId, boolean isAccepted) throws ObjectNotFoundException;
863 * Invalidates the authentication token for the specified user.
865 * @param userId the ID of the user whose token should be updated
866 * @throws ObjectNotFoundException if the user could not be found
868 public void invalidateUserToken(Long userId) throws ObjectNotFoundException;
871 * Retrieve folder user and group permissions
873 * @param userId the ID of the user whose token should be updated
874 * @param folderId the ID of the folder
875 * @return the Set of permissions from requested folder
876 * @throws ObjectNotFoundException if the user or folder could not be found
877 * @throws InsufficientPermissionsException
879 public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId)
880 throws ObjectNotFoundException, InsufficientPermissionsException;
883 * Retrieve file user and group permissions
885 * @param userId the ID of the user whose token should be updated
886 * @param fileId the ID of the folder
887 * @return the Set of permissions from requested folder
888 * @throws ObjectNotFoundException if the user or folder could not be found
889 * @throws InsufficientPermissionsException
891 public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId)
892 throws ObjectNotFoundException, InsufficientPermissionsException;
895 * Returns a list of all shared root folders of a user.
897 * @param userId the ID of the User
898 * @return the list of shared root folders
899 * @throws ObjectNotFoundException if the user cannot be found
901 public List<FolderDTO> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
904 * Returns a list of all shared files of a user that are not
905 * inside other shared folders.
907 * @param userId the ID of the User
908 * @return the list of shared files
909 * @throws ObjectNotFoundException if the user cannot be found
911 public List<FileHeaderDTO> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
914 * Returns a list of all shared files of a user.
916 * @param userId the ID of the User
917 * @return the list of shared files
918 * @throws ObjectNotFoundException if the user cannot be found
920 public List<FileHeaderDTO> getSharedFiles(Long userId) throws ObjectNotFoundException;
923 * Returns a list of all shared folders of a user.
925 * @param userId the ID of the User
926 * @return the list of shared folders
927 * @throws ObjectNotFoundException if the user cannot be found
929 public List<FolderDTO> getSharedFolders(Long userId) throws ObjectNotFoundException;
932 * Returns a list of all shared root folders of a user that calling
933 * user has at least read permissions.
935 * @param ownerId the ID of the User
936 * @return the list of shared root folders
937 * @param callingUserId
939 * @throws ObjectNotFoundException if the user cannot be found
941 public List<FolderDTO> getSharedRootFolders(Long ownerId, Long callingUserId)
942 throws ObjectNotFoundException;
945 * Returns a list of all shared files of a user that calling user has
946 * at least read permissions..
948 * @param ownerId the ID of the User
949 * @return the list of shared files
950 * @param callingUserId
951 * @throws ObjectNotFoundException if the user cannot be found
953 public List<FileHeaderDTO> getSharedFiles(Long ownerId, Long callingUserId)
954 throws ObjectNotFoundException;
957 * Remove a user member from a group
959 * @param userId the ID of the User owning the group
960 * @param groupId the ID of the requested group
961 * @param memberId the ID of the member to be removed
963 * @throws ObjectNotFoundException if the user or group was not found, with
964 * the exception message mentioning the precise problem
965 * @throws InsufficientPermissionsException
967 public void removeMemberFromGroup(Long userId, Long groupId, Long memberId)
968 throws ObjectNotFoundException, InsufficientPermissionsException;
971 * Retrieves the list of users sharing files to user identified by user id
973 * @return the List of users sharing files to user
974 * @throws ObjectNotFoundException
976 public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
983 * @return list of files that match query
984 * @throws ObjectNotFoundException if no user or query was specified
986 public List<FileHeaderDTO> searchFiles(Long userId, String query) throws ObjectNotFoundException;
989 * Creates a nonce for the specified user.
991 * @param userId the ID of the user
992 * @return the new nonce
993 * @throws ObjectNotFoundException if the user could not be found
995 public Nonce createNonce(Long userId) throws ObjectNotFoundException;
998 * Find the nonce object for the specified encoded nonce, that should be
999 * associated with the specified user.
1001 * @param nonce the issued nonce in Base64 encoding
1002 * @param userId the ID of the user for whom this nonce should have been issued
1003 * @return the retrieved nonce object
1004 * @throws ObjectNotFoundException if the nonce or user were not found
1006 public Nonce getNonce(String nonce, Long userId) throws ObjectNotFoundException;
1009 * Remove the specified nonce from the persistent store.
1011 * @param id the ID of the nonce
1012 * @throws ObjectNotFoundException if the specified nonce could not be found
1014 public void removeNonce(Long id) throws ObjectNotFoundException;
1017 * Activate the supplied nonce for the specified user.
1019 * @param userId the ID of the user
1020 * @param nonce the nonce to activate
1021 * @param nonceExpiryDate the expiry date of the nonce
1022 * @throws ObjectNotFoundException
1024 public void activateUserNonce(Long userId, String nonce, Date nonceExpiryDate) throws ObjectNotFoundException;
1027 * Retrieves user statistics.
1029 * @param userId the ID of the user
1030 * @return the statistics
1031 * @throws ObjectNotFoundException
1034 public StatsDTO getUserStatistics(Long userId) throws ObjectNotFoundException;
1037 * Retrieves file versions
1039 * @param userId the ID of the user
1040 * @param fileId the ID of the file
1041 * @return the list of filebodies
1042 * @throws ObjectNotFoundException
1043 * @throws InsufficientPermissionsException
1046 public List<FileBodyDTO> getVersions(Long userId, Long fileId)
1047 throws ObjectNotFoundException, InsufficientPermissionsException;
1050 * Restore the file contents to the specified version.
1052 * @param userId the ID of the user
1053 * @param fileId the ID of the file
1054 * @param version the version number of the desired file contents
1055 * @throws ObjectNotFoundException if the user or file was not
1056 * found, with the exception message mentioning the precise problem
1057 * @throws InsufficientPermissionsException if the user does not have the
1058 * appropriate privileges
1059 * @throws QuotaExceededException if the user quota limit would be exceeded
1060 * @throws GSSIOException if there was an error while accessing the file contents
1062 public void restoreVersion(Long userId, Long fileId, int version)
1063 throws ObjectNotFoundException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
1066 * Remove file version identified by bodyId
1068 * @param userId the ID of the user
1069 * @param fileId the ID of the file
1070 * @param bodyId the ID of the body
1072 * @throws ObjectNotFoundException
1073 * @throws InsufficientPermissionsException
1076 public void removeVersion(Long userId, Long fileId, Long bodyId)
1077 throws ObjectNotFoundException, InsufficientPermissionsException;
1080 * Removes all old file versions for specified file keeping only the current revision
1082 * @param userId the ID of the user
1083 * @param fileId the ID of the file
1085 * @throws ObjectNotFoundException
1086 * @throws InsufficientPermissionsException
1089 public void removeOldVersions(Long userId, Long fileId)
1090 throws ObjectNotFoundException, InsufficientPermissionsException;
1093 * It is used by the Solr mbean to rebuild the index.
1095 public void rebuildSolrIndex();
1098 * Creates a new file with the specified owner, parent folder and name. The
1099 * new file has the same permissions as its parent folder. The file contents
1100 * are already uploaded outside of externalAPI and the uploaded file is used as a parameter.
1102 * @param userId the ID of the current user
1103 * @param folderId the ID of the parent folder
1104 * @param name the name of the new file
1105 * @param mimeType the MIME type of the file
1106 * @param fileSize the uploaded file size
1107 * @param filePath the uploaded file full path
1108 * @return The FileHeaderDTO created
1109 * @throws DuplicateNameException if the specified name already exists in
1110 * the parent folder, as either a folder or file
1111 * @throws ObjectNotFoundException if the user or parent folder was not
1112 * found, with the exception message mentioning the precise
1114 * @throws GSSIOException if there was an error while storing the file contents
1115 * @throws InsufficientPermissionsException
1116 * @throws QuotaExceededException
1118 public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
1119 throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
1120 InsufficientPermissionsException, QuotaExceededException;
1123 * Create a new FileBody with the supplied uploaded file as contents and make it the current body
1126 * @param userId the ID of the current user
1127 * @param fileId the ID of the file header object
1128 * @param mimeType the content type of the file
1129 * @param fileSize the uploaded file size
1130 * @param filePath the uploaded file full path
1131 * @return The FileHeaderDTO updated
1132 * @throws ObjectNotFoundException if the user or file was not found, with
1133 * the exception message mentioning the precise problem
1134 * @throws GSSIOException when an IO exception occurs
1135 * @throws InsufficientPermissionsException
1136 * @throws QuotaExceededException
1138 public FileHeaderDTO updateFileContents(Long userId, Long fileId, String mimeType,
1139 long fileSize, String filePath) throws ObjectNotFoundException, GSSIOException,
1140 InsufficientPermissionsException, QuotaExceededException;
1143 * Create a file based on inputstream without using transaction.
1148 * @throws IOException
1149 * @throws ObjectNotFoundException
1151 @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
1152 public File uploadFile(InputStream stream, Long userId)
1153 throws IOException, ObjectNotFoundException;
1155 public void createFileUploadProgress(Long userId, String filename,
1156 Long bytesTransfered, Long fileSize) throws ObjectNotFoundException;
1158 public FileUploadStatus getFileUploadStatus(Long userId, String fileName);
1160 public void removeFileUploadProgress(Long userId, String filename)
1161 throws ObjectNotFoundException;
1164 * Fetch the file body with the specified version number.
1166 * @param userId the ID of the current user
1167 * @param fileId the ID of the file header
1168 * @param version the version number
1169 * @return the file body
1170 * @throws ObjectNotFoundException if the user file or version
1172 * @throws InsufficientPermissionsException if the user does not
1173 * have enough privileges for reading this file
1175 public FileBodyDTO getFileVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException;
1178 * Search the system for a user with the specified email address.
1179 * If no such user is found, the method returns null.
1181 public User findUserByEmail(String email);
1184 * Update the user with the values from the supplied object.
1186 public void updateUser(User user);
1189 * Update accounting information for given user.
1191 * @param user The user to update
1192 * @param date Date of transaction
1193 * @param bandwidthDiff Bandwidth used; positive for addition,
1194 * negative for subtraction (e.g. to rollback)
1196 public void updateAccounting(User user, Date date, long bandwidthDiff);
1199 * Check if the user with the specified ID has permission to read the
1200 * folder with the supplied ID.
1202 public boolean canReadFolder(Long userId, Long folderId) throws ObjectNotFoundException;
1205 * Reset WebDAV password for given user.
1208 * @return the new password
1209 * @throws ObjectNotFoundException
1211 public String resetWebDAVPassword(Long userId) throws ObjectNotFoundException;
1214 * Find the invite for the specified invitation code.
1216 * @param code the invitation code
1217 * @return the Invitation or null if not found
1219 public Invitation findInvite(String code);