Statistics
| Branch: | Tag: | Revision:

root / src / gr / ebs / gss / server / ejb / ExternalAPIRemote.java @ d114cfe2

History | View | Annotate | Download (30.1 kB)

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.Date;
35
import java.util.List;
36
import java.util.Set;
37

    
38
import javax.ejb.Remote;
39

    
40
/**
41
 * The External API for GSS clients.
42
 *
43
 * @author chstath
44
 */
45
@Remote
46
public interface ExternalAPIRemote {
47

    
48
        /**
49
         * Retrieves the root folder for the specified user. The caller must ensure
50
         * that the userId exists.
51
         *
52
         * @param userId
53
         * @return Folder
54
         * @throws ObjectNotFoundException if no Folder or user was found
55
         */
56
        public FolderDTO getRootFolder(Long userId) throws ObjectNotFoundException;
57

    
58
        /**
59
         * Retrieve the folder with the specified ID.
60
         *
61
         * @param userId the ID of the current user
62
         * @param folderId the ID of the folder to retrieve
63
         * @return the folder found
64
         * @throws ObjectNotFoundException if the folder or the user was not found
65
         * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
66
         */
67
        public FolderDTO getFolder(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
68

    
69
        /**
70
         * Returns the user with the specified ID.
71
         *
72
         * @param userId The ID of the User to be found
73
         * @return The User object
74
         * @throws ObjectNotFoundException if the user cannot be found
75
         */
76
        public User getUser(Long userId) throws ObjectNotFoundException;
77

    
78
        /**
79
         * Returns the user with the specified ID.
80
         *
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
84
         */
85
        public UserDTO getUserDTO(Long userId) throws ObjectNotFoundException;
86

    
87
        /**
88
         * Returns the group with the specified ID.
89
         *
90
         * @param groupId The ID of the Group to be found
91
         * @return The Group object
92
         * @throws ObjectNotFoundException if the group cannot be found
93
         */
94
        public GroupDTO getGroup(Long groupId) throws ObjectNotFoundException;
95

    
96
        /**
97
         * Retrieve the list of groups for a particular user.
98
         *
99
         * @param userId the ID of the User
100
         * @return a List of Groups that belong to the specified User
101
         * @throws ObjectNotFoundException if the user was not found
102
         */
103
        public List<GroupDTO> getGroups(Long userId) throws ObjectNotFoundException;
104

    
105
        /**
106
         * Returns a list of files contained in the folder specified by its id.
107
         *
108
         * @param userId the ID of the User
109
         * @param folderId the ID of the folder containing the files
110
         * @param ignoreDeleted
111
         * @return the list of file header objects
112
         * @throws ObjectNotFoundException if the user or the folder cannot be found
113
         * @throws InsufficientPermissionsException
114
         */
115
        public List<FileHeaderDTO> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException, InsufficientPermissionsException;
116

    
117
        /**
118
         * Returns a list of users for the specified group
119
         *
120
         * @param userId the ID of the User
121
         * @param groupId the ID of the requested group
122
         * @return List<UserDTO>
123
         * @throws ObjectNotFoundException if the user or group was not found, with
124
         *             the exception message mentioning the precise problem
125
         */
126
        public List<UserDTO> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
127

    
128
        /**
129
         * Returns a list of users for the specified username
130
         *
131
         * @param username the username of the User
132
         * @return List<UserDTO>
133
         */
134
        public List<UserDTO> getUsersByUserNameLike(String username);
135

    
136
        /**
137
         * Creates a new folder with the specified owner, parent folder and name.
138
         * New folder has the same permissions as its parent
139
         *
140
         * @param userId
141
         * @param parentId
142
         * @param name
143
         * @return the new folder
144
         * @throws DuplicateNameException if the specified name already exists in
145
         *             the parent folder, as either a folder or file
146
         * @throws ObjectNotFoundException if the user or parent folder was not
147
         *             found, with the exception message mentioning the precise
148
         *             problem
149
         * @throws InsufficientPermissionsException
150
         */
151
        public FolderDTO createFolder(Long userId, Long parentId, String name) throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
152

    
153
        /**
154
         * Deletes the specified folder if the specified user has the appropriate
155
         * permission
156
         *
157
         * @param userId
158
         * @param folderId
159
         * @throws InsufficientPermissionsException if the user does not have the
160
         *             appropriate privileges
161
         * @throws ObjectNotFoundException if the user or folder was not found, with
162
         *             the exception message mentioning the precise problem
163
         */
164
        public void deleteFolder(Long userId, Long folderId) throws InsufficientPermissionsException, ObjectNotFoundException;
165

    
166
        /**
167
         * Retrieve the subfolders of the specified folder.
168
         *
169
         * @param userId the ID of the current user
170
         * @param folderId the ID of the folder to retrieve
171
         * @return the list of subfolders found
172
         * @throws ObjectNotFoundException if the folder or user was not found
173
         * @throws InsufficientPermissionsException
174
         */
175
        public List<FolderDTO> getSubfolders(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
176

    
177

    
178
        /**
179
         * Retrieve the subfolders of the specified folder that are shared to others.
180
         *
181
         * @param userId the ID of the current user
182
         * @param folderId the ID of the folder to retrieve
183
         * @return the list of subfolders found
184
         * @throws ObjectNotFoundException if the folder or user was not found
185
         */
186
        public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
187

    
188
        /**
189
         * Modifies the specified folder if the specified user has the appropriate
190
         * permission.
191
         *
192
         * @param userId the ID of the current user
193
         * @param folderId the ID of the folder to retrieve
194
         * @param folderName
195
         * @return the updated folder
196
         * @throws InsufficientPermissionsException if the user does not have the
197
         *             appropriate privileges
198
         * @throws ObjectNotFoundException if the user or folder was not found, with
199
         *             the exception message mentioning the precise problem
200
         * @throws DuplicateNameException if the specified name already exists in
201
         *             the parent folder, as either a folder or file
202
         */
203
        public FolderDTO modifyFolder(Long userId, Long folderId, String folderName) throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
204

    
205
        /**
206
         * Adds a user to the specified group
207
         *
208
         * @param userId the ID of the current user
209
         * @param groupId the id of the new group
210
         * @param userToAddId the id of the user to add
211
         * @throws DuplicateNameException if the user already exists in group
212
         * @throws ObjectNotFoundException if the user or group was not found, with
213
         *             the exception message mentioning the precise problem
214
         * @throws InsufficientPermissionsException
215
         */
216
        public void addUserToGroup(Long userId, Long groupId, Long userToAddId) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
217

    
218
        /**
219
         * Creates a new group with the specified owner and name.
220
         *
221
         * @param userId the ID of the current user
222
         * @param name the name of the new group
223
         * @throws DuplicateNameException if the new group name already exists
224
         * @throws ObjectNotFoundException if the user or group was not found, with
225
         *             the exception message mentioning the precise problem
226
         */
227
        public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
228

    
229
        /**
230
         * Deletes the specified group in the specified user's namespace.
231
         *
232
         * @param userId the ID of the current user
233
         * @param groupId the ID of the group to delete
234
         * @throws ObjectNotFoundException if the user or group was not found, with
235
         *             the exception message mentioning the precise problem
236
         * @throws InsufficientPermissionsException
237
         */
238
        public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
239

    
240
        /**
241
         * Creates a new file with the specified owner, parent folder and name. The
242
         * new file has the same permissions as its parent folder. The file contents
243
         * are read from the input stream to a new File object.
244
         *
245
         * @param userId the ID of the current user
246
         * @param folderId the ID of the parent folder
247
         * @param name the name of the new file
248
         * @param mimeType the MIME type of the file
249
         * @param stream the input stream with the file contents
250
         * @return The FileHeaderDTO created
251
         * @throws DuplicateNameException if the specified name already exists in
252
         *             the parent folder, as either a folder or file
253
         * @throws ObjectNotFoundException if the user or parent folder was not
254
         *             found, with the exception message mentioning the precise
255
         *             problem
256
         * @throws GSSIOException if there was an error while storing the file contents
257
         * @throws InsufficientPermissionsException
258
         */
259
        public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, InputStream stream) throws DuplicateNameException, ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
260

    
261
        /**
262
         * Deletes the specified file in the specified user's namespace.
263
         *
264
         * @param userId the ID of the current user
265
         * @param fileId the ID of the file to delete
266
         * @throws ObjectNotFoundException if the user or file was not found, with
267
         *             the exception message mentioning the precise problem
268
         * @throws InsufficientPermissionsException if the user does not have the
269
         *             appropriate privileges
270
         */
271
        public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
272

    
273
        /**
274
         * Creates a new tag for the specified user and file.
275
         *
276
         * @param userId the creator of the tag
277
         * @param fileHeaderId the file that is tagged
278
         * @param tag the tag
279
         * @throws ObjectNotFoundException if the user or the file was not found
280
         */
281
        public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
282

    
283
        /**
284
         * Returns all tags defined by the specified user
285
         *
286
         * @param userId
287
         * @return Set<String>
288
         * @throws ObjectNotFoundException if the user was null
289
         */
290
        public Set<String> getUserTags(final Long userId) throws ObjectNotFoundException;
291

    
292
        /**
293
         * Updates the attributes of the specified file.
294
         *
295
         * @param userId
296
         * @param fileId
297
         * @param name
298
         * @param tagSet a String that contains tags separated by comma
299
         * @param modificationDate the modification date
300
         * @throws ObjectNotFoundException
301
         * @throws InsufficientPermissionsException
302
         */
303
        public void updateFile(Long userId, Long fileId, String name, String tagSet, Date modificationDate)
304
                        throws ObjectNotFoundException, InsufficientPermissionsException;
305

    
306
        /**
307
         * Retrieve the contents of the current body for the file
308
         * with the specified FileHeader ID. The file contents
309
         * are provided as an InputStream from which the caller can
310
         * retrieve the raw bytes.
311
         *
312
         * @param userId the ID of the current user
313
         * @param fileId the ID of the file to retrieve
314
         * @return an InputStream from the current file body contents
315
         * @throws ObjectNotFoundException if the file or the user was not found
316
         * @throws InsufficientPermissionsException  if the user does not have the
317
         *             appropriate privileges
318
         */
319
        public InputStream getFileContents(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
320

    
321
        /**
322
         * Retrieve the file with the specified ID.
323
         *
324
         * @param userId the ID of the current user
325
         * @param fileId the ID of the file to retrieve
326
         * @return the file found
327
         * @throws ObjectNotFoundException if the file or the user was not found, with
328
         *                         the exception message mentioning the precise problem
329
         * @throws InsufficientPermissionsException
330
         */
331
        public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
332

    
333
        /**
334
         * Get the resource (file or folder) at the specified path in
335
         * the specified user's namespace. The returned object will be of type
336
         * FileHeaderDTO or FolderDTO.<p><strong>Note:</strong> this method does not
337
         * receive the current user as a parameter, therefore it is unable to perform
338
         * the necessary permission checks and should <strong>NOT</strong> be directly
339
         * exposed to remote clients. It is the caller's responsibility to verify that
340
         * the calling user has the required privileges for performing any subsequent
341
         * action on the resource through one of the other ExternalAPI methods.
342
         *
343
         * @param ownerId the ID of the user owning the namespace
344
         * @param path the absolute path in the user's namespace
345
         * @param ignoreDeleted if true, resources that have been moved to the trash
346
         *                         will be ignored
347
         * @throws ObjectNotFoundException if the user or resource was not found, with
348
         *                         the exception message mentioning the precise problem
349
         * @return the resource found
350
         */
351
        public Object getResourceAtPath(Long ownerId, String path, boolean ignoreDeleted)
352
                        throws ObjectNotFoundException;
353

    
354
        /**
355
         * Copy the provided file to the specified destination.
356
         *
357
         * @param userId the ID of the current user
358
         * @param fileId the IF of the provided file
359
         * @param dest the path to the destination folder
360
         * @throws ObjectNotFoundException if the user, file or destination was not
361
         *                         found, with        the exception message mentioning the precise problem
362
         * @throws GSSIOException if there was an error while accessing the file contents
363
         * @throws DuplicateNameException if the specified name already exists in
364
         *          the destination folder, as either a folder or file
365
         * @throws InsufficientPermissionsException
366
         */
367
        public void copyFile(Long userId, Long fileId, String dest) throws ObjectNotFoundException, DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
368

    
369
        /**
370
         * Copy the provided file to the specified destination.
371
         *
372
         * @param userId the ID of the current user
373
         * @param fileId the IF of the provided file
374
         * @param destId the ID of the destination folder
375
         * @param destName the name of the new file
376
         * @throws ObjectNotFoundException if the user, file or destination was not
377
         *                         found, with        the exception message mentioning the precise problem
378
         * @throws GSSIOException if there was an error while accessing the file contents
379
         * @throws DuplicateNameException if the specified name already exists in
380
         *          the destination folder, as either a folder or file
381
         * @throws InsufficientPermissionsException
382
         */
383
        public void copyFile(Long userId, Long fileId, Long destId, String destName) throws ObjectNotFoundException, DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
384

    
385
        /**
386
         * Copy the provided folder to the specified destination.
387
         *
388
         * @param userId the ID of the current user
389
         * @param folderId the IF of the provided folder
390
         * @param dest the path to the destination folder
391
         * @throws ObjectNotFoundException if the user, folder or destination was not
392
         *                         found, with        the exception message mentioning the precise problem
393
         * @throws DuplicateNameException if the specified name already exists in
394
         *          the destination folder, as either a folder or file
395
         * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
396
         *          appropriate privileges
397
         */
398
        public void copyFolder(Long userId, Long folderId, String dest) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException, QuotaExceededException;
399

    
400
        /**
401
         * Copy the provided folder to the specified destination.
402
         *
403
         * @param userId the ID of the current user
404
         * @param folderId the IF of the provided folder
405
         * @param destId the ID of the destination folder
406
         * @param destName the name of the new folder
407
         * @throws ObjectNotFoundException if the user, folder or destination was not
408
         *                         found, with        the exception message mentioning the precise problem
409
         * @throws DuplicateNameException if the specified name already exists in
410
         *          the destination folder, as either a folder or file
411
         * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
412
         *          appropriate privileges
413
         */
414
        public void copyFolder(Long userId, Long folderId, Long destId, String destName) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException, QuotaExceededException;
415

    
416
        /**
417
         * Copy the provided folder and all its subfolders and files to the specified destination.
418
         *
419
         * @param userId the ID of the current user
420
         * @param folderId the IF of the provided folder
421
         * @param destId the ID of the destination folder
422
         * @param destName the name of the new folder
423
         * @throws ObjectNotFoundException if the user, folder or destination was not
424
         *                         found, with        the exception message mentioning the precise problem
425
         * @throws DuplicateNameException if the specified name already exists in
426
         *          the destination folder, as either a folder or file
427
         * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
428
         *          appropriate privileges
429
         * @throws GSSIOException
430
         */
431
        public void copyFolderStructure(Long userId, Long folderId, Long destId, String destName) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,GSSIOException, QuotaExceededException;
432

    
433
        /**
434
         * Marks  the specified file as deleted in the specified user's namespace.
435
         *
436
         * @param userId the ID of the current user
437
         * @param fileId the ID of the file to delete
438
         * @throws ObjectNotFoundException if the user or file was not found, with
439
         *             the exception message mentioning the precise problem
440
         * @throws InsufficientPermissionsException if the user does not have the
441
         *             appropriate privileges
442
         */
443
        public void moveFileToTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
444

    
445
        /**
446
         * Marks  the specified deleted file as undeleted in the specified user's namespace.
447
         *
448
         * @param userId the ID of the current user
449
         * @param fileId the ID of the file to undelete
450
         * @throws ObjectNotFoundException if the user or file was not found, with
451
         *             the exception message mentioning the precise problem
452
         * @throws InsufficientPermissionsException if the user does not have the
453
         *             appropriate privileges
454
         */
455
        public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
456

    
457
        /**
458
         * Marks  the specified folder as deleted in the specified user's namespace.
459
         *
460
         * @param userId the ID of the current user
461
         * @param folderId the ID of the folder to delete
462
         * @throws ObjectNotFoundException if the user or file was not found, with
463
         *             the exception message mentioning the precise problem
464
         * @throws InsufficientPermissionsException if the user does not have the
465
         *             appropriate privileges
466
         */
467
        public void moveFolderToTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
468

    
469
        /**
470
         * Marks  the specified deleted folder as undeleted in the specified user's namespace.
471
         *
472
         * @param userId the ID of the current user
473
         * @param folderId the ID of the folder to undelete
474
         * @throws ObjectNotFoundException if the user or file was not found, with
475
         *             the exception message mentioning the precise problem
476
         * @throws InsufficientPermissionsException if the user does not have the
477
         *             appropriate privileges
478
         */
479
        public void removeFolderFromTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
480

    
481
        /**
482
         * Move the provided folder and all its subfolders and files to the specified destination.
483
         *
484
         * @param userId the ID of the current user
485
         * @param folderId the IF of the provided folder
486
         * @param destId the ID of the destination folder
487
         * @param destName the name of the new folder
488
         * @throws ObjectNotFoundException if the user, folder or destination was not
489
         *                         found, with        the exception message mentioning the precise problem
490
         * @throws DuplicateNameException if the specified name already exists in
491
         *          the destination folder, as either a folder or file
492
         * @throws InsufficientPermissionsException if the user does not have the
493
         *          appropriate privileges
494
         * @throws GSSIOException
495
         */
496
        public void moveFolder(Long userId, Long folderId, Long destId, String destName) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
497

    
498
        /**
499
         * move the provided file to the specified destination.
500
         *
501
         * @param userId the ID of the current user
502
         * @param fileId the IF of the provided file
503
         * @param destId the ID of the destination folder
504
         * @param destName the name of the new file
505
         * @throws InsufficientPermissionsException
506
         * @throws ObjectNotFoundException if the user, file or destination was not
507
         *                         found, with        the exception message mentioning the precise problem
508
         * @throws GSSIOException if there was an error while accessing the file contents
509
         * @throws DuplicateNameException if the specified name already exists in
510
         *          the destination folder, as either a folder or file
511
         */
512
        public void moveFile(Long userId, Long fileId, Long destId, String destName) throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException, GSSIOException, QuotaExceededException;
513

    
514
        /**
515
         * Returns a list of All deleted files of a user.
516
         *
517
         * @param userId the ID of the User
518
         *          * @return the list of deleted file header objects
519
         * @throws ObjectNotFoundException if the user cannot be found
520
         */
521
        public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException;
522

    
523
        /**
524
         * Returns a list of All deleted root folders of a user.
525
         *
526
         * @param userId the ID of the User
527
         *          * @return the list of deleted file header objects
528
         * @throws ObjectNotFoundException if the user cannot be found
529
         */
530
        public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
531

    
532
        /**
533
         * Empty Trash by deleting all marked as deleted files and folders
534
         * @param userId
535
         * @throws ObjectNotFoundException if something goes wrong in the delete process
536
         * @throws InsufficientPermissionsException  if something goes wrong in the delete process
537
         */
538
        public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
539

    
540
        /**
541
         * Restores All Trashed Items by undeleting all marked as deleted files and folders
542
         * @param userId
543
         * @throws ObjectNotFoundException if something goes wrong in the delete process
544
         * @throws InsufficientPermissionsException if the user does not have the
545
         *          appropriate privileges
546
         */
547
        public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
548

    
549
        /**
550
         * Search the system for a user with the specified username.
551
         * If no such user is found, the method returns null.
552
         *
553
         * @param username the username to search for
554
         * @return the User object with the specified username
555
         */
556
        public User findUser(String username);
557

    
558
        /**
559
         * Create a new user with the specified name, username and e-mail address.
560
         *
561
         * @param username the username of the new user
562
         * @param name the full name of the new user
563
         * @param mail the e-mail of the new user
564
         * @return the newly-created User object
565
         * @throws DuplicateNameException if a user with the same username already exists
566
         * @throws ObjectNotFoundException if no username was provided
567
         */
568
        public User createUser(String username, String name, String mail) throws DuplicateNameException, ObjectNotFoundException;
569

    
570
        /**
571
         * Updates the authentication token for the specified user.
572
         *
573
         * @param userId the ID of the user whose token should be updated
574
         * @return the updated user
575
         * @throws ObjectNotFoundException if the user could not be found
576
         */
577
        public User updateUserToken(Long userId) throws ObjectNotFoundException;
578

    
579
        /**
580
         * Invalidates the authentication token for the specified user.
581
         *
582
         * @param userId the ID of the user whose token should be updated
583
         * @throws ObjectNotFoundException if the user could not be found
584
         */
585
        public void invalidateUserToken(Long userId) throws ObjectNotFoundException;
586

    
587
        /**
588
         * Retrieve folder user and group permissions
589
         *
590
         * @param userId the ID of the user whose token should be updated
591
         * @param folderId the ID of the folder
592
         * @return the Set of permissions from requested folder
593
         * @throws ObjectNotFoundException if the user or folder could not be found
594
         * @throws InsufficientPermissionsException
595
         */
596
        public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
597

    
598

    
599
        /**
600
         * update folder permissions
601
         * @param userId
602
         * @param folderId
603
         * @param permissions
604
         * @throws ObjectNotFoundException
605
         * @throws InsufficientPermissionsException
606
         */
607
        public void setFolderPermissions(Long userId, Long folderId, Set<PermissionDTO> permissions) throws ObjectNotFoundException, InsufficientPermissionsException;
608

    
609

    
610
        /**
611
         * Retrieve file user and group permissions
612
         *
613
         * @param userId the ID of the user whose token should be updated
614
         * @param fileId the ID of the folder
615
         * @return the Set of permissions from requested folder
616
         * @throws ObjectNotFoundException if the user or folder could not be found
617
         * @throws InsufficientPermissionsException
618
         */
619
        public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
620

    
621

    
622
        /**
623
         * update file permissions
624
         * @param userId
625
         * @param fileId
626
         * @param permissions
627
         * @throws ObjectNotFoundException
628
         * @throws InsufficientPermissionsException
629
         */
630
        public void setFilePermissions(Long userId, Long fileId, Boolean ReadForAll, Set<PermissionDTO> permissions) throws ObjectNotFoundException, InsufficientPermissionsException;
631

    
632
        /**
633
         * Returns a list of All Shared root folders of a user.
634
         *
635
         * @param userId the ID of the User
636
         *          * @return the list of shared root folders
637
         * @throws ObjectNotFoundException if the user cannot be found
638
         */
639
        public List<FolderDTO> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
640

    
641
        /**
642
         * Returns a list of All Shared  files of a user.
643
         *
644
         * @param userId the ID of the User
645
         *          * @return the list of shared files
646
         * @throws ObjectNotFoundException if the user cannot be found
647
         */
648
        public List<FileHeaderDTO> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
649

    
650
        /**
651
         * Returns a list of All Shared root folders of a user that calling user has at least read permissions.
652
         *
653
         * @param ownerId the ID of the User
654
         * @return the list of shared root folders
655
         * @param callingUserId
656
         *
657
         * @throws ObjectNotFoundException if the user cannot be found
658
         */
659
        public List<FolderDTO> getSharedRootFolders(Long ownerId, Long callingUserId) throws ObjectNotFoundException;
660

    
661
        /**
662
         * Returns a list of All Shared  files of a user that calling user has at least read permissions..
663
         *
664
         * @param ownerId the ID of the User
665
         * @return the list of shared files
666
         * @param callingUserId
667
         * @throws ObjectNotFoundException if the user cannot be found
668
         */
669
        public List<FileHeaderDTO> getSharedFiles(Long ownerId, Long callingUserId) throws ObjectNotFoundException;
670

    
671
        /**
672
         * Remove a user member from a group
673
         *
674
         * @param userId the ID of the User owning the group
675
         * @param groupId the ID of the requested group
676
         * @param memberId the ID of the member to be removed
677
         *
678
         * @throws ObjectNotFoundException if the user or group was not found, with
679
         *             the exception message mentioning the precise problem
680
         * @throws InsufficientPermissionsException
681
         */
682
        public void removeMemberFromGroup(Long userId, Long groupId, Long memberId) throws ObjectNotFoundException, InsufficientPermissionsException;
683

    
684
        /**
685
         * Retrieves the list of users sharing files to user identified by user id
686
         * @param userId
687
         * @return the List of users sharing files to user
688
         * @throws ObjectNotFoundException
689
         */
690
        public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
691

    
692
        /**
693
         * Indexes the file meta-data and contents. It actually sends the info to be indexed to a message queue
694
         * and the actual indexing will be done in the background
695
         *
696
         * @param fileId The id of the file to be indexed. The message processor will retreive all file data
697
         * by using this id
698
         * @param delete if true the file is removed from the index
699
         */
700
        public void indexFile(Long fileId, boolean delete);
701

    
702
        /**
703
         * Search Files
704
         *
705
         * @param userId
706
         * @param query
707
         * @return list of files that match query
708
         * @throws ObjectNotFoundException
709
         */
710
        public List<FileHeaderDTO> searchFiles(Long userId, String query) throws ObjectNotFoundException;
711

    
712
        /**
713
         * It is used by the Solr mbean to rebuild the index.
714
         */
715
        public void rebuildSolrIndex();
716

    
717
        /**
718
         * Search the system for a user with the specified email address.
719
         * If no such user is found, the method returns null.
720
         */
721
        public User findUserByEmail(String email);
722

    
723
        /**
724
         * Update the user with the values from the supplied object.
725
         */
726
        public void updateUser(User user);
727

    
728
        /**
729
         * Check if the user with the specified ID has permission to read the
730
         * folder with the supplied ID.
731
         */
732
        public boolean canReadFolder(Long userId, Long folderId) throws ObjectNotFoundException;
733
}