Uploaded files should be counted towards owner's (i.e. namespace owner's) quota,...
[pithos] / src / gr / ebs / gss / server / ejb / ExternalAPIRemote.java
1 /*
2  * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
3  *
4  * This file is part of GSS.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19 package gr.ebs.gss.server.ejb;
20
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.User;
27 import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
28 import gr.ebs.gss.server.domain.dto.FolderDTO;
29 import gr.ebs.gss.server.domain.dto.GroupDTO;
30 import gr.ebs.gss.server.domain.dto.PermissionDTO;
31 import gr.ebs.gss.server.domain.dto.UserDTO;
32
33 import java.io.InputStream;
34 import java.util.List;
35 import java.util.Set;
36
37 import javax.ejb.Remote;
38
39 /**
40  * The External API for GSS clients.
41  *
42  * @author chstath
43  */
44 @Remote
45 public interface ExternalAPIRemote {
46
47         /**
48          * Retrieves the root folder for the specified user. The caller must ensure
49          * that the userId exists.
50          *
51          * @param userId
52          * @return Folder
53          * @throws ObjectNotFoundException if no Folder or user was found
54          */
55         public FolderDTO getRootFolder(Long userId) throws ObjectNotFoundException;
56
57         /**
58          * Retrieve the folder with the specified ID.
59          *
60          * @param userId the ID of the current user
61          * @param folderId the ID of the folder to retrieve
62          * @return the folder found
63          * @throws ObjectNotFoundException if the folder or the user was not found
64          * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
65          */
66         public FolderDTO getFolder(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
67
68         /**
69          * Returns the user with the specified ID.
70          *
71          * @param userId The ID of the User to be found
72          * @return The User object
73          * @throws ObjectNotFoundException if the user cannot be found
74          */
75         public User getUser(Long userId) throws ObjectNotFoundException;
76
77         /**
78          * Returns the user with the specified ID.
79          *
80          * @param userId The ID of the User to be found
81          * @return The User object
82          * @throws ObjectNotFoundException if the user cannot be found
83          */
84         public UserDTO getUserDTO(Long userId) throws ObjectNotFoundException;
85
86         /**
87          * Returns the group with the specified ID.
88          *
89          * @param groupId The ID of the Group to be found
90          * @return The Group object
91          * @throws ObjectNotFoundException if the group cannot be found
92          */
93         public GroupDTO getGroup(Long groupId) throws ObjectNotFoundException;
94
95         /**
96          * Retrieve the list of groups for a particular user.
97          *
98          * @param userId the ID of the User
99          * @return a List of Groups that belong to the specified User
100          * @throws ObjectNotFoundException if the user was not found
101          */
102         public List<GroupDTO> getGroups(Long userId) throws ObjectNotFoundException;
103
104         /**
105          * Returns a list of files contained in the folder specified by its id.
106          *
107          * @param userId the ID of the User
108          * @param folderId the ID of the folder containing the files
109          * @param ignoreDeleted
110          * @return the list of file header objects
111          * @throws ObjectNotFoundException if the user or the folder cannot be found
112          * @throws InsufficientPermissionsException
113          */
114         public List<FileHeaderDTO> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException, InsufficientPermissionsException;
115
116         /**
117          * Returns a list of users for the specified group
118          *
119          * @param userId the ID of the User
120          * @param groupId the ID of the requested group
121          * @return List<UserDTO>
122          * @throws ObjectNotFoundException if the user or group was not found, with
123          *             the exception message mentioning the precise problem
124          */
125         public List<UserDTO> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
126
127         /**
128          * Returns a list of users for the specified username
129          *
130          * @param username the username of the User
131          * @return List<UserDTO>
132          */
133         public List<UserDTO> getUsersByUserNameLike(String username);
134
135         /**
136          * Creates a new folder with the specified owner, parent folder and name.
137          * New folder has the same permissions as its parent
138          *
139          * @param userId
140          * @param parentId
141          * @param name
142          * @throws DuplicateNameException if the specified name already exists in
143          *             the parent folder, as either a folder or file
144          * @throws ObjectNotFoundException if the user or parent folder was not
145          *             found, with the exception message mentioning the precise
146          *             problem
147          * @throws InsufficientPermissionsException
148          */
149         public void createFolder(Long userId, Long parentId, String name) throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
150
151         /**
152          * Deletes the specified folder if the specified user has the appropriate
153          * permission
154          *
155          * @param userId
156          * @param folderId
157          * @throws InsufficientPermissionsException if the user does not have the
158          *             appropriate privileges
159          * @throws ObjectNotFoundException if the user or folder was not found, with
160          *             the exception message mentioning the precise problem
161          */
162         public void deleteFolder(Long userId, Long folderId) throws InsufficientPermissionsException, ObjectNotFoundException;
163
164         /**
165          * Retrieve the subfolders of the specified folder.
166          *
167          * @param userId the ID of the current user
168          * @param folderId the ID of the folder to retrieve
169          * @return the list of subfolders found
170          * @throws ObjectNotFoundException if the folder or user was not found
171          * @throws InsufficientPermissionsException
172          */
173         public List<FolderDTO> getSubfolders(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
174
175
176         /**
177          * Retrieve the subfolders of the specified folder that are shared to others.
178          *
179          * @param userId the ID of the current user
180          * @param folderId the ID of the folder to retrieve
181          * @return the list of subfolders found
182          * @throws ObjectNotFoundException if the folder or user was not found
183          */
184         public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
185
186         /**
187          * Modifies the specified folder if the specified user has the appropriate
188          * permission.
189          *
190          * @param userId the ID of the current user
191          * @param folderId the ID of the folder to retrieve
192          * @param folderName
193          * @throws InsufficientPermissionsException if the user does not have the
194          *             appropriate privileges
195          * @throws ObjectNotFoundException if the user or folder was not found, with
196          *             the exception message mentioning the precise problem
197          * @throws DuplicateNameException if the specified name already exists in
198          *             the parent folder, as either a folder or file
199          */
200         public void modifyFolder(Long userId, Long folderId, String folderName) throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
201
202         /**
203          * Adds a user to the specified group
204          *
205          * @param userId the ID of the current user
206          * @param groupId the id of the new group
207          * @param userToAddId the id of the user to add
208          * @throws DuplicateNameException if the user already exists in group
209          * @throws ObjectNotFoundException if the user or group was not found, with
210          *             the exception message mentioning the precise problem
211          * @throws InsufficientPermissionsException
212          */
213         public void addUserToGroup(Long userId, Long groupId, Long userToAddId) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
214
215         /**
216          * Creates a new group with the specified owner and name.
217          *
218          * @param userId the ID of the current user
219          * @param name the name of the new group
220          * @throws DuplicateNameException if the new group name already exists
221          * @throws ObjectNotFoundException if the user or group was not found, with
222          *             the exception message mentioning the precise problem
223          */
224         public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
225
226         /**
227          * Deletes the specified group in the specified user's namespace.
228          *
229          * @param userId the ID of the current user
230          * @param groupId the ID of the group to delete
231          * @throws ObjectNotFoundException if the user or group was not found, with
232          *             the exception message mentioning the precise problem
233          * @throws InsufficientPermissionsException
234          */
235         public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
236
237         /**
238          * Creates a new file with the specified owner, parent folder and name. The
239          * new file has the same permissions as its parent folder. The file contents
240          * are read from the input stream to a new File object.
241          *
242          * @param userId the ID of the current user
243          * @param folderId the ID of the parent folder
244          * @param name the name of the new file
245          * @param mimeType the MIME type of the file
246          * @param stream the input stream with the file contents
247          * @return The FileHeaderDTO created
248          * @throws DuplicateNameException if the specified name already exists in
249          *             the parent folder, as either a folder or file
250          * @throws ObjectNotFoundException if the user or parent folder was not
251          *             found, with the exception message mentioning the precise
252          *             problem
253          * @throws GSSIOException if there was an error while storing the file contents
254          * @throws InsufficientPermissionsException
255          */
256         public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, InputStream stream) throws DuplicateNameException, ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
257
258         /**
259          * Deletes the specified file in the specified user's namespace.
260          *
261          * @param userId the ID of the current user
262          * @param fileId the ID of the file to delete
263          * @throws ObjectNotFoundException if the user or file was not found, with
264          *             the exception message mentioning the precise problem
265          * @throws InsufficientPermissionsException if the user does not have the
266          *             appropriate privileges
267          */
268         public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
269
270         /**
271          * Creates a new tag for the specified user and file.
272          *
273          * @param userId the creator of the tag
274          * @param fileHeaderId the file that is tagged
275          * @param tag the tag
276          * @throws ObjectNotFoundException if the user or the file was not found
277          */
278         public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
279
280         /**
281          * Returns all tags defined by the specified user
282          *
283          * @param userId
284          * @return Set<String>
285          * @throws ObjectNotFoundException if the user was null
286          */
287         public Set<String> getUserTags(final Long userId) throws ObjectNotFoundException;
288
289         /**
290          * Updates name and tags for the specified file
291          *
292          * @param userId
293          * @param fileId
294          * @param name
295          * @param tagSet a String that contains tags separated by comma
296          * @throws ObjectNotFoundException
297          * @throws InsufficientPermissionsException
298          */
299         public void updateFile(Long userId, Long fileId, String name, String tagSet) throws ObjectNotFoundException, InsufficientPermissionsException;
300
301         /**
302          * Retrieve the contents of the current body for the file
303          * with the specified FileHeader ID. The file contents
304          * are provided as an InputStream from which the caller can
305          * retrieve the raw bytes.
306          *
307          * @param userId the ID of the current user
308          * @param fileId the ID of the file to retrieve
309          * @return an InputStream from the current file body contents
310          * @throws ObjectNotFoundException if the file or the user was not found
311          * @throws InsufficientPermissionsException  if the user does not have the
312          *             appropriate privileges
313          */
314         public InputStream getFileContents(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
315
316         /**
317          * Retrieve the file with the specified ID.
318          *
319          * @param userId the ID of the current user
320          * @param fileId the ID of the file to retrieve
321          * @return the file found
322          * @throws ObjectNotFoundException if the file or the user was not found, with
323          *                      the exception message mentioning the precise problem
324          * @throws InsufficientPermissionsException
325          */
326         public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
327
328         /**
329          * Get the resource (file or folder) at the specified path in
330          * the specified user's namespace. The returned object will be of type
331          * FileHeaderDTO or FolderDTO.<p><strong>Note:</strong> this method does not
332          * receive the current user as a parameter, therefore it is unable to perform
333          * the necessary permission checks and should <strong>NOT</strong> be directly
334          * exposed to remote clients. It is the caller's responsibility to verify that
335          * the calling user has the required privileges for performing any subsequent
336          * action on the resource through one of the other ExternalAPI methods.
337          *
338          * @param ownerId the ID of the user owning the namespace
339          * @param path the absolute path in the user's namespace
340          * @param ignoreDeleted if true, resources that have been moved to the trash
341          *                      will be ignored
342          * @throws ObjectNotFoundException if the user or resource was not found, with
343          *                      the exception message mentioning the precise problem
344          * @return the resource found
345          */
346         public Object getResourceAtPath(Long ownerId, String path, boolean ignoreDeleted)
347                         throws ObjectNotFoundException;
348
349         /**
350          * Copy the provided file to the specified destination.
351          *
352          * @param userId the ID of the current user
353          * @param fileId the IF of the provided file
354          * @param dest the path to the destination folder
355          * @throws ObjectNotFoundException if the user, file or destination was not
356          *                      found, with     the exception message mentioning the precise problem
357          * @throws GSSIOException if there was an error while accessing the file contents
358          * @throws DuplicateNameException if the specified name already exists in
359          *          the destination folder, as either a folder or file
360          * @throws InsufficientPermissionsException
361          */
362         public void copyFile(Long userId, Long fileId, String dest) throws ObjectNotFoundException, DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
363
364         /**
365          * Copy the provided file to the specified destination.
366          *
367          * @param userId the ID of the current user
368          * @param fileId the IF of the provided file
369          * @param destId the ID of the destination folder
370          * @param destName the name of the new file
371          * @throws ObjectNotFoundException if the user, file or destination was not
372          *                      found, with     the exception message mentioning the precise problem
373          * @throws GSSIOException if there was an error while accessing the file contents
374          * @throws DuplicateNameException if the specified name already exists in
375          *          the destination folder, as either a folder or file
376          * @throws InsufficientPermissionsException
377          */
378         public void copyFile(Long userId, Long fileId, Long destId, String destName) throws ObjectNotFoundException, DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
379
380         /**
381          * Copy the provided folder to the specified destination.
382          *
383          * @param userId the ID of the current user
384          * @param folderId the IF of the provided folder
385          * @param dest the path to the destination folder
386          * @throws ObjectNotFoundException if the user, folder or destination was not
387          *                      found, with     the exception message mentioning the precise problem
388          * @throws DuplicateNameException if the specified name already exists in
389          *          the destination folder, as either a folder or file
390          * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
391          *          appropriate privileges
392          */
393         public void copyFolder(Long userId, Long folderId, String dest) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException, QuotaExceededException;
394
395         /**
396          * Copy the provided folder to the specified destination.
397          *
398          * @param userId the ID of the current user
399          * @param folderId the IF of the provided folder
400          * @param destId the ID of the destination folder
401          * @param destName the name of the new folder
402          * @throws ObjectNotFoundException if the user, folder or destination was not
403          *                      found, with     the exception message mentioning the precise problem
404          * @throws DuplicateNameException if the specified name already exists in
405          *          the destination folder, as either a folder or file
406          * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
407          *          appropriate privileges
408          */
409         public void copyFolder(Long userId, Long folderId, Long destId, String destName) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException, QuotaExceededException;
410
411         /**
412          * Copy the provided folder and all its subfolders and files to the specified destination.
413          *
414          * @param userId the ID of the current user
415          * @param folderId the IF of the provided folder
416          * @param destId the ID of the destination folder
417          * @param destName the name of the new folder
418          * @throws ObjectNotFoundException if the user, folder or destination was not
419          *                      found, with     the exception message mentioning the precise problem
420          * @throws DuplicateNameException if the specified name already exists in
421          *          the destination folder, as either a folder or file
422          * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
423          *          appropriate privileges
424          * @throws GSSIOException
425          */
426         public void copyFolderStructure(Long userId, Long folderId, Long destId, String destName) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,GSSIOException, QuotaExceededException;
427
428         /**
429          * Marks  the specified file as deleted in the specified user's namespace.
430          *
431          * @param userId the ID of the current user
432          * @param fileId the ID of the file to delete
433          * @throws ObjectNotFoundException if the user or file was not found, with
434          *             the exception message mentioning the precise problem
435          * @throws InsufficientPermissionsException if the user does not have the
436          *             appropriate privileges
437          */
438         public void moveFileToTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
439
440         /**
441          * Marks  the specified deleted file as undeleted in the specified user's namespace.
442          *
443          * @param userId the ID of the current user
444          * @param fileId the ID of the file to undelete
445          * @throws ObjectNotFoundException if the user or file was not found, with
446          *             the exception message mentioning the precise problem
447          * @throws InsufficientPermissionsException if the user does not have the
448          *             appropriate privileges
449          */
450         public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
451
452         /**
453          * Marks  the specified folder as deleted in the specified user's namespace.
454          *
455          * @param userId the ID of the current user
456          * @param folderId the ID of the folder to delete
457          * @throws ObjectNotFoundException if the user or file was not found, with
458          *             the exception message mentioning the precise problem
459          * @throws InsufficientPermissionsException if the user does not have the
460          *             appropriate privileges
461          */
462         public void moveFolderToTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
463
464         /**
465          * Marks  the specified deleted folder as undeleted in the specified user's namespace.
466          *
467          * @param userId the ID of the current user
468          * @param folderId the ID of the folder to undelete
469          * @throws ObjectNotFoundException if the user or file was not found, with
470          *             the exception message mentioning the precise problem
471          * @throws InsufficientPermissionsException if the user does not have the
472          *             appropriate privileges
473          */
474         public void removeFolderFromTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
475
476         /**
477          * Move the provided folder and all its subfolders and files to the specified destination.
478          *
479          * @param userId the ID of the current user
480          * @param folderId the IF of the provided folder
481          * @param destId the ID of the destination folder
482          * @param destName the name of the new folder
483          * @throws ObjectNotFoundException if the user, folder or destination was not
484          *                      found, with     the exception message mentioning the precise problem
485          * @throws DuplicateNameException if the specified name already exists in
486          *          the destination folder, as either a folder or file
487          * @throws InsufficientPermissionsException if the user does not have the
488          *          appropriate privileges
489          * @throws GSSIOException
490          */
491         public void moveFolder(Long userId, Long folderId, Long destId, String destName) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
492
493         /**
494          * move the provided file to the specified destination.
495          *
496          * @param userId the ID of the current user
497          * @param fileId the IF of the provided file
498          * @param destId the ID of the destination folder
499          * @param destName the name of the new file
500          * @throws InsufficientPermissionsException
501          * @throws ObjectNotFoundException if the user, file or destination was not
502          *                      found, with     the exception message mentioning the precise problem
503          * @throws GSSIOException if there was an error while accessing the file contents
504          * @throws DuplicateNameException if the specified name already exists in
505          *          the destination folder, as either a folder or file
506          */
507         public void moveFile(Long userId, Long fileId, Long destId, String destName) throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException, GSSIOException, QuotaExceededException;
508
509         /**
510          * Returns a list of All deleted files of a user.
511          *
512          * @param userId the ID of the User
513          *       * @return the list of deleted file header objects
514          * @throws ObjectNotFoundException if the user cannot be found
515          */
516         public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException;
517
518         /**
519          * Returns a list of All deleted root folders of a user.
520          *
521          * @param userId the ID of the User
522          *       * @return the list of deleted file header objects
523          * @throws ObjectNotFoundException if the user cannot be found
524          */
525         public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
526
527         /**
528          * Empty Trash by deleting all marked as deleted files and folders
529          * @param userId
530          * @throws ObjectNotFoundException if something goes wrong in the delete process
531          * @throws InsufficientPermissionsException  if something goes wrong in the delete process
532          */
533         public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
534
535         /**
536          * Restores All Trashed Items by undeleting all marked as deleted files and folders
537          * @param userId
538          * @throws ObjectNotFoundException if something goes wrong in the delete process
539          * @throws InsufficientPermissionsException if the user does not have the
540          *          appropriate privileges
541          */
542         public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
543
544         /**
545          * Search the system for a user with the specified username.
546          * If no such user is found, the method returns null.
547          *
548          * @param username the username to search for
549          * @return the User object with the specified username
550          */
551         public User findUser(String username);
552
553         /**
554          * Create a new user with the specified name, username and e-mail address.
555          *
556          * @param username the username of the new user
557          * @param name the full name of the new user
558          * @param mail the e-mail of the new user
559          * @return the newly-created User object
560          * @throws DuplicateNameException if a user with the same username already exists
561          * @throws ObjectNotFoundException if no username was provided
562          */
563         public User createUser(String username, String name, String mail) throws DuplicateNameException, ObjectNotFoundException;
564
565         /**
566          * Updates the authentication token for the specified user.
567          *
568          * @param userId the ID of the user whose token should be updated
569          * @return the updated user
570          * @throws ObjectNotFoundException if the user could not be found
571          */
572         public User updateUserToken(Long userId) throws ObjectNotFoundException;
573
574         /**
575          * Invalidates the authentication token for the specified user.
576          *
577          * @param userId the ID of the user whose token should be updated
578          * @throws ObjectNotFoundException if the user could not be found
579          */
580         public void invalidateUserToken(Long userId) throws ObjectNotFoundException;
581
582         /**
583          * Retrieve folder user and group permissions
584          *
585          * @param userId the ID of the user whose token should be updated
586          * @param folderId the ID of the folder
587          * @return the Set of permissions from requested folder
588          * @throws ObjectNotFoundException if the user or folder could not be found
589          * @throws InsufficientPermissionsException
590          */
591         public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
592
593
594         /**
595          * update folder permissions
596          * @param userId
597          * @param folderId
598          * @param permissions
599          * @throws ObjectNotFoundException
600          * @throws InsufficientPermissionsException
601          */
602         public void setFolderPermissions(Long userId, Long folderId, Set<PermissionDTO> permissions) throws ObjectNotFoundException, InsufficientPermissionsException;
603
604
605         /**
606          * Retrieve file user and group permissions
607          *
608          * @param userId the ID of the user whose token should be updated
609          * @param fileId the ID of the folder
610          * @return the Set of permissions from requested folder
611          * @throws ObjectNotFoundException if the user or folder could not be found
612          * @throws InsufficientPermissionsException
613          */
614         public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
615
616
617         /**
618          * update file permissions
619          * @param userId
620          * @param fileId
621          * @param permissions
622          * @throws ObjectNotFoundException
623          * @throws InsufficientPermissionsException
624          */
625         public void setFilePermissions(Long userId, Long fileId, Boolean ReadForAll, Set<PermissionDTO> permissions) throws ObjectNotFoundException, InsufficientPermissionsException;
626
627         /**
628          * Returns a list of All Shared root folders of a user.
629          *
630          * @param userId the ID of the User
631          *       * @return the list of shared root folders
632          * @throws ObjectNotFoundException if the user cannot be found
633          */
634         public List<FolderDTO> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
635
636         /**
637          * Returns a list of All Shared  files of a user.
638          *
639          * @param userId the ID of the User
640          *       * @return the list of shared files
641          * @throws ObjectNotFoundException if the user cannot be found
642          */
643         public List<FileHeaderDTO> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
644
645         /**
646          * Returns a list of All Shared root folders of a user that calling user has at least read permissions.
647          *
648          * @param ownerId the ID of the User
649          * @return the list of shared root folders
650          * @param callingUserId
651          *
652          * @throws ObjectNotFoundException if the user cannot be found
653          */
654         public List<FolderDTO> getSharedRootFolders(Long ownerId, Long callingUserId) throws ObjectNotFoundException;
655
656         /**
657          * Returns a list of All Shared  files of a user that calling user has at least read permissions..
658          *
659          * @param ownerId the ID of the User
660          * @return the list of shared files
661          * @param callingUserId
662          * @throws ObjectNotFoundException if the user cannot be found
663          */
664         public List<FileHeaderDTO> getSharedFiles(Long ownerId, Long callingUserId) throws ObjectNotFoundException;
665
666         /**
667          * Remove a user member from a group
668          *
669          * @param userId the ID of the User owning the group
670          * @param groupId the ID of the requested group
671          * @param memberId the ID of the member to be removed
672          *
673          * @throws ObjectNotFoundException if the user or group was not found, with
674          *             the exception message mentioning the precise problem
675          * @throws InsufficientPermissionsException
676          */
677         public void removeMemberFromGroup(Long userId, Long groupId, Long memberId) throws ObjectNotFoundException, InsufficientPermissionsException;
678
679         /**
680          * Retrieves the list of users sharing files to user identified by user id
681          * @param userId
682          * @return the List of users sharing files to user
683          * @throws ObjectNotFoundException
684          */
685         public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
686
687         /**
688          * Indexes the file meta-data and contents. It actually sends the info to be indexed to a message queue
689          * and the actual indexing will be done in the background
690          *
691          * @param fileId The id of the file to be indexed. The message processor will retreive all file data
692          * by using this id
693          * @param delete if true the file is removed from the index
694          */
695         public void indexFile(Long fileId, boolean delete);
696
697         /**
698          * Search Files
699          *
700          * @param userId
701          * @param query
702          * @return list of files that match query
703          * @throws ObjectNotFoundException
704          */
705         public List<FileHeaderDTO> searchFiles(Long userId, String query) throws ObjectNotFoundException;
706
707         /**
708          * It is used by the Solr mbean to rebuild the index.
709          */
710         public void rebuildSolrIndex();
711
712         /**
713          * Search the system for a user with the specified email address.
714          * If no such user is found, the method returns null.
715          */
716         public User findUserByEmail(String email);
717
718         /**
719          * Update the user with the values from the supplied object.
720          */
721         public void updateUser(User user);
722
723         /**
724          * Check if the user with the specified ID has permission to read the
725          * folder with the supplied ID.
726          */
727         public boolean canReadFolder(Long userId, Long folderId) throws ObjectNotFoundException;
728 }