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.UserLogin;
34 import gr.ebs.gss.server.domain.dto.FileBodyDTO;
35 import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
36 import gr.ebs.gss.server.domain.dto.FolderDTO;
37 import gr.ebs.gss.server.domain.dto.GroupDTO;
38 import gr.ebs.gss.server.domain.dto.PermissionDTO;
39 import gr.ebs.gss.server.domain.dto.StatsDTO;
40 import gr.ebs.gss.server.domain.dto.UserDTO;
43 import java.io.IOException;
44 import java.io.InputStream;
45 import java.util.Date;
46 import java.util.List;
49 import javax.ejb.Local;
50 import javax.ejb.TransactionAttribute;
51 import javax.ejb.TransactionAttributeType;
53 import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
56 * The External API for GSS clients.
61 public interface ExternalAPI {
64 * Retrieves the root folder for the specified user. The caller must ensure
65 * that the userId exists.
69 * @throws ObjectNotFoundException if no Folder or user was found
71 public FolderDTO getRootFolder(Long userId) throws ObjectNotFoundException;
74 * Retrieve the folder with the specified ID.
76 * @param userId the ID of the current user
77 * @param folderId the ID of the folder to retrieve
78 * @return the folder found
79 * @throws ObjectNotFoundException if the folder or the user was not found
80 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
82 public FolderDTO getFolder(Long userId, Long folderId) throws ObjectNotFoundException,
83 InsufficientPermissionsException;
86 * Returns the user with the specified ID.
88 * @param userId The ID of the User to be found
89 * @return The User object
90 * @throws ObjectNotFoundException if the user cannot be found
92 public User getUser(Long userId) throws ObjectNotFoundException;
95 * Returns the user with the specified ID.
97 * @param userId The ID of the User to be found
98 * @return The User object
99 * @throws ObjectNotFoundException if the user cannot be found
101 public UserDTO getUserDTO(Long userId) throws ObjectNotFoundException;
104 * Returns the group with the specified ID.
106 * @param groupId The ID of the Group to be found
107 * @return The Group object
108 * @throws ObjectNotFoundException if the group cannot be found
110 public GroupDTO getGroup(Long groupId) throws ObjectNotFoundException;
113 * Returns the group with the specified name that belongs to the
116 * @param userId the ID of the user
117 * @param name the name of the group
118 * @return The Group object
119 * @throws ObjectNotFoundException if the group cannot be found
121 public GroupDTO getGroup(Long userId, String name) throws ObjectNotFoundException;
124 * Retrieve the list of groups for a particular user.
126 * @param userId the ID of the User
127 * @return a List of Groups that belong to the specified User
128 * @throws ObjectNotFoundException if the user was not found
130 public List<GroupDTO> getGroups(Long userId) throws ObjectNotFoundException;
133 * Returns a list of files contained in the folder specified by its id.
135 * @param userId the ID of the User
136 * @param folderId the ID of the folder containing the files
137 * @param ignoreDeleted
138 * @return the list of file header objects
139 * @throws ObjectNotFoundException if the user or the folder cannot be found
140 * @throws InsufficientPermissionsException
142 public List<FileHeaderDTO> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException,
143 InsufficientPermissionsException;
146 * Returns a list of users for the specified group
148 * @param userId the ID of the User
149 * @param groupId the ID of the requested group
150 * @return List<UserDTO>
151 * @throws ObjectNotFoundException if the user or group was not found, with
152 * the exception message mentioning the precise problem
154 public List<UserDTO> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
157 * Returns a list of users matching the specified username
159 * @param username the username of the User
160 * @return List<UserDTO>
162 public List<UserDTO> getUsersByUserNameLike(String username);
165 * Creates a new folder with the specified owner, parent folder and name.
166 * New folder has the same permissions as its parent
171 * @return the new folder
172 * @throws DuplicateNameException if the specified name already exists in
173 * the parent folder, as either a folder or file
174 * @throws ObjectNotFoundException if the user or parent folder was not
175 * found, with the exception message mentioning the precise
177 * @throws InsufficientPermissionsException
179 public FolderDTO createFolder(Long userId, Long parentId, String name) throws DuplicateNameException,
180 ObjectNotFoundException, InsufficientPermissionsException;
183 * Deletes the specified folder, if the specified user has the appropriate
186 * @param userId the ID of the current user
187 * @param folderId the ID of the folder to delete
188 * @throws InsufficientPermissionsException if the user does not have the
189 * appropriate privileges
190 * @throws ObjectNotFoundException if the user or folder was not found, with
191 * the exception message mentioning the precise problem
193 public void deleteFolder(Long userId, Long folderId)
194 throws InsufficientPermissionsException, ObjectNotFoundException;
197 * Retrieve the subfolders of the specified folder.
199 * @param userId the ID of the current user
200 * @param folderId the ID of the folder to retrieve
201 * @return the list of subfolders found
202 * @throws ObjectNotFoundException if the folder or user was not found
203 * @throws InsufficientPermissionsException
205 public List<FolderDTO> getSubfolders(Long userId, Long folderId)
206 throws ObjectNotFoundException, InsufficientPermissionsException;
209 * Retrieve the folder with the specified ID with subfolders.
211 * @param userId the ID of the current user
212 * @param folderId the ID of the folder to retrieve
213 * @return the folder found
214 * @throws ObjectNotFoundException if the folder or the user was not found
215 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
217 public FolderDTO getFolderWithSubfolders(Long userId, Long folderId)
218 throws ObjectNotFoundException, InsufficientPermissionsException;
221 * Retrieve the folder with the specified ID with subfolders.
223 * @param userId the ID of the current user
224 * @param callingUserId the ID of the user requesting this operation
225 * @param folderId the ID of the folder to retrieve
226 * @return the folder found
227 * @throws ObjectNotFoundException if the folder or the user was not found
228 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
230 public FolderDTO getFolderWithSubfolders(Long userId, Long callingUserId, Long folderId)
231 throws ObjectNotFoundException, InsufficientPermissionsException;
233 * Retrieve the subfolders of the specified folder that are shared to others.
235 * @param userId the ID of the current user
236 * @param folderId the ID of the folder to retrieve
237 * @return the list of subfolders found
238 * @throws ObjectNotFoundException if the folder or user was not found
240 public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
243 * Retrieve the subfolders of the specified folder that are shared to others.
245 * @param userId the ID of the current user
246 * @param callingUserId the id of the user requesting this operation
247 * @param folderId the ID of the folder to retrieve
248 * @return the list of subfolders found
249 * @throws ObjectNotFoundException if the folder or user was not found
251 public List<FolderDTO> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException;
253 * Modifies the specified folder if the specified user has the appropriate
256 * @param userId the ID of the current user
257 * @param folderId the ID of the folder to retrieve
261 * @return the updated folder
262 * @throws InsufficientPermissionsException if the user does not have the
263 * appropriate privileges
264 * @throws ObjectNotFoundException if the user or folder was not found, with
265 * the exception message mentioning the precise problem
266 * @throws DuplicateNameException if the specified name already exists in
267 * the parent folder, as either a folder or file
269 public FolderDTO updateFolder(Long userId, Long folderId, String folderName,
271 Set<PermissionDTO> permissions)
272 throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
275 * Adds a user to the specified group
277 * @param userId the ID of the current user
278 * @param groupId the id of the new group
279 * @param userToAddId the id of the user to add
280 * @throws DuplicateNameException if the user already exists in group
281 * @throws ObjectNotFoundException if the user or group was not found, with
282 * the exception message mentioning the precise problem
283 * @throws InsufficientPermissionsException
285 public void addUserToGroup(Long userId, Long groupId, Long userToAddId)
286 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
289 * Creates a new group with the specified owner and name.
291 * @param userId the ID of the current user
292 * @param name the name of the new group
293 * @throws DuplicateNameException if the new group name already exists
294 * @throws ObjectNotFoundException if the user or group was not found, with
295 * the exception message mentioning the precise problem
297 public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
300 * Deletes the specified group in the specified user's namespace.
302 * @param userId the ID of the current user
303 * @param groupId the ID of the group to delete
304 * @throws ObjectNotFoundException if the user or group was not found, with
305 * the exception message mentioning the precise problem
306 * @throws InsufficientPermissionsException
308 public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
311 * Creates a new file with the specified owner, parent folder and name. The
312 * new file has the same permissions as its parent folder. The file contents
313 * are read from the input stream to a new File object.
315 * @param userId the ID of the current user
316 * @param folderId the ID of the parent folder
317 * @param name the name of the new file
318 * @param mimeType the MIME type of the file
319 * @param stream the input stream with the file contents
320 * @return The FileHeaderDTO created
321 * @throws DuplicateNameException if the specified name already exists in
322 * the parent folder, as either a folder or file
323 * @throws ObjectNotFoundException if the user or parent folder was not
324 * found, with the exception message mentioning the precise
326 * @throws GSSIOException if there was an error while storing the file contents
327 * @throws InsufficientPermissionsException
328 * @throws QuotaExceededException
330 public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType,
331 InputStream stream) throws DuplicateNameException, ObjectNotFoundException,
332 GSSIOException, InsufficientPermissionsException, QuotaExceededException;
335 * Deletes the specified file, provided the specified user has
336 * the necessary permissions.
338 * @param userId the ID of the current user
339 * @param fileId the ID of the file to delete
340 * @throws ObjectNotFoundException if the user or file was not found, with
341 * the exception message mentioning the precise problem
342 * @throws InsufficientPermissionsException if the user does not have the
343 * appropriate privileges
345 public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
348 * Deletes the specified file in the specified user's namespace.
350 * @param userId the ID of the current user
351 * @param fileIds the IDs of the files to delete
352 * @throws ObjectNotFoundException if the user or file was not found, with
353 * the exception message mentioning the precise problem
354 * @throws InsufficientPermissionsException if the user does not have the
355 * appropriate privileges
357 public void deleteFiles(Long userId, List<Long> fileIds)
358 throws ObjectNotFoundException, InsufficientPermissionsException;
361 * Creates a new tag for the specified user and file.
363 * @param userId the creator of the tag
364 * @param fileHeaderId the file that is tagged
366 * @throws ObjectNotFoundException if the user or the file was not found
368 public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
371 * Returns all tags defined by the specified user
374 * @return Set<String>
375 * @throws ObjectNotFoundException if the user was null
377 public Set<String> getUserTags(final Long userId) throws ObjectNotFoundException;
380 * Updates the attributes of the specified file.
385 * @param tagSet a String that contains tags separated by comma
386 * @param modificationDate the modification date
387 * @param versioned the new value of the versioned flag
390 * @throws DuplicateNameException
391 * @throws ObjectNotFoundException
392 * @throws InsufficientPermissionsException
394 public void updateFile(Long userId, Long fileId, String name, String tagSet,
395 Date modificationDate, Boolean versioned, Boolean readForAll,
396 Set<PermissionDTO> permissions)
397 throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
400 * Retrieve the contents of the current body for the file
401 * with the specified FileHeader ID. The file contents
402 * are provided as an InputStream from which the caller can
403 * retrieve the raw bytes.
405 * @param userId the ID of the current user
406 * @param fileId the ID of the file to retrieve
407 * @return an InputStream from the current file body contents
408 * @throws ObjectNotFoundException if the file or the user was not found
409 * @throws InsufficientPermissionsException if the user does not have the
410 * appropriate privileges
412 public InputStream getFileContents(Long userId, Long fileId)
413 throws ObjectNotFoundException, InsufficientPermissionsException;
416 * Retrieve the contents of the body identified by bodyId for the file
417 * with the specified FileHeader ID. The file contents
418 * are provided as an InputStream from which the caller can
419 * retrieve the raw bytes.
421 * @param userId the ID of the current user
422 * @param fileId the ID of the file to retrieve
423 * @param bodyId the body ID
424 * @return an InputStream from the current file body contents
425 * @throws ObjectNotFoundException if the file or the user was not found
426 * @throws InsufficientPermissionsException if the user does not have the
427 * appropriate privileges
429 public InputStream getFileContents(Long userId, Long fileId, Long bodyId)
430 throws ObjectNotFoundException, InsufficientPermissionsException;
433 * Retrieve the file with the specified ID.
435 * @param userId the ID of the current user
436 * @param fileId the ID of the file to retrieve
437 * @return the file found
438 * @throws ObjectNotFoundException if the file or the user was not found, with
439 * the exception message mentioning the precise problem
440 * @throws InsufficientPermissionsException
442 public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException,
443 InsufficientPermissionsException;
446 * Retrieve the filebody with the specified ID.
448 * @param userId the ID of the current user
449 * @param fileId the ID of the file to retrieve
450 * @param bodyId the ID of the body
451 * @return the file found
452 * @throws ObjectNotFoundException if the file or the user was not found, with
453 * the exception message mentioning the precise problem
454 * @throws InsufficientPermissionsException
456 public FileBodyDTO getFileBody(Long userId, Long fileId, Long bodyId)
457 throws ObjectNotFoundException, InsufficientPermissionsException;
460 * Get the resource (file or folder) at the specified path in
461 * the specified user's namespace. The returned object will be of type
462 * FileHeaderDTO or FolderDTO.<p><strong>Note:</strong> this method does not
463 * receive the current user as a parameter, therefore it is unable to perform
464 * the necessary permission checks and should <strong>NOT</strong> be directly
465 * exposed to remote clients. It is the caller's responsibility to verify that
466 * the calling user has the required privileges for performing any subsequent
467 * action on the resource through one of the other ExternalAPI methods.
469 * @param ownerId the ID of the user owning the namespace
470 * @param path the absolute path in the user's namespace
471 * @param ignoreDeleted if true, resources that have been moved to the trash
473 * @throws ObjectNotFoundException if the user or resource was not found, with
474 * the exception message mentioning the precise problem
475 * @return the resource found
477 public Object getResourceAtPath(Long ownerId, String path, boolean ignoreDeleted)
478 throws ObjectNotFoundException;
481 * Copy the provided file to the specified destination.
483 * @param userId the ID of the current user
484 * @param fileId the IF of the provided file
485 * @param dest the path of the new resource
486 * @throws ObjectNotFoundException if the user, file or destination was not
487 * found, with the exception message mentioning the precise problem
488 * @throws DuplicateNameException if the specified name already exists in
489 * the destination folder, as either a folder or file
490 * @throws GSSIOException if there was an error while accessing the file contents
491 * @throws InsufficientPermissionsException
492 * @throws QuotaExceededException
494 public void copyFile(Long userId, Long fileId, String dest) throws ObjectNotFoundException,
495 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
498 * Copy the provided file to the specified destination.
500 * @param userId the ID of the current user
501 * @param ownerId the ID of the owner of the destination namespace
502 * @param fileId the IF of the provided file
503 * @param dest the path of the new resource
504 * @throws ObjectNotFoundException if the user, file or destination was not
505 * found, with the exception message mentioning the precise problem
506 * @throws DuplicateNameException if the specified name already exists in
507 * the destination folder, as either a folder or file
508 * @throws GSSIOException if there was an error while accessing the file contents
509 * @throws InsufficientPermissionsException
510 * @throws QuotaExceededException
512 public void copyFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException,
513 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
516 * Copy the provided file to the specified destination.
518 * @param userId the ID of the current user
519 * @param fileIds the IDs of the provided files
520 * @param destId the ID of the destination folder
521 * @throws ObjectNotFoundException if the user, file or destination was not
522 * found, with the exception message mentioning the precise problem
523 * @throws GSSIOException if there was an error while accessing the file contents
524 * @throws DuplicateNameException if the specified name already exists in
525 * the destination folder, as either a folder or file
526 * @throws InsufficientPermissionsException
527 * @throws QuotaExceededException
529 public void copyFiles(Long userId, List<Long> fileIds, Long destId)
530 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
531 InsufficientPermissionsException, QuotaExceededException;
534 * Copy the provided file to the specified destination.
536 * @param userId the ID of the current user
537 * @param fileId the IF of the provided file
538 * @param destId the ID of the destination folder
539 * @param destName the name of the new file
540 * @throws ObjectNotFoundException if the user, file or destination was not
541 * found, with the exception message mentioning the precise problem
542 * @throws GSSIOException if there was an error while accessing the file contents
543 * @throws DuplicateNameException if the specified name already exists in
544 * the destination folder, as either a folder or file
545 * @throws InsufficientPermissionsException
546 * @throws QuotaExceededException
548 public void copyFile(Long userId, Long fileId, Long destId, String destName)
549 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
550 InsufficientPermissionsException, QuotaExceededException;
553 * Copy the provided folder to the specified destination.
555 * @param userId the ID of the current user
556 * @param folderId the IF of the provided folder
557 * @param dest the path of the new folder
558 * @throws ObjectNotFoundException if the user, folder or destination was not
559 * found, with the exception message mentioning the precise problem
560 * @throws DuplicateNameException if the specified name already exists in
561 * the destination folder, as either a folder or file
562 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
563 * appropriate privileges
565 public void copyFolder(Long userId, Long folderId, String dest) throws ObjectNotFoundException,
566 DuplicateNameException, InsufficientPermissionsException;
569 * Copy the provided folder to the specified destination.
571 * @param userId the ID of the current user
572 * @param folderId the IF of the provided folder
573 * @param destId the ID of the destination folder
574 * @param destName the name of the new folder
575 * @throws ObjectNotFoundException if the user, folder or destination was not
576 * found, with the exception message mentioning the precise problem
577 * @throws DuplicateNameException if the specified name already exists in
578 * the destination folder, as either a folder or file
579 * @throws InsufficientPermissionsException InsufficientPermissionsException
580 * if the user does not have the appropriate privileges
582 public void copyFolder(Long userId, Long folderId, Long destId, String destName)
583 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
586 * Copy the provided folder and all its subfolders and files to the specified destination.
588 * @param userId the ID of the current user
589 * @param ownerId the ID of the owner of the destination namespace
590 * @param folderId the IF of the provided folder
591 * @param dest the path of the new folder
592 * @throws ObjectNotFoundException if the user, folder or destination was not
593 * found, with the exception message mentioning the precise problem
594 * @throws DuplicateNameException if the specified name already exists in
595 * the destination folder, as either a folder or file
596 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
597 * appropriate privileges
598 * @throws QuotaExceededException if the user quota limit would be exceeded
599 * @throws GSSIOException if there was an error while accessing the file contents
601 public void copyFolderStructureToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
602 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
605 * Copy the provided folder and all its subfolders and files to the specified destination.
607 * @param userId the ID of the current user
608 * @param folderId the IF of the provided folder
609 * @param destId the ID of the destination folder
610 * @param destName the name of the new folder
611 * @throws ObjectNotFoundException if the user, folder or destination was not
612 * found, with the exception message mentioning the precise problem
613 * @throws DuplicateNameException if the specified name already exists in
614 * the destination folder, as either a folder or file
615 * @throws InsufficientPermissionsException InsufficientPermissionsException
616 * if the user does not have the appropriate privileges
617 * @throws GSSIOException if there was an error while accessing the file contents
618 * @throws QuotaExceededException if the user quota limit would be exceeded
620 public void copyFolderStructure(Long userId, Long folderId, Long destId, String destName)
621 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
622 GSSIOException, QuotaExceededException;
625 * Marks the specified file as deleted in the specified user's namespace.
627 * @param userId the ID of the current user
628 * @param fileId the ID of the file to delete
629 * @throws ObjectNotFoundException if the user or file was not found, with
630 * the exception message mentioning the precise problem
631 * @throws InsufficientPermissionsException if the user does not have the
632 * appropriate privileges
634 public void moveFileToTrash(Long userId, Long fileId) throws ObjectNotFoundException,
635 InsufficientPermissionsException;
638 * Marks the specified deleted file as undeleted in the specified user's namespace.
640 * @param userId the ID of the current user
641 * @param fileId the ID of the file to undelete
642 * @throws ObjectNotFoundException if the user or file was not found, with
643 * the exception message mentioning the precise problem
644 * @throws InsufficientPermissionsException if the user does not have the
645 * appropriate privileges
648 public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
651 * Marks the specified files as deleted in the specified user's namespace.
653 * @param userId the ID of the current user
654 * @param fileIds the IDs of the file to delete
655 * @throws ObjectNotFoundException if the user or file was not found, with
656 * the exception message mentioning the precise problem
657 * @throws InsufficientPermissionsException if the user does not have the
658 * appropriate privileges
660 public void moveFilesToTrash(Long userId, List<Long> fileIds)
661 throws ObjectNotFoundException, InsufficientPermissionsException;
664 * Marks the specified deleted files as undeleted in the specified user's namespace.
666 * @param userId the ID of the current user
667 * @param fileIds the IDs of the file to undelete
668 * @throws ObjectNotFoundException if the user or file was not found, with
669 * the exception message mentioning the precise problem
670 * @throws InsufficientPermissionsException if the user does not have the
671 * appropriate privileges
673 public void removeFilesFromTrash(Long userId, List<Long> fileIds) throws ObjectNotFoundException, InsufficientPermissionsException;
676 * Marks the specified folder as deleted in the specified user's namespace.
678 * @param userId the ID of the current user
679 * @param folderId the ID of the folder to delete
680 * @throws ObjectNotFoundException if the user or file was not found, with
681 * the exception message mentioning the precise problem
682 * @throws InsufficientPermissionsException if the user does not have the
683 * appropriate privileges
685 public void moveFolderToTrash(Long userId, Long folderId)
686 throws ObjectNotFoundException, InsufficientPermissionsException;
689 * Marks the specified deleted folder as undeleted in the specified user's namespace.
691 * @param userId the ID of the current user
692 * @param folderId the ID of the folder to undelete
693 * @throws ObjectNotFoundException if the user or file was not found, with
694 * the exception message mentioning the precise problem
695 * @throws InsufficientPermissionsException if the user does not have the
696 * appropriate privileges
699 public void removeFolderFromTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
702 * Move the provided folder and all its subfolders and files to the specified destination.
704 * @param userId the ID of the current user
705 * @param folderId the IF of the provided folder
706 * @param destId the ID of the destination folder
707 * @param destName the name of the new folder
708 * @throws ObjectNotFoundException if the user, folder or destination was not
709 * found, with the exception message mentioning the precise problem
710 * @throws DuplicateNameException if the specified name already exists in
711 * the destination folder, as either a folder or file
712 * @throws InsufficientPermissionsException if the user does not have the
713 * appropriate privileges
714 * @throws GSSIOException
715 * @throws QuotaExceededException
717 public void moveFolder(Long userId, Long folderId, Long destId, String destName)
718 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
719 GSSIOException, QuotaExceededException;
722 * Move the provided folder and all its subfolders and files to the specified destination.
724 * @param userId the ID of the current user
725 * @param ownerId the owner of the destination namespace
726 * @param folderId the IF of the provided folder
727 * @param dest the path of the new folder
728 * @throws ObjectNotFoundException if the user, folder or destination was not
729 * found, with the exception message mentioning the precise problem
730 * @throws DuplicateNameException if the specified name already exists in
731 * the destination folder, as either a folder or file
732 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
733 * appropriate privileges
734 * @throws GSSIOException
735 * @throws QuotaExceededException
737 public void moveFolderToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
738 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
741 * Move the provided file to the specified destination.
743 * @param userId the ID of the current user
744 * @param fileId the IF of the provided file
745 * @param destId the ID of the destination folder
746 * @param destName the name of the new file
747 * @throws InsufficientPermissionsException
748 * @throws ObjectNotFoundException if the user, file or destination was not
749 * found, with the exception message mentioning the precise problem
750 * @throws GSSIOException if there was an error while accessing the file contents
751 * @throws DuplicateNameException if the specified name already exists in
752 * the destination folder, as either a folder or file
753 * @throws QuotaExceededException
755 public void moveFile(Long userId, Long fileId, Long destId, String destName)
756 throws InsufficientPermissionsException, ObjectNotFoundException,
757 DuplicateNameException, GSSIOException, QuotaExceededException;
760 * Move the provided file to the specified destination.
762 * @param userId the ID of the current user
763 * @param ownerId the owner of the destination namespace
764 * @param fileId the IF of the provided file
765 * @param dest the path of the new file
766 * @throws InsufficientPermissionsException
767 * @throws ObjectNotFoundException if the user, file or destination was not
768 * found, with the exception message mentioning the precise problem
769 * @throws GSSIOException if there was an error while accessing the file contents
770 * @throws DuplicateNameException if the specified name already exists in
771 * the destination folder, as either a folder or file
772 * @throws QuotaExceededException
774 public void moveFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException, InsufficientPermissionsException, DuplicateNameException, GSSIOException, QuotaExceededException;
777 * move the provided file to the specified destination.
779 * @param userId the ID of the current user
780 * @param fileIds the IDs of the provided files
781 * @param destId the ID of the destination folder
782 * @throws InsufficientPermissionsException
783 * @throws ObjectNotFoundException if the user, file or destination was not
784 * found, with the exception message mentioning the precise problem
785 * @throws GSSIOException if there was an error while accessing the file contents
786 * @throws DuplicateNameException if the specified name already exists in
787 * the destination folder, as either a folder or file
788 * @throws QuotaExceededException
790 public void moveFiles(Long userId, List<Long> fileIds, Long destId)
791 throws InsufficientPermissionsException, ObjectNotFoundException,
792 DuplicateNameException, GSSIOException, QuotaExceededException;
795 * Returns a list of All deleted files of a user.
797 * @param userId the ID of the User
798 * * @return the list of deleted file header objects
799 * @throws ObjectNotFoundException if the user cannot be found
801 public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException;
804 * Returns a list of All deleted root folders of a user.
806 * @param userId the ID of the User
807 * * @return the list of deleted file header objects
808 * @throws ObjectNotFoundException if the user cannot be found
810 public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
813 * Empty Trash by deleting all marked as deleted files and folders
815 * @throws ObjectNotFoundException if something goes wrong in the delete process
816 * @throws InsufficientPermissionsException if something goes wrong in the delete process
818 public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
821 * Restores All Trashed Items by undeleting all marked as deleted files and folders
823 * @throws ObjectNotFoundException if something goes wrong in the delete process
824 * @throws InsufficientPermissionsException
826 public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
829 * Search the system for a user with the specified username.
830 * If no such user is found, the method returns null.
832 * @param username the username to search for
833 * @return the User object with the specified username
835 public User findUser(String username);
838 * Create a new user with the specified name, username and e-mail address.
840 * @param username the username of the new user
841 * @param name the name of the new user
842 * @param mail the e-mail of the new user
843 * @param idp the IdP of the new user
844 * @param idpid the IdP identifier of the new user
845 * @return the newly-created User object
846 * @throws DuplicateNameException if a user with the same username already exists
847 * @throws ObjectNotFoundException if no username was provided
849 public User createUser(String username, String name, String mail, String idp, String idpid)
850 throws DuplicateNameException, ObjectNotFoundException;
853 * Updates the authentication token for the specified user.
855 * @param userId the ID of the user whose token should be updated
856 * @return the updated user
857 * @throws ObjectNotFoundException if the user could not be found
859 public User updateUserToken(Long userId) throws ObjectNotFoundException;
862 * Updates the policy acceptance flag for the specified user.
864 * @param userId the ID of the user whose flag should be updated
865 * @param isAccepted the new value of the flag
866 * @return the updated user
867 * @throws ObjectNotFoundException if the user could not be found
869 public User updateUserPolicyAcceptance(Long userId, boolean isAccepted) throws ObjectNotFoundException;
872 * Invalidates the authentication token for the specified user.
874 * @param userId the ID of the user whose token should be updated
875 * @throws ObjectNotFoundException if the user could not be found
877 public void invalidateUserToken(Long userId) throws ObjectNotFoundException;
880 * Retrieve folder user and group permissions
882 * @param userId the ID of the user whose token should be updated
883 * @param folderId the ID of the folder
884 * @return the Set of permissions from requested folder
885 * @throws ObjectNotFoundException if the user or folder could not be found
886 * @throws InsufficientPermissionsException
888 public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId)
889 throws ObjectNotFoundException, InsufficientPermissionsException;
892 * Retrieve file user and group permissions
894 * @param userId the ID of the user whose token should be updated
895 * @param fileId the ID of the folder
896 * @return the Set of permissions from requested folder
897 * @throws ObjectNotFoundException if the user or folder could not be found
898 * @throws InsufficientPermissionsException
900 public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId)
901 throws ObjectNotFoundException, InsufficientPermissionsException;
904 * Returns a list of all shared root folders of a user.
906 * @param userId the ID of the User
907 * @return the list of shared root folders
908 * @throws ObjectNotFoundException if the user cannot be found
910 public List<FolderDTO> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
913 * Returns a list of all shared files of a user that are not
914 * inside other shared folders.
916 * @param userId the ID of the User
917 * @return the list of shared files
918 * @throws ObjectNotFoundException if the user cannot be found
920 public List<FileHeaderDTO> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
923 * Returns a list of all shared files of a user.
925 * @param userId the ID of the User
926 * @return the list of shared files
927 * @throws ObjectNotFoundException if the user cannot be found
929 public List<FileHeaderDTO> getSharedFiles(Long userId) throws ObjectNotFoundException;
932 * Returns a list of all shared folders of a user.
934 * @param userId the ID of the User
935 * @return the list of shared folders
936 * @throws ObjectNotFoundException if the user cannot be found
938 public List<FolderDTO> getSharedFolders(Long userId) throws ObjectNotFoundException;
941 * Returns a list of all shared root folders of a user that calling
942 * user has at least read permissions.
944 * @param ownerId the ID of the User
945 * @return the list of shared root folders
946 * @param callingUserId
948 * @throws ObjectNotFoundException if the user cannot be found
950 public List<FolderDTO> getSharedRootFolders(Long ownerId, Long callingUserId)
951 throws ObjectNotFoundException;
954 * Returns a list of all shared files of a user that calling user has
955 * at least read permissions..
957 * @param ownerId the ID of the User
958 * @return the list of shared files
959 * @param callingUserId
960 * @throws ObjectNotFoundException if the user cannot be found
962 public List<FileHeaderDTO> getSharedFiles(Long ownerId, Long callingUserId)
963 throws ObjectNotFoundException;
966 * Remove a user member from a group
968 * @param userId the ID of the User owning the group
969 * @param groupId the ID of the requested group
970 * @param memberId the ID of the member to be removed
972 * @throws ObjectNotFoundException if the user or group was not found, with
973 * the exception message mentioning the precise problem
974 * @throws InsufficientPermissionsException
976 public void removeMemberFromGroup(Long userId, Long groupId, Long memberId)
977 throws ObjectNotFoundException, InsufficientPermissionsException;
980 * Retrieves the list of users sharing files to user identified by user id
982 * @return the List of users sharing files to user
983 * @throws ObjectNotFoundException
985 public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
992 * @return list of files that match query
993 * @throws ObjectNotFoundException if no user or query was specified
995 public List<FileHeader> searchFiles(Long userId, String query) throws ObjectNotFoundException;
998 * Creates a nonce for the specified user.
1000 * @param userId the ID of the user
1001 * @return the new nonce
1002 * @throws ObjectNotFoundException if the user could not be found
1004 public Nonce createNonce(Long userId) throws ObjectNotFoundException;
1007 * Find the nonce object for the specified encoded nonce, that should be
1008 * associated with the specified user.
1010 * @param nonce the issued nonce in Base64 encoding
1011 * @param userId the ID of the user for whom this nonce should have been issued
1012 * @return the retrieved nonce object
1013 * @throws ObjectNotFoundException if the nonce or user were not found
1015 public Nonce getNonce(String nonce, Long userId) throws ObjectNotFoundException;
1018 * Remove the specified nonce from the persistent store.
1020 * @param id the ID of the nonce
1021 * @throws ObjectNotFoundException if the specified nonce could not be found
1023 public void removeNonce(Long id) throws ObjectNotFoundException;
1026 * Activate the supplied nonce for the specified user.
1028 * @param userId the ID of the user
1029 * @param nonce the nonce to activate
1030 * @param nonceExpiryDate the expiry date of the nonce
1031 * @throws ObjectNotFoundException
1033 public void activateUserNonce(Long userId, String nonce, Date nonceExpiryDate) throws ObjectNotFoundException;
1036 * Retrieves user statistics.
1038 * @param userId the ID of the user
1039 * @return the statistics
1040 * @throws ObjectNotFoundException
1043 public StatsDTO getUserStatistics(Long userId) throws ObjectNotFoundException;
1046 * Retrieves file versions
1048 * @param userId the ID of the user
1049 * @param fileId the ID of the file
1050 * @return the list of filebodies
1051 * @throws ObjectNotFoundException
1052 * @throws InsufficientPermissionsException
1055 public List<FileBodyDTO> getVersions(Long userId, Long fileId)
1056 throws ObjectNotFoundException, InsufficientPermissionsException;
1059 * Restore the file contents to the specified version.
1061 * @param userId the ID of the user
1062 * @param fileId the ID of the file
1063 * @param version the version number of the desired file contents
1064 * @throws ObjectNotFoundException if the user or file was not
1065 * found, with the exception message mentioning the precise problem
1066 * @throws InsufficientPermissionsException if the user does not have the
1067 * appropriate privileges
1068 * @throws QuotaExceededException if the user quota limit would be exceeded
1069 * @throws GSSIOException if there was an error while accessing the file contents
1071 public void restoreVersion(Long userId, Long fileId, int version)
1072 throws ObjectNotFoundException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
1075 * Remove file version identified by bodyId
1077 * @param userId the ID of the user
1078 * @param fileId the ID of the file
1079 * @param bodyId the ID of the body
1081 * @throws ObjectNotFoundException
1082 * @throws InsufficientPermissionsException
1085 public void removeVersion(Long userId, Long fileId, Long bodyId)
1086 throws ObjectNotFoundException, InsufficientPermissionsException;
1089 * Removes all old file versions for specified file keeping only the current revision
1091 * @param userId the ID of the user
1092 * @param fileId the ID of the file
1094 * @throws ObjectNotFoundException
1095 * @throws InsufficientPermissionsException
1098 public void removeOldVersions(Long userId, Long fileId)
1099 throws ObjectNotFoundException, InsufficientPermissionsException;
1102 * It is used by the Solr mbean to rebuild the index.
1104 public String rebuildSolrIndex();
1107 * It is used by the Solr mbean to refresh the index. It does not delete anything just re-add everything in the index
1109 public String refreshSolrIndex();
1112 * Creates a new file with the specified owner, parent folder and name. The
1113 * new file has the same permissions as its parent folder. The file contents
1114 * are already uploaded outside of externalAPI and the uploaded file is used as a parameter.
1116 * @param userId the ID of the current user
1117 * @param folderId the ID of the parent folder
1118 * @param name the name of the new file
1119 * @param mimeType the MIME type of the file
1120 * @param fileSize the uploaded file size
1121 * @param filePath the uploaded file full path
1122 * @return The FileHeaderDTO created
1123 * @throws DuplicateNameException if the specified name already exists in
1124 * the parent folder, as either a folder or file
1125 * @throws ObjectNotFoundException if the user or parent folder was not
1126 * found, with the exception message mentioning the precise
1128 * @throws GSSIOException if there was an error while storing the file contents
1129 * @throws InsufficientPermissionsException
1130 * @throws QuotaExceededException
1132 public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
1133 throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
1134 InsufficientPermissionsException, QuotaExceededException;
1137 * Create a new FileBody with the supplied uploaded file as contents and make it the current body
1140 * @param userId the ID of the current user
1141 * @param fileId the ID of the file header object
1142 * @param mimeType the content type of the file
1143 * @param fileSize the uploaded file size
1144 * @param filePath the uploaded file full path
1145 * @return The FileHeaderDTO updated
1146 * @throws ObjectNotFoundException if the user or file was not found, with
1147 * the exception message mentioning the precise problem
1148 * @throws GSSIOException when an IO exception occurs
1149 * @throws InsufficientPermissionsException
1150 * @throws QuotaExceededException
1152 public FileHeaderDTO updateFileContents(Long userId, Long fileId, String mimeType,
1153 long fileSize, String filePath) throws ObjectNotFoundException, GSSIOException,
1154 InsufficientPermissionsException, QuotaExceededException;
1157 * Create a file based on inputstream without using transaction.
1162 * @throws IOException
1163 * @throws ObjectNotFoundException
1165 @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
1166 public File uploadFile(InputStream stream, Long userId)
1167 throws IOException, ObjectNotFoundException;
1169 public void createFileUploadProgress(Long userId, String filename,
1170 Long bytesTransfered, Long fileSize) throws ObjectNotFoundException;
1172 public FileUploadStatus getFileUploadStatus(Long userId, String fileName);
1174 public void removeFileUploadProgress(Long userId, String filename)
1175 throws ObjectNotFoundException;
1178 * Fetch the file body with the specified version number.
1180 * @param userId the ID of the current user
1181 * @param fileId the ID of the file header
1182 * @param version the version number
1183 * @return the file body
1184 * @throws ObjectNotFoundException if the user file or version
1186 * @throws InsufficientPermissionsException if the user does not
1187 * have enough privileges for reading this file
1189 public FileBodyDTO getFileVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException;
1192 * Search the system for a user with the specified email address.
1193 * If no such user is found, the method returns null.
1195 public User findUserByEmail(String email);
1198 * Update the user with the values from the supplied object.
1200 public void updateUser(User user);
1203 * Update accounting information for given user.
1205 * @param user The user to update
1206 * @param date Date of transaction
1207 * @param bandwidthDiff Bandwidth used; positive for addition,
1208 * negative for subtraction (e.g. to rollback)
1210 public void updateAccounting(User user, Date date, long bandwidthDiff);
1213 * Check if the user with the specified ID has permission to read the
1214 * folder with the supplied ID.
1216 public boolean canReadFolder(Long userId, Long folderId) throws ObjectNotFoundException;
1219 * Reset WebDAV password for given user.
1222 * @return the new password
1223 * @throws ObjectNotFoundException
1225 public String resetWebDAVPassword(Long userId) throws ObjectNotFoundException;
1228 * Find the invite for the specified invitation code.
1230 * @param code the invitation code
1231 * @return the Invitation or null if not found
1233 public Invitation findInvite(String code);
1236 * Create a new user in the connected IdP.
1238 * @param username the username of the new user
1239 * @param firstname the first name of the new user
1240 * @param lastname the last name of the new user
1241 * @param email the e-mail of the new user
1242 * @param password the password of the new user
1244 public void createLdapUser(String username, String firstname, String lastname, String email, String password);
1247 * Retrieves the available user classes.
1249 public List<UserClass> getUserClasses();
1252 * Upgrades the user class to the default "coupon bearer" class and marks
1253 * the provided coupon as used.
1255 * @param username the username of the user
1256 * @param code the coupon code
1257 * @return the new user class
1258 * @throws InvitationUsedException when trying to reuse an already used invitation
1259 * @throws ObjectNotFoundException if the user was not found
1261 public UserClass upgradeUserClass(String username, String code)
1262 throws ObjectNotFoundException, InvitationUsedException;
1265 * Retrieve the user class for coupon-bearing users.
1267 public UserClass getCouponUserClass();
1270 * Delete the actual file in the specified file system path.
1272 public void deleteActualFile(String path);
1275 * Update the userLogin with the values from the supplied object.
1277 public void addUserLogin(UserLogin userLogin);
1280 * Retrieves the user's current session login and the user's last login
1282 * @return a list of last two user logins
1283 * @throws ObjectNotFoundException
1285 public List<UserLogin> getLastUserLogins(Long userId) throws ObjectNotFoundException;
1288 * Posts the file specified by id to solr indexing server
1293 public void postFileToSolr(CommonsHttpSolrServer solr, Long id);