Statistics
| Branch: | Tag: | Revision:

root / src / gr / ebs / gss / server / ejb / ExternalAPI.java @ 0fcbf8bd

History | View | Annotate | Download (50.8 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.net.MalformedURLException;
44
import java.util.Date;
45
import java.util.List;
46
import java.util.Set;
47

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

    
52
import org.apache.commons.configuration.Configuration;
53
import org.apache.solr.client.solrj.SolrServerException;
54

    
55
/**
56
 * The External API for GSS clients.
57
 *
58
 * @author past
59
 */
60
@Local
61
public interface ExternalAPI {
62

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

    
73
        /**
74
         * Retrieve the folder with the specified ID.
75
         *
76
         * @param userId the ID of the current user
77
         * @param folderId the ID of the folder to retrieve
78
         * @return the folder found
79
         * @throws ObjectNotFoundException if the folder or the user was not found
80
         * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
81
         */
82
        public FolderDTO getFolder(Long userId, Long folderId) throws ObjectNotFoundException,
83
                        InsufficientPermissionsException;
84

    
85
        /**
86
         * Returns the user with the specified ID.
87
         *
88
         * @param userId The ID of the User to be found
89
         * @return The User object
90
         * @throws ObjectNotFoundException if the user cannot be found
91
         */
92
        public User getUser(Long userId) throws ObjectNotFoundException;
93

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

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

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

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

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

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

    
156
        /**
157
         * Returns a list of users matching the specified username
158
         *
159
         * @param username the username of the User
160
         * @return List<UserDTO>
161
         */
162
        public List<UserDTO> getUsersByUserNameLike(String username);
163

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

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

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

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

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

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

    
274
        /**
275
         * Adds a user to the specified group
276
         *
277
         * @param userId the ID of the current user
278
         * @param groupId the id of the new group
279
         * @param userToAddId the id of the user to add
280
         * @throws DuplicateNameException if the user already exists in group
281
         * @throws ObjectNotFoundException if the user or group was not found, with
282
         *             the exception message mentioning the precise problem
283
         * @throws InsufficientPermissionsException
284
         */
285
        public void addUserToGroup(Long userId, Long groupId, Long userToAddId)
286
                        throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
287

    
288
        /**
289
         * Creates a new group with the specified owner and name.
290
         *
291
         * @param userId the ID of the current user
292
         * @param name the name of the new group
293
         * @throws DuplicateNameException if the new group name already exists
294
         * @throws ObjectNotFoundException if the user or group was not found, with
295
         *             the exception message mentioning the precise problem
296
         */
297
        public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
298

    
299
        /**
300
         * Deletes the specified group in the specified user's namespace.
301
         *
302
         * @param userId the ID of the current user
303
         * @param groupId the ID of the group to delete
304
         * @throws ObjectNotFoundException if the user or group was not found, with
305
         *             the exception message mentioning the precise problem
306
         * @throws InsufficientPermissionsException
307
         */
308
        public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
309

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

    
334
        /**
335
         * Deletes the specified file, provided the specified user has
336
         * the necessary permissions.
337
         *
338
         * @param userId the ID of the current user
339
         * @param fileId the ID of the file to delete
340
         * @throws ObjectNotFoundException if the user or file was not found, with
341
         *             the exception message mentioning the precise problem
342
         * @throws InsufficientPermissionsException if the user does not have the
343
         *             appropriate privileges
344
         */
345
        public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
346

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

    
360
        /**
361
         * Creates a new tag for the specified user and file.
362
         *
363
         * @param userId the creator of the tag
364
         * @param fileHeaderId the file that is tagged
365
         * @param tag the tag
366
         * @throws ObjectNotFoundException if the user or the file was not found
367
         */
368
        public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
369

    
370
        /**
371
         * Returns all tags defined by the specified user
372
         *
373
         * @param userId
374
         * @return Set<String>
375
         * @throws ObjectNotFoundException if the user was null
376
         */
377
        public Set<String> getUserTags(final Long userId) throws ObjectNotFoundException;
378

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

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

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

    
432
        /**
433
         * Retrieve the file with the specified ID.
434
         *
435
         * @param userId the ID of the current user
436
         * @param fileId the ID of the file to retrieve
437
         * @return the file found
438
         * @throws ObjectNotFoundException if the file or the user was not found, with
439
         *                         the exception message mentioning the precise problem
440
         * @throws InsufficientPermissionsException
441
         */
442
        public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException,
443
                        InsufficientPermissionsException;
444

    
445
        /**
446
         * Retrieve the filebody with the specified ID.
447
         *
448
         * @param userId the ID of the current user
449
         * @param fileId the ID of the file to retrieve
450
         * @param bodyId the ID of the body
451
         * @return the file found
452
         * @throws ObjectNotFoundException if the file or the user was not found, with
453
         *                         the exception message mentioning the precise problem
454
         * @throws InsufficientPermissionsException
455
         */
456
        public FileBodyDTO getFileBody(Long userId, Long fileId, Long bodyId)
457
                        throws ObjectNotFoundException, InsufficientPermissionsException;
458

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

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

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

    
515
        /**
516
         * Copy the provided file to the specified destination.
517
         *
518
         * @param userId the ID of the current user
519
         * @param fileIds the IDs of the provided files
520
         * @param destId the ID of the destination folder
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
         * @throws InsufficientPermissionsException
527
         * @throws QuotaExceededException
528
         */
529
        public void copyFiles(Long userId, List<Long> fileIds, Long destId)
530
                        throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
531
                        InsufficientPermissionsException, QuotaExceededException;
532

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

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

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

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

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

    
624
        /**
625
         * Marks  the specified file as deleted in the specified user's namespace.
626
         *
627
         * @param userId the ID of the current user
628
         * @param fileId the ID of the file to delete
629
         * @throws ObjectNotFoundException if the user or file was not found, with
630
         *             the exception message mentioning the precise problem
631
         * @throws InsufficientPermissionsException if the user does not have the
632
         *             appropriate privileges
633
         */
634
        public void moveFileToTrash(Long userId, Long fileId) throws ObjectNotFoundException,
635
                        InsufficientPermissionsException;
636

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

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

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

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

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

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

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

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

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

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

    
794
        /**
795
         * Returns a list of All deleted files of a user.
796
         *
797
         * @param userId the ID of the User
798
         *          * @return the list of deleted file header objects
799
         * @throws ObjectNotFoundException if the user cannot be found
800
         */
801
        public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException;
802

    
803
        /**
804
         * Returns a list of All deleted root folders of a user.
805
         *
806
         * @param userId the ID of the User
807
         *          * @return the list of deleted file header objects
808
         * @throws ObjectNotFoundException if the user cannot be found
809
         */
810
        public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
811

    
812
        /**
813
         * Empty Trash by deleting all marked as deleted files and folders
814
         * @param userId
815
         * @throws ObjectNotFoundException if something goes wrong in the delete process
816
         * @throws InsufficientPermissionsException if something goes wrong in the delete process
817
         */
818
        public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
819

    
820
        /**
821
         * Restores All Trashed Items by undeleting all marked as deleted files and folders
822
         * @param userId
823
         * @throws ObjectNotFoundException if something goes wrong in the delete process
824
         * @throws InsufficientPermissionsException
825
         */
826
        public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
827

    
828
        /**
829
         * Search the system for a user with the specified username.
830
         * If no such user is found, the method returns null.
831
         *
832
         * @param username the username to search for
833
         * @return the User object with the specified username
834
         */
835
        public User findUser(String username);
836

    
837
        /**
838
         * Create a new user with the specified name, username and e-mail address.
839
         *
840
         * @param username the username of the new user
841
         * @param name the name of the new user
842
         * @param mail the e-mail of the new user
843
         * @param idp the IdP of the new user
844
         * @param idpid the IdP identifier of the new user
845
         * @return the newly-created User object
846
         * @throws DuplicateNameException if a user with the same username already exists
847
         * @throws ObjectNotFoundException if no username was provided
848
         */
849
        public User createUser(String username, String name, String mail, String idp, String idpid)
850
                        throws DuplicateNameException, ObjectNotFoundException;
851

    
852
        /**
853
         * Updates the authentication token for the specified user.
854
         *
855
         * @param userId the ID of the user whose token should be updated
856
         * @return the updated user
857
         * @throws ObjectNotFoundException if the user could not be found
858
         */
859
        public User updateUserToken(Long userId) throws ObjectNotFoundException;
860

    
861
        /**
862
         * Updates the policy acceptance flag for the specified user.
863
         *
864
         * @param userId the ID of the user whose flag should be updated
865
         * @param isAccepted the new value of the flag
866
         * @return the updated user
867
         * @throws ObjectNotFoundException if the user could not be found
868
         */
869
        public User updateUserPolicyAcceptance(Long userId, boolean isAccepted) throws ObjectNotFoundException;
870

    
871
        /**
872
         * Invalidates the authentication token for the specified user.
873
         *
874
         * @param userId the ID of the user whose token should be updated
875
         * @throws ObjectNotFoundException if the user could not be found
876
         */
877
        public void invalidateUserToken(Long userId) throws ObjectNotFoundException;
878

    
879
        /**
880
         * Retrieve folder user and group permissions
881
         *
882
         * @param userId the ID of the user whose token should be updated
883
         * @param folderId the ID of the folder
884
         * @return the Set of permissions from requested folder
885
         * @throws ObjectNotFoundException if the user or folder could not be found
886
         * @throws InsufficientPermissionsException
887
         */
888
        public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId)
889
                        throws ObjectNotFoundException, InsufficientPermissionsException;
890

    
891
        /**
892
         * Retrieve file user and group permissions
893
         *
894
         * @param userId the ID of the user whose token should be updated
895
         * @param fileId the ID of the folder
896
         * @return the Set of permissions from requested folder
897
         * @throws ObjectNotFoundException if the user or folder could not be found
898
         * @throws InsufficientPermissionsException
899
         */
900
        public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId)
901
                        throws ObjectNotFoundException, InsufficientPermissionsException;
902

    
903
        /**
904
         * Returns a list of all shared root folders of a user.
905
         *
906
         * @param userId the ID of the User
907
         * @return the list of shared root folders
908
         * @throws ObjectNotFoundException if the user cannot be found
909
         */
910
        public List<FolderDTO> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
911

    
912
        /**
913
         * Returns a list of all shared files of a user that are not
914
         * inside other shared folders.
915
         *
916
         * @param userId the ID of the User
917
         * @return the list of shared files
918
         * @throws ObjectNotFoundException if the user cannot be found
919
         */
920
        public List<FileHeaderDTO> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
921

    
922
        /**
923
         * Returns a list of all shared files of a user.
924
         *
925
         * @param userId the ID of the User
926
         * @return the list of shared files
927
         * @throws ObjectNotFoundException if the user cannot be found
928
         */
929
        public List<FileHeaderDTO> getSharedFiles(Long userId) throws ObjectNotFoundException;
930

    
931
        /**
932
         * Returns a list of all shared folders of a user.
933
         *
934
         * @param userId the ID of the User
935
         * @return the list of shared folders
936
         * @throws ObjectNotFoundException if the user cannot be found
937
         */
938
        public List<FolderDTO> getSharedFolders(Long userId) throws ObjectNotFoundException;
939

    
940
        /**
941
         * Returns a list of all shared root folders of a user that calling
942
         * user has at least read permissions.
943
         *
944
         * @param ownerId the ID of the User
945
         * @return the list of shared root folders
946
         * @param callingUserId
947
         *
948
         * @throws ObjectNotFoundException if the user cannot be found
949
         */
950
        public List<FolderDTO> getSharedRootFolders(Long ownerId, Long callingUserId)
951
                        throws ObjectNotFoundException;
952

    
953
        /**
954
         * Returns a list of all shared  files of a user that calling user has
955
         * at least read permissions..
956
         *
957
         * @param ownerId the ID of the User
958
         * @return the list of shared files
959
         * @param callingUserId
960
         * @throws ObjectNotFoundException if the user cannot be found
961
         */
962
        public List<FileHeaderDTO> getSharedFiles(Long ownerId, Long callingUserId)
963
                        throws ObjectNotFoundException;
964

    
965
        /**
966
         * Remove a user member from a group
967
         *
968
         * @param userId the ID of the User owning the group
969
         * @param groupId the ID of the requested group
970
         * @param memberId the ID of the member to be removed
971
         *
972
         * @throws ObjectNotFoundException if the user or group was not found, with
973
         *             the exception message mentioning the precise problem
974
         * @throws InsufficientPermissionsException
975
         */
976
        public void removeMemberFromGroup(Long userId, Long groupId, Long memberId)
977
                        throws ObjectNotFoundException, InsufficientPermissionsException;
978

    
979
        /**
980
         * Retrieves the list of users sharing files to user identified by user id
981
         * @param userId
982
         * @return the List of users sharing files to user
983
         * @throws ObjectNotFoundException
984
         */
985
        public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
986

    
987
        /**
988
         * Search Files
989
         *
990
         * @param userId
991
         * @param query
992
         * @return list of files that match query
993
         * @throws ObjectNotFoundException if no user or query was specified
994
         */
995
        public List<FileHeaderDTO> searchFiles(Long userId, String query) throws ObjectNotFoundException;
996

    
997
        /**
998
         * Creates a nonce for the specified user.
999
         *
1000
         * @param userId the ID of the user
1001
         * @return the new nonce
1002
         * @throws ObjectNotFoundException if the user could not be found
1003
         */
1004
        public Nonce createNonce(Long userId) throws ObjectNotFoundException;
1005

    
1006
        /**
1007
         * Find the nonce object for the specified encoded nonce, that should be
1008
         * associated with the specified user.
1009
         *
1010
         * @param nonce the issued nonce in Base64 encoding
1011
         * @param userId the ID of the user for whom this nonce should have been issued
1012
         * @return the retrieved nonce object
1013
         * @throws ObjectNotFoundException if the nonce or user were not found
1014
         */
1015
        public Nonce getNonce(String nonce, Long userId) throws ObjectNotFoundException;
1016

    
1017
        /**
1018
         * Remove the specified nonce from the persistent store.
1019
         *
1020
         * @param id the ID of the nonce
1021
         * @throws ObjectNotFoundException if the specified nonce could not be found
1022
         */
1023
        public void removeNonce(Long id) throws ObjectNotFoundException;
1024

    
1025
        /**
1026
         * Activate the supplied nonce for the specified user.
1027
         *
1028
         * @param userId the ID of the user
1029
         * @param nonce the nonce to activate
1030
         * @param nonceExpiryDate the expiry date of the nonce
1031
         * @throws ObjectNotFoundException
1032
         */
1033
        public void activateUserNonce(Long userId, String nonce, Date nonceExpiryDate) throws ObjectNotFoundException;
1034

    
1035
        /**
1036
         * Retrieves user statistics.
1037
         *
1038
         * @param userId the ID of the user
1039
         * @return the statistics
1040
         * @throws ObjectNotFoundException
1041
         *
1042
         */
1043
        public StatsDTO getUserStatistics(Long userId) throws ObjectNotFoundException;
1044

    
1045
        /**
1046
         * Retrieves file versions
1047
         *
1048
         * @param userId the ID of the user
1049
         * @param fileId the ID of the file
1050
         * @return the list of filebodies
1051
         * @throws ObjectNotFoundException
1052
         * @throws InsufficientPermissionsException
1053
         *
1054
         */
1055
        public List<FileBodyDTO> getVersions(Long userId, Long fileId)
1056
                        throws ObjectNotFoundException, InsufficientPermissionsException;
1057

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

    
1074
        /**
1075
         * Remove file version identified by bodyId
1076
         *
1077
         * @param userId the ID of the user
1078
         * @param fileId the ID of the file
1079
         * @param bodyId the ID of the body
1080
         *
1081
         * @throws ObjectNotFoundException
1082
         * @throws InsufficientPermissionsException
1083
         *
1084
         */
1085
        public void removeVersion(Long userId, Long fileId, Long bodyId)
1086
                        throws ObjectNotFoundException, InsufficientPermissionsException;
1087

    
1088
        /**
1089
         * Removes all old file versions for specified file keeping only the current revision
1090
         *
1091
         * @param userId the ID of the user
1092
         * @param fileId the ID of the file
1093
         *
1094
         * @throws ObjectNotFoundException
1095
         * @throws InsufficientPermissionsException
1096
         *
1097
         */
1098
        public void removeOldVersions(Long userId, Long fileId)
1099
                        throws ObjectNotFoundException, InsufficientPermissionsException;
1100

    
1101
        /**
1102
         * It is used by the Solr mbean to rebuild the index.
1103
         */
1104
        public void rebuildSolrIndex();
1105

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

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

    
1151
        /**
1152
         * Create a file based on inputstream without using transaction.
1153
         *
1154
         * @param stream
1155
         * @param userId
1156
         * @return the file
1157
         * @throws IOException
1158
         * @throws ObjectNotFoundException
1159
         */
1160
        @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
1161
        public File uploadFile(InputStream stream, Long userId)
1162
                        throws IOException, ObjectNotFoundException;
1163

    
1164
        public void createFileUploadProgress(Long userId, String filename,
1165
                                Long bytesTransfered, Long fileSize) throws ObjectNotFoundException;
1166

    
1167
        public FileUploadStatus getFileUploadStatus(Long userId, String fileName);
1168

    
1169
        public void removeFileUploadProgress(Long userId, String filename)
1170
                        throws ObjectNotFoundException;
1171

    
1172
        /**
1173
         * Fetch the file body with the specified version number.
1174
         *
1175
         * @param userId the ID of the current user
1176
         * @param fileId the ID of the file header
1177
         * @param version the version number
1178
         * @return the file body
1179
         * @throws ObjectNotFoundException if the user file or version
1180
         *                         were not found
1181
         * @throws InsufficientPermissionsException if the user does not
1182
         *                         have enough privileges for reading this file
1183
         */
1184
        public FileBodyDTO getFileVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException;
1185

    
1186
        /**
1187
         * Search the system for a user with the specified email address.
1188
         * If no such user is found, the method returns null.
1189
         */
1190
        public User findUserByEmail(String email);
1191

    
1192
        /**
1193
         * Update the user with the values from the supplied object.
1194
         */
1195
        public void updateUser(User user);
1196

    
1197
        /**
1198
         * Update accounting information for given user.
1199
         *
1200
         * @param user The user to update
1201
         * @param date Date of transaction
1202
         * @param bandwidthDiff Bandwidth used; positive for addition,
1203
         * negative for subtraction (e.g. to rollback)
1204
         */
1205
        public void updateAccounting(User user, Date date, long bandwidthDiff);
1206

    
1207
        /**
1208
         * Check if the user with the specified ID has permission to read the
1209
         * folder with the supplied ID.
1210
         */
1211
        public boolean canReadFolder(Long userId, Long folderId) throws ObjectNotFoundException;
1212

    
1213
        /**
1214
         * Reset WebDAV password for given user.
1215
         *
1216
         * @param userId
1217
         * @return the new password
1218
         * @throws ObjectNotFoundException
1219
         */
1220
        public String resetWebDAVPassword(Long userId) throws ObjectNotFoundException;
1221

    
1222
        /**
1223
         * Find the invite for the specified invitation code.
1224
         *
1225
         * @param code the invitation code
1226
         * @return the Invitation or null if not found
1227
         */
1228
        public Invitation findInvite(String code);
1229

    
1230
        /**
1231
         * Create a new user in the connected IdP.
1232
         *
1233
         * @param username the username of the new user
1234
         * @param firstname the first name of the new user
1235
         * @param lastname the last name of the new user
1236
         * @param email the e-mail of the new user
1237
         * @param password the password of the new user
1238
         */
1239
        public void createLdapUser(String username, String firstname, String lastname, String email, String password);
1240

    
1241
        /**
1242
         * Retrieves the available user classes.
1243
         */
1244
        public List<UserClass> getUserClasses();
1245

    
1246
        /**
1247
         * Upgrades the user class to the default "coupon bearer" class and marks
1248
         * the provided coupon as used.
1249
         *
1250
         * @param username the username of the user
1251
         * @param code the coupon code
1252
         * @return the new user class
1253
         * @throws InvitationUsedException when trying to reuse an already used invitation
1254
         * @throws ObjectNotFoundException if the user was not found
1255
         */
1256
        public UserClass upgradeUserClass(String username, String code)
1257
                        throws ObjectNotFoundException, InvitationUsedException;
1258

    
1259
        /**
1260
         * Retrieve the user class for coupon-bearing users.
1261
         */
1262
        public UserClass getCouponUserClass();
1263

    
1264
        /**
1265
         * Delete the actual file in the specified file system path.
1266
         */
1267
        public void deleteActualFile(String path);
1268

    
1269
        /**
1270
         * Posts the file specified by id to solr indexing server
1271
         * 
1272
         * @param id
1273
         */
1274
        public void postFileToSolr(Long id);
1275
}