Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (30 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.FileHeader;
27
import gr.ebs.gss.server.domain.Folder;
28
import gr.ebs.gss.server.domain.Group;
29
import gr.ebs.gss.server.domain.Permission;
30
import gr.ebs.gss.server.domain.User;
31
import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
32
import gr.ebs.gss.server.domain.dto.FolderDTO;
33
import gr.ebs.gss.server.domain.dto.PermissionDTO;
34
import gr.ebs.gss.server.domain.dto.UserDTO;
35

    
36
import java.io.InputStream;
37
import java.util.Date;
38
import java.util.List;
39
import java.util.Set;
40

    
41
import javax.ejb.Remote;
42

    
43
/**
44
 * The External API for GSS clients.
45
 *
46
 * @author chstath
47
 */
48
@Remote
49
public interface ExternalAPIRemote {
50

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

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

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

    
81
        /**
82
         * Returns the user with the specified ID.
83
         *
84
         * @param userId The ID of the User to be found
85
         * @return The User object
86
         * @throws ObjectNotFoundException if the user cannot be found
87
         */
88
        public UserDTO getUserDTO(Long userId) throws ObjectNotFoundException;
89

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

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

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

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

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

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

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

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

    
180

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

    
191
        /**
192
         * Modifies the specified folder if the specified user has the appropriate
193
         * permission.
194
         *
195
         * @param userId the ID of the current user
196
         * @param folderId the ID of the folder to retrieve
197
         * @param folderName
198
         * @param readForAll
199
         * @param permissions
200
         * @return the updated folder
201
         * @throws InsufficientPermissionsException if the user does not have the
202
         *             appropriate privileges
203
         * @throws ObjectNotFoundException if the user or folder was not found, with
204
         *             the exception message mentioning the precise problem
205
         * @throws DuplicateNameException if the specified name already exists in
206
         *             the parent folder, as either a folder or file
207
         */
208
        public Folder updateFolder(Long userId, Long folderId, String folderName,
209
                                Boolean readForAll,
210
                                Set<Permission> permissions)
211
                        throws InsufficientPermissionsException, ObjectNotFoundException,
212
                        DuplicateNameException;
213

    
214
        /**
215
         * Adds a user to the specified group
216
         *
217
         * @param userId the ID of the current user
218
         * @param groupId the id of the new group
219
         * @param userToAddId the id of the user to add
220
         * @throws DuplicateNameException if the user already exists in group
221
         * @throws ObjectNotFoundException if the user or group was not found, with
222
         *             the exception message mentioning the precise problem
223
         * @throws InsufficientPermissionsException
224
         */
225
        public void addUserToGroup(Long userId, Long groupId, Long userToAddId) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
226

    
227
        /**
228
         * Creates a new group with the specified owner and name.
229
         *
230
         * @param userId the ID of the current user
231
         * @param name the name of the new group
232
         * @throws DuplicateNameException if the new group name already exists
233
         * @throws ObjectNotFoundException if the user or group was not found, with
234
         *             the exception message mentioning the precise problem
235
         */
236
        public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
237

    
238
        /**
239
         * Deletes the specified group in the specified user's namespace.
240
         *
241
         * @param userId the ID of the current user
242
         * @param groupId the ID of the group to delete
243
         * @throws ObjectNotFoundException if the user or group was not found, with
244
         *             the exception message mentioning the precise problem
245
         * @throws InsufficientPermissionsException
246
         */
247
        public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
248

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

    
270
        /**
271
         * Deletes the specified file in the specified user's namespace.
272
         *
273
         * @param userId the ID of the current user
274
         * @param fileId the ID of the file to delete
275
         * @throws ObjectNotFoundException if the user or file was not found, with
276
         *             the exception message mentioning the precise problem
277
         * @throws InsufficientPermissionsException if the user does not have the
278
         *             appropriate privileges
279
         */
280
        public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
281

    
282
        /**
283
         * Creates a new tag for the specified user and file.
284
         *
285
         * @param userId the creator of the tag
286
         * @param fileHeaderId the file that is tagged
287
         * @param tag the tag
288
         * @throws ObjectNotFoundException if the user or the file was not found
289
         */
290
        public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
291

    
292
        /**
293
         * Returns all tags defined by the specified user
294
         *
295
         * @param userId
296
         * @return Set<String>
297
         * @throws ObjectNotFoundException if the user was null
298
         */
299
        public Set<String> getUserTags(final Long userId) throws ObjectNotFoundException;
300

    
301
        /**
302
         * Updates the attributes of the specified file.
303
         *
304
         * @param userId
305
         * @param fileId
306
         * @param name
307
         * @param tagSet a String that contains tags separated by comma
308
         * @param modificationDate the modification date
309
         * @param versioned the new value of the versioned flag
310
         * @param readForAll
311
         * @param permissions
312
         * @throws DuplicateNameException
313
         * @throws ObjectNotFoundException
314
         * @throws InsufficientPermissionsException
315
         */
316
        public void updateFile(Long userId, Long fileId, String name, String tagSet,
317
                        Date modificationDate, Boolean versioned, Boolean readForAll,
318
                        Set<Permission> permissions)
319
                        throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
320

    
321
        /**
322
         * Retrieve the contents of the current body for the file
323
         * with the specified FileHeader ID. The file contents
324
         * are provided as an InputStream from which the caller can
325
         * retrieve the raw bytes.
326
         *
327
         * @param userId the ID of the current user
328
         * @param fileId the ID of the file to retrieve
329
         * @return an InputStream from the current file body contents
330
         * @throws ObjectNotFoundException if the file or the user was not found
331
         * @throws InsufficientPermissionsException  if the user does not have the
332
         *             appropriate privileges
333
         */
334
        public InputStream getFileContents(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
335

    
336
        /**
337
         * Retrieve the file with the specified ID.
338
         *
339
         * @param userId the ID of the current user
340
         * @param fileId the ID of the file to retrieve
341
         * @return the file found
342
         * @throws ObjectNotFoundException if the file or the user was not found, with
343
         *                         the exception message mentioning the precise problem
344
         * @throws InsufficientPermissionsException
345
         */
346
        public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
347

    
348
        /**
349
         * Get the resource (file or folder) at the specified path in
350
         * the specified user's namespace. The returned object will be of type
351
         * FileHeaderDTO or FolderDTO.<p><strong>Note:</strong> this method does not
352
         * receive the current user as a parameter, therefore it is unable to perform
353
         * the necessary permission checks and should <strong>NOT</strong> be directly
354
         * exposed to remote clients. It is the caller's responsibility to verify that
355
         * the calling user has the required privileges for performing any subsequent
356
         * action on the resource through one of the other ExternalAPI methods.
357
         *
358
         * @param ownerId the ID of the user owning the namespace
359
         * @param path the absolute path in the user's namespace
360
         * @param ignoreDeleted if true, resources that have been moved to the trash
361
         *                         will be ignored
362
         * @throws ObjectNotFoundException if the user or resource was not found, with
363
         *                         the exception message mentioning the precise problem
364
         * @return the resource found
365
         */
366
        public Object getResourceAtPath(Long ownerId, String path, boolean ignoreDeleted)
367
                        throws ObjectNotFoundException;
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 dest the path to the destination folder
375
         * @throws ObjectNotFoundException if the user, file or destination was not
376
         *                         found, with        the exception message mentioning the precise problem
377
         * @throws GSSIOException if there was an error while accessing the file contents
378
         * @throws DuplicateNameException if the specified name already exists in
379
         *          the destination folder, as either a folder or file
380
         * @throws InsufficientPermissionsException
381
         */
382
        public void copyFile(Long userId, Long fileId, String dest) throws ObjectNotFoundException, DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
383

    
384
        /**
385
         * Copy the provided file to the specified destination.
386
         *
387
         * @param userId the ID of the current user
388
         * @param fileId the IF of the provided file
389
         * @param destId the ID of the destination folder
390
         * @param destName the name of the new file
391
         * @throws ObjectNotFoundException if the user, file or destination was not
392
         *                         found, with        the exception message mentioning the precise problem
393
         * @throws GSSIOException if there was an error while accessing the file contents
394
         * @throws DuplicateNameException if the specified name already exists in
395
         *          the destination folder, as either a folder or file
396
         * @throws InsufficientPermissionsException
397
         */
398
        public void copyFile(Long userId, Long fileId, Long destId, String destName) throws ObjectNotFoundException, DuplicateNameException, GSSIOException, 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 dest the path to the destination folder
406
         * @throws ObjectNotFoundException if the user, folder or destination was not
407
         *                         found, with        the exception message mentioning the precise problem
408
         * @throws DuplicateNameException if the specified name already exists in
409
         *          the destination folder, as either a folder or file
410
         * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
411
         *          appropriate privileges
412
         */
413
        public void copyFolder(Long userId, Long folderId, String dest) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException, QuotaExceededException;
414

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

    
431
        /**
432
         * Copy the provided folder and all its subfolders and files to the specified destination.
433
         *
434
         * @param userId the ID of the current user
435
         * @param folderId the IF of the provided folder
436
         * @param destId the ID of the destination folder
437
         * @param destName the name of the new folder
438
         * @throws ObjectNotFoundException if the user, folder or destination was not
439
         *                         found, with        the exception message mentioning the precise problem
440
         * @throws DuplicateNameException if the specified name already exists in
441
         *          the destination folder, as either a folder or file
442
         * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
443
         *          appropriate privileges
444
         * @throws GSSIOException
445
         */
446
        public void copyFolderStructure(Long userId, Long folderId, Long destId, String destName) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,GSSIOException, QuotaExceededException;
447

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

    
460
        /**
461
         * Marks  the specified deleted file as undeleted in the specified user's namespace.
462
         *
463
         * @param userId the ID of the current user
464
         * @param fileId the ID of the file to undelete
465
         * @throws ObjectNotFoundException if the user or file was not found, with
466
         *             the exception message mentioning the precise problem
467
         * @throws InsufficientPermissionsException if the user does not have the
468
         *             appropriate privileges
469
         */
470
        public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
471

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

    
484
        /**
485
         * Marks  the specified deleted folder as undeleted in the specified user's namespace.
486
         *
487
         * @param userId the ID of the current user
488
         * @param folderId the ID of the folder to undelete
489
         * @throws ObjectNotFoundException if the user or file was not found, with
490
         *             the exception message mentioning the precise problem
491
         * @throws InsufficientPermissionsException if the user does not have the
492
         *             appropriate privileges
493
         */
494
        public void removeFolderFromTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
495

    
496
        /**
497
         * Move the provided folder and all its subfolders and files to the specified destination.
498
         *
499
         * @param userId the ID of the current user
500
         * @param folderId the IF of the provided folder
501
         * @param destId the ID of the destination folder
502
         * @param destName the name of the new folder
503
         * @throws ObjectNotFoundException if the user, folder or destination was not
504
         *                         found, with        the exception message mentioning the precise problem
505
         * @throws DuplicateNameException if the specified name already exists in
506
         *          the destination folder, as either a folder or file
507
         * @throws InsufficientPermissionsException if the user does not have the
508
         *          appropriate privileges
509
         * @throws GSSIOException
510
         */
511
        public void moveFolder(Long userId, Long folderId, Long destId, String destName) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
512

    
513
        /**
514
         * move the provided file to the specified destination.
515
         *
516
         * @param userId the ID of the current user
517
         * @param fileId the IF of the provided file
518
         * @param destId the ID of the destination folder
519
         * @param destName the name of the new file
520
         * @throws InsufficientPermissionsException
521
         * @throws ObjectNotFoundException if the user, file or destination was not
522
         *                         found, with        the exception message mentioning the precise problem
523
         * @throws GSSIOException if there was an error while accessing the file contents
524
         * @throws DuplicateNameException if the specified name already exists in
525
         *          the destination folder, as either a folder or file
526
         */
527
        public void moveFile(Long userId, Long fileId, Long destId, String destName) throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException, GSSIOException, QuotaExceededException;
528

    
529
        /**
530
         * Returns a list of All deleted files of a user.
531
         *
532
         * @param userId the ID of the User
533
         *          * @return the list of deleted file header objects
534
         * @throws ObjectNotFoundException if the user cannot be found
535
         */
536
        public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException;
537

    
538
        /**
539
         * Returns a list of All deleted root folders of a user.
540
         *
541
         * @param userId the ID of the User
542
         *          * @return the list of deleted file header objects
543
         * @throws ObjectNotFoundException if the user cannot be found
544
         */
545
        public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
546

    
547
        /**
548
         * Empty Trash by deleting all marked as deleted files and folders
549
         * @param userId
550
         * @throws ObjectNotFoundException if something goes wrong in the delete process
551
         * @throws InsufficientPermissionsException  if something goes wrong in the delete process
552
         */
553
        public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
554

    
555
        /**
556
         * Restores All Trashed Items by undeleting all marked as deleted files and folders
557
         * @param userId
558
         * @throws ObjectNotFoundException if something goes wrong in the delete process
559
         * @throws InsufficientPermissionsException if the user does not have the
560
         *          appropriate privileges
561
         */
562
        public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
563

    
564
        /**
565
         * Search the system for a user with the specified username.
566
         * If no such user is found, the method returns null.
567
         *
568
         * @param username the username to search for
569
         * @return the User object with the specified username
570
         */
571
        public User findUser(String username);
572

    
573
        /**
574
         * Create a new user with the specified name, username and e-mail address.
575
         *
576
         * @param username the username of the new user
577
         * @param name the full name of the new user
578
         * @param mail the e-mail of the new user
579
         * @param idp the IdP of the new user
580
         * @param idpid the IdP ID of the new user
581
         * @return the newly-created User object
582
         * @throws DuplicateNameException if a user with the same username already exists
583
         * @throws ObjectNotFoundException if no username was provided
584
         */
585
        public User createUser(String username, String name, String mail,
586
                                String idp, String idpid) throws DuplicateNameException,
587
                                ObjectNotFoundException;
588

    
589
        /**
590
         * Updates the authentication token for the specified user.
591
         *
592
         * @param userId the ID of the user whose token should be updated
593
         * @return the updated user
594
         * @throws ObjectNotFoundException if the user could not be found
595
         */
596
        public User updateUserToken(Long userId) throws ObjectNotFoundException;
597

    
598
        /**
599
         * Invalidates the authentication token for the specified user.
600
         *
601
         * @param userId the ID of the user whose token should be updated
602
         * @throws ObjectNotFoundException if the user could not be found
603
         */
604
        public void invalidateUserToken(Long userId) throws ObjectNotFoundException;
605

    
606
        /**
607
         * Retrieve folder user and group permissions
608
         *
609
         * @param userId the ID of the user whose token should be updated
610
         * @param folderId the ID of the folder
611
         * @return the Set of permissions from requested folder
612
         * @throws ObjectNotFoundException if the user or folder could not be found
613
         * @throws InsufficientPermissionsException
614
         */
615
        public Set<Permission> getFolderPermissions(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
616

    
617
        /**
618
         * Retrieve file user and group permissions
619
         *
620
         * @param userId the ID of the user whose token should be updated
621
         * @param fileId the ID of the folder
622
         * @return the Set of permissions from requested folder
623
         * @throws ObjectNotFoundException if the user or folder could not be found
624
         * @throws InsufficientPermissionsException
625
         */
626
        public Set<Permission> getFilePermissions(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
627

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

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

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

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

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

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

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

    
698
        /**
699
         * Search Files
700
         *
701
         * @param userId
702
         * @param query
703
         * @return list of files that match query
704
         * @throws ObjectNotFoundException
705
         */
706
        public List<FileHeader> searchFiles(Long userId, String query) throws ObjectNotFoundException;
707

    
708
        /**
709
         * It is used by the Solr mbean to rebuild the index.
710
         */
711
        public String rebuildSolrIndex();
712

    
713
        /**
714
         * Search the system for a user with the specified email address.
715
         * If no such user is found, the method returns null.
716
         */
717
        public User findUserByEmail(String email);
718

    
719
        /**
720
         * Update the user with the values from the supplied object.
721
         */
722
        public void updateUser(User user);
723

    
724
        /**
725
         * Check if the user with the specified ID has permission to read the
726
         * folder with the supplied ID.
727
         */
728
        public boolean canReadFolder(Long userId, Long folderId) throws ObjectNotFoundException;
729
}