Statistics
| Branch: | Tag: | Revision:

root / src / gr / ebs / gss / server / ejb / ExternalAPI.java @ 01a30cd0

History | View | Annotate | Download (50.3 kB)

1
/*
2
 * Copyright 2007, 2008, 2009, 2010 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.InvitationUsedException;
25
import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
26
import gr.ebs.gss.client.exceptions.QuotaExceededException;
27
import gr.ebs.gss.server.domain.FileUploadStatus;
28
import gr.ebs.gss.server.domain.Invitation;
29
import gr.ebs.gss.server.domain.Nonce;
30
import gr.ebs.gss.server.domain.User;
31
import gr.ebs.gss.server.domain.UserClass;
32
import gr.ebs.gss.server.domain.dto.FileBodyDTO;
33
import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
34
import gr.ebs.gss.server.domain.dto.FolderDTO;
35
import gr.ebs.gss.server.domain.dto.GroupDTO;
36
import gr.ebs.gss.server.domain.dto.PermissionDTO;
37
import gr.ebs.gss.server.domain.dto.StatsDTO;
38
import gr.ebs.gss.server.domain.dto.UserDTO;
39

    
40
import java.io.File;
41
import java.io.IOException;
42
import java.io.InputStream;
43
import java.util.Date;
44
import java.util.List;
45
import java.util.Set;
46

    
47
import javax.ejb.Local;
48
import javax.ejb.TransactionAttribute;
49
import javax.ejb.TransactionAttributeType;
50

    
51
/**
52
 * The External API for GSS clients.
53
 *
54
 * @author past
55
 */
56
@Local
57
public interface ExternalAPI {
58

    
59
        /**
60
         * Retrieves the root folder for the specified user. The caller must ensure
61
         * that the userId exists.
62
         *
63
         * @param userId
64
         * @return Folder
65
         * @throws ObjectNotFoundException if no Folder or user was found
66
         */
67
        public FolderDTO getRootFolder(Long userId) throws ObjectNotFoundException;
68

    
69
        /**
70
         * Retrieve the folder with the specified ID.
71
         *
72
         * @param userId the ID of the current user
73
         * @param folderId the ID of the folder to retrieve
74
         * @return the folder found
75
         * @throws ObjectNotFoundException if the folder or the user was not found
76
         * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
77
         */
78
        public FolderDTO getFolder(Long userId, Long folderId) throws ObjectNotFoundException,
79
                        InsufficientPermissionsException;
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 User getUser(Long userId) throws ObjectNotFoundException;
89

    
90
        /**
91
         * Returns the user with the specified ID.
92
         *
93
         * @param userId The ID of the User to be found
94
         * @return The User object
95
         * @throws ObjectNotFoundException if the user cannot be found
96
         */
97
        public UserDTO getUserDTO(Long userId) throws ObjectNotFoundException;
98

    
99
        /**
100
         * Returns the group with the specified ID.
101
         *
102
         * @param groupId The ID of the Group to be found
103
         * @return The Group object
104
         * @throws ObjectNotFoundException if the group cannot be found
105
         */
106
        public GroupDTO getGroup(Long groupId) throws ObjectNotFoundException;
107

    
108
        /**
109
         * Returns the group with the specified name that belongs to the
110
         * specified user.
111
         *
112
         * @param userId the ID of the user
113
         * @param name the name of the group
114
         * @return The Group object
115
         * @throws ObjectNotFoundException if the group cannot be found
116
         */
117
        public GroupDTO getGroup(Long userId, String name) throws ObjectNotFoundException;
118

    
119
        /**
120
         * Retrieve the list of groups for a particular user.
121
         *
122
         * @param userId the ID of the User
123
         * @return a List of Groups that belong to the specified User
124
         * @throws ObjectNotFoundException if the user was not found
125
         */
126
        public List<GroupDTO> getGroups(Long userId) throws ObjectNotFoundException;
127

    
128
        /**
129
         * Returns a list of files contained in the folder specified by its id.
130
         *
131
         * @param userId the ID of the User
132
         * @param folderId the ID of the folder containing the files
133
         * @param ignoreDeleted
134
         * @return the list of file header objects
135
         * @throws ObjectNotFoundException if the user or the folder cannot be found
136
         * @throws InsufficientPermissionsException
137
         */
138
        public List<FileHeaderDTO> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException,
139
                        InsufficientPermissionsException;
140

    
141
        /**
142
         * Returns a list of users for the specified group
143
         *
144
         * @param userId the ID of the User
145
         * @param groupId the ID of the requested group
146
         * @return List<UserDTO>
147
         * @throws ObjectNotFoundException if the user or group was not found, with
148
         *             the exception message mentioning the precise problem
149
         */
150
        public List<UserDTO> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
151

    
152
        /**
153
         * Returns a list of users matching the specified username
154
         *
155
         * @param username the username of the User
156
         * @return List<UserDTO>
157
         */
158
        public List<UserDTO> getUsersByUserNameLike(String username);
159

    
160
        /**
161
         * Creates a new folder with the specified owner, parent folder and name.
162
         * New folder has the same permissions as its parent
163
         *
164
         * @param userId
165
         * @param parentId
166
         * @param name
167
         * @return the new folder
168
         * @throws DuplicateNameException if the specified name already exists in
169
         *             the parent folder, as either a folder or file
170
         * @throws ObjectNotFoundException if the user or parent folder was not
171
         *             found, with the exception message mentioning the precise
172
         *             problem
173
         * @throws InsufficientPermissionsException
174
         */
175
        public FolderDTO createFolder(Long userId, Long parentId, String name) throws DuplicateNameException,
176
                        ObjectNotFoundException, InsufficientPermissionsException;
177

    
178
        /**
179
         * Deletes the specified folder, if the specified user has the appropriate
180
         * permission.
181
         *
182
         * @param userId the ID of the current user
183
         * @param folderId the ID of the folder to delete
184
         * @throws InsufficientPermissionsException if the user does not have the
185
         *             appropriate privileges
186
         * @throws ObjectNotFoundException if the user or folder was not found, with
187
         *             the exception message mentioning the precise problem
188
         */
189
        public void deleteFolder(Long userId, Long folderId)
190
                        throws InsufficientPermissionsException, ObjectNotFoundException;
191

    
192
        /**
193
         * Retrieve the subfolders of the specified folder.
194
         *
195
         * @param userId the ID of the current user
196
         * @param folderId the ID of the folder to retrieve
197
         * @return the list of subfolders found
198
         * @throws ObjectNotFoundException if the folder or user was not found
199
         * @throws InsufficientPermissionsException
200
         */
201
        public List<FolderDTO> getSubfolders(Long userId, Long folderId)
202
                        throws ObjectNotFoundException, InsufficientPermissionsException;
203

    
204
        /**
205
         * Retrieve the folder with the specified ID with subfolders.
206
         *
207
         * @param userId the ID of the current user
208
         * @param folderId the ID of the folder to retrieve
209
         * @return the folder found
210
         * @throws ObjectNotFoundException if the folder or the user was not found
211
         * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
212
         */
213
        public FolderDTO getFolderWithSubfolders(Long userId, Long folderId)
214
                        throws ObjectNotFoundException, InsufficientPermissionsException;
215

    
216
        /**
217
         * Retrieve the folder with the specified ID with subfolders.
218
         *
219
         * @param userId the ID of the current user
220
         * @param callingUserId the ID of the user requesting this operation
221
         * @param folderId the ID of the folder to retrieve
222
         * @return the folder found
223
         * @throws ObjectNotFoundException if the folder or the user was not found
224
         * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
225
         */
226
        public FolderDTO getFolderWithSubfolders(Long userId, Long callingUserId, Long folderId)
227
                        throws ObjectNotFoundException, InsufficientPermissionsException;
228
        /**
229
         * Retrieve the subfolders of the specified folder that are shared to others.
230
         *
231
         * @param userId the ID of the current user
232
         * @param folderId the ID of the folder to retrieve
233
         * @return the list of subfolders found
234
         * @throws ObjectNotFoundException if the folder or user was not found
235
         */
236
        public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
237

    
238
        /**
239
         * Retrieve the subfolders of the specified folder that are shared to others.
240
         *
241
         * @param userId the ID of the current user
242
         * @param callingUserId the id of the user requesting this operation
243
         * @param folderId the ID of the folder to retrieve
244
         * @return the list of subfolders found
245
         * @throws ObjectNotFoundException if the folder or user was not found
246
         */
247
        public List<FolderDTO> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException;
248
        /**
249
         * Modifies the specified folder if the specified user has the appropriate
250
         * permission.
251
         *
252
         * @param userId the ID of the current user
253
         * @param folderId the ID of the folder to retrieve
254
         * @param folderName
255
         * @param permissions
256
         * @return the updated folder
257
         * @throws InsufficientPermissionsException if the user does not have the
258
         *             appropriate privileges
259
         * @throws ObjectNotFoundException if the user or folder was not found, with
260
         *             the exception message mentioning the precise problem
261
         * @throws DuplicateNameException if the specified name already exists in
262
         *             the parent folder, as either a folder or file
263
         */
264
        public FolderDTO updateFolder(Long userId, Long folderId, String folderName, Set<PermissionDTO> permissions)
265
                        throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
266

    
267
        /**
268
         * Adds a user to the specified group
269
         *
270
         * @param userId the ID of the current user
271
         * @param groupId the id of the new group
272
         * @param userToAddId the id of the user to add
273
         * @throws DuplicateNameException if the user already exists in group
274
         * @throws ObjectNotFoundException if the user or group was not found, with
275
         *             the exception message mentioning the precise problem
276
         * @throws InsufficientPermissionsException
277
         */
278
        public void addUserToGroup(Long userId, Long groupId, Long userToAddId)
279
                        throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
280

    
281
        /**
282
         * Creates a new group with the specified owner and name.
283
         *
284
         * @param userId the ID of the current user
285
         * @param name the name of the new group
286
         * @throws DuplicateNameException if the new group name already exists
287
         * @throws ObjectNotFoundException if the user or group was not found, with
288
         *             the exception message mentioning the precise problem
289
         */
290
        public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
291

    
292
        /**
293
         * Deletes the specified group in the specified user's namespace.
294
         *
295
         * @param userId the ID of the current user
296
         * @param groupId the ID of the group to delete
297
         * @throws ObjectNotFoundException if the user or group was not found, with
298
         *             the exception message mentioning the precise problem
299
         * @throws InsufficientPermissionsException
300
         */
301
        public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
302

    
303
        /**
304
         * Creates a new file with the specified owner, parent folder and name. The
305
         * new file has the same permissions as its parent folder. The file contents
306
         * are read from the input stream to a new File object.
307
         *
308
         * @param userId the ID of the current user
309
         * @param folderId the ID of the parent folder
310
         * @param name the name of the new file
311
         * @param mimeType the MIME type of the file
312
         * @param stream the input stream with the file contents
313
         * @return The FileHeaderDTO created
314
         * @throws DuplicateNameException if the specified name already exists in
315
         *             the parent folder, as either a folder or file
316
         * @throws ObjectNotFoundException if the user or parent folder was not
317
         *             found, with the exception message mentioning the precise
318
         *             problem
319
         * @throws GSSIOException if there was an error while storing the file contents
320
         * @throws InsufficientPermissionsException
321
         * @throws QuotaExceededException
322
         */
323
        public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType,
324
                                InputStream stream) throws DuplicateNameException, ObjectNotFoundException,
325
                                GSSIOException, InsufficientPermissionsException, QuotaExceededException;
326

    
327
        /**
328
         * Deletes the specified file, provided the specified user has
329
         * the necessary permissions.
330
         *
331
         * @param userId the ID of the current user
332
         * @param fileId the ID of the file to delete
333
         * @throws ObjectNotFoundException if the user or file was not found, with
334
         *             the exception message mentioning the precise problem
335
         * @throws InsufficientPermissionsException if the user does not have the
336
         *             appropriate privileges
337
         */
338
        public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
339

    
340
        /**
341
         * Deletes the specified file in the specified user's namespace.
342
         *
343
         * @param userId the ID of the current user
344
         * @param fileIds the IDs of the files to delete
345
         * @throws ObjectNotFoundException if the user or file was not found, with
346
         *             the exception message mentioning the precise problem
347
         * @throws InsufficientPermissionsException if the user does not have the
348
         *             appropriate privileges
349
         */
350
        public void deleteFiles(Long userId, List<Long> fileIds)
351
                        throws ObjectNotFoundException, InsufficientPermissionsException;
352

    
353
        /**
354
         * Creates a new tag for the specified user and file.
355
         *
356
         * @param userId the creator of the tag
357
         * @param fileHeaderId the file that is tagged
358
         * @param tag the tag
359
         * @throws ObjectNotFoundException if the user or the file was not found
360
         */
361
        public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
362

    
363
        /**
364
         * Returns all tags defined by the specified user
365
         *
366
         * @param userId
367
         * @return Set<String>
368
         * @throws ObjectNotFoundException if the user was null
369
         */
370
        public Set<String> getUserTags(final Long userId) throws ObjectNotFoundException;
371

    
372
        /**
373
         * Updates the attributes of the specified file.
374
         *
375
         * @param userId
376
         * @param fileId
377
         * @param name
378
         * @param tagSet a String that contains tags separated by comma
379
         * @param modificationDate the modification date
380
         * @param versioned the new value of the versioned flag
381
         * @param readForAll
382
         * @param permissions
383
         * @throws DuplicateNameException
384
         * @throws ObjectNotFoundException
385
         * @throws InsufficientPermissionsException
386
         */
387
        public void updateFile(Long userId, Long fileId, String name, String tagSet,
388
                        Date modificationDate, Boolean versioned, Boolean readForAll,
389
                        Set<PermissionDTO> permissions)
390
                        throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
391

    
392
        /**
393
         * Retrieve the contents of the current body for the file
394
         * with the specified FileHeader ID. The file contents
395
         * are provided as an InputStream from which the caller can
396
         * retrieve the raw bytes.
397
         *
398
         * @param userId the ID of the current user
399
         * @param fileId the ID of the file to retrieve
400
         * @return an InputStream from the current file body contents
401
         * @throws ObjectNotFoundException if the file or the user was not found
402
         * @throws InsufficientPermissionsException  if the user does not have the
403
         *             appropriate privileges
404
         */
405
        public InputStream getFileContents(Long userId, Long fileId)
406
                        throws ObjectNotFoundException, InsufficientPermissionsException;
407

    
408
        /**
409
         * Retrieve the contents of the  body identified by bodyId for the file
410
         * with the specified FileHeader ID. The file contents
411
         * are provided as an InputStream from which the caller can
412
         * retrieve the raw bytes.
413
         *
414
         * @param userId the ID of the current user
415
         * @param fileId the ID of the file to retrieve
416
         * @param bodyId the body ID
417
         * @return an InputStream from the current file body contents
418
         * @throws ObjectNotFoundException if the file or the user was not found
419
         * @throws InsufficientPermissionsException  if the user does not have the
420
         *             appropriate privileges
421
         */
422
        public InputStream getFileContents(Long userId, Long fileId, Long bodyId)
423
                        throws ObjectNotFoundException, InsufficientPermissionsException;
424

    
425
        /**
426
         * Retrieve the file with the specified ID.
427
         *
428
         * @param userId the ID of the current user
429
         * @param fileId the ID of the file to retrieve
430
         * @return the file found
431
         * @throws ObjectNotFoundException if the file or the user was not found, with
432
         *                         the exception message mentioning the precise problem
433
         * @throws InsufficientPermissionsException
434
         */
435
        public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException,
436
                        InsufficientPermissionsException;
437

    
438
        /**
439
         * Retrieve the filebody with the specified ID.
440
         *
441
         * @param userId the ID of the current user
442
         * @param fileId the ID of the file to retrieve
443
         * @param bodyId the ID of the body
444
         * @return the file found
445
         * @throws ObjectNotFoundException if the file or the user was not found, with
446
         *                         the exception message mentioning the precise problem
447
         * @throws InsufficientPermissionsException
448
         */
449
        public FileBodyDTO getFileBody(Long userId, Long fileId, Long bodyId)
450
                        throws ObjectNotFoundException, InsufficientPermissionsException;
451

    
452
        /**
453
         * Get the resource (file or folder) at the specified path in
454
         * the specified user's namespace. The returned object will be of type
455
         * FileHeaderDTO or FolderDTO.<p><strong>Note:</strong> this method does not
456
         * receive the current user as a parameter, therefore it is unable to perform
457
         * the necessary permission checks and should <strong>NOT</strong> be directly
458
         * exposed to remote clients. It is the caller's responsibility to verify that
459
         * the calling user has the required privileges for performing any subsequent
460
         * action on the resource through one of the other ExternalAPI methods.
461
         *
462
         * @param ownerId the ID of the user owning the namespace
463
         * @param path the absolute path in the user's namespace
464
         * @param ignoreDeleted if true, resources that have been moved to the trash
465
         *                         will be ignored
466
         * @throws ObjectNotFoundException if the user or resource was not found, with
467
         *                         the exception message mentioning the precise problem
468
         * @return the resource found
469
         */
470
        public Object getResourceAtPath(Long ownerId, String path, boolean ignoreDeleted)
471
                        throws ObjectNotFoundException;
472

    
473
        /**
474
         * Copy the provided file to the specified destination.
475
         *
476
         * @param userId the ID of the current user
477
         * @param fileId the IF of the provided file
478
         * @param dest the path of the new resource
479
         * @throws ObjectNotFoundException if the user, file or destination was not
480
         *                         found, with        the exception message mentioning the precise problem
481
         * @throws DuplicateNameException if the specified name already exists in
482
         *          the destination folder, as either a folder or file
483
         * @throws GSSIOException if there was an error while accessing the file contents
484
         * @throws InsufficientPermissionsException
485
         * @throws QuotaExceededException
486
         */
487
        public void copyFile(Long userId, Long fileId, String dest) throws ObjectNotFoundException,
488
                        DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
489

    
490
        /**
491
         * Copy the provided file to the specified destination.
492
         *
493
         * @param userId the ID of the current user
494
         * @param ownerId the ID of the owner of the destination namespace
495
         * @param fileId the IF of the provided file
496
         * @param dest the path of the new resource
497
         * @throws ObjectNotFoundException if the user, file or destination was not
498
         *                         found, with        the exception message mentioning the precise problem
499
         * @throws DuplicateNameException if the specified name already exists in
500
         *          the destination folder, as either a folder or file
501
         * @throws GSSIOException if there was an error while accessing the file contents
502
         * @throws InsufficientPermissionsException
503
         * @throws QuotaExceededException
504
         */
505
        public void copyFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException,
506
                        DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
507

    
508
        /**
509
         * Copy the provided file to the specified destination.
510
         *
511
         * @param userId the ID of the current user
512
         * @param fileIds the IDs of the provided files
513
         * @param destId the ID of the destination folder
514
         * @throws ObjectNotFoundException if the user, file or destination was not
515
         *                         found, with        the exception message mentioning the precise problem
516
         * @throws GSSIOException if there was an error while accessing the file contents
517
         * @throws DuplicateNameException if the specified name already exists in
518
         *          the destination folder, as either a folder or file
519
         * @throws InsufficientPermissionsException
520
         * @throws QuotaExceededException
521
         */
522
        public void copyFiles(Long userId, List<Long> fileIds, Long destId)
523
                        throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
524
                        InsufficientPermissionsException, QuotaExceededException;
525

    
526
        /**
527
         * Copy the provided file to the specified destination.
528
         *
529
         * @param userId the ID of the current user
530
         * @param fileId the IF of the provided file
531
         * @param destId the ID of the destination folder
532
         * @param destName the name of the new file
533
         * @throws ObjectNotFoundException if the user, file or destination was not
534
         *                         found, with        the exception message mentioning the precise problem
535
         * @throws GSSIOException if there was an error while accessing the file contents
536
         * @throws DuplicateNameException if the specified name already exists in
537
         *          the destination folder, as either a folder or file
538
         * @throws InsufficientPermissionsException
539
         * @throws QuotaExceededException
540
         */
541
        public void copyFile(Long userId, Long fileId, Long destId, String destName)
542
                        throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
543
                        InsufficientPermissionsException, QuotaExceededException;
544

    
545
        /**
546
         * Copy the provided folder to the specified destination.
547
         *
548
         * @param userId the ID of the current user
549
         * @param folderId the IF of the provided folder
550
         * @param dest the path of the new folder
551
         * @throws ObjectNotFoundException if the user, folder or destination was not
552
         *                         found, with        the exception message mentioning the precise problem
553
         * @throws DuplicateNameException if the specified name already exists in
554
         *          the destination folder, as either a folder or file
555
         * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
556
         *          appropriate privileges
557
         */
558
        public void copyFolder(Long userId, Long folderId, String dest) throws ObjectNotFoundException,
559
                        DuplicateNameException, InsufficientPermissionsException;
560

    
561
        /**
562
         * Copy the provided folder to the specified destination.
563
         *
564
         * @param userId the ID of the current user
565
         * @param folderId the IF of the provided folder
566
         * @param destId the ID of the destination folder
567
         * @param destName the name of the new folder
568
         * @throws ObjectNotFoundException if the user, folder or destination was not
569
         *                         found, with        the exception message mentioning the precise problem
570
         * @throws DuplicateNameException if the specified name already exists in
571
         *          the destination folder, as either a folder or file
572
         * @throws InsufficientPermissionsException InsufficientPermissionsException
573
         *                         if the user does not have the appropriate privileges
574
         */
575
        public void copyFolder(Long userId, Long folderId, Long destId, String destName)
576
                        throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
577

    
578
        /**
579
         * Copy the provided folder and all its subfolders and files to the specified destination.
580
         *
581
         * @param userId the ID of the current user
582
         * @param ownerId the ID of the owner of the destination namespace
583
         * @param folderId the IF of the provided folder
584
         * @param dest the path of the new folder
585
         * @throws ObjectNotFoundException if the user, folder or destination was not
586
         *                         found, with        the exception message mentioning the precise problem
587
         * @throws DuplicateNameException if the specified name already exists in
588
         *          the destination folder, as either a folder or file
589
         * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
590
         *          appropriate privileges
591
         * @throws QuotaExceededException if the user quota limit would be exceeded
592
         * @throws GSSIOException if there was an error while accessing the file contents
593
         */
594
        public void copyFolderStructureToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
595
                        DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
596

    
597
        /**
598
         * Copy the provided folder and all its subfolders and files to the specified destination.
599
         *
600
         * @param userId the ID of the current user
601
         * @param folderId the IF of the provided folder
602
         * @param destId the ID of the destination folder
603
         * @param destName the name of the new folder
604
         * @throws ObjectNotFoundException if the user, folder or destination was not
605
         *                         found, with        the exception message mentioning the precise problem
606
         * @throws DuplicateNameException if the specified name already exists in
607
         *          the destination folder, as either a folder or file
608
         * @throws InsufficientPermissionsException InsufficientPermissionsException
609
         *                         if the user does not have the appropriate privileges
610
         * @throws GSSIOException if there was an error while accessing the file contents
611
         * @throws QuotaExceededException if the user quota limit would be exceeded
612
         */
613
        public void copyFolderStructure(Long userId, Long folderId, Long destId, String destName)
614
                        throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
615
                        GSSIOException, QuotaExceededException;
616

    
617
        /**
618
         * Marks  the specified file as deleted in the specified user's namespace.
619
         *
620
         * @param userId the ID of the current user
621
         * @param fileId the ID of the file to delete
622
         * @throws ObjectNotFoundException if the user or file was not found, with
623
         *             the exception message mentioning the precise problem
624
         * @throws InsufficientPermissionsException if the user does not have the
625
         *             appropriate privileges
626
         */
627
        public void moveFileToTrash(Long userId, Long fileId) throws ObjectNotFoundException,
628
                        InsufficientPermissionsException;
629

    
630
        /**
631
         * Marks  the specified deleted file as undeleted in the specified user's namespace.
632
         *
633
         * @param userId the ID of the current user
634
         * @param fileId the ID of the file to undelete
635
         * @throws ObjectNotFoundException if the user or file was not found, with
636
         *             the exception message mentioning the precise problem
637
         * @throws InsufficientPermissionsException if the user does not have the
638
         *             appropriate privileges
639
         *
640
         */
641
        public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
642

    
643
        /**
644
         * Marks  the specified files as deleted in the specified user's namespace.
645
         *
646
         * @param userId the ID of the current user
647
         * @param fileIds the IDs of the file to delete
648
         * @throws ObjectNotFoundException if the user or file was not found, with
649
         *             the exception message mentioning the precise problem
650
         * @throws InsufficientPermissionsException if the user does not have the
651
         *             appropriate privileges
652
         */
653
        public void moveFilesToTrash(Long userId, List<Long> fileIds)
654
                        throws ObjectNotFoundException, InsufficientPermissionsException;
655

    
656
        /**
657
         * Marks  the specified deleted files as undeleted in the specified user's namespace.
658
         *
659
         * @param userId the ID of the current user
660
         * @param fileIds the IDs of the file to undelete
661
         * @throws ObjectNotFoundException if the user or file was not found, with
662
         *             the exception message mentioning the precise problem
663
         * @throws InsufficientPermissionsException if the user does not have the
664
         *             appropriate privileges
665
         */
666
        public void removeFilesFromTrash(Long userId, List<Long> fileIds) throws ObjectNotFoundException, InsufficientPermissionsException;
667

    
668
        /**
669
         * Marks  the specified folder as deleted in the specified user's namespace.
670
         *
671
         * @param userId the ID of the current user
672
         * @param folderId the ID of the folder to delete
673
         * @throws ObjectNotFoundException if the user or file was not found, with
674
         *             the exception message mentioning the precise problem
675
         * @throws InsufficientPermissionsException if the user does not have the
676
         *             appropriate privileges
677
         */
678
        public void moveFolderToTrash(Long userId, Long folderId)
679
                        throws ObjectNotFoundException, InsufficientPermissionsException;
680

    
681
        /**
682
         * Marks  the specified deleted folder as undeleted in the specified user's namespace.
683
         *
684
         * @param userId the ID of the current user
685
         * @param folderId the ID of the folder to undelete
686
         * @throws ObjectNotFoundException if the user or file was not found, with
687
         *             the exception message mentioning the precise problem
688
         * @throws InsufficientPermissionsException if the user does not have the
689
         *          appropriate privileges
690
         *
691
         */
692
        public void removeFolderFromTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
693

    
694
        /**
695
         * Move the provided folder and all its subfolders and files to the specified destination.
696
         *
697
         * @param userId the ID of the current user
698
         * @param folderId the IF of the provided folder
699
         * @param destId the ID of the destination folder
700
         * @param destName the name of the new folder
701
         * @throws ObjectNotFoundException if the user, folder or destination was not
702
         *                         found, with        the exception message mentioning the precise problem
703
         * @throws DuplicateNameException if the specified name already exists in
704
         *          the destination folder, as either a folder or file
705
         * @throws InsufficientPermissionsException if the user does not have the
706
         *          appropriate privileges
707
         * @throws GSSIOException
708
         * @throws QuotaExceededException
709
         */
710
        public void moveFolder(Long userId, Long folderId, Long destId, String destName)
711
                        throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
712
                        GSSIOException, QuotaExceededException;
713

    
714
        /**
715
         * Move the provided folder and all its subfolders and files to the specified destination.
716
         *
717
         * @param userId the ID of the current user
718
         * @param ownerId the owner of the destination namespace
719
         * @param folderId the IF of the provided folder
720
         * @param dest the path of the new folder
721
         * @throws ObjectNotFoundException if the user, folder or destination was not
722
         *                         found, with        the exception message mentioning the precise problem
723
         * @throws DuplicateNameException if the specified name already exists in
724
         *          the destination folder, as either a folder or file
725
         * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
726
         *          appropriate privileges
727
         * @throws GSSIOException
728
         * @throws QuotaExceededException
729
         */
730
        public void moveFolderToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
731
                        DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
732

    
733
        /**
734
         * Move the provided file to the specified destination.
735
         *
736
         * @param userId the ID of the current user
737
         * @param fileId the IF of the provided file
738
         * @param destId the ID of the destination folder
739
         * @param destName the name of the new file
740
         * @throws InsufficientPermissionsException
741
         * @throws ObjectNotFoundException if the user, file or destination was not
742
         *                         found, with        the exception message mentioning the precise problem
743
         * @throws GSSIOException if there was an error while accessing the file contents
744
         * @throws DuplicateNameException if the specified name already exists in
745
         *          the destination folder, as either a folder or file
746
         * @throws QuotaExceededException
747
         */
748
        public void moveFile(Long userId, Long fileId, Long destId, String destName)
749
                        throws InsufficientPermissionsException, ObjectNotFoundException,
750
                        DuplicateNameException, GSSIOException, QuotaExceededException;
751

    
752
        /**
753
         * Move the provided file to the specified destination.
754
         *
755
         * @param userId the ID of the current user
756
         * @param ownerId the owner of the destination namespace
757
         * @param fileId the IF of the provided file
758
         * @param dest the path of the new file
759
         * @throws InsufficientPermissionsException
760
         * @throws ObjectNotFoundException if the user, file or destination was not
761
         *                         found, with        the exception message mentioning the precise problem
762
         * @throws GSSIOException if there was an error while accessing the file contents
763
         * @throws DuplicateNameException if the specified name already exists in
764
         *          the destination folder, as either a folder or file
765
         * @throws QuotaExceededException
766
         */
767
        public void moveFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException, InsufficientPermissionsException, DuplicateNameException, GSSIOException, QuotaExceededException;
768

    
769
        /**
770
         * move the provided file to the specified destination.
771
         *
772
         * @param userId the ID of the current user
773
         * @param fileIds the IDs of the provided files
774
         * @param destId the ID of the destination folder
775
         * @throws InsufficientPermissionsException
776
         * @throws ObjectNotFoundException if the user, file or destination was not
777
         *                         found, with        the exception message mentioning the precise problem
778
         * @throws GSSIOException if there was an error while accessing the file contents
779
         * @throws DuplicateNameException if the specified name already exists in
780
         *          the destination folder, as either a folder or file
781
         * @throws QuotaExceededException
782
         */
783
        public void moveFiles(Long userId, List<Long> fileIds, Long destId)
784
                        throws InsufficientPermissionsException, ObjectNotFoundException,
785
                        DuplicateNameException, GSSIOException, QuotaExceededException;
786

    
787
        /**
788
         * Returns a list of All deleted files of a user.
789
         *
790
         * @param userId the ID of the User
791
         *          * @return the list of deleted file header objects
792
         * @throws ObjectNotFoundException if the user cannot be found
793
         */
794
        public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException;
795

    
796
        /**
797
         * Returns a list of All deleted root folders of a user.
798
         *
799
         * @param userId the ID of the User
800
         *          * @return the list of deleted file header objects
801
         * @throws ObjectNotFoundException if the user cannot be found
802
         */
803
        public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
804

    
805
        /**
806
         * Empty Trash by deleting all marked as deleted files and folders
807
         * @param userId
808
         * @throws ObjectNotFoundException if something goes wrong in the delete process
809
         * @throws InsufficientPermissionsException if something goes wrong in the delete process
810
         */
811
        public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
812

    
813
        /**
814
         * Restores All Trashed Items by undeleting all marked as deleted files and folders
815
         * @param userId
816
         * @throws ObjectNotFoundException if something goes wrong in the delete process
817
         * @throws InsufficientPermissionsException
818
         */
819
        public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
820

    
821
        /**
822
         * Search the system for a user with the specified username.
823
         * If no such user is found, the method returns null.
824
         *
825
         * @param username the username to search for
826
         * @return the User object with the specified username
827
         */
828
        public User findUser(String username);
829

    
830
        /**
831
         * Create a new user with the specified name, username and e-mail address.
832
         *
833
         * @param username the username of the new user
834
         * @param name the name of the new user
835
         * @param mail the e-mail of the new user
836
         * @param idp the IdP of the new user
837
         * @param idpid the IdP identifier of the new user
838
         * @return the newly-created User object
839
         * @throws DuplicateNameException if a user with the same username already exists
840
         * @throws ObjectNotFoundException if no username was provided
841
         */
842
        public User createUser(String username, String name, String mail, String idp, String idpid)
843
                        throws DuplicateNameException, ObjectNotFoundException;
844

    
845
        /**
846
         * Updates the authentication token for the specified user.
847
         *
848
         * @param userId the ID of the user whose token should be updated
849
         * @return the updated user
850
         * @throws ObjectNotFoundException if the user could not be found
851
         */
852
        public User updateUserToken(Long userId) throws ObjectNotFoundException;
853

    
854
        /**
855
         * Updates the policy acceptance flag for the specified user.
856
         *
857
         * @param userId the ID of the user whose flag should be updated
858
         * @param isAccepted the new value of the flag
859
         * @return the updated user
860
         * @throws ObjectNotFoundException if the user could not be found
861
         */
862
        public User updateUserPolicyAcceptance(Long userId, boolean isAccepted) throws ObjectNotFoundException;
863

    
864
        /**
865
         * Invalidates the authentication token for the specified user.
866
         *
867
         * @param userId the ID of the user whose token should be updated
868
         * @throws ObjectNotFoundException if the user could not be found
869
         */
870
        public void invalidateUserToken(Long userId) throws ObjectNotFoundException;
871

    
872
        /**
873
         * Retrieve folder user and group permissions
874
         *
875
         * @param userId the ID of the user whose token should be updated
876
         * @param folderId the ID of the folder
877
         * @return the Set of permissions from requested folder
878
         * @throws ObjectNotFoundException if the user or folder could not be found
879
         * @throws InsufficientPermissionsException
880
         */
881
        public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId)
882
                        throws ObjectNotFoundException, InsufficientPermissionsException;
883

    
884
        /**
885
         * Retrieve file user and group permissions
886
         *
887
         * @param userId the ID of the user whose token should be updated
888
         * @param fileId the ID of the folder
889
         * @return the Set of permissions from requested folder
890
         * @throws ObjectNotFoundException if the user or folder could not be found
891
         * @throws InsufficientPermissionsException
892
         */
893
        public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId)
894
                        throws ObjectNotFoundException, InsufficientPermissionsException;
895

    
896
        /**
897
         * Returns a list of all shared root folders of a user.
898
         *
899
         * @param userId the ID of the User
900
         * @return the list of shared root folders
901
         * @throws ObjectNotFoundException if the user cannot be found
902
         */
903
        public List<FolderDTO> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
904

    
905
        /**
906
         * Returns a list of all shared files of a user that are not
907
         * inside other shared folders.
908
         *
909
         * @param userId the ID of the User
910
         * @return the list of shared files
911
         * @throws ObjectNotFoundException if the user cannot be found
912
         */
913
        public List<FileHeaderDTO> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
914

    
915
        /**
916
         * Returns a list of all shared files of a user.
917
         *
918
         * @param userId the ID of the User
919
         * @return the list of shared files
920
         * @throws ObjectNotFoundException if the user cannot be found
921
         */
922
        public List<FileHeaderDTO> getSharedFiles(Long userId) throws ObjectNotFoundException;
923

    
924
        /**
925
         * Returns a list of all shared folders of a user.
926
         *
927
         * @param userId the ID of the User
928
         * @return the list of shared folders
929
         * @throws ObjectNotFoundException if the user cannot be found
930
         */
931
        public List<FolderDTO> getSharedFolders(Long userId) throws ObjectNotFoundException;
932

    
933
        /**
934
         * Returns a list of all shared root folders of a user that calling
935
         * user has at least read permissions.
936
         *
937
         * @param ownerId the ID of the User
938
         * @return the list of shared root folders
939
         * @param callingUserId
940
         *
941
         * @throws ObjectNotFoundException if the user cannot be found
942
         */
943
        public List<FolderDTO> getSharedRootFolders(Long ownerId, Long callingUserId)
944
                        throws ObjectNotFoundException;
945

    
946
        /**
947
         * Returns a list of all shared  files of a user that calling user has
948
         * at least read permissions..
949
         *
950
         * @param ownerId the ID of the User
951
         * @return the list of shared files
952
         * @param callingUserId
953
         * @throws ObjectNotFoundException if the user cannot be found
954
         */
955
        public List<FileHeaderDTO> getSharedFiles(Long ownerId, Long callingUserId)
956
                        throws ObjectNotFoundException;
957

    
958
        /**
959
         * Remove a user member from a group
960
         *
961
         * @param userId the ID of the User owning the group
962
         * @param groupId the ID of the requested group
963
         * @param memberId the ID of the member to be removed
964
         *
965
         * @throws ObjectNotFoundException if the user or group was not found, with
966
         *             the exception message mentioning the precise problem
967
         * @throws InsufficientPermissionsException
968
         */
969
        public void removeMemberFromGroup(Long userId, Long groupId, Long memberId)
970
                        throws ObjectNotFoundException, InsufficientPermissionsException;
971

    
972
        /**
973
         * Retrieves the list of users sharing files to user identified by user id
974
         * @param userId
975
         * @return the List of users sharing files to user
976
         * @throws ObjectNotFoundException
977
         */
978
        public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
979

    
980
        /**
981
         * Search Files
982
         *
983
         * @param userId
984
         * @param query
985
         * @return list of files that match query
986
         * @throws ObjectNotFoundException if no user or query was specified
987
         */
988
        public List<FileHeaderDTO> searchFiles(Long userId, String query) throws ObjectNotFoundException;
989

    
990
        /**
991
         * Creates a nonce for the specified user.
992
         *
993
         * @param userId the ID of the user
994
         * @return the new nonce
995
         * @throws ObjectNotFoundException if the user could not be found
996
         */
997
        public Nonce createNonce(Long userId) throws ObjectNotFoundException;
998

    
999
        /**
1000
         * Find the nonce object for the specified encoded nonce, that should be
1001
         * associated with the specified user.
1002
         *
1003
         * @param nonce the issued nonce in Base64 encoding
1004
         * @param userId the ID of the user for whom this nonce should have been issued
1005
         * @return the retrieved nonce object
1006
         * @throws ObjectNotFoundException if the nonce or user were not found
1007
         */
1008
        public Nonce getNonce(String nonce, Long userId) throws ObjectNotFoundException;
1009

    
1010
        /**
1011
         * Remove the specified nonce from the persistent store.
1012
         *
1013
         * @param id the ID of the nonce
1014
         * @throws ObjectNotFoundException if the specified nonce could not be found
1015
         */
1016
        public void removeNonce(Long id) throws ObjectNotFoundException;
1017

    
1018
        /**
1019
         * Activate the supplied nonce for the specified user.
1020
         *
1021
         * @param userId the ID of the user
1022
         * @param nonce the nonce to activate
1023
         * @param nonceExpiryDate the expiry date of the nonce
1024
         * @throws ObjectNotFoundException
1025
         */
1026
        public void activateUserNonce(Long userId, String nonce, Date nonceExpiryDate) throws ObjectNotFoundException;
1027

    
1028
        /**
1029
         * Retrieves user statistics.
1030
         *
1031
         * @param userId the ID of the user
1032
         * @return the statistics
1033
         * @throws ObjectNotFoundException
1034
         *
1035
         */
1036
        public StatsDTO getUserStatistics(Long userId) throws ObjectNotFoundException;
1037

    
1038
        /**
1039
         * Retrieves file versions
1040
         *
1041
         * @param userId the ID of the user
1042
         * @param fileId the ID of the file
1043
         * @return the list of filebodies
1044
         * @throws ObjectNotFoundException
1045
         * @throws InsufficientPermissionsException
1046
         *
1047
         */
1048
        public List<FileBodyDTO> getVersions(Long userId, Long fileId)
1049
                        throws ObjectNotFoundException, InsufficientPermissionsException;
1050

    
1051
        /**
1052
         * Restore the file contents to the specified version.
1053
         *
1054
         * @param userId the ID of the user
1055
         * @param fileId the ID of the file
1056
         * @param version the version number of the desired file contents
1057
         * @throws ObjectNotFoundException if the user or file was not
1058
         *                         found, with        the exception message mentioning the precise problem
1059
         * @throws InsufficientPermissionsException if the user does not have the
1060
         *          appropriate privileges
1061
         * @throws QuotaExceededException if the user quota limit would be exceeded
1062
         * @throws GSSIOException if there was an error while accessing the file contents
1063
         */
1064
        public void restoreVersion(Long userId, Long fileId, int version)
1065
                        throws ObjectNotFoundException, InsufficientPermissionsException,  GSSIOException, QuotaExceededException;
1066

    
1067
        /**
1068
         * Remove file version identified by bodyId
1069
         *
1070
         * @param userId the ID of the user
1071
         * @param fileId the ID of the file
1072
         * @param bodyId the ID of the body
1073
         *
1074
         * @throws ObjectNotFoundException
1075
         * @throws InsufficientPermissionsException
1076
         *
1077
         */
1078
        public void removeVersion(Long userId, Long fileId, Long bodyId)
1079
                        throws ObjectNotFoundException, InsufficientPermissionsException;
1080

    
1081
        /**
1082
         * Removes all old file versions for specified file keeping only the current revision
1083
         *
1084
         * @param userId the ID of the user
1085
         * @param fileId the ID of the file
1086
         *
1087
         * @throws ObjectNotFoundException
1088
         * @throws InsufficientPermissionsException
1089
         *
1090
         */
1091
        public void removeOldVersions(Long userId, Long fileId)
1092
                        throws ObjectNotFoundException, InsufficientPermissionsException;
1093

    
1094
        /**
1095
         * It is used by the Solr mbean to rebuild the index.
1096
         */
1097
        public void rebuildSolrIndex();
1098

    
1099
        /**
1100
         * Creates a new file with the specified owner, parent folder and name. The
1101
         * new file has the same permissions as its parent folder. The file contents
1102
         * are already uploaded outside of externalAPI and the uploaded file is used as a parameter.
1103
         *
1104
         * @param userId the ID of the current user
1105
         * @param folderId the ID of the parent folder
1106
         * @param name the name of the new file
1107
         * @param mimeType the MIME type of the file
1108
         * @param fileSize the uploaded file size
1109
         * @param filePath the uploaded file full path
1110
         * @return The FileHeaderDTO created
1111
         * @throws DuplicateNameException if the specified name already exists in
1112
         *             the parent folder, as either a folder or file
1113
         * @throws ObjectNotFoundException if the user or parent folder was not
1114
         *             found, with the exception message mentioning the precise
1115
         *             problem
1116
         * @throws GSSIOException if there was an error while storing the file contents
1117
         * @throws InsufficientPermissionsException
1118
         * @throws QuotaExceededException
1119
         */
1120
        public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
1121
                        throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
1122
                        InsufficientPermissionsException, QuotaExceededException;
1123

    
1124
        /**
1125
         * Create a new FileBody with the supplied uploaded file as contents and make it the current body
1126
         * of the file.
1127
         *
1128
         * @param userId the ID of the current user
1129
         * @param fileId the ID of the file header object
1130
         * @param mimeType the content type of the file
1131
         * @param fileSize the uploaded file size
1132
         * @param filePath the uploaded file full path
1133
         * @return The FileHeaderDTO updated
1134
         * @throws ObjectNotFoundException if the user or file was not found, with
1135
         *                         the exception message mentioning the precise problem
1136
         * @throws GSSIOException when an IO exception occurs
1137
         * @throws InsufficientPermissionsException
1138
         * @throws QuotaExceededException
1139
         */
1140
        public FileHeaderDTO updateFileContents(Long userId, Long fileId, String mimeType,
1141
                                long fileSize, String filePath) throws ObjectNotFoundException, GSSIOException,
1142
                                InsufficientPermissionsException, QuotaExceededException;
1143

    
1144
        /**
1145
         * Create a file based on inputstream without using transaction.
1146
         *
1147
         * @param stream
1148
         * @param userId
1149
         * @return the file
1150
         * @throws IOException
1151
         * @throws ObjectNotFoundException
1152
         */
1153
        @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
1154
        public File uploadFile(InputStream stream, Long userId)
1155
                        throws IOException, ObjectNotFoundException;
1156

    
1157
        public void createFileUploadProgress(Long userId, String filename,
1158
                                Long bytesTransfered, Long fileSize) throws ObjectNotFoundException;
1159

    
1160
        public FileUploadStatus getFileUploadStatus(Long userId, String fileName);
1161

    
1162
        public void removeFileUploadProgress(Long userId, String filename)
1163
                        throws ObjectNotFoundException;
1164

    
1165
        /**
1166
         * Fetch the file body with the specified version number.
1167
         *
1168
         * @param userId the ID of the current user
1169
         * @param fileId the ID of the file header
1170
         * @param version the version number
1171
         * @return the file body
1172
         * @throws ObjectNotFoundException if the user file or version
1173
         *                         were not found
1174
         * @throws InsufficientPermissionsException if the user does not
1175
         *                         have enough privileges for reading this file
1176
         */
1177
        public FileBodyDTO getFileVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException;
1178

    
1179
        /**
1180
         * Search the system for a user with the specified email address.
1181
         * If no such user is found, the method returns null.
1182
         */
1183
        public User findUserByEmail(String email);
1184

    
1185
        /**
1186
         * Update the user with the values from the supplied object.
1187
         */
1188
        public void updateUser(User user);
1189

    
1190
        /**
1191
         * Update accounting information for given user.
1192
         *
1193
         * @param user The user to update
1194
         * @param date Date of transaction
1195
         * @param bandwidthDiff Bandwidth used; positive for addition,
1196
         * negative for subtraction (e.g. to rollback)
1197
         */
1198
        public void updateAccounting(User user, Date date, long bandwidthDiff);
1199

    
1200
        /**
1201
         * Check if the user with the specified ID has permission to read the
1202
         * folder with the supplied ID.
1203
         */
1204
        public boolean canReadFolder(Long userId, Long folderId) throws ObjectNotFoundException;
1205

    
1206
        /**
1207
         * Reset WebDAV password for given user.
1208
         *
1209
         * @param userId
1210
         * @return the new password
1211
         * @throws ObjectNotFoundException
1212
         */
1213
        public String resetWebDAVPassword(Long userId) throws ObjectNotFoundException;
1214

    
1215
        /**
1216
         * Find the invite for the specified invitation code.
1217
         *
1218
         * @param code the invitation code
1219
         * @return the Invitation or null if not found
1220
         */
1221
        public Invitation findInvite(String code);
1222

    
1223
        /**
1224
         * Create a new user in the connected IdP.
1225
         *
1226
         * @param username the username of the new user
1227
         * @param firstname the first name of the new user
1228
         * @param lastname the last name of the new user
1229
         * @param email the e-mail of the new user
1230
         * @param password the password of the new user
1231
         */
1232
        public void createLdapUser(String username, String firstname, String lastname, String email, String password);
1233

    
1234
        /**
1235
         * Retrieves the available user classes.
1236
         */
1237
        public List<UserClass> getUserClasses();
1238

    
1239
        /**
1240
         * Upgrades the user class to the default "coupon bearer" class and marks
1241
         * the provided coupon as used.
1242
         * @throws InvitationUsedException when trying to resuse an already used invitation
1243
         * @throws ObjectNotFoundException if the user was not found
1244
         */
1245
        public void upgradeUserClass(String username, String code)
1246
                        throws ObjectNotFoundException, InvitationUsedException;
1247

    
1248
        /**
1249
         * Retrieve the user class for coupon-bearing users.
1250
         */
1251
        public UserClass getCouponUserClass();
1252
}