2 * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
4 * This file is part of GSS.
6 * GSS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
19 package gr.ebs.gss.server.ejb;
21 import gr.ebs.gss.client.exceptions.DuplicateNameException;
22 import gr.ebs.gss.client.exceptions.GSSIOException;
23 import gr.ebs.gss.client.exceptions.InsufficientPermissionsException;
24 import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
25 import gr.ebs.gss.client.exceptions.QuotaExceededException;
26 import gr.ebs.gss.server.domain.FileUploadStatus;
27 import gr.ebs.gss.server.domain.Nonce;
28 import gr.ebs.gss.server.domain.User;
29 import gr.ebs.gss.server.domain.dto.FileBodyDTO;
30 import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
31 import gr.ebs.gss.server.domain.dto.FolderDTO;
32 import gr.ebs.gss.server.domain.dto.GroupDTO;
33 import gr.ebs.gss.server.domain.dto.PermissionDTO;
34 import gr.ebs.gss.server.domain.dto.StatsDTO;
35 import gr.ebs.gss.server.domain.dto.UserDTO;
38 import java.io.IOException;
39 import java.io.InputStream;
40 import java.util.Date;
41 import java.util.List;
44 import javax.ejb.Local;
45 import javax.ejb.TransactionAttribute;
46 import javax.ejb.TransactionAttributeType;
49 * The External API for GSS clients.
54 public interface ExternalAPI {
57 * Retrieves the root folder for the specified user. The caller must ensure
58 * that the userId exists.
62 * @throws ObjectNotFoundException if no Folder or user was found
64 public FolderDTO getRootFolder(Long userId) throws ObjectNotFoundException;
67 * Retrieve the folder with the specified ID.
69 * @param userId the ID of the current user
70 * @param folderId the ID of the folder to retrieve
71 * @return the folder found
72 * @throws ObjectNotFoundException if the folder or the user was not found
73 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
75 public FolderDTO getFolder(Long userId, Long folderId) throws ObjectNotFoundException,
76 InsufficientPermissionsException;
79 * Returns the user with the specified ID.
81 * @param userId The ID of the User to be found
82 * @return The User object
83 * @throws ObjectNotFoundException if the user cannot be found
85 public User getUser(Long userId) throws ObjectNotFoundException;
88 * Returns the user with the specified ID.
90 * @param userId The ID of the User to be found
91 * @return The User object
92 * @throws ObjectNotFoundException if the user cannot be found
94 public UserDTO getUserDTO(Long userId) throws ObjectNotFoundException;
97 * Returns the group with the specified ID.
99 * @param groupId The ID of the Group to be found
100 * @return The Group object
101 * @throws ObjectNotFoundException if the group cannot be found
103 public GroupDTO getGroup(Long groupId) throws ObjectNotFoundException;
106 * Returns the group with the specified name that belongs to the
109 * @param userId the ID of the user
110 * @param name the name of the group
111 * @return The Group object
112 * @throws ObjectNotFoundException if the group cannot be found
114 public GroupDTO getGroup(Long userId, String name) throws ObjectNotFoundException;
117 * Retrieve the list of groups for a particular user.
119 * @param userId the ID of the User
120 * @return a List of Groups that belong to the specified User
121 * @throws ObjectNotFoundException if the user was not found
123 public List<GroupDTO> getGroups(Long userId) throws ObjectNotFoundException;
126 * Returns a list of files contained in the folder specified by its id.
128 * @param userId the ID of the User
129 * @param folderId the ID of the folder containing the files
130 * @param ignoreDeleted
131 * @return the list of file header objects
132 * @throws ObjectNotFoundException if the user or the folder cannot be found
133 * @throws InsufficientPermissionsException
135 public List<FileHeaderDTO> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException,
136 InsufficientPermissionsException;
139 * Returns a list of users for the specified group
141 * @param userId the ID of the User
142 * @param groupId the ID of the requested group
143 * @return List<UserDTO>
144 * @throws ObjectNotFoundException if the user or group was not found, with
145 * the exception message mentioning the precise problem
147 public List<UserDTO> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
150 * Returns a list of users matching the specified username
152 * @param username the username of the User
153 * @return List<UserDTO>
155 public List<UserDTO> getUsersByUserNameLike(String username);
158 * Creates a new folder with the specified owner, parent folder and name.
159 * New folder has the same permissions as its parent
164 * @return the new folder
165 * @throws DuplicateNameException if the specified name already exists in
166 * the parent folder, as either a folder or file
167 * @throws ObjectNotFoundException if the user or parent folder was not
168 * found, with the exception message mentioning the precise
170 * @throws InsufficientPermissionsException
172 public FolderDTO createFolder(Long userId, Long parentId, String name) throws DuplicateNameException,
173 ObjectNotFoundException, InsufficientPermissionsException;
176 * Deletes the specified folder, if the specified user has the appropriate
179 * @param userId the ID of the current user
180 * @param folderId the ID of the folder to delete
181 * @throws InsufficientPermissionsException if the user does not have the
182 * appropriate privileges
183 * @throws ObjectNotFoundException if the user or folder was not found, with
184 * the exception message mentioning the precise problem
186 public void deleteFolder(Long userId, Long folderId)
187 throws InsufficientPermissionsException, ObjectNotFoundException;
190 * Retrieve the subfolders of the specified folder.
192 * @param userId the ID of the current user
193 * @param folderId the ID of the folder to retrieve
194 * @return the list of subfolders found
195 * @throws ObjectNotFoundException if the folder or user was not found
196 * @throws InsufficientPermissionsException
198 public List<FolderDTO> getSubfolders(Long userId, Long folderId)
199 throws ObjectNotFoundException, InsufficientPermissionsException;
202 * Retrieve the folder with the specified ID with subfolders.
204 * @param userId the ID of the current user
205 * @param folderId the ID of the folder to retrieve
206 * @return the folder found
207 * @throws ObjectNotFoundException if the folder or the user was not found
208 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
210 public FolderDTO getFolderWithSubfolders(Long userId, Long folderId)
211 throws ObjectNotFoundException, InsufficientPermissionsException;
214 * Retrieve the folder with the specified ID with subfolders.
216 * @param userId the ID of the current user
217 * @param callingUserId the ID of the user requesting this operation
218 * @param folderId the ID of the folder to retrieve
219 * @return the folder found
220 * @throws ObjectNotFoundException if the folder or the user was not found
221 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
223 public FolderDTO getFolderWithSubfolders(Long userId, Long callingUserId, Long folderId)
224 throws ObjectNotFoundException, InsufficientPermissionsException;
226 * Retrieve the subfolders of the specified folder that are shared to others.
228 * @param userId the ID of the current user
229 * @param folderId the ID of the folder to retrieve
230 * @return the list of subfolders found
231 * @throws ObjectNotFoundException if the folder or user was not found
233 public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
236 * Retrieve the subfolders of the specified folder that are shared to others.
238 * @param userId the ID of the current user
239 * @param callingUserId the id of the user requesting this operation
240 * @param folderId the ID of the folder to retrieve
241 * @return the list of subfolders found
242 * @throws ObjectNotFoundException if the folder or user was not found
244 public List<FolderDTO> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException;
246 * Modifies the specified folder if the specified user has the appropriate
249 * @param userId the ID of the current user
250 * @param folderId the ID of the folder to retrieve
253 * @return the updated folder
254 * @throws InsufficientPermissionsException if the user does not have the
255 * appropriate privileges
256 * @throws ObjectNotFoundException if the user or folder was not found, with
257 * the exception message mentioning the precise problem
258 * @throws DuplicateNameException if the specified name already exists in
259 * the parent folder, as either a folder or file
261 public FolderDTO updateFolder(Long userId, Long folderId, String folderName, Set<PermissionDTO> permissions)
262 throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
265 * Adds a user to the specified group
267 * @param userId the ID of the current user
268 * @param groupId the id of the new group
269 * @param userToAddId the id of the user to add
270 * @throws DuplicateNameException if the user already exists in group
271 * @throws ObjectNotFoundException if the user or group was not found, with
272 * the exception message mentioning the precise problem
273 * @throws InsufficientPermissionsException
275 public void addUserToGroup(Long userId, Long groupId, Long userToAddId)
276 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
279 * Creates a new group with the specified owner and name.
281 * @param userId the ID of the current user
282 * @param name the name of the new group
283 * @throws DuplicateNameException if the new group name already exists
284 * @throws ObjectNotFoundException if the user or group was not found, with
285 * the exception message mentioning the precise problem
287 public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
290 * Deletes the specified group in the specified user's namespace.
292 * @param userId the ID of the current user
293 * @param groupId the ID of the group to delete
294 * @throws ObjectNotFoundException if the user or group was not found, with
295 * the exception message mentioning the precise problem
296 * @throws InsufficientPermissionsException
298 public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
301 * Creates a new file with the specified owner, parent folder and name. The
302 * new file has the same permissions as its parent folder. The file contents
303 * are read from the input stream to a new File object.
305 * @param userId the ID of the current user
306 * @param folderId the ID of the parent folder
307 * @param name the name of the new file
308 * @param mimeType the MIME type of the file
309 * @param stream the input stream with the file contents
310 * @return The FileHeaderDTO created
311 * @throws DuplicateNameException if the specified name already exists in
312 * the parent folder, as either a folder or file
313 * @throws ObjectNotFoundException if the user or parent folder was not
314 * found, with the exception message mentioning the precise
316 * @throws GSSIOException if there was an error while storing the file contents
317 * @throws InsufficientPermissionsException
318 * @throws QuotaExceededException
320 public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType,
321 InputStream stream) throws DuplicateNameException, ObjectNotFoundException,
322 GSSIOException, InsufficientPermissionsException, QuotaExceededException;
325 * Deletes the specified file, provided the specified user has
326 * the necessary permissions.
328 * @param userId the ID of the current user
329 * @param fileId the ID of the file to delete
330 * @throws ObjectNotFoundException if the user or file was not found, with
331 * the exception message mentioning the precise problem
332 * @throws InsufficientPermissionsException if the user does not have the
333 * appropriate privileges
335 public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
338 * Deletes the specified file in the specified user's namespace.
340 * @param userId the ID of the current user
341 * @param fileIds the IDs of the files to delete
342 * @throws ObjectNotFoundException if the user or file was not found, with
343 * the exception message mentioning the precise problem
344 * @throws InsufficientPermissionsException if the user does not have the
345 * appropriate privileges
347 public void deleteFiles(Long userId, List<Long> fileIds)
348 throws ObjectNotFoundException, InsufficientPermissionsException;
351 * Creates a new tag for the specified user and file.
353 * @param userId the creator of the tag
354 * @param fileHeaderId the file that is tagged
356 * @throws ObjectNotFoundException if the user or the file was not found
358 public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
361 * Returns all tags defined by the specified user
364 * @return Set<String>
365 * @throws ObjectNotFoundException if the user was null
367 public Set<String> getUserTags(final Long userId) throws ObjectNotFoundException;
370 * Updates the attributes of the specified file.
375 * @param tagSet a String that contains tags separated by comma
376 * @param modificationDate the modification date
377 * @param versioned the new value of the versioned flag
380 * @throws DuplicateNameException
381 * @throws ObjectNotFoundException
382 * @throws InsufficientPermissionsException
384 public void updateFile(Long userId, Long fileId, String name, String tagSet,
385 Date modificationDate, Boolean versioned, Boolean readForAll,
386 Set<PermissionDTO> permissions)
387 throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
390 * Retrieve the contents of the current body for the file
391 * with the specified FileHeader ID. The file contents
392 * are provided as an InputStream from which the caller can
393 * retrieve the raw bytes.
395 * @param userId the ID of the current user
396 * @param fileId the ID of the file to retrieve
397 * @return an InputStream from the current file body contents
398 * @throws ObjectNotFoundException if the file or the user was not found
399 * @throws InsufficientPermissionsException if the user does not have the
400 * appropriate privileges
402 public InputStream getFileContents(Long userId, Long fileId)
403 throws ObjectNotFoundException, InsufficientPermissionsException;
406 * Retrieve the contents of the body identified by bodyId for the file
407 * with the specified FileHeader ID. The file contents
408 * are provided as an InputStream from which the caller can
409 * retrieve the raw bytes.
411 * @param userId the ID of the current user
412 * @param fileId the ID of the file to retrieve
413 * @param bodyId the body ID
414 * @return an InputStream from the current file body contents
415 * @throws ObjectNotFoundException if the file or the user was not found
416 * @throws InsufficientPermissionsException if the user does not have the
417 * appropriate privileges
419 public InputStream getFileContents(Long userId, Long fileId, Long bodyId)
420 throws ObjectNotFoundException, InsufficientPermissionsException;
423 * Retrieve the file with the specified ID.
425 * @param userId the ID of the current user
426 * @param fileId the ID of the file to retrieve
427 * @return the file found
428 * @throws ObjectNotFoundException if the file or the user was not found, with
429 * the exception message mentioning the precise problem
430 * @throws InsufficientPermissionsException
432 public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException,
433 InsufficientPermissionsException;
436 * Retrieve the filebody with the specified ID.
438 * @param userId the ID of the current user
439 * @param fileId the ID of the file to retrieve
440 * @param bodyId the ID of the body
441 * @return the file found
442 * @throws ObjectNotFoundException if the file or the user was not found, with
443 * the exception message mentioning the precise problem
444 * @throws InsufficientPermissionsException
446 public FileBodyDTO getFileBody(Long userId, Long fileId, Long bodyId)
447 throws ObjectNotFoundException, InsufficientPermissionsException;
450 * Get the resource (file or folder) at the specified path in
451 * the specified user's namespace. The returned object will be of type
452 * FileHeaderDTO or FolderDTO.<p><strong>Note:</strong> this method does not
453 * receive the current user as a parameter, therefore it is unable to perform
454 * the necessary permission checks and should <strong>NOT</strong> be directly
455 * exposed to remote clients. It is the caller's responsibility to verify that
456 * the calling user has the required privileges for performing any subsequent
457 * action on the resource through one of the other ExternalAPI methods.
459 * @param ownerId the ID of the user owning the namespace
460 * @param path the absolute path in the user's namespace
461 * @param ignoreDeleted if true, resources that have been moved to the trash
463 * @throws ObjectNotFoundException if the user or resource was not found, with
464 * the exception message mentioning the precise problem
465 * @return the resource found
467 public Object getResourceAtPath(Long ownerId, String path, boolean ignoreDeleted)
468 throws ObjectNotFoundException;
471 * Copy the provided file to the specified destination.
473 * @param userId the ID of the current user
474 * @param fileId the IF of the provided file
475 * @param dest the path of the new resource
476 * @throws ObjectNotFoundException if the user, file or destination was not
477 * found, with the exception message mentioning the precise problem
478 * @throws DuplicateNameException if the specified name already exists in
479 * the destination folder, as either a folder or file
480 * @throws GSSIOException if there was an error while accessing the file contents
481 * @throws InsufficientPermissionsException
482 * @throws QuotaExceededException
484 public void copyFile(Long userId, Long fileId, String dest) throws ObjectNotFoundException,
485 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
488 * Copy the provided file to the specified destination.
490 * @param userId the ID of the current user
491 * @param ownerId the ID of the owner of the destination namespace
492 * @param fileId the IF of the provided file
493 * @param dest the path of the new resource
494 * @throws ObjectNotFoundException if the user, file or destination was not
495 * found, with the exception message mentioning the precise problem
496 * @throws DuplicateNameException if the specified name already exists in
497 * the destination folder, as either a folder or file
498 * @throws GSSIOException if there was an error while accessing the file contents
499 * @throws InsufficientPermissionsException
500 * @throws QuotaExceededException
502 public void copyFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException,
503 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
506 * Copy the provided file to the specified destination.
508 * @param userId the ID of the current user
509 * @param fileIds the IDs of the provided files
510 * @param destId the ID of the destination folder
511 * @throws ObjectNotFoundException if the user, file or destination was not
512 * found, with the exception message mentioning the precise problem
513 * @throws GSSIOException if there was an error while accessing the file contents
514 * @throws DuplicateNameException if the specified name already exists in
515 * the destination folder, as either a folder or file
516 * @throws InsufficientPermissionsException
517 * @throws QuotaExceededException
519 public void copyFiles(Long userId, List<Long> fileIds, Long destId)
520 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
521 InsufficientPermissionsException, QuotaExceededException;
524 * Copy the provided file to the specified destination.
526 * @param userId the ID of the current user
527 * @param fileId the IF of the provided file
528 * @param destId the ID of the destination folder
529 * @param destName the name of the new file
530 * @throws ObjectNotFoundException if the user, file or destination was not
531 * found, with the exception message mentioning the precise problem
532 * @throws GSSIOException if there was an error while accessing the file contents
533 * @throws DuplicateNameException if the specified name already exists in
534 * the destination folder, as either a folder or file
535 * @throws InsufficientPermissionsException
536 * @throws QuotaExceededException
538 public void copyFile(Long userId, Long fileId, Long destId, String destName)
539 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
540 InsufficientPermissionsException, QuotaExceededException;
543 * Copy the provided folder to the specified destination.
545 * @param userId the ID of the current user
546 * @param folderId the IF of the provided folder
547 * @param dest the path of the new folder
548 * @throws ObjectNotFoundException if the user, folder or destination was not
549 * found, with the exception message mentioning the precise problem
550 * @throws DuplicateNameException if the specified name already exists in
551 * the destination folder, as either a folder or file
552 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
553 * appropriate privileges
555 public void copyFolder(Long userId, Long folderId, String dest) throws ObjectNotFoundException,
556 DuplicateNameException, InsufficientPermissionsException;
559 * Copy the provided folder to the specified destination.
561 * @param userId the ID of the current user
562 * @param folderId the IF of the provided folder
563 * @param destId the ID of the destination folder
564 * @param destName the name of the new folder
565 * @throws ObjectNotFoundException if the user, folder or destination was not
566 * found, with the exception message mentioning the precise problem
567 * @throws DuplicateNameException if the specified name already exists in
568 * the destination folder, as either a folder or file
569 * @throws InsufficientPermissionsException InsufficientPermissionsException
570 * if the user does not have the appropriate privileges
572 public void copyFolder(Long userId, Long folderId, Long destId, String destName)
573 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
576 * Copy the provided folder and all its subfolders and files to the specified destination.
578 * @param userId the ID of the current user
579 * @param ownerId the ID of the owner of the destination namespace
580 * @param folderId the IF of the provided folder
581 * @param dest the path of the new folder
582 * @throws ObjectNotFoundException if the user, folder or destination was not
583 * found, with the exception message mentioning the precise problem
584 * @throws DuplicateNameException if the specified name already exists in
585 * the destination folder, as either a folder or file
586 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
587 * appropriate privileges
588 * @throws QuotaExceededException if the user quota limit would be exceeded
589 * @throws GSSIOException if there was an error while accessing the file contents
591 public void copyFolderStructureToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
592 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
595 * Copy the provided folder and all its subfolders and files to the specified destination.
597 * @param userId the ID of the current user
598 * @param folderId the IF of the provided folder
599 * @param destId the ID of the destination folder
600 * @param destName the name of the new folder
601 * @throws ObjectNotFoundException if the user, folder or destination was not
602 * found, with the exception message mentioning the precise problem
603 * @throws DuplicateNameException if the specified name already exists in
604 * the destination folder, as either a folder or file
605 * @throws InsufficientPermissionsException InsufficientPermissionsException
606 * if the user does not have the appropriate privileges
607 * @throws GSSIOException if there was an error while accessing the file contents
608 * @throws QuotaExceededException if the user quota limit would be exceeded
610 public void copyFolderStructure(Long userId, Long folderId, Long destId, String destName)
611 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
612 GSSIOException, QuotaExceededException;
615 * Marks the specified file as deleted in the specified user's namespace.
617 * @param userId the ID of the current user
618 * @param fileId the ID of the file to delete
619 * @throws ObjectNotFoundException if the user or file was not found, with
620 * the exception message mentioning the precise problem
621 * @throws InsufficientPermissionsException if the user does not have the
622 * appropriate privileges
624 public void moveFileToTrash(Long userId, Long fileId) throws ObjectNotFoundException,
625 InsufficientPermissionsException;
628 * Marks the specified deleted file as undeleted in the specified user's namespace.
630 * @param userId the ID of the current user
631 * @param fileId the ID of the file to undelete
632 * @throws ObjectNotFoundException if the user or file was not found, with
633 * the exception message mentioning the precise problem
634 * @throws InsufficientPermissionsException if the user does not have the
635 * appropriate privileges
638 public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
641 * Marks the specified files as deleted in the specified user's namespace.
643 * @param userId the ID of the current user
644 * @param fileIds the IDs of the file to delete
645 * @throws ObjectNotFoundException if the user or file was not found, with
646 * the exception message mentioning the precise problem
647 * @throws InsufficientPermissionsException if the user does not have the
648 * appropriate privileges
650 public void moveFilesToTrash(Long userId, List<Long> fileIds)
651 throws ObjectNotFoundException, InsufficientPermissionsException;
654 * Marks the specified deleted files as undeleted in the specified user's namespace.
656 * @param userId the ID of the current user
657 * @param fileIds the IDs of the file to undelete
658 * @throws ObjectNotFoundException if the user or file was not found, with
659 * the exception message mentioning the precise problem
660 * @throws InsufficientPermissionsException if the user does not have the
661 * appropriate privileges
663 public void removeFilesFromTrash(Long userId, List<Long> fileIds) throws ObjectNotFoundException, InsufficientPermissionsException;
666 * Marks the specified folder as deleted in the specified user's namespace.
668 * @param userId the ID of the current user
669 * @param folderId the ID of the folder to delete
670 * @throws ObjectNotFoundException if the user or file was not found, with
671 * the exception message mentioning the precise problem
672 * @throws InsufficientPermissionsException if the user does not have the
673 * appropriate privileges
675 public void moveFolderToTrash(Long userId, Long folderId)
676 throws ObjectNotFoundException, InsufficientPermissionsException;
679 * Marks the specified deleted folder as undeleted in the specified user's namespace.
681 * @param userId the ID of the current user
682 * @param folderId the ID of the folder to undelete
683 * @throws ObjectNotFoundException if the user or file was not found, with
684 * the exception message mentioning the precise problem
685 * @throws InsufficientPermissionsException if the user does not have the
686 * appropriate privileges
689 public void removeFolderFromTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
692 * Move the provided folder and all its subfolders and files to the specified destination.
694 * @param userId the ID of the current user
695 * @param folderId the IF of the provided folder
696 * @param destId the ID of the destination folder
697 * @param destName the name of the new folder
698 * @throws ObjectNotFoundException if the user, folder or destination was not
699 * found, with the exception message mentioning the precise problem
700 * @throws DuplicateNameException if the specified name already exists in
701 * the destination folder, as either a folder or file
702 * @throws InsufficientPermissionsException if the user does not have the
703 * appropriate privileges
704 * @throws GSSIOException
705 * @throws QuotaExceededException
707 public void moveFolder(Long userId, Long folderId, Long destId, String destName)
708 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
709 GSSIOException, QuotaExceededException;
712 * Move the provided folder and all its subfolders and files to the specified destination.
714 * @param userId the ID of the current user
715 * @param ownerId the owner of the destination namespace
716 * @param folderId the IF of the provided folder
717 * @param dest the path of the new folder
718 * @throws ObjectNotFoundException if the user, folder or destination was not
719 * found, with the exception message mentioning the precise problem
720 * @throws DuplicateNameException if the specified name already exists in
721 * the destination folder, as either a folder or file
722 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
723 * appropriate privileges
724 * @throws GSSIOException
725 * @throws QuotaExceededException
727 public void moveFolderToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
728 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
731 * Move the provided file to the specified destination.
733 * @param userId the ID of the current user
734 * @param fileId the IF of the provided file
735 * @param destId the ID of the destination folder
736 * @param destName the name of the new file
737 * @throws InsufficientPermissionsException
738 * @throws ObjectNotFoundException if the user, file or destination was not
739 * found, with the exception message mentioning the precise problem
740 * @throws GSSIOException if there was an error while accessing the file contents
741 * @throws DuplicateNameException if the specified name already exists in
742 * the destination folder, as either a folder or file
743 * @throws QuotaExceededException
745 public void moveFile(Long userId, Long fileId, Long destId, String destName)
746 throws InsufficientPermissionsException, ObjectNotFoundException,
747 DuplicateNameException, GSSIOException, QuotaExceededException;
750 * Move the provided file to the specified destination.
752 * @param userId the ID of the current user
753 * @param ownerId the owner of the destination namespace
754 * @param fileId the IF of the provided file
755 * @param dest the path of the new file
756 * @throws InsufficientPermissionsException
757 * @throws ObjectNotFoundException if the user, file or destination was not
758 * found, with the exception message mentioning the precise problem
759 * @throws GSSIOException if there was an error while accessing the file contents
760 * @throws DuplicateNameException if the specified name already exists in
761 * the destination folder, as either a folder or file
762 * @throws QuotaExceededException
764 public void moveFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException, InsufficientPermissionsException, DuplicateNameException, GSSIOException, QuotaExceededException;
767 * move the provided file to the specified destination.
769 * @param userId the ID of the current user
770 * @param fileIds the IDs of the provided files
771 * @param destId the ID of the destination folder
772 * @throws InsufficientPermissionsException
773 * @throws ObjectNotFoundException if the user, file or destination was not
774 * found, with the exception message mentioning the precise problem
775 * @throws GSSIOException if there was an error while accessing the file contents
776 * @throws DuplicateNameException if the specified name already exists in
777 * the destination folder, as either a folder or file
778 * @throws QuotaExceededException
780 public void moveFiles(Long userId, List<Long> fileIds, Long destId)
781 throws InsufficientPermissionsException, ObjectNotFoundException,
782 DuplicateNameException, GSSIOException, QuotaExceededException;
785 * Returns a list of All deleted files of a user.
787 * @param userId the ID of the User
788 * * @return the list of deleted file header objects
789 * @throws ObjectNotFoundException if the user cannot be found
791 public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException;
794 * Returns a list of All deleted root folders of a user.
796 * @param userId the ID of the User
797 * * @return the list of deleted file header objects
798 * @throws ObjectNotFoundException if the user cannot be found
800 public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
803 * Empty Trash by deleting all marked as deleted files and folders
805 * @throws ObjectNotFoundException if something goes wrong in the delete process
806 * @throws InsufficientPermissionsException if something goes wrong in the delete process
808 public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
811 * Restores All Trashed Items by undeleting all marked as deleted files and folders
813 * @throws ObjectNotFoundException if something goes wrong in the delete process
814 * @throws InsufficientPermissionsException
816 public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
819 * Search the system for a user with the specified username.
820 * If no such user is found, the method returns null.
822 * @param username the username to search for
823 * @return the User object with the specified username
825 public User findUser(String username);
828 * Create a new user with the specified name, username and e-mail address.
830 * @param username the username of the new user
831 * @param name the full name of the new user
832 * @param mail the e-mail of the new user
833 * @param persistentId the persistent ID of the new user
834 * @return the newly-created User object
835 * @throws DuplicateNameException if a user with the same username already exists
836 * @throws ObjectNotFoundException if no username was provided
838 public User createUser(String username, String name, String mail, String persistentId)
839 throws DuplicateNameException, ObjectNotFoundException;
842 * Updates the authentication token for the specified user.
844 * @param userId the ID of the user whose token should be updated
845 * @return the updated user
846 * @throws ObjectNotFoundException if the user could not be found
848 public User updateUserToken(Long userId) throws ObjectNotFoundException;
851 * Updates the policy acceptance flag for the specified user.
853 * @param userId the ID of the user whose flag should be updated
854 * @param isAccepted the new value of the flag
855 * @return the updated user
856 * @throws ObjectNotFoundException if the user could not be found
858 public User updateUserPolicyAcceptance(Long userId, boolean isAccepted) throws ObjectNotFoundException;
861 * Invalidates the authentication token for the specified user.
863 * @param userId the ID of the user whose token should be updated
864 * @throws ObjectNotFoundException if the user could not be found
866 public void invalidateUserToken(Long userId) throws ObjectNotFoundException;
869 * Retrieve folder user and group permissions
871 * @param userId the ID of the user whose token should be updated
872 * @param folderId the ID of the folder
873 * @return the Set of permissions from requested folder
874 * @throws ObjectNotFoundException if the user or folder could not be found
875 * @throws InsufficientPermissionsException
877 public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId)
878 throws ObjectNotFoundException, InsufficientPermissionsException;
881 * Retrieve file user and group permissions
883 * @param userId the ID of the user whose token should be updated
884 * @param fileId the ID of the folder
885 * @return the Set of permissions from requested folder
886 * @throws ObjectNotFoundException if the user or folder could not be found
887 * @throws InsufficientPermissionsException
889 public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId)
890 throws ObjectNotFoundException, InsufficientPermissionsException;
893 * Returns a list of all shared root folders of a user.
895 * @param userId the ID of the User
896 * @return the list of shared root folders
897 * @throws ObjectNotFoundException if the user cannot be found
899 public List<FolderDTO> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
902 * Returns a list of all shared files of a user that are not
903 * inside other shared folders.
905 * @param userId the ID of the User
906 * @return the list of shared files
907 * @throws ObjectNotFoundException if the user cannot be found
909 public List<FileHeaderDTO> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
912 * Returns a list of all shared files of a user.
914 * @param userId the ID of the User
915 * @return the list of shared files
916 * @throws ObjectNotFoundException if the user cannot be found
918 public List<FileHeaderDTO> getSharedFiles(Long userId) throws ObjectNotFoundException;
921 * Returns a list of all shared folders of a user.
923 * @param userId the ID of the User
924 * @return the list of shared folders
925 * @throws ObjectNotFoundException if the user cannot be found
927 public List<FolderDTO> getSharedFolders(Long userId) throws ObjectNotFoundException;
930 * Returns a list of all shared root folders of a user that calling
931 * user has at least read permissions.
933 * @param ownerId the ID of the User
934 * @return the list of shared root folders
935 * @param callingUserId
937 * @throws ObjectNotFoundException if the user cannot be found
939 public List<FolderDTO> getSharedRootFolders(Long ownerId, Long callingUserId)
940 throws ObjectNotFoundException;
943 * Returns a list of all shared files of a user that calling user has
944 * at least read permissions..
946 * @param ownerId the ID of the User
947 * @return the list of shared files
948 * @param callingUserId
949 * @throws ObjectNotFoundException if the user cannot be found
951 public List<FileHeaderDTO> getSharedFiles(Long ownerId, Long callingUserId)
952 throws ObjectNotFoundException;
955 * Remove a user member from a group
957 * @param userId the ID of the User owning the group
958 * @param groupId the ID of the requested group
959 * @param memberId the ID of the member to be removed
961 * @throws ObjectNotFoundException if the user or group was not found, with
962 * the exception message mentioning the precise problem
963 * @throws InsufficientPermissionsException
965 public void removeMemberFromGroup(Long userId, Long groupId, Long memberId)
966 throws ObjectNotFoundException, InsufficientPermissionsException;
969 * Retrieves the list of users sharing files to user identified by user id
971 * @return the List of users sharing files to user
972 * @throws ObjectNotFoundException
974 public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
981 * @return list of files that match query
982 * @throws ObjectNotFoundException if no user or query was specified
984 public List<FileHeaderDTO> searchFiles(Long userId, String query) throws ObjectNotFoundException;
987 * Creates a nonce for the specified user.
989 * @param userId the ID of the user
990 * @return the new nonce
991 * @throws ObjectNotFoundException if the user could not be found
993 public Nonce createNonce(Long userId) throws ObjectNotFoundException;
996 * Find the nonce object for the specified encoded nonce, that should be
997 * associated with the specified user.
999 * @param nonce the issued nonce in Base64 encoding
1000 * @param userId the ID of the user for whom this nonce should have been issued
1001 * @return the retrieved nonce object
1002 * @throws ObjectNotFoundException if the nonce or user were not found
1004 public Nonce getNonce(String nonce, Long userId) throws ObjectNotFoundException;
1007 * Remove the specified nonce from the persistent store.
1009 * @param id the ID of the nonce
1010 * @throws ObjectNotFoundException if the specified nonce could not be found
1012 public void removeNonce(Long id) throws ObjectNotFoundException;
1015 * Activate the supplied nonce for the specified user.
1017 * @param userId the ID of the user
1018 * @param nonce the nonce to activate
1019 * @param nonceExpiryDate the expiry date of the nonce
1020 * @throws ObjectNotFoundException
1022 public void activateUserNonce(Long userId, String nonce, Date nonceExpiryDate) throws ObjectNotFoundException;
1025 * Retrieves user statistics.
1027 * @param userId the ID of the user
1028 * @return the statistics
1029 * @throws ObjectNotFoundException
1032 public StatsDTO getUserStatistics(Long userId) throws ObjectNotFoundException;
1035 * Retrieves file versions
1037 * @param userId the ID of the user
1038 * @param fileId the ID of the file
1039 * @return the list of filebodies
1040 * @throws ObjectNotFoundException
1041 * @throws InsufficientPermissionsException
1044 public List<FileBodyDTO> getVersions(Long userId, Long fileId)
1045 throws ObjectNotFoundException, InsufficientPermissionsException;
1048 * Restore the file contents to the specified version.
1050 * @param userId the ID of the user
1051 * @param fileId the ID of the file
1052 * @param version the version number of the desired file contents
1053 * @throws ObjectNotFoundException if the user or file was not
1054 * found, with the exception message mentioning the precise problem
1055 * @throws InsufficientPermissionsException if the user does not have the
1056 * appropriate privileges
1057 * @throws QuotaExceededException if the user quota limit would be exceeded
1058 * @throws GSSIOException if there was an error while accessing the file contents
1060 public void restoreVersion(Long userId, Long fileId, int version)
1061 throws ObjectNotFoundException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
1064 * Remove file version identified by bodyId
1066 * @param userId the ID of the user
1067 * @param fileId the ID of the file
1068 * @param bodyId the ID of the body
1070 * @throws ObjectNotFoundException
1071 * @throws InsufficientPermissionsException
1074 public void removeVersion(Long userId, Long fileId, Long bodyId)
1075 throws ObjectNotFoundException, InsufficientPermissionsException;
1078 * Removes all old file versions for specified file keeping only the current revision
1080 * @param userId the ID of the user
1081 * @param fileId the ID of the file
1083 * @throws ObjectNotFoundException
1084 * @throws InsufficientPermissionsException
1087 public void removeOldVersions(Long userId, Long fileId)
1088 throws ObjectNotFoundException, InsufficientPermissionsException;
1091 * It is used by the Solr mbean to rebuild the index.
1093 public void rebuildSolrIndex();
1096 * Creates a new file with the specified owner, parent folder and name. The
1097 * new file has the same permissions as its parent folder. The file contents
1098 * are already uploaded outside of externalAPI and the uploaded file is used as a parameter.
1100 * @param userId the ID of the current user
1101 * @param folderId the ID of the parent folder
1102 * @param name the name of the new file
1103 * @param mimeType the MIME type of the file
1104 * @param fileSize the uploaded file size
1105 * @param filePath the uploaded file full path
1106 * @return The FileHeaderDTO created
1107 * @throws DuplicateNameException if the specified name already exists in
1108 * the parent folder, as either a folder or file
1109 * @throws ObjectNotFoundException if the user or parent folder was not
1110 * found, with the exception message mentioning the precise
1112 * @throws GSSIOException if there was an error while storing the file contents
1113 * @throws InsufficientPermissionsException
1114 * @throws QuotaExceededException
1116 public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
1117 throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
1118 InsufficientPermissionsException, QuotaExceededException;
1121 * Create a new FileBody with the supplied uploaded file as contents and make it the current body
1124 * @param userId the ID of the current user
1125 * @param fileId the ID of the file header object
1126 * @param mimeType the content type of the file
1127 * @param fileSize the uploaded file size
1128 * @param filePath the uploaded file full path
1129 * @return The FileHeaderDTO updated
1130 * @throws ObjectNotFoundException if the user or file was not found, with
1131 * the exception message mentioning the precise problem
1132 * @throws GSSIOException when an IO exception occurs
1133 * @throws InsufficientPermissionsException
1134 * @throws QuotaExceededException
1136 public FileHeaderDTO updateFileContents(Long userId, Long fileId, String mimeType,
1137 long fileSize, String filePath) throws ObjectNotFoundException, GSSIOException,
1138 InsufficientPermissionsException, QuotaExceededException;
1141 * Create a file based on inputstream without using transaction.
1146 * @throws IOException
1147 * @throws ObjectNotFoundException
1149 @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
1150 public File uploadFile(InputStream stream, Long userId)
1151 throws IOException, ObjectNotFoundException;
1153 public void createFileUploadProgress(Long userId, String filename,
1154 Long bytesTransfered, Long fileSize) throws ObjectNotFoundException;
1156 public FileUploadStatus getFileUploadStatus(Long userId, String fileName);
1158 public void removeFileUploadProgress(Long userId, String filename)
1159 throws ObjectNotFoundException;
1162 * Fetch the file body with the specified version number.
1164 * @param userId the ID of the current user
1165 * @param fileId the ID of the file header
1166 * @param version the version number
1167 * @return the file body
1168 * @throws ObjectNotFoundException if the user file or version
1170 * @throws InsufficientPermissionsException if the user does not
1171 * have enough privileges for reading this file
1173 public FileBodyDTO getFileVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException;
1176 * Search the system for a user with the specified email address.
1177 * If no such user is found, the method returns null.
1179 public User findUserByEmail(String email);
1182 * Update the user with the values from the supplied object.
1184 public void updateUser(User user);
1187 * Update accounting information for given user.
1189 * @param user The user to update
1190 * @param date Date of transaction
1191 * @param bandwidthDiff Bandwidth used; positive for addition,
1192 * negative for subtraction (e.g. to rollback)
1194 public void updateAccounting(User user, Date date, long bandwidthDiff);
1197 * Check if the user with the specified ID has permission to read the
1198 * folder with the supplied ID.
1200 public boolean canReadFolder(Long userId, Long folderId) throws ObjectNotFoundException;
1203 * Reset WebDAV password for given user.
1206 * @return the new password
1207 * @throws ObjectNotFoundException
1209 public String resetWebDAVPassword(Long userId) throws ObjectNotFoundException;