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.FileHeader;
28 import gr.ebs.gss.server.domain.FileUploadStatus;
29 import gr.ebs.gss.server.domain.Invitation;
30 import gr.ebs.gss.server.domain.Nonce;
31 import gr.ebs.gss.server.domain.User;
32 import gr.ebs.gss.server.domain.UserClass;
33 import gr.ebs.gss.server.domain.dto.FileBodyDTO;
34 import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
35 import gr.ebs.gss.server.domain.dto.FolderDTO;
36 import gr.ebs.gss.server.domain.dto.GroupDTO;
37 import gr.ebs.gss.server.domain.dto.PermissionDTO;
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 FolderDTO 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 FolderDTO 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 GroupDTO 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 GroupDTO 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<GroupDTO> 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<FileHeaderDTO> 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
149 * @return List<UserDTO>
150 * @throws ObjectNotFoundException if the user or group was not found, with
151 * the exception message mentioning the precise problem
153 public List<UserDTO> 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
159 * @return List<UserDTO>
161 public List<UserDTO> 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 FolderDTO 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<FolderDTO> getSubfolders(Long userId, Long folderId)
205 throws ObjectNotFoundException, InsufficientPermissionsException;
208 * Retrieve the folder with the specified ID with subfolders.
210 * @param userId the ID of the current user
211 * @param folderId the ID of the folder to retrieve
212 * @return the folder found
213 * @throws ObjectNotFoundException if the folder or the user was not found
214 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
216 public FolderDTO getFolderWithSubfolders(Long userId, Long folderId)
217 throws ObjectNotFoundException, InsufficientPermissionsException;
220 * Retrieve the folder with the specified ID with subfolders.
222 * @param userId the ID of the current user
223 * @param callingUserId the ID of the user requesting this operation
224 * @param folderId the ID of the folder to retrieve
225 * @return the folder found
226 * @throws ObjectNotFoundException if the folder or the user was not found
227 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
229 public FolderDTO getFolderWithSubfolders(Long userId, Long callingUserId, Long folderId)
230 throws ObjectNotFoundException, InsufficientPermissionsException;
232 * Retrieve the subfolders of the specified folder that are shared to others.
234 * @param userId the ID of the current user
235 * @param folderId the ID of the folder to retrieve
236 * @return the list of subfolders found
237 * @throws ObjectNotFoundException if the folder or user was not found
239 public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
242 * Retrieve the subfolders of the specified folder that are shared to others.
244 * @param userId the ID of the current user
245 * @param callingUserId the id of the user requesting this operation
246 * @param folderId the ID of the folder to retrieve
247 * @return the list of subfolders found
248 * @throws ObjectNotFoundException if the folder or user was not found
250 public List<FolderDTO> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException;
252 * Modifies the specified folder if the specified user has the appropriate
255 * @param userId the ID of the current user
256 * @param folderId the ID of the folder to retrieve
260 * @return the updated folder
261 * @throws InsufficientPermissionsException if the user does not have the
262 * appropriate privileges
263 * @throws ObjectNotFoundException if the user or folder was not found, with
264 * the exception message mentioning the precise problem
265 * @throws DuplicateNameException if the specified name already exists in
266 * the parent folder, as either a folder or file
268 public FolderDTO updateFolder(Long userId, Long folderId, String folderName,
270 Set<PermissionDTO> permissions)
271 throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
274 * Adds a user to the specified group
276 * @param userId the ID of the current user
277 * @param groupId the id of the new group
278 * @param userToAddId the id of the user to add
279 * @throws DuplicateNameException if the user already exists in group
280 * @throws ObjectNotFoundException if the user or group was not found, with
281 * the exception message mentioning the precise problem
282 * @throws InsufficientPermissionsException
284 public void addUserToGroup(Long userId, Long groupId, Long userToAddId)
285 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
288 * Creates a new group with the specified owner and name.
290 * @param userId the ID of the current user
291 * @param name the name of the new group
292 * @throws DuplicateNameException if the new group name already exists
293 * @throws ObjectNotFoundException if the user or group was not found, with
294 * the exception message mentioning the precise problem
296 public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
299 * Deletes the specified group in the specified user's namespace.
301 * @param userId the ID of the current user
302 * @param groupId the ID of the group to delete
303 * @throws ObjectNotFoundException if the user or group was not found, with
304 * the exception message mentioning the precise problem
305 * @throws InsufficientPermissionsException
307 public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
310 * Creates a new file with the specified owner, parent folder and name. The
311 * new file has the same permissions as its parent folder. The file contents
312 * are read from the input stream to a new File object.
314 * @param userId the ID of the current user
315 * @param folderId the ID of the parent folder
316 * @param name the name of the new file
317 * @param mimeType the MIME type of the file
318 * @param stream the input stream with the file contents
319 * @return The FileHeaderDTO created
320 * @throws DuplicateNameException if the specified name already exists in
321 * the parent folder, as either a folder or file
322 * @throws ObjectNotFoundException if the user or parent folder was not
323 * found, with the exception message mentioning the precise
325 * @throws GSSIOException if there was an error while storing the file contents
326 * @throws InsufficientPermissionsException
327 * @throws QuotaExceededException
329 public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType,
330 InputStream stream) throws DuplicateNameException, ObjectNotFoundException,
331 GSSIOException, InsufficientPermissionsException, QuotaExceededException;
334 * Deletes the specified file, provided the specified user has
335 * the necessary permissions.
337 * @param userId the ID of the current user
338 * @param fileId the ID of the file to delete
339 * @throws ObjectNotFoundException if the user or file was not found, with
340 * the exception message mentioning the precise problem
341 * @throws InsufficientPermissionsException if the user does not have the
342 * appropriate privileges
344 public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
347 * Deletes the specified file in the specified user's namespace.
349 * @param userId the ID of the current user
350 * @param fileIds the IDs of the files to delete
351 * @throws ObjectNotFoundException if the user or file was not found, with
352 * the exception message mentioning the precise problem
353 * @throws InsufficientPermissionsException if the user does not have the
354 * appropriate privileges
356 public void deleteFiles(Long userId, List<Long> fileIds)
357 throws ObjectNotFoundException, InsufficientPermissionsException;
360 * Creates a new tag for the specified user and file.
362 * @param userId the creator of the tag
363 * @param fileHeaderId the file that is tagged
365 * @throws ObjectNotFoundException if the user or the file was not found
367 public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
370 * Returns all tags defined by the specified user
373 * @return Set<String>
374 * @throws ObjectNotFoundException if the user was null
376 public Set<String> getUserTags(final Long userId) throws ObjectNotFoundException;
379 * Updates the attributes of the specified file.
384 * @param tagSet a String that contains tags separated by comma
385 * @param modificationDate the modification date
386 * @param versioned the new value of the versioned flag
389 * @throws DuplicateNameException
390 * @throws ObjectNotFoundException
391 * @throws InsufficientPermissionsException
393 public void updateFile(Long userId, Long fileId, String name, String tagSet,
394 Date modificationDate, Boolean versioned, Boolean readForAll,
395 Set<PermissionDTO> permissions)
396 throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
399 * Retrieve the contents of the current body for the file
400 * with the specified FileHeader ID. The file contents
401 * are provided as an InputStream from which the caller can
402 * retrieve the raw bytes.
404 * @param userId the ID of the current user
405 * @param fileId the ID of the file to retrieve
406 * @return an InputStream from the current file body contents
407 * @throws ObjectNotFoundException if the file or the user was not found
408 * @throws InsufficientPermissionsException if the user does not have the
409 * appropriate privileges
411 public InputStream getFileContents(Long userId, Long fileId)
412 throws ObjectNotFoundException, InsufficientPermissionsException;
415 * Retrieve the contents of the body identified by bodyId for the file
416 * with the specified FileHeader ID. The file contents
417 * are provided as an InputStream from which the caller can
418 * retrieve the raw bytes.
420 * @param userId the ID of the current user
421 * @param fileId the ID of the file to retrieve
422 * @param bodyId the body ID
423 * @return an InputStream from the current file body contents
424 * @throws ObjectNotFoundException if the file or the user was not found
425 * @throws InsufficientPermissionsException if the user does not have the
426 * appropriate privileges
428 public InputStream getFileContents(Long userId, Long fileId, Long bodyId)
429 throws ObjectNotFoundException, InsufficientPermissionsException;
432 * Retrieve the file with the specified ID.
434 * @param userId the ID of the current user
435 * @param fileId the ID of the file to retrieve
436 * @return the file found
437 * @throws ObjectNotFoundException if the file or the user was not found, with
438 * the exception message mentioning the precise problem
439 * @throws InsufficientPermissionsException
441 public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException,
442 InsufficientPermissionsException;
445 * Retrieve the filebody with the specified ID.
447 * @param userId the ID of the current user
448 * @param fileId the ID of the file to retrieve
449 * @param bodyId the ID of the body
450 * @return the file found
451 * @throws ObjectNotFoundException if the file or the user was not found, with
452 * the exception message mentioning the precise problem
453 * @throws InsufficientPermissionsException
455 public FileBodyDTO getFileBody(Long userId, Long fileId, Long bodyId)
456 throws ObjectNotFoundException, InsufficientPermissionsException;
459 * Get the resource (file or folder) at the specified path in
460 * the specified user's namespace. The returned object will be of type
461 * FileHeaderDTO or FolderDTO.<p><strong>Note:</strong> this method does not
462 * receive the current user as a parameter, therefore it is unable to perform
463 * the necessary permission checks and should <strong>NOT</strong> be directly
464 * exposed to remote clients. It is the caller's responsibility to verify that
465 * the calling user has the required privileges for performing any subsequent
466 * action on the resource through one of the other ExternalAPI methods.
468 * @param ownerId the ID of the user owning the namespace
469 * @param path the absolute path in the user's namespace
470 * @param ignoreDeleted if true, resources that have been moved to the trash
472 * @throws ObjectNotFoundException if the user or resource was not found, with
473 * the exception message mentioning the precise problem
474 * @return the resource found
476 public Object getResourceAtPath(Long ownerId, String path, boolean ignoreDeleted)
477 throws ObjectNotFoundException;
480 * Copy the provided file to the specified destination.
482 * @param userId the ID of the current user
483 * @param fileId the IF of the provided file
484 * @param dest the path of the new resource
485 * @throws ObjectNotFoundException if the user, file or destination was not
486 * found, with the exception message mentioning the precise problem
487 * @throws DuplicateNameException if the specified name already exists in
488 * the destination folder, as either a folder or file
489 * @throws GSSIOException if there was an error while accessing the file contents
490 * @throws InsufficientPermissionsException
491 * @throws QuotaExceededException
493 public void copyFile(Long userId, Long fileId, String dest) throws ObjectNotFoundException,
494 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
497 * Copy the provided file to the specified destination.
499 * @param userId the ID of the current user
500 * @param ownerId the ID of the owner of the destination namespace
501 * @param fileId the IF of the provided file
502 * @param dest the path of the new resource
503 * @throws ObjectNotFoundException if the user, file or destination was not
504 * found, with the exception message mentioning the precise problem
505 * @throws DuplicateNameException if the specified name already exists in
506 * the destination folder, as either a folder or file
507 * @throws GSSIOException if there was an error while accessing the file contents
508 * @throws InsufficientPermissionsException
509 * @throws QuotaExceededException
511 public void copyFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException,
512 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
515 * Copy the provided file to the specified destination.
517 * @param userId the ID of the current user
518 * @param fileIds the IDs of the provided files
519 * @param destId the ID of the destination folder
520 * @throws ObjectNotFoundException if the user, file or destination was not
521 * found, with the exception message mentioning the precise problem
522 * @throws GSSIOException if there was an error while accessing the file contents
523 * @throws DuplicateNameException if the specified name already exists in
524 * the destination folder, as either a folder or file
525 * @throws InsufficientPermissionsException
526 * @throws QuotaExceededException
528 public void copyFiles(Long userId, List<Long> fileIds, Long destId)
529 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
530 InsufficientPermissionsException, QuotaExceededException;
533 * Copy the provided file to the specified destination.
535 * @param userId the ID of the current user
536 * @param fileId the IF of the provided file
537 * @param destId the ID of the destination folder
538 * @param destName the name of the new file
539 * @throws ObjectNotFoundException if the user, file or destination was not
540 * found, with the exception message mentioning the precise problem
541 * @throws GSSIOException if there was an error while accessing the file contents
542 * @throws DuplicateNameException if the specified name already exists in
543 * the destination folder, as either a folder or file
544 * @throws InsufficientPermissionsException
545 * @throws QuotaExceededException
547 public void copyFile(Long userId, Long fileId, Long destId, String destName)
548 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
549 InsufficientPermissionsException, QuotaExceededException;
552 * Copy the provided folder to the specified destination.
554 * @param userId the ID of the current user
555 * @param folderId the IF of the provided folder
556 * @param dest the path of the new folder
557 * @throws ObjectNotFoundException if the user, folder or destination was not
558 * found, with the exception message mentioning the precise problem
559 * @throws DuplicateNameException if the specified name already exists in
560 * the destination folder, as either a folder or file
561 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
562 * appropriate privileges
564 public void copyFolder(Long userId, Long folderId, String dest) throws ObjectNotFoundException,
565 DuplicateNameException, InsufficientPermissionsException;
568 * Copy the provided folder to the specified destination.
570 * @param userId the ID of the current user
571 * @param folderId the IF of the provided folder
572 * @param destId the ID of the destination folder
573 * @param destName the name of the new folder
574 * @throws ObjectNotFoundException if the user, folder or destination was not
575 * found, with the exception message mentioning the precise problem
576 * @throws DuplicateNameException if the specified name already exists in
577 * the destination folder, as either a folder or file
578 * @throws InsufficientPermissionsException InsufficientPermissionsException
579 * if the user does not have the appropriate privileges
581 public void copyFolder(Long userId, Long folderId, Long destId, String destName)
582 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
585 * Copy the provided folder and all its subfolders and files to the specified destination.
587 * @param userId the ID of the current user
588 * @param ownerId the ID of the owner of the destination namespace
589 * @param folderId the IF of the provided folder
590 * @param dest the path of the new folder
591 * @throws ObjectNotFoundException if the user, folder or destination was not
592 * found, with the exception message mentioning the precise problem
593 * @throws DuplicateNameException if the specified name already exists in
594 * the destination folder, as either a folder or file
595 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
596 * appropriate privileges
597 * @throws QuotaExceededException if the user quota limit would be exceeded
598 * @throws GSSIOException if there was an error while accessing the file contents
600 public void copyFolderStructureToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
601 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
604 * Copy the provided folder and all its subfolders and files to the specified destination.
606 * @param userId the ID of the current user
607 * @param folderId the IF of the provided folder
608 * @param destId the ID of the destination folder
609 * @param destName the name of the new folder
610 * @throws ObjectNotFoundException if the user, folder or destination was not
611 * found, with the exception message mentioning the precise problem
612 * @throws DuplicateNameException if the specified name already exists in
613 * the destination folder, as either a folder or file
614 * @throws InsufficientPermissionsException InsufficientPermissionsException
615 * if the user does not have the appropriate privileges
616 * @throws GSSIOException if there was an error while accessing the file contents
617 * @throws QuotaExceededException if the user quota limit would be exceeded
619 public void copyFolderStructure(Long userId, Long folderId, Long destId, String destName)
620 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
621 GSSIOException, QuotaExceededException;
624 * Marks the specified file as deleted in the specified user's namespace.
626 * @param userId the ID of the current user
627 * @param fileId the ID of the file to delete
628 * @throws ObjectNotFoundException if the user or file was not found, with
629 * the exception message mentioning the precise problem
630 * @throws InsufficientPermissionsException if the user does not have the
631 * appropriate privileges
633 public void moveFileToTrash(Long userId, Long fileId) throws ObjectNotFoundException,
634 InsufficientPermissionsException;
637 * Marks the specified deleted file as undeleted in the specified user's namespace.
639 * @param userId the ID of the current user
640 * @param fileId the ID of the file to undelete
641 * @throws ObjectNotFoundException if the user or file was not found, with
642 * the exception message mentioning the precise problem
643 * @throws InsufficientPermissionsException if the user does not have the
644 * appropriate privileges
647 public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
650 * Marks the specified files as deleted in the specified user's namespace.
652 * @param userId the ID of the current user
653 * @param fileIds the IDs of the file to delete
654 * @throws ObjectNotFoundException if the user or file was not found, with
655 * the exception message mentioning the precise problem
656 * @throws InsufficientPermissionsException if the user does not have the
657 * appropriate privileges
659 public void moveFilesToTrash(Long userId, List<Long> fileIds)
660 throws ObjectNotFoundException, InsufficientPermissionsException;
663 * Marks the specified deleted files as undeleted in the specified user's namespace.
665 * @param userId the ID of the current user
666 * @param fileIds the IDs of the file to undelete
667 * @throws ObjectNotFoundException if the user or file was not found, with
668 * the exception message mentioning the precise problem
669 * @throws InsufficientPermissionsException if the user does not have the
670 * appropriate privileges
672 public void removeFilesFromTrash(Long userId, List<Long> fileIds) throws ObjectNotFoundException, InsufficientPermissionsException;
675 * Marks the specified folder as deleted in the specified user's namespace.
677 * @param userId the ID of the current user
678 * @param folderId the ID of the folder to delete
679 * @throws ObjectNotFoundException if the user or file was not found, with
680 * the exception message mentioning the precise problem
681 * @throws InsufficientPermissionsException if the user does not have the
682 * appropriate privileges
684 public void moveFolderToTrash(Long userId, Long folderId)
685 throws ObjectNotFoundException, InsufficientPermissionsException;
688 * Marks the specified deleted folder as undeleted in the specified user's namespace.
690 * @param userId the ID of the current user
691 * @param folderId the ID of the folder to undelete
692 * @throws ObjectNotFoundException if the user or file was not found, with
693 * the exception message mentioning the precise problem
694 * @throws InsufficientPermissionsException if the user does not have the
695 * appropriate privileges
698 public void removeFolderFromTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
701 * Move the provided folder and all its subfolders and files to the specified destination.
703 * @param userId the ID of the current user
704 * @param folderId the IF of the provided folder
705 * @param destId the ID of the destination folder
706 * @param destName the name of the new folder
707 * @throws ObjectNotFoundException if the user, folder or destination was not
708 * found, with the exception message mentioning the precise problem
709 * @throws DuplicateNameException if the specified name already exists in
710 * the destination folder, as either a folder or file
711 * @throws InsufficientPermissionsException if the user does not have the
712 * appropriate privileges
713 * @throws GSSIOException
714 * @throws QuotaExceededException
716 public void moveFolder(Long userId, Long folderId, Long destId, String destName)
717 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
718 GSSIOException, QuotaExceededException;
721 * Move the provided folder and all its subfolders and files to the specified destination.
723 * @param userId the ID of the current user
724 * @param ownerId the owner of the destination namespace
725 * @param folderId the IF of the provided folder
726 * @param dest the path of the new folder
727 * @throws ObjectNotFoundException if the user, folder or destination was not
728 * found, with the exception message mentioning the precise problem
729 * @throws DuplicateNameException if the specified name already exists in
730 * the destination folder, as either a folder or file
731 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
732 * appropriate privileges
733 * @throws GSSIOException
734 * @throws QuotaExceededException
736 public void moveFolderToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
737 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
740 * Move the provided file to the specified destination.
742 * @param userId the ID of the current user
743 * @param fileId the IF of the provided file
744 * @param destId the ID of the destination folder
745 * @param destName the name of the new file
746 * @throws InsufficientPermissionsException
747 * @throws ObjectNotFoundException if the user, file or destination was not
748 * found, with the exception message mentioning the precise problem
749 * @throws GSSIOException if there was an error while accessing the file contents
750 * @throws DuplicateNameException if the specified name already exists in
751 * the destination folder, as either a folder or file
752 * @throws QuotaExceededException
754 public void moveFile(Long userId, Long fileId, Long destId, String destName)
755 throws InsufficientPermissionsException, ObjectNotFoundException,
756 DuplicateNameException, GSSIOException, QuotaExceededException;
759 * Move the provided file to the specified destination.
761 * @param userId the ID of the current user
762 * @param ownerId the owner of the destination namespace
763 * @param fileId the IF of the provided file
764 * @param dest the path of the new file
765 * @throws InsufficientPermissionsException
766 * @throws ObjectNotFoundException if the user, file or destination was not
767 * found, with the exception message mentioning the precise problem
768 * @throws GSSIOException if there was an error while accessing the file contents
769 * @throws DuplicateNameException if the specified name already exists in
770 * the destination folder, as either a folder or file
771 * @throws QuotaExceededException
773 public void moveFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException, InsufficientPermissionsException, DuplicateNameException, GSSIOException, QuotaExceededException;
776 * move the provided file to the specified destination.
778 * @param userId the ID of the current user
779 * @param fileIds the IDs of the provided files
780 * @param destId the ID of the destination folder
781 * @throws InsufficientPermissionsException
782 * @throws ObjectNotFoundException if the user, file or destination was not
783 * found, with the exception message mentioning the precise problem
784 * @throws GSSIOException if there was an error while accessing the file contents
785 * @throws DuplicateNameException if the specified name already exists in
786 * the destination folder, as either a folder or file
787 * @throws QuotaExceededException
789 public void moveFiles(Long userId, List<Long> fileIds, Long destId)
790 throws InsufficientPermissionsException, ObjectNotFoundException,
791 DuplicateNameException, GSSIOException, QuotaExceededException;
794 * Returns a list of All deleted files of a user.
796 * @param userId the ID of the User
797 * * @return the list of deleted file header objects
798 * @throws ObjectNotFoundException if the user cannot be found
800 public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException;
803 * Returns a list of All deleted root folders of a user.
805 * @param userId the ID of the User
806 * * @return the list of deleted file header objects
807 * @throws ObjectNotFoundException if the user cannot be found
809 public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
812 * Empty Trash by deleting all marked as deleted files and folders
814 * @throws ObjectNotFoundException if something goes wrong in the delete process
815 * @throws InsufficientPermissionsException if something goes wrong in the delete process
817 public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
820 * Restores All Trashed Items by undeleting all marked as deleted files and folders
822 * @throws ObjectNotFoundException if something goes wrong in the delete process
823 * @throws InsufficientPermissionsException
825 public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
828 * Search the system for a user with the specified username.
829 * If no such user is found, the method returns null.
831 * @param username the username to search for
832 * @return the User object with the specified username
834 public User findUser(String username);
837 * Create a new user with the specified name, username and e-mail address.
839 * @param username the username of the new user
840 * @param name the name of the new user
841 * @param mail the e-mail of the new user
842 * @param idp the IdP of the new user
843 * @param idpid the IdP identifier of the new user
844 * @return the newly-created User object
845 * @throws DuplicateNameException if a user with the same username already exists
846 * @throws ObjectNotFoundException if no username was provided
848 public User createUser(String username, String name, String mail, String idp, String idpid)
849 throws DuplicateNameException, ObjectNotFoundException;
852 * Updates the authentication token for the specified user.
854 * @param userId the ID of the user whose token should be updated
855 * @return the updated user
856 * @throws ObjectNotFoundException if the user could not be found
858 public User updateUserToken(Long userId) throws ObjectNotFoundException;
861 * Updates the policy acceptance flag for the specified user.
863 * @param userId the ID of the user whose flag should be updated
864 * @param isAccepted the new value of the flag
865 * @return the updated user
866 * @throws ObjectNotFoundException if the user could not be found
868 public User updateUserPolicyAcceptance(Long userId, boolean isAccepted) throws ObjectNotFoundException;
871 * Invalidates the authentication token for the specified user.
873 * @param userId the ID of the user whose token should be updated
874 * @throws ObjectNotFoundException if the user could not be found
876 public void invalidateUserToken(Long userId) throws ObjectNotFoundException;
879 * Retrieve folder user and group permissions
881 * @param userId the ID of the user whose token should be updated
882 * @param folderId the ID of the folder
883 * @return the Set of permissions from requested folder
884 * @throws ObjectNotFoundException if the user or folder could not be found
885 * @throws InsufficientPermissionsException
887 public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId)
888 throws ObjectNotFoundException, InsufficientPermissionsException;
891 * Retrieve file user and group permissions
893 * @param userId the ID of the user whose token should be updated
894 * @param fileId the ID of the folder
895 * @return the Set of permissions from requested folder
896 * @throws ObjectNotFoundException if the user or folder could not be found
897 * @throws InsufficientPermissionsException
899 public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId)
900 throws ObjectNotFoundException, InsufficientPermissionsException;
903 * Returns a list of all shared root folders of a user.
905 * @param userId the ID of the User
906 * @return the list of shared root folders
907 * @throws ObjectNotFoundException if the user cannot be found
909 public List<FolderDTO> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
912 * Returns a list of all shared files of a user that are not
913 * inside other shared folders.
915 * @param userId the ID of the User
916 * @return the list of shared files
917 * @throws ObjectNotFoundException if the user cannot be found
919 public List<FileHeaderDTO> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
922 * Returns a list of all shared files of a user.
924 * @param userId the ID of the User
925 * @return the list of shared files
926 * @throws ObjectNotFoundException if the user cannot be found
928 public List<FileHeaderDTO> getSharedFiles(Long userId) throws ObjectNotFoundException;
931 * Returns a list of all shared folders of a user.
933 * @param userId the ID of the User
934 * @return the list of shared folders
935 * @throws ObjectNotFoundException if the user cannot be found
937 public List<FolderDTO> getSharedFolders(Long userId) throws ObjectNotFoundException;
940 * Returns a list of all shared root folders of a user that calling
941 * user has at least read permissions.
943 * @param ownerId the ID of the User
944 * @return the list of shared root folders
945 * @param callingUserId
947 * @throws ObjectNotFoundException if the user cannot be found
949 public List<FolderDTO> getSharedRootFolders(Long ownerId, Long callingUserId)
950 throws ObjectNotFoundException;
953 * Returns a list of all shared files of a user that calling user has
954 * at least read permissions..
956 * @param ownerId the ID of the User
957 * @return the list of shared files
958 * @param callingUserId
959 * @throws ObjectNotFoundException if the user cannot be found
961 public List<FileHeaderDTO> getSharedFiles(Long ownerId, Long callingUserId)
962 throws ObjectNotFoundException;
965 * Remove a user member from a group
967 * @param userId the ID of the User owning the group
968 * @param groupId the ID of the requested group
969 * @param memberId the ID of the member to be removed
971 * @throws ObjectNotFoundException if the user or group was not found, with
972 * the exception message mentioning the precise problem
973 * @throws InsufficientPermissionsException
975 public void removeMemberFromGroup(Long userId, Long groupId, Long memberId)
976 throws ObjectNotFoundException, InsufficientPermissionsException;
979 * Retrieves the list of users sharing files to user identified by user id
981 * @return the List of users sharing files to user
982 * @throws ObjectNotFoundException
984 public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
991 * @return list of files that match query
992 * @throws ObjectNotFoundException if no user or query was specified
994 public List<FileHeader> searchFiles(Long userId, String query) throws ObjectNotFoundException;
997 * Creates a nonce for the specified user.
999 * @param userId the ID of the user
1000 * @return the new nonce
1001 * @throws ObjectNotFoundException if the user could not be found
1003 public Nonce createNonce(Long userId) throws ObjectNotFoundException;
1006 * Find the nonce object for the specified encoded nonce, that should be
1007 * associated with the specified user.
1009 * @param nonce the issued nonce in Base64 encoding
1010 * @param userId the ID of the user for whom this nonce should have been issued
1011 * @return the retrieved nonce object
1012 * @throws ObjectNotFoundException if the nonce or user were not found
1014 public Nonce getNonce(String nonce, Long userId) throws ObjectNotFoundException;
1017 * Remove the specified nonce from the persistent store.
1019 * @param id the ID of the nonce
1020 * @throws ObjectNotFoundException if the specified nonce could not be found
1022 public void removeNonce(Long id) throws ObjectNotFoundException;
1025 * Activate the supplied nonce for the specified user.
1027 * @param userId the ID of the user
1028 * @param nonce the nonce to activate
1029 * @param nonceExpiryDate the expiry date of the nonce
1030 * @throws ObjectNotFoundException
1032 public void activateUserNonce(Long userId, String nonce, Date nonceExpiryDate) throws ObjectNotFoundException;
1035 * Retrieves user statistics.
1037 * @param userId the ID of the user
1038 * @return the statistics
1039 * @throws ObjectNotFoundException
1042 public StatsDTO getUserStatistics(Long userId) throws ObjectNotFoundException;
1045 * Retrieves file versions
1047 * @param userId the ID of the user
1048 * @param fileId the ID of the file
1049 * @return the list of filebodies
1050 * @throws ObjectNotFoundException
1051 * @throws InsufficientPermissionsException
1054 public List<FileBodyDTO> getVersions(Long userId, Long fileId)
1055 throws ObjectNotFoundException, InsufficientPermissionsException;
1058 * Restore the file contents to the specified version.
1060 * @param userId the ID of the user
1061 * @param fileId the ID of the file
1062 * @param version the version number of the desired file contents
1063 * @throws ObjectNotFoundException if the user or file was not
1064 * found, with the exception message mentioning the precise problem
1065 * @throws InsufficientPermissionsException if the user does not have the
1066 * appropriate privileges
1067 * @throws QuotaExceededException if the user quota limit would be exceeded
1068 * @throws GSSIOException if there was an error while accessing the file contents
1070 public void restoreVersion(Long userId, Long fileId, int version)
1071 throws ObjectNotFoundException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
1074 * Remove file version identified by bodyId
1076 * @param userId the ID of the user
1077 * @param fileId the ID of the file
1078 * @param bodyId the ID of the body
1080 * @throws ObjectNotFoundException
1081 * @throws InsufficientPermissionsException
1084 public void removeVersion(Long userId, Long fileId, Long bodyId)
1085 throws ObjectNotFoundException, InsufficientPermissionsException;
1088 * Removes all old file versions for specified file keeping only the current revision
1090 * @param userId the ID of the user
1091 * @param fileId the ID of the file
1093 * @throws ObjectNotFoundException
1094 * @throws InsufficientPermissionsException
1097 public void removeOldVersions(Long userId, Long fileId)
1098 throws ObjectNotFoundException, InsufficientPermissionsException;
1101 * It is used by the Solr mbean to rebuild the index.
1103 public String rebuildSolrIndex();
1106 * It is used by the Solr mbean to refresh the index. It does not delete anything just re-add everything in the index
1108 public String refreshSolrIndex();
1111 * Creates a new file with the specified owner, parent folder and name. The
1112 * new file has the same permissions as its parent folder. The file contents
1113 * are already uploaded outside of externalAPI and the uploaded file is used as a parameter.
1115 * @param userId the ID of the current user
1116 * @param folderId the ID of the parent folder
1117 * @param name the name of the new file
1118 * @param mimeType the MIME type of the file
1119 * @param fileSize the uploaded file size
1120 * @param filePath the uploaded file full path
1121 * @return The FileHeaderDTO created
1122 * @throws DuplicateNameException if the specified name already exists in
1123 * the parent folder, as either a folder or file
1124 * @throws ObjectNotFoundException if the user or parent folder was not
1125 * found, with the exception message mentioning the precise
1127 * @throws GSSIOException if there was an error while storing the file contents
1128 * @throws InsufficientPermissionsException
1129 * @throws QuotaExceededException
1131 public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
1132 throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
1133 InsufficientPermissionsException, QuotaExceededException;
1136 * Create a new FileBody with the supplied uploaded file as contents and make it the current body
1139 * @param userId the ID of the current user
1140 * @param fileId the ID of the file header object
1141 * @param mimeType the content type of the file
1142 * @param fileSize the uploaded file size
1143 * @param filePath the uploaded file full path
1144 * @return The FileHeaderDTO updated
1145 * @throws ObjectNotFoundException if the user or file was not found, with
1146 * the exception message mentioning the precise problem
1147 * @throws GSSIOException when an IO exception occurs
1148 * @throws InsufficientPermissionsException
1149 * @throws QuotaExceededException
1151 public FileHeaderDTO updateFileContents(Long userId, Long fileId, String mimeType,
1152 long fileSize, String filePath) throws ObjectNotFoundException, GSSIOException,
1153 InsufficientPermissionsException, QuotaExceededException;
1156 * Create a file based on inputstream without using transaction.
1161 * @throws IOException
1162 * @throws ObjectNotFoundException
1164 @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
1165 public File uploadFile(InputStream stream, Long userId)
1166 throws IOException, ObjectNotFoundException;
1168 public void createFileUploadProgress(Long userId, String filename,
1169 Long bytesTransfered, Long fileSize) throws ObjectNotFoundException;
1171 public FileUploadStatus getFileUploadStatus(Long userId, String fileName);
1173 public void removeFileUploadProgress(Long userId, String filename)
1174 throws ObjectNotFoundException;
1177 * Fetch the file body with the specified version number.
1179 * @param userId the ID of the current user
1180 * @param fileId the ID of the file header
1181 * @param version the version number
1182 * @return the file body
1183 * @throws ObjectNotFoundException if the user file or version
1185 * @throws InsufficientPermissionsException if the user does not
1186 * have enough privileges for reading this file
1188 public FileBodyDTO getFileVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException;
1191 * Search the system for a user with the specified email address.
1192 * If no such user is found, the method returns null.
1194 public User findUserByEmail(String email);
1197 * Update the user with the values from the supplied object.
1199 public void updateUser(User user);
1202 * Update accounting information for given user.
1204 * @param user The user to update
1205 * @param date Date of transaction
1206 * @param bandwidthDiff Bandwidth used; positive for addition,
1207 * negative for subtraction (e.g. to rollback)
1209 public void updateAccounting(User user, Date date, long bandwidthDiff);
1212 * Check if the user with the specified ID has permission to read the
1213 * folder with the supplied ID.
1215 public boolean canReadFolder(Long userId, Long folderId) throws ObjectNotFoundException;
1218 * Reset WebDAV password for given user.
1221 * @return the new password
1222 * @throws ObjectNotFoundException
1224 public String resetWebDAVPassword(Long userId) throws ObjectNotFoundException;
1227 * Find the invite for the specified invitation code.
1229 * @param code the invitation code
1230 * @return the Invitation or null if not found
1232 public Invitation findInvite(String code);
1235 * Create a new user in the connected IdP.
1237 * @param username the username of the new user
1238 * @param firstname the first name of the new user
1239 * @param lastname the last name of the new user
1240 * @param email the e-mail of the new user
1241 * @param password the password of the new user
1243 public void createLdapUser(String username, String firstname, String lastname, String email, String password);
1246 * Retrieves the available user classes.
1248 public List<UserClass> getUserClasses();
1251 * Upgrades the user class to the default "coupon bearer" class and marks
1252 * the provided coupon as used.
1254 * @param username the username of the user
1255 * @param code the coupon code
1256 * @return the new user class
1257 * @throws InvitationUsedException when trying to reuse an already used invitation
1258 * @throws ObjectNotFoundException if the user was not found
1260 public UserClass upgradeUserClass(String username, String code)
1261 throws ObjectNotFoundException, InvitationUsedException;
1264 * Retrieve the user class for coupon-bearing users.
1266 public UserClass getCouponUserClass();
1269 * Delete the actual file in the specified file system path.
1271 public void deleteActualFile(String path);
1274 * Posts the file specified by id to solr indexing server
1279 public void postFileToSolr(CommonsHttpSolrServer solr, Long id);