2 * Copyright 2007, 2008, 2009, 2010 Electronic Business Systems Ltd.
4 * This file is part of GSS.
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.
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.
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/>.
19 package gr.ebs.gss.server.ejb;
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.FileBody;
28 import gr.ebs.gss.server.domain.FileHeader;
29 import gr.ebs.gss.server.domain.FileUploadStatus;
30 import gr.ebs.gss.server.domain.Folder;
31 import gr.ebs.gss.server.domain.Group;
32 import gr.ebs.gss.server.domain.Invitation;
33 import gr.ebs.gss.server.domain.Nonce;
34 import gr.ebs.gss.server.domain.Permission;
35 import gr.ebs.gss.server.domain.User;
36 import gr.ebs.gss.server.domain.UserClass;
37 import gr.ebs.gss.server.domain.UserLogin;
38 import gr.ebs.gss.server.domain.dto.StatsDTO;
39 import gr.ebs.gss.server.domain.dto.UserDTO;
42 import java.io.IOException;
43 import java.io.InputStream;
44 import java.util.Date;
45 import java.util.List;
48 import javax.ejb.Local;
49 import javax.ejb.TransactionAttribute;
50 import javax.ejb.TransactionAttributeType;
52 import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
55 * The External API for GSS clients.
60 public interface ExternalAPI {
63 * Retrieves the root folder for the specified user. The caller must ensure
64 * that the userId exists.
68 * @throws ObjectNotFoundException if no Folder or user was found
70 public Folder getRootFolder(Long userId) throws ObjectNotFoundException;
73 * Retrieve the folder with the specified ID.
75 * @param userId the ID of the current user
76 * @param folderId the ID of the folder to retrieve
77 * @return the folder found
78 * @throws ObjectNotFoundException if the folder or the user was not found
79 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
81 public Folder getFolder(Long userId, Long folderId) throws ObjectNotFoundException,
82 InsufficientPermissionsException;
85 * Returns the user with the specified ID.
87 * @param userId The ID of the User to be found
88 * @return The User object
89 * @throws ObjectNotFoundException if the user cannot be found
91 public User getUser(Long userId) throws ObjectNotFoundException;
94 * Returns the user with the specified ID.
96 * @param userId The ID of the User to be found
97 * @return The User object
98 * @throws ObjectNotFoundException if the user cannot be found
100 public UserDTO getUserDTO(Long userId) throws ObjectNotFoundException;
103 * Returns the group with the specified ID.
105 * @param groupId The ID of the Group to be found
106 * @return The Group object
107 * @throws ObjectNotFoundException if the group cannot be found
109 public Group getGroup(Long groupId) throws ObjectNotFoundException;
112 * Returns the group with the specified name that belongs to the
115 * @param userId the ID of the user
116 * @param name the name of the group
117 * @return The Group object
118 * @throws ObjectNotFoundException if the group cannot be found
120 public Group getGroup(Long userId, String name) throws ObjectNotFoundException;
123 * Retrieve the list of groups for a particular user.
125 * @param userId the ID of the User
126 * @return a List of Groups that belong to the specified User
127 * @throws ObjectNotFoundException if the user was not found
129 public List<Group> getGroups(Long userId) throws ObjectNotFoundException;
132 * Returns a list of files contained in the folder specified by its id.
134 * @param userId the ID of the User
135 * @param folderId the ID of the folder containing the files
136 * @param ignoreDeleted
137 * @return the list of file header objects
138 * @throws ObjectNotFoundException if the user or the folder cannot be found
139 * @throws InsufficientPermissionsException
141 public List<FileHeader> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException,
142 InsufficientPermissionsException;
145 * Returns a list of users for the specified group
147 * @param userId the ID of the User
148 * @param groupId the ID of the requested group
150 * @throws ObjectNotFoundException if the user or group was not found, with
151 * the exception message mentioning the precise problem
153 public List<User> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
156 * Returns a list of users matching the specified username
158 * @param username the username of the User
161 public List<User> getUsersByUserNameLike(String username);
164 * Creates a new folder with the specified owner, parent folder and name.
165 * New folder has the same permissions as its parent
170 * @return the new folder
171 * @throws DuplicateNameException if the specified name already exists in
172 * the parent folder, as either a folder or file
173 * @throws ObjectNotFoundException if the user or parent folder was not
174 * found, with the exception message mentioning the precise
176 * @throws InsufficientPermissionsException
178 public Folder createFolder(Long userId, Long parentId, String name) throws DuplicateNameException,
179 ObjectNotFoundException, InsufficientPermissionsException;
182 * Deletes the specified folder, if the specified user has the appropriate
185 * @param userId the ID of the current user
186 * @param folderId the ID of the folder to delete
187 * @throws InsufficientPermissionsException if the user does not have the
188 * appropriate privileges
189 * @throws ObjectNotFoundException if the user or folder was not found, with
190 * the exception message mentioning the precise problem
192 public void deleteFolder(Long userId, Long folderId)
193 throws InsufficientPermissionsException, ObjectNotFoundException;
196 * Retrieve the subfolders of the specified folder.
198 * @param userId the ID of the current user
199 * @param folderId the ID of the folder to retrieve
200 * @return the list of subfolders found
201 * @throws ObjectNotFoundException if the folder or user was not found
202 * @throws InsufficientPermissionsException
204 public List<Folder> getSubfolders(Long userId, Long folderId)
205 throws ObjectNotFoundException, InsufficientPermissionsException;
208 * Retrieve the subfolders of the specified folder that are shared to others.
210 * @param userId the ID of the current user
211 * @param folderId the ID of the folder to retrieve
212 * @return the list of subfolders found
213 * @throws ObjectNotFoundException if the folder or user was not found
215 public List<Folder> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
218 * Retrieve the subfolders of the specified folder that are shared to others.
220 * @param userId the ID of the current user
221 * @param callingUserId the id of the user requesting this operation
222 * @param folderId the ID of the folder to retrieve
223 * @return the list of subfolders found
224 * @throws ObjectNotFoundException if the folder or user was not found
226 public List<Folder> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException;
228 * Modifies the specified folder if the specified user has the appropriate
231 * @param userId the ID of the current user
232 * @param folderId the ID of the folder to retrieve
236 * @return the updated folder
237 * @throws InsufficientPermissionsException if the user does not have the
238 * appropriate privileges
239 * @throws ObjectNotFoundException if the user or folder was not found, with
240 * the exception message mentioning the precise problem
241 * @throws DuplicateNameException if the specified name already exists in
242 * the parent folder, as either a folder or file
244 public Folder updateFolder(Long userId, Long folderId, String folderName,
246 Set<Permission> permissions)
247 throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
250 * Adds a user to the specified group
252 * @param userId the ID of the current user
253 * @param groupId the id of the new group
254 * @param userToAddId the id of the user to add
255 * @throws DuplicateNameException if the user already exists in group
256 * @throws ObjectNotFoundException if the user or group was not found, with
257 * the exception message mentioning the precise problem
258 * @throws InsufficientPermissionsException
260 public void addUserToGroup(Long userId, Long groupId, Long userToAddId)
261 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
264 * Creates a new group with the specified owner and name.
266 * @param userId the ID of the current user
267 * @param name the name of the new group
268 * @throws DuplicateNameException if the new group name already exists
269 * @throws ObjectNotFoundException if the user or group was not found, with
270 * the exception message mentioning the precise problem
272 public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
275 * Deletes the specified group in the specified user's namespace.
277 * @param userId the ID of the current user
278 * @param groupId the ID of the group to delete
279 * @throws ObjectNotFoundException if the user or group was not found, with
280 * the exception message mentioning the precise problem
281 * @throws InsufficientPermissionsException
283 public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
286 * Creates a new file with the specified owner, parent folder and name. The
287 * new file has the same permissions as its parent folder. The file contents
288 * are read from the input stream to a new File object.
290 * @param userId the ID of the current user
291 * @param folderId the ID of the parent folder
292 * @param name the name of the new file
293 * @param mimeType the MIME type of the file
294 * @param stream the input stream with the file contents
295 * @return The FileHeader created
296 * @throws DuplicateNameException if the specified name already exists in
297 * the parent folder, as either a folder or file
298 * @throws ObjectNotFoundException if the user or parent folder was not
299 * found, with the exception message mentioning the precise
301 * @throws GSSIOException if there was an error while storing the file contents
302 * @throws InsufficientPermissionsException
303 * @throws QuotaExceededException
305 public FileHeader createFile(Long userId, Long folderId, String name, String mimeType,
306 InputStream stream) throws DuplicateNameException, ObjectNotFoundException,
307 GSSIOException, InsufficientPermissionsException, QuotaExceededException;
310 * Deletes the specified file, provided the specified user has
311 * the necessary permissions.
313 * @param userId the ID of the current user
314 * @param fileId the ID of the file to delete
315 * @throws ObjectNotFoundException if the user or file was not found, with
316 * the exception message mentioning the precise problem
317 * @throws InsufficientPermissionsException if the user does not have the
318 * appropriate privileges
320 public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
323 * Creates a new tag for the specified user and file.
325 * @param userId the creator of the tag
326 * @param fileHeaderId the file that is tagged
328 * @throws ObjectNotFoundException if the user or the file was not found
330 public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
333 * Returns all tags defined by the specified user
336 * @return Set<String>
337 * @throws ObjectNotFoundException if the user was null
339 public Set<String> getUserTags(final Long userId) throws ObjectNotFoundException;
342 * Updates the attributes of the specified file.
347 * @param tagSet a String that contains tags separated by comma
348 * @param modificationDate the modification date
349 * @param versioned the new value of the versioned flag
352 * @throws DuplicateNameException
353 * @throws ObjectNotFoundException
354 * @throws InsufficientPermissionsException
356 public void updateFile(Long userId, Long fileId, String name, String tagSet,
357 Date modificationDate, Boolean versioned, Boolean readForAll,
358 Set<Permission> permissions)
359 throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
362 * Retrieve the contents of the current body for the file
363 * with the specified FileHeader ID. The file contents
364 * are provided as an InputStream from which the caller can
365 * retrieve the raw bytes.
367 * @param userId the ID of the current user
368 * @param fileId the ID of the file to retrieve
369 * @return an InputStream from the current file body contents
370 * @throws ObjectNotFoundException if the file or the user was not found
371 * @throws InsufficientPermissionsException if the user does not have the
372 * appropriate privileges
374 public InputStream getFileContents(Long userId, Long fileId)
375 throws ObjectNotFoundException, InsufficientPermissionsException;
378 * Retrieve the contents of the body identified by bodyId for the file
379 * with the specified FileHeader ID. The file contents
380 * are provided as an InputStream from which the caller can
381 * retrieve the raw bytes.
383 * @param userId the ID of the current user
384 * @param fileId the ID of the file to retrieve
385 * @param bodyId the body ID
386 * @return an InputStream from the current file body contents
387 * @throws ObjectNotFoundException if the file or the user was not found
388 * @throws InsufficientPermissionsException if the user does not have the
389 * appropriate privileges
391 public InputStream getFileContents(Long userId, Long fileId, Long bodyId)
392 throws ObjectNotFoundException, InsufficientPermissionsException;
395 * Retrieve the file with the specified ID.
397 * @param userId the ID of the current user
398 * @param fileId the ID of the file to retrieve
399 * @return the file found
400 * @throws ObjectNotFoundException if the file or the user was not found, with
401 * the exception message mentioning the precise problem
402 * @throws InsufficientPermissionsException
404 public FileHeader getFile(Long userId, Long fileId) throws ObjectNotFoundException,
405 InsufficientPermissionsException;
408 * Retrieve the filebody with the specified ID.
410 * @param userId the ID of the current user
411 * @param fileId the ID of the file to retrieve
412 * @param bodyId the ID of the body
413 * @return the file found
414 * @throws ObjectNotFoundException if the file or the user was not found, with
415 * the exception message mentioning the precise problem
416 * @throws InsufficientPermissionsException
418 public FileBody getFileBody(Long userId, Long fileId, Long bodyId)
419 throws ObjectNotFoundException, InsufficientPermissionsException;
422 * Get the resource (file or folder) at the specified path in
423 * the specified user's namespace. The returned object will be of type
424 * FileHeader or Folder.<p><strong>Note:</strong> this method does not
425 * receive the current user as a parameter, therefore it is unable to perform
426 * the necessary permission checks and should <strong>NOT</strong> be directly
427 * exposed to remote clients. It is the caller's responsibility to verify that
428 * the calling user has the required privileges for performing any subsequent
429 * action on the resource through one of the other ExternalAPI methods.
431 * @param ownerId the ID of the user owning the namespace
432 * @param path the absolute path in the user's namespace
433 * @param ignoreDeleted if true, resources that have been moved to the trash
435 * @throws ObjectNotFoundException if the user or resource was not found, with
436 * the exception message mentioning the precise problem
437 * @return the resource found
439 public Object getResourceAtPath(Long ownerId, String path, boolean ignoreDeleted)
440 throws ObjectNotFoundException;
443 * Copy the provided file to the specified destination.
445 * @param userId the ID of the current user
446 * @param fileId the IF of the provided file
447 * @param dest the path of the new resource
448 * @throws ObjectNotFoundException if the user, file or destination was not
449 * found, with the exception message mentioning the precise problem
450 * @throws DuplicateNameException if the specified name already exists in
451 * the destination folder, as either a folder or file
452 * @throws GSSIOException if there was an error while accessing the file contents
453 * @throws InsufficientPermissionsException
454 * @throws QuotaExceededException
456 public void copyFile(Long userId, Long fileId, String dest) throws ObjectNotFoundException,
457 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
460 * Copy the provided file to the specified destination.
462 * @param userId the ID of the current user
463 * @param ownerId the ID of the owner of the destination namespace
464 * @param fileId the IF of the provided file
465 * @param dest the path of the new resource
466 * @throws ObjectNotFoundException if the user, file or destination was not
467 * found, with the exception message mentioning the precise problem
468 * @throws DuplicateNameException if the specified name already exists in
469 * the destination folder, as either a folder or file
470 * @throws GSSIOException if there was an error while accessing the file contents
471 * @throws InsufficientPermissionsException
472 * @throws QuotaExceededException
474 public void copyFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException,
475 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
478 * Copy the provided file to the specified destination.
480 * @param userId the ID of the current user
481 * @param fileIds the IDs of the provided files
482 * @param destId the ID of the destination folder
483 * @throws ObjectNotFoundException if the user, file or destination was not
484 * found, with the exception message mentioning the precise problem
485 * @throws GSSIOException if there was an error while accessing the file contents
486 * @throws DuplicateNameException if the specified name already exists in
487 * the destination folder, as either a folder or file
488 * @throws InsufficientPermissionsException
489 * @throws QuotaExceededException
491 public void copyFiles(Long userId, List<Long> fileIds, Long destId)
492 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
493 InsufficientPermissionsException, QuotaExceededException;
496 * Copy the provided file to the specified destination.
498 * @param userId the ID of the current user
499 * @param fileId the IF of the provided file
500 * @param destId the ID of the destination folder
501 * @param destName the name of the new file
502 * @throws ObjectNotFoundException if the user, file or destination was not
503 * found, with the exception message mentioning the precise problem
504 * @throws GSSIOException if there was an error while accessing the file contents
505 * @throws DuplicateNameException if the specified name already exists in
506 * the destination folder, as either a folder or file
507 * @throws InsufficientPermissionsException
508 * @throws QuotaExceededException
510 public void copyFile(Long userId, Long fileId, Long destId, String destName)
511 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
512 InsufficientPermissionsException, QuotaExceededException;
515 * Copy the provided folder to the specified destination.
517 * @param userId the ID of the current user
518 * @param folderId the IF of the provided folder
519 * @param dest the path of the new folder
520 * @throws ObjectNotFoundException if the user, folder or destination was not
521 * found, with the exception message mentioning the precise problem
522 * @throws DuplicateNameException if the specified name already exists in
523 * the destination folder, as either a folder or file
524 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
525 * appropriate privileges
527 public void copyFolder(Long userId, Long folderId, String dest) throws ObjectNotFoundException,
528 DuplicateNameException, InsufficientPermissionsException;
531 * Copy the provided folder to the specified destination.
533 * @param userId the ID of the current user
534 * @param folderId the IF of the provided folder
535 * @param destId the ID of the destination folder
536 * @param destName the name of the new folder
537 * @throws ObjectNotFoundException if the user, folder or destination was not
538 * found, with the exception message mentioning the precise problem
539 * @throws DuplicateNameException if the specified name already exists in
540 * the destination folder, as either a folder or file
541 * @throws InsufficientPermissionsException InsufficientPermissionsException
542 * if the user does not have the appropriate privileges
544 public void copyFolder(Long userId, Long folderId, Long destId, String destName)
545 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
548 * Copy the provided folder and all its subfolders and files to the specified destination.
550 * @param userId the ID of the current user
551 * @param ownerId the ID of the owner of the destination namespace
552 * @param folderId the IF of the provided folder
553 * @param dest the path of the new folder
554 * @throws ObjectNotFoundException if the user, folder or destination was not
555 * found, with the exception message mentioning the precise problem
556 * @throws DuplicateNameException if the specified name already exists in
557 * the destination folder, as either a folder or file
558 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
559 * appropriate privileges
560 * @throws QuotaExceededException if the user quota limit would be exceeded
561 * @throws GSSIOException if there was an error while accessing the file contents
563 public void copyFolderStructureToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
564 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
567 * Copy the provided folder and all its subfolders and files to the specified destination.
569 * @param userId the ID of the current user
570 * @param folderId the IF of the provided folder
571 * @param destId the ID of the destination folder
572 * @param destName the name of the new folder
573 * @throws ObjectNotFoundException if the user, folder or destination was not
574 * found, with the exception message mentioning the precise problem
575 * @throws DuplicateNameException if the specified name already exists in
576 * the destination folder, as either a folder or file
577 * @throws InsufficientPermissionsException InsufficientPermissionsException
578 * if the user does not have the appropriate privileges
579 * @throws GSSIOException if there was an error while accessing the file contents
580 * @throws QuotaExceededException if the user quota limit would be exceeded
582 public void copyFolderStructure(Long userId, Long folderId, Long destId, String destName)
583 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
584 GSSIOException, QuotaExceededException;
587 * Marks the specified file as deleted in the specified user's namespace.
589 * @param userId the ID of the current user
590 * @param fileId the ID of the file to delete
591 * @throws ObjectNotFoundException if the user or file was not found, with
592 * the exception message mentioning the precise problem
593 * @throws InsufficientPermissionsException if the user does not have the
594 * appropriate privileges
596 public void moveFileToTrash(Long userId, Long fileId) throws ObjectNotFoundException,
597 InsufficientPermissionsException;
600 * Marks the specified deleted file as undeleted in the specified user's namespace.
602 * @param userId the ID of the current user
603 * @param fileId the ID of the file to undelete
604 * @throws ObjectNotFoundException if the user or file was not found, with
605 * the exception message mentioning the precise problem
606 * @throws InsufficientPermissionsException if the user does not have the
607 * appropriate privileges
610 public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
613 * Marks the specified folder as deleted in the specified user's namespace.
615 * @param userId the ID of the current user
616 * @param folderId the ID of the folder to delete
617 * @throws ObjectNotFoundException if the user or file was not found, with
618 * the exception message mentioning the precise problem
619 * @throws InsufficientPermissionsException if the user does not have the
620 * appropriate privileges
622 public void moveFolderToTrash(Long userId, Long folderId)
623 throws ObjectNotFoundException, InsufficientPermissionsException;
626 * Marks the specified deleted folder as undeleted in the specified user's namespace.
628 * @param userId the ID of the current user
629 * @param folderId the ID of the folder to undelete
630 * @throws ObjectNotFoundException if the user or file was not found, with
631 * the exception message mentioning the precise problem
632 * @throws InsufficientPermissionsException if the user does not have the
633 * appropriate privileges
636 public void removeFolderFromTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
639 * Move the provided folder and all its subfolders and files to the specified destination.
641 * @param userId the ID of the current user
642 * @param folderId the IF of the provided folder
643 * @param destId the ID of the destination folder
644 * @param destName the name of the new folder
645 * @throws ObjectNotFoundException if the user, folder or destination was not
646 * found, with the exception message mentioning the precise problem
647 * @throws DuplicateNameException if the specified name already exists in
648 * the destination folder, as either a folder or file
649 * @throws InsufficientPermissionsException if the user does not have the
650 * appropriate privileges
651 * @throws GSSIOException
652 * @throws QuotaExceededException
654 public void moveFolder(Long userId, Long folderId, Long destId, String destName)
655 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
656 GSSIOException, QuotaExceededException;
659 * Move the provided folder and all its subfolders and files to the specified destination.
661 * @param userId the ID of the current user
662 * @param ownerId the owner of the destination namespace
663 * @param folderId the IF of the provided folder
664 * @param dest the path of the new folder
665 * @throws ObjectNotFoundException if the user, folder or destination was not
666 * found, with the exception message mentioning the precise problem
667 * @throws DuplicateNameException if the specified name already exists in
668 * the destination folder, as either a folder or file
669 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
670 * appropriate privileges
671 * @throws GSSIOException
672 * @throws QuotaExceededException
674 public void moveFolderToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
675 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
678 * Move the provided file to the specified destination.
680 * @param userId the ID of the current user
681 * @param fileId the IF of the provided file
682 * @param destId the ID of the destination folder
683 * @param destName the name of the new file
684 * @throws InsufficientPermissionsException
685 * @throws ObjectNotFoundException if the user, file or destination was not
686 * found, with the exception message mentioning the precise problem
687 * @throws GSSIOException if there was an error while accessing the file contents
688 * @throws DuplicateNameException if the specified name already exists in
689 * the destination folder, as either a folder or file
690 * @throws QuotaExceededException
692 public void moveFile(Long userId, Long fileId, Long destId, String destName)
693 throws InsufficientPermissionsException, ObjectNotFoundException,
694 DuplicateNameException, GSSIOException, QuotaExceededException;
697 * Move the provided file to the specified destination.
699 * @param userId the ID of the current user
700 * @param ownerId the owner of the destination namespace
701 * @param fileId the IF of the provided file
702 * @param dest the path of the new file
703 * @throws InsufficientPermissionsException
704 * @throws ObjectNotFoundException if the user, file or destination was not
705 * found, with the exception message mentioning the precise problem
706 * @throws GSSIOException if there was an error while accessing the file contents
707 * @throws DuplicateNameException if the specified name already exists in
708 * the destination folder, as either a folder or file
709 * @throws QuotaExceededException
711 public void moveFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException, InsufficientPermissionsException, DuplicateNameException, GSSIOException, QuotaExceededException;
714 * move the provided file to the specified destination.
716 * @param userId the ID of the current user
717 * @param fileIds the IDs of the provided files
718 * @param destId the ID of the destination folder
719 * @throws InsufficientPermissionsException
720 * @throws ObjectNotFoundException if the user, file or destination was not
721 * found, with the exception message mentioning the precise problem
722 * @throws GSSIOException if there was an error while accessing the file contents
723 * @throws DuplicateNameException if the specified name already exists in
724 * the destination folder, as either a folder or file
725 * @throws QuotaExceededException
727 public void moveFiles(Long userId, List<Long> fileIds, Long destId)
728 throws InsufficientPermissionsException, ObjectNotFoundException,
729 DuplicateNameException, GSSIOException, QuotaExceededException;
732 * Returns a list of All deleted files of a user.
734 * @param userId the ID of the User
735 * * @return the list of deleted file header objects
736 * @throws ObjectNotFoundException if the user cannot be found
738 public List<FileHeader> getDeletedFiles(Long userId) throws ObjectNotFoundException;
741 * Returns a list of All deleted root folders of a user.
743 * @param userId the ID of the User
744 * * @return the list of deleted file header objects
745 * @throws ObjectNotFoundException if the user cannot be found
747 public List<Folder> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
750 * Empty Trash by deleting all marked as deleted files and folders
752 * @throws ObjectNotFoundException if something goes wrong in the delete process
753 * @throws InsufficientPermissionsException if something goes wrong in the delete process
755 public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
758 * Restores All Trashed Items by undeleting all marked as deleted files and folders
760 * @throws ObjectNotFoundException if something goes wrong in the delete process
761 * @throws InsufficientPermissionsException
763 public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
766 * Search the system for a user with the specified username.
767 * If no such user is found, the method returns null.
769 * @param username the username to search for
770 * @return the User object with the specified username
772 public User findUser(String username);
775 * Create a new user with the specified name, username and e-mail address.
777 * @param username the username of the new user
778 * @param name the name of the new user
779 * @param mail the e-mail of the new user
780 * @param idp the IdP of the new user
781 * @param idpid the IdP identifier of the new user
782 * @return the newly-created User object
783 * @throws DuplicateNameException if a user with the same username already exists
784 * @throws ObjectNotFoundException if no username was provided
786 public User createUser(String username, String name, String mail, String idp, String idpid)
787 throws DuplicateNameException, ObjectNotFoundException;
790 * Updates the authentication token for the specified user.
792 * @param userId the ID of the user whose token should be updated
793 * @return the updated user
794 * @throws ObjectNotFoundException if the user could not be found
796 public User updateUserToken(Long userId) throws ObjectNotFoundException;
799 * Updates the policy acceptance flag for the specified user.
801 * @param userId the ID of the user whose flag should be updated
802 * @param isAccepted the new value of the flag
803 * @return the updated user
804 * @throws ObjectNotFoundException if the user could not be found
806 public User updateUserPolicyAcceptance(Long userId, boolean isAccepted) throws ObjectNotFoundException;
809 * Invalidates the authentication token for the specified user.
811 * @param userId the ID of the user whose token should be updated
812 * @throws ObjectNotFoundException if the user could not be found
814 public void invalidateUserToken(Long userId) throws ObjectNotFoundException;
817 * Retrieve folder user and group permissions
819 * @param userId the ID of the user whose token should be updated
820 * @param folderId the ID of the folder
821 * @return the Set of permissions from requested folder
822 * @throws ObjectNotFoundException if the user or folder could not be found
823 * @throws InsufficientPermissionsException
825 public Set<Permission> getFolderPermissions(Long userId, Long folderId)
826 throws ObjectNotFoundException, InsufficientPermissionsException;
829 * Retrieve file user and group permissions
831 * @param userId the ID of the user whose token should be updated
832 * @param fileId the ID of the folder
833 * @return the Set of permissions from requested folder
834 * @throws ObjectNotFoundException if the user or folder could not be found
835 * @throws InsufficientPermissionsException
837 public Set<Permission> getFilePermissions(Long userId, Long fileId)
838 throws ObjectNotFoundException, InsufficientPermissionsException;
841 * Returns a list of all shared root folders of a user.
843 * @param userId the ID of the User
844 * @return the list of shared root folders
845 * @throws ObjectNotFoundException if the user cannot be found
847 public List<Folder> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
850 * Returns a list of all shared files of a user that are not
851 * inside other shared folders.
853 * @param userId the ID of the User
854 * @return the list of shared files
855 * @throws ObjectNotFoundException if the user cannot be found
857 public List<FileHeader> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
860 * Returns a list of all shared files of a user.
862 * @param userId the ID of the User
863 * @return the list of shared files
864 * @throws ObjectNotFoundException if the user cannot be found
866 public List<FileHeader> getSharedFiles(Long userId) throws ObjectNotFoundException;
869 * Returns a list of all shared folders of a user.
871 * @param userId the ID of the User
872 * @return the list of shared folders
873 * @throws ObjectNotFoundException if the user cannot be found
875 public List<Folder> getSharedFolders(Long userId) throws ObjectNotFoundException;
878 * Returns a list of all shared root folders of a user that calling
879 * user has at least read permissions.
881 * @param ownerId the ID of the User
882 * @return the list of shared root folders
883 * @param callingUserId
885 * @throws ObjectNotFoundException if the user cannot be found
887 public List<Folder> getSharedRootFolders(Long ownerId, Long callingUserId)
888 throws ObjectNotFoundException;
891 * Returns a list of all shared files of a user that calling user has
892 * at least read permissions..
894 * @param ownerId the ID of the User
895 * @return the list of shared files
896 * @param callingUserId
897 * @throws ObjectNotFoundException if the user cannot be found
899 public List<FileHeader> getSharedFiles(Long ownerId, Long callingUserId)
900 throws ObjectNotFoundException;
903 * Remove a user member from a group
905 * @param userId the ID of the User owning the group
906 * @param groupId the ID of the requested group
907 * @param memberId the ID of the member to be removed
909 * @throws ObjectNotFoundException if the user or group was not found, with
910 * the exception message mentioning the precise problem
911 * @throws InsufficientPermissionsException
913 public void removeMemberFromGroup(Long userId, Long groupId, Long memberId)
914 throws ObjectNotFoundException, InsufficientPermissionsException;
917 * Retrieves the list of users sharing files to user identified by user id
919 * @return the List of users sharing files to user
920 * @throws ObjectNotFoundException
922 public List<User> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
929 * @return list of files that match query
930 * @throws ObjectNotFoundException if no user or query was specified
932 public List<FileHeader> searchFiles(Long userId, String query) throws ObjectNotFoundException;
935 * Creates a nonce for the specified user.
937 * @param userId the ID of the user
938 * @return the new nonce
939 * @throws ObjectNotFoundException if the user could not be found
941 public Nonce createNonce(Long userId) throws ObjectNotFoundException;
944 * Find the nonce object for the specified encoded nonce, that should be
945 * associated with the specified user.
947 * @param nonce the issued nonce in Base64 encoding
948 * @param userId the ID of the user for whom this nonce should have been issued
949 * @return the retrieved nonce object
950 * @throws ObjectNotFoundException if the nonce or user were not found
952 public Nonce getNonce(String nonce, Long userId) throws ObjectNotFoundException;
955 * Remove the specified nonce from the persistent store.
957 * @param id the ID of the nonce
958 * @throws ObjectNotFoundException if the specified nonce could not be found
960 public void removeNonce(Long id) throws ObjectNotFoundException;
963 * Activate the supplied nonce for the specified user.
965 * @param userId the ID of the user
966 * @param nonce the nonce to activate
967 * @param nonceExpiryDate the expiry date of the nonce
968 * @throws ObjectNotFoundException
970 public void activateUserNonce(Long userId, String nonce, Date nonceExpiryDate) throws ObjectNotFoundException;
973 * Retrieves user statistics.
975 * @param userId the ID of the user
976 * @return the statistics
977 * @throws ObjectNotFoundException
980 public StatsDTO getUserStatistics(Long userId) throws ObjectNotFoundException;
983 * Restore the file contents to the specified version.
985 * @param userId the ID of the user
986 * @param fileId the ID of the file
987 * @param version the version number of the desired file contents
988 * @throws ObjectNotFoundException if the user or file was not
989 * found, with the exception message mentioning the precise problem
990 * @throws InsufficientPermissionsException if the user does not have the
991 * appropriate privileges
992 * @throws QuotaExceededException if the user quota limit would be exceeded
993 * @throws GSSIOException if there was an error while accessing the file contents
995 public void restoreVersion(Long userId, Long fileId, int version)
996 throws ObjectNotFoundException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
999 * Removes all old file versions for specified file keeping only the current revision
1001 * @param userId the ID of the user
1002 * @param fileId the ID of the file
1004 * @throws ObjectNotFoundException
1005 * @throws InsufficientPermissionsException
1008 public void removeOldVersions(Long userId, Long fileId)
1009 throws ObjectNotFoundException, InsufficientPermissionsException;
1012 * It is used by the Solr mbean to rebuild the index.
1014 public String rebuildSolrIndex();
1017 * It is used by the Solr mbean to refresh the index. It does not delete anything just re-add everything in the index
1019 public String refreshSolrIndex();
1022 * Creates a new file with the specified owner, parent folder and name. The
1023 * new file has the same permissions as its parent folder. The file contents
1024 * are already uploaded outside of externalAPI and the uploaded file is used as a parameter.
1026 * @param userId the ID of the current user
1027 * @param folderId the ID of the parent folder
1028 * @param name the name of the new file
1029 * @param mimeType the MIME type of the file
1030 * @param fileSize the uploaded file size
1031 * @param filePath the uploaded file full path
1032 * @return The FileHeader created
1033 * @throws DuplicateNameException if the specified name already exists in
1034 * the parent folder, as either a folder or file
1035 * @throws ObjectNotFoundException if the user or parent folder was not
1036 * found, with the exception message mentioning the precise
1038 * @throws GSSIOException if there was an error while storing the file contents
1039 * @throws InsufficientPermissionsException
1040 * @throws QuotaExceededException
1042 public FileHeader createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
1043 throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
1044 InsufficientPermissionsException, QuotaExceededException;
1047 * Create a new FileBody with the supplied uploaded file as contents and make it the current body
1050 * @param userId the ID of the current user
1051 * @param fileId the ID of the file header object
1052 * @param mimeType the content type of the file
1053 * @param fileSize the uploaded file size
1054 * @param filePath the uploaded file full path
1055 * @return The FileHeader updated
1056 * @throws ObjectNotFoundException if the user or file was not found, with
1057 * the exception message mentioning the precise problem
1058 * @throws GSSIOException when an IO exception occurs
1059 * @throws InsufficientPermissionsException
1060 * @throws QuotaExceededException
1062 public FileHeader updateFileContents(Long userId, Long fileId, String mimeType,
1063 long fileSize, String filePath) throws ObjectNotFoundException, GSSIOException,
1064 InsufficientPermissionsException, QuotaExceededException;
1067 * Create a file based on inputstream without using transaction.
1072 * @throws IOException
1073 * @throws ObjectNotFoundException
1075 @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
1076 public File uploadFile(InputStream stream, Long userId)
1077 throws IOException, ObjectNotFoundException;
1079 public void createFileUploadProgress(Long userId, String filename,
1080 Long bytesTransfered, Long fileSize) throws ObjectNotFoundException;
1082 public FileUploadStatus getFileUploadStatus(Long userId, String fileName);
1084 public void removeFileUploadProgress(Long userId, String filename)
1085 throws ObjectNotFoundException;
1088 * Fetch the file body with the specified version number.
1090 * @param userId the ID of the current user
1091 * @param fileId the ID of the file header
1092 * @param version the version number
1093 * @return the file body
1094 * @throws ObjectNotFoundException if the user file or version
1096 * @throws InsufficientPermissionsException if the user does not
1097 * have enough privileges for reading this file
1099 public FileBody getFileVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException;
1102 * Search the system for a user with the specified email address.
1103 * If no such user is found, the method returns null.
1105 public User findUserByEmail(String email);
1108 * Update the user with the values from the supplied object.
1110 public void updateUser(User user);
1113 * Update accounting information for given user.
1115 * @param user The user to update
1116 * @param date Date of transaction
1117 * @param bandwidthDiff Bandwidth used; positive for addition,
1118 * negative for subtraction (e.g. to rollback)
1120 public void updateAccounting(User user, Date date, long bandwidthDiff);
1123 * Check if the user with the specified ID has permission to read the
1124 * folder with the supplied ID.
1126 public boolean canReadFolder(Long userId, Long folderId) throws ObjectNotFoundException;
1129 * Reset WebDAV password for given user.
1132 * @return the new password
1133 * @throws ObjectNotFoundException
1135 public String resetWebDAVPassword(Long userId) throws ObjectNotFoundException;
1138 * Find the invite for the specified invitation code.
1140 * @param code the invitation code
1141 * @return the Invitation or null if not found
1143 public Invitation findInvite(String code);
1146 * Create a new user in the connected IdP.
1148 * @param username the username of the new user
1149 * @param firstname the first name of the new user
1150 * @param lastname the last name of the new user
1151 * @param email the e-mail of the new user
1152 * @param password the password of the new user
1154 public void createLdapUser(String username, String firstname, String lastname, String email, String password);
1157 * Retrieves the available user classes.
1159 public List<UserClass> getUserClasses();
1162 * Upgrades the user class to the default "coupon bearer" class and marks
1163 * the provided coupon as used.
1165 * @param username the username of the user
1166 * @param code the coupon code
1167 * @return the new user class
1168 * @throws InvitationUsedException when trying to reuse an already used invitation
1169 * @throws ObjectNotFoundException if the user was not found
1171 public UserClass upgradeUserClass(String username, String code)
1172 throws ObjectNotFoundException, InvitationUsedException;
1175 * Retrieve the user class for coupon-bearing users.
1177 public UserClass getCouponUserClass();
1180 * Delete the actual file in the specified file system path.
1182 public void deleteActualFile(String path);
1185 * Update the userLogin with the values from the supplied object.
1187 public void addUserLogin(UserLogin userLogin);
1190 * Retrieves the user's current session login and the user's last login
1192 * @return a list of last two user logins
1193 * @throws ObjectNotFoundException
1195 public List<UserLogin> getLastUserLogins(Long userId) throws ObjectNotFoundException;
1198 * Posts the file specified by id to solr indexing server
1203 public void postFileToSolr(CommonsHttpSolrServer solr, Long id);
1207 * @throws ObjectNotFoundException
1209 public Folder expandFolder(Folder folder) throws ObjectNotFoundException;
1214 * @throws ObjectNotFoundException
1216 FileHeader expandFile(FileHeader folder) throws ObjectNotFoundException;
1221 * @throws ObjectNotFoundException
1223 Group expandGroup(Group folder) throws ObjectNotFoundException;