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.FileLock;
30 import gr.ebs.gss.server.domain.Invitation;
31 import gr.ebs.gss.server.domain.Nonce;
32 import gr.ebs.gss.server.domain.User;
33 import gr.ebs.gss.server.domain.UserClass;
34 import gr.ebs.gss.server.domain.UserLogin;
35 import gr.ebs.gss.server.domain.WebDavNonce;
36 import gr.ebs.gss.server.domain.dto.FileBodyDTO;
37 import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
38 import gr.ebs.gss.server.domain.dto.FolderDTO;
39 import gr.ebs.gss.server.domain.dto.GroupDTO;
40 import gr.ebs.gss.server.domain.dto.PermissionDTO;
41 import gr.ebs.gss.server.domain.dto.StatsDTO;
42 import gr.ebs.gss.server.domain.dto.UserDTO;
45 import java.io.IOException;
46 import java.io.InputStream;
47 import java.util.Date;
48 import java.util.List;
51 import javax.ejb.Local;
52 import javax.ejb.TransactionAttribute;
53 import javax.ejb.TransactionAttributeType;
55 import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
58 * The External API for GSS clients.
63 public interface ExternalAPI {
66 * Retrieves the root folder for the specified user. The caller must ensure
67 * that the userId exists.
71 * @throws ObjectNotFoundException if no Folder or user was found
73 public FolderDTO getRootFolder(Long userId) throws ObjectNotFoundException;
76 * Retrieve the folder with the specified ID.
78 * @param userId the ID of the current user
79 * @param folderId the ID of the folder to retrieve
80 * @return the folder found
81 * @throws ObjectNotFoundException if the folder or the user was not found
82 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
84 public FolderDTO getFolder(Long userId, Long folderId) throws ObjectNotFoundException,
85 InsufficientPermissionsException;
88 * Returns the user with the specified ID.
90 * @param userId The ID of the User to be found
91 * @return The User object
92 * @throws ObjectNotFoundException if the user cannot be found
94 public User getUser(Long userId) throws ObjectNotFoundException;
97 * Returns the user with the specified ID.
99 * @param userId The ID of the User to be found
100 * @return The User object
101 * @throws ObjectNotFoundException if the user cannot be found
103 public UserDTO getUserDTO(Long userId) throws ObjectNotFoundException;
106 * Returns the group with the specified ID.
108 * @param groupId The ID of the Group to be found
109 * @return The Group object
110 * @throws ObjectNotFoundException if the group cannot be found
112 public GroupDTO getGroup(Long groupId) throws ObjectNotFoundException;
115 * Returns the group with the specified name that belongs to the
118 * @param userId the ID of the user
119 * @param name the name of the group
120 * @return The Group object
121 * @throws ObjectNotFoundException if the group cannot be found
123 public GroupDTO getGroup(Long userId, String name) throws ObjectNotFoundException;
126 * Retrieve the list of groups for a particular user.
128 * @param userId the ID of the User
129 * @return a List of Groups that belong to the specified User
130 * @throws ObjectNotFoundException if the user was not found
132 public List<GroupDTO> getGroups(Long userId) throws ObjectNotFoundException;
135 * Returns a list of files contained in the folder specified by its id.
137 * @param userId the ID of the User
138 * @param folderId the ID of the folder containing the files
139 * @param ignoreDeleted
140 * @return the list of file header objects
141 * @throws ObjectNotFoundException if the user or the folder cannot be found
142 * @throws InsufficientPermissionsException
144 public List<FileHeaderDTO> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException,
145 InsufficientPermissionsException;
148 * Returns a list of users for the specified group
150 * @param userId the ID of the User
151 * @param groupId the ID of the requested group
152 * @return List<UserDTO>
153 * @throws ObjectNotFoundException if the user or group was not found, with
154 * the exception message mentioning the precise problem
156 public List<UserDTO> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
159 * Returns a list of users matching the specified username
161 * @param username the username of the User
162 * @return List<UserDTO>
164 public List<UserDTO> getUsersByUserNameLike(String username);
167 * Creates a new folder with the specified owner, parent folder and name.
168 * New folder has the same permissions as its parent
173 * @return the new folder
174 * @throws DuplicateNameException if the specified name already exists in
175 * the parent folder, as either a folder or file
176 * @throws ObjectNotFoundException if the user or parent folder was not
177 * found, with the exception message mentioning the precise
179 * @throws InsufficientPermissionsException
181 public FolderDTO createFolder(Long userId, Long parentId, String name) throws DuplicateNameException,
182 ObjectNotFoundException, InsufficientPermissionsException;
185 * Deletes the specified folder, if the specified user has the appropriate
188 * @param userId the ID of the current user
189 * @param folderId the ID of the folder to delete
190 * @throws InsufficientPermissionsException if the user does not have the
191 * appropriate privileges
192 * @throws ObjectNotFoundException if the user or folder was not found, with
193 * the exception message mentioning the precise problem
195 public void deleteFolder(Long userId, Long folderId)
196 throws InsufficientPermissionsException, ObjectNotFoundException;
199 * Retrieve the subfolders of the specified folder.
201 * @param userId the ID of the current user
202 * @param folderId the ID of the folder to retrieve
203 * @return the list of subfolders found
204 * @throws ObjectNotFoundException if the folder or user was not found
205 * @throws InsufficientPermissionsException
207 public List<FolderDTO> getSubfolders(Long userId, Long folderId)
208 throws ObjectNotFoundException, InsufficientPermissionsException;
211 * Retrieve the folder with the specified ID with subfolders.
213 * @param userId the ID of the current user
214 * @param folderId the ID of the folder to retrieve
215 * @return the folder found
216 * @throws ObjectNotFoundException if the folder or the user was not found
217 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
219 public FolderDTO getFolderWithSubfolders(Long userId, Long folderId)
220 throws ObjectNotFoundException, InsufficientPermissionsException;
223 * Retrieve the folder with the specified ID with subfolders.
225 * @param userId the ID of the current user
226 * @param callingUserId the ID of the user requesting this operation
227 * @param folderId the ID of the folder to retrieve
228 * @return the folder found
229 * @throws ObjectNotFoundException if the folder or the user was not found
230 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
232 public FolderDTO getFolderWithSubfolders(Long userId, Long callingUserId, Long folderId)
233 throws ObjectNotFoundException, InsufficientPermissionsException;
235 * Retrieve the subfolders of the specified folder that are shared to others.
237 * @param userId the ID of the current user
238 * @param folderId the ID of the folder to retrieve
239 * @return the list of subfolders found
240 * @throws ObjectNotFoundException if the folder or user was not found
242 public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
245 * Retrieve the subfolders of the specified folder that are shared to others.
247 * @param userId the ID of the current user
248 * @param callingUserId the id of the user requesting this operation
249 * @param folderId the ID of the folder to retrieve
250 * @return the list of subfolders found
251 * @throws ObjectNotFoundException if the folder or user was not found
253 public List<FolderDTO> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException;
255 * Modifies the specified folder if the specified user has the appropriate
258 * @param userId the ID of the current user
259 * @param folderId the ID of the folder to retrieve
263 * @return the updated folder
264 * @throws InsufficientPermissionsException if the user does not have the
265 * appropriate privileges
266 * @throws ObjectNotFoundException if the user or folder was not found, with
267 * the exception message mentioning the precise problem
268 * @throws DuplicateNameException if the specified name already exists in
269 * the parent folder, as either a folder or file
271 public FolderDTO updateFolder(Long userId, Long folderId, String folderName,
273 Set<PermissionDTO> permissions)
274 throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
277 * Adds a user to the specified group
279 * @param userId the ID of the current user
280 * @param groupId the id of the new group
281 * @param userToAddId the id of the user to add
282 * @throws DuplicateNameException if the user already exists in group
283 * @throws ObjectNotFoundException if the user or group was not found, with
284 * the exception message mentioning the precise problem
285 * @throws InsufficientPermissionsException
287 public void addUserToGroup(Long userId, Long groupId, Long userToAddId)
288 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
291 * Creates a new group with the specified owner and name.
293 * @param userId the ID of the current user
294 * @param name the name of the new group
295 * @throws DuplicateNameException if the new group name already exists
296 * @throws ObjectNotFoundException if the user or group was not found, with
297 * the exception message mentioning the precise problem
299 public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
302 * Deletes the specified group in the specified user's namespace.
304 * @param userId the ID of the current user
305 * @param groupId the ID of the group to delete
306 * @throws ObjectNotFoundException if the user or group was not found, with
307 * the exception message mentioning the precise problem
308 * @throws InsufficientPermissionsException
310 public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
313 * Creates a new file with the specified owner, parent folder and name. The
314 * new file has the same permissions as its parent folder. The file contents
315 * are read from the input stream to a new File object.
317 * @param userId the ID of the current user
318 * @param folderId the ID of the parent folder
319 * @param name the name of the new file
320 * @param mimeType the MIME type of the file
321 * @param stream the input stream with the file contents
322 * @return The FileHeaderDTO created
323 * @throws DuplicateNameException if the specified name already exists in
324 * the parent folder, as either a folder or file
325 * @throws ObjectNotFoundException if the user or parent folder was not
326 * found, with the exception message mentioning the precise
328 * @throws GSSIOException if there was an error while storing the file contents
329 * @throws InsufficientPermissionsException
330 * @throws QuotaExceededException
332 public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType,
333 InputStream stream) throws DuplicateNameException, ObjectNotFoundException,
334 GSSIOException, InsufficientPermissionsException, QuotaExceededException;
337 * Deletes the specified file, provided the specified user has
338 * the necessary permissions.
340 * @param userId the ID of the current user
341 * @param fileId the ID of the file to delete
342 * @throws ObjectNotFoundException if the user or file was not found, with
343 * the exception message mentioning the precise problem
344 * @throws InsufficientPermissionsException if the user does not have the
345 * appropriate privileges
347 public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
350 * Creates a new tag for the specified user and file.
352 * @param userId the creator of the tag
353 * @param fileHeaderId the file that is tagged
355 * @throws ObjectNotFoundException if the user or the file was not found
357 public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
360 * Returns all tags defined by the specified user
363 * @return Set<String>
364 * @throws ObjectNotFoundException if the user was null
366 public Set<String> getUserTags(final Long userId) throws ObjectNotFoundException;
369 * Updates the attributes of the specified file.
374 * @param tagSet a String that contains tags separated by comma
375 * @param modificationDate the modification date
376 * @param versioned the new value of the versioned flag
379 * @throws DuplicateNameException
380 * @throws ObjectNotFoundException
381 * @throws InsufficientPermissionsException
383 public void updateFile(Long userId, Long fileId, String name, String tagSet,
384 Date modificationDate, Boolean versioned, Boolean readForAll,
385 Set<PermissionDTO> permissions)
386 throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
389 * Retrieve the contents of the current body for the file
390 * with the specified FileHeader ID. The file contents
391 * are provided as an InputStream from which the caller can
392 * retrieve the raw bytes.
394 * @param userId the ID of the current user
395 * @param fileId the ID of the file to retrieve
396 * @return an InputStream from the current file body contents
397 * @throws ObjectNotFoundException if the file or the user was not found
398 * @throws InsufficientPermissionsException if the user does not have the
399 * appropriate privileges
401 public InputStream getFileContents(Long userId, Long fileId)
402 throws ObjectNotFoundException, InsufficientPermissionsException;
405 * Retrieve the contents of the body identified by bodyId for the file
406 * with the specified FileHeader ID. The file contents
407 * are provided as an InputStream from which the caller can
408 * retrieve the raw bytes.
410 * @param userId the ID of the current user
411 * @param fileId the ID of the file to retrieve
412 * @param bodyId the body ID
413 * @return an InputStream from the current file body contents
414 * @throws ObjectNotFoundException if the file or the user was not found
415 * @throws InsufficientPermissionsException if the user does not have the
416 * appropriate privileges
418 public InputStream getFileContents(Long userId, Long fileId, Long bodyId)
419 throws ObjectNotFoundException, InsufficientPermissionsException;
422 * Retrieve the file with the specified ID.
424 * @param userId the ID of the current user
425 * @param fileId the ID of the file to retrieve
426 * @return the file found
427 * @throws ObjectNotFoundException if the file or the user was not found, with
428 * the exception message mentioning the precise problem
429 * @throws InsufficientPermissionsException
431 public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException,
432 InsufficientPermissionsException;
435 * Retrieve the filebody with the specified ID.
437 * @param userId the ID of the current user
438 * @param fileId the ID of the file to retrieve
439 * @param bodyId the ID of the body
440 * @return the file found
441 * @throws ObjectNotFoundException if the file or the user was not found, with
442 * the exception message mentioning the precise problem
443 * @throws InsufficientPermissionsException
445 public FileBodyDTO getFileBody(Long userId, Long fileId, Long bodyId)
446 throws ObjectNotFoundException, InsufficientPermissionsException;
449 * Get the resource (file or folder) at the specified path in
450 * the specified user's namespace. The returned object will be of type
451 * FileHeaderDTO or FolderDTO.<p><strong>Note:</strong> this method does not
452 * receive the current user as a parameter, therefore it is unable to perform
453 * the necessary permission checks and should <strong>NOT</strong> be directly
454 * exposed to remote clients. It is the caller's responsibility to verify that
455 * the calling user has the required privileges for performing any subsequent
456 * action on the resource through one of the other ExternalAPI methods.
458 * @param ownerId the ID of the user owning the namespace
459 * @param path the absolute path in the user's namespace
460 * @param ignoreDeleted if true, resources that have been moved to the trash
462 * @throws ObjectNotFoundException if the user or resource was not found, with
463 * the exception message mentioning the precise problem
464 * @return the resource found
466 public Object getResourceAtPath(Long ownerId, String path, boolean ignoreDeleted)
467 throws ObjectNotFoundException;
470 * Copy the provided file to the specified destination.
472 * @param userId the ID of the current user
473 * @param fileId the IF of the provided file
474 * @param dest the path of the new resource
475 * @throws ObjectNotFoundException if the user, file or destination was not
476 * found, with the exception message mentioning the precise problem
477 * @throws DuplicateNameException if the specified name already exists in
478 * the destination folder, as either a folder or file
479 * @throws GSSIOException if there was an error while accessing the file contents
480 * @throws InsufficientPermissionsException
481 * @throws QuotaExceededException
483 public void copyFile(Long userId, Long fileId, String dest) throws ObjectNotFoundException,
484 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
487 * Copy the provided file to the specified destination.
489 * @param userId the ID of the current user
490 * @param ownerId the ID of the owner of the destination namespace
491 * @param fileId the IF of the provided file
492 * @param dest the path of the new resource
493 * @throws ObjectNotFoundException if the user, file or destination was not
494 * found, with the exception message mentioning the precise problem
495 * @throws DuplicateNameException if the specified name already exists in
496 * the destination folder, as either a folder or file
497 * @throws GSSIOException if there was an error while accessing the file contents
498 * @throws InsufficientPermissionsException
499 * @throws QuotaExceededException
501 public void copyFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException,
502 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
505 * Copy the provided file to the specified destination.
507 * @param userId the ID of the current user
508 * @param fileIds the IDs of the provided files
509 * @param destId the ID of the destination folder
510 * @throws ObjectNotFoundException if the user, file or destination was not
511 * found, with the exception message mentioning the precise problem
512 * @throws GSSIOException if there was an error while accessing the file contents
513 * @throws DuplicateNameException if the specified name already exists in
514 * the destination folder, as either a folder or file
515 * @throws InsufficientPermissionsException
516 * @throws QuotaExceededException
518 public void copyFiles(Long userId, List<Long> fileIds, Long destId)
519 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
520 InsufficientPermissionsException, QuotaExceededException;
523 * Copy the provided file to the specified destination.
525 * @param userId the ID of the current user
526 * @param fileId the IF of the provided file
527 * @param destId the ID of the destination folder
528 * @param destName the name of the new file
529 * @throws ObjectNotFoundException if the user, file or destination was not
530 * found, with the exception message mentioning the precise problem
531 * @throws GSSIOException if there was an error while accessing the file contents
532 * @throws DuplicateNameException if the specified name already exists in
533 * the destination folder, as either a folder or file
534 * @throws InsufficientPermissionsException
535 * @throws QuotaExceededException
537 public void copyFile(Long userId, Long fileId, Long destId, String destName)
538 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
539 InsufficientPermissionsException, QuotaExceededException;
542 * Copy the provided folder to the specified destination.
544 * @param userId the ID of the current user
545 * @param folderId the IF of the provided folder
546 * @param dest the path of the new folder
547 * @throws ObjectNotFoundException if the user, folder or destination was not
548 * found, with the exception message mentioning the precise problem
549 * @throws DuplicateNameException if the specified name already exists in
550 * the destination folder, as either a folder or file
551 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
552 * appropriate privileges
554 public void copyFolder(Long userId, Long folderId, String dest) throws ObjectNotFoundException,
555 DuplicateNameException, InsufficientPermissionsException;
558 * Copy the provided folder to the specified destination.
560 * @param userId the ID of the current user
561 * @param folderId the IF of the provided folder
562 * @param destId the ID of the destination folder
563 * @param destName the name of the new folder
564 * @throws ObjectNotFoundException if the user, folder or destination was not
565 * found, with the exception message mentioning the precise problem
566 * @throws DuplicateNameException if the specified name already exists in
567 * the destination folder, as either a folder or file
568 * @throws InsufficientPermissionsException InsufficientPermissionsException
569 * if the user does not have the appropriate privileges
571 public void copyFolder(Long userId, Long folderId, Long destId, String destName)
572 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
575 * Copy the provided folder and all its subfolders and files to the specified destination.
577 * @param userId the ID of the current user
578 * @param ownerId the ID of the owner of the destination namespace
579 * @param folderId the IF of the provided folder
580 * @param dest the path of the new folder
581 * @throws ObjectNotFoundException if the user, folder or destination was not
582 * found, with the exception message mentioning the precise problem
583 * @throws DuplicateNameException if the specified name already exists in
584 * the destination folder, as either a folder or file
585 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
586 * appropriate privileges
587 * @throws QuotaExceededException if the user quota limit would be exceeded
588 * @throws GSSIOException if there was an error while accessing the file contents
590 public void copyFolderStructureToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
591 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
594 * Copy the provided folder and all its subfolders and files to the specified destination.
596 * @param userId the ID of the current user
597 * @param folderId the IF of the provided folder
598 * @param destId the ID of the destination folder
599 * @param destName the name of the new folder
600 * @throws ObjectNotFoundException if the user, folder or destination was not
601 * found, with the exception message mentioning the precise problem
602 * @throws DuplicateNameException if the specified name already exists in
603 * the destination folder, as either a folder or file
604 * @throws InsufficientPermissionsException InsufficientPermissionsException
605 * if the user does not have the appropriate privileges
606 * @throws GSSIOException if there was an error while accessing the file contents
607 * @throws QuotaExceededException if the user quota limit would be exceeded
609 public void copyFolderStructure(Long userId, Long folderId, Long destId, String destName)
610 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
611 GSSIOException, QuotaExceededException;
614 * Marks the specified file as deleted in the specified user's namespace.
616 * @param userId the ID of the current user
617 * @param fileId the ID of the file to delete
618 * @throws ObjectNotFoundException if the user or file was not found, with
619 * the exception message mentioning the precise problem
620 * @throws InsufficientPermissionsException if the user does not have the
621 * appropriate privileges
623 public void moveFileToTrash(Long userId, Long fileId) throws ObjectNotFoundException,
624 InsufficientPermissionsException;
627 * Marks the specified deleted file as undeleted in the specified user's namespace.
629 * @param userId the ID of the current user
630 * @param fileId the ID of the file to undelete
631 * @throws ObjectNotFoundException if the user or file was not found, with
632 * the exception message mentioning the precise problem
633 * @throws InsufficientPermissionsException if the user does not have the
634 * appropriate privileges
637 public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
640 * Marks the specified folder as deleted in the specified user's namespace.
642 * @param userId the ID of the current user
643 * @param folderId the ID of the folder to delete
644 * @throws ObjectNotFoundException if the user or file was not found, with
645 * the exception message mentioning the precise problem
646 * @throws InsufficientPermissionsException if the user does not have the
647 * appropriate privileges
649 public void moveFolderToTrash(Long userId, Long folderId)
650 throws ObjectNotFoundException, InsufficientPermissionsException;
653 * Marks the specified deleted folder as undeleted in the specified user's namespace.
655 * @param userId the ID of the current user
656 * @param folderId the ID of the folder to undelete
657 * @throws ObjectNotFoundException if the user or file was not found, with
658 * the exception message mentioning the precise problem
659 * @throws InsufficientPermissionsException if the user does not have the
660 * appropriate privileges
663 public void removeFolderFromTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
666 * Move the provided folder and all its subfolders and files to the specified destination.
668 * @param userId the ID of the current user
669 * @param folderId the IF of the provided folder
670 * @param destId the ID of the destination folder
671 * @param destName the name of the new folder
672 * @throws ObjectNotFoundException if the user, folder or destination was not
673 * found, with the exception message mentioning the precise problem
674 * @throws DuplicateNameException if the specified name already exists in
675 * the destination folder, as either a folder or file
676 * @throws InsufficientPermissionsException if the user does not have the
677 * appropriate privileges
678 * @throws GSSIOException
679 * @throws QuotaExceededException
681 public void moveFolder(Long userId, Long folderId, Long destId, String destName)
682 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
683 GSSIOException, QuotaExceededException;
686 * Move the provided folder and all its subfolders and files to the specified destination.
688 * @param userId the ID of the current user
689 * @param ownerId the owner of the destination namespace
690 * @param folderId the IF of the provided folder
691 * @param dest the path of the new folder
692 * @throws ObjectNotFoundException if the user, folder or destination was not
693 * found, with the exception message mentioning the precise problem
694 * @throws DuplicateNameException if the specified name already exists in
695 * the destination folder, as either a folder or file
696 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
697 * appropriate privileges
698 * @throws GSSIOException
699 * @throws QuotaExceededException
701 public void moveFolderToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
702 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
705 * Move the provided file to the specified destination.
707 * @param userId the ID of the current user
708 * @param fileId the IF of the provided file
709 * @param destId the ID of the destination folder
710 * @param destName the name of the new file
711 * @throws InsufficientPermissionsException
712 * @throws ObjectNotFoundException if the user, file or destination was not
713 * found, with the exception message mentioning the precise problem
714 * @throws GSSIOException if there was an error while accessing the file contents
715 * @throws DuplicateNameException if the specified name already exists in
716 * the destination folder, as either a folder or file
717 * @throws QuotaExceededException
719 public void moveFile(Long userId, Long fileId, Long destId, String destName)
720 throws InsufficientPermissionsException, ObjectNotFoundException,
721 DuplicateNameException, GSSIOException, QuotaExceededException;
724 * Move the provided file to the specified destination.
726 * @param userId the ID of the current user
727 * @param ownerId the owner of the destination namespace
728 * @param fileId the IF of the provided file
729 * @param dest the path of the new file
730 * @throws InsufficientPermissionsException
731 * @throws ObjectNotFoundException if the user, file or destination was not
732 * found, with the exception message mentioning the precise problem
733 * @throws GSSIOException if there was an error while accessing the file contents
734 * @throws DuplicateNameException if the specified name already exists in
735 * the destination folder, as either a folder or file
736 * @throws QuotaExceededException
738 public void moveFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException, InsufficientPermissionsException, DuplicateNameException, GSSIOException, QuotaExceededException;
741 * move the provided file to the specified destination.
743 * @param userId the ID of the current user
744 * @param fileIds the IDs of the provided files
745 * @param destId the ID of the destination folder
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 moveFiles(Long userId, List<Long> fileIds, Long destId)
755 throws InsufficientPermissionsException, ObjectNotFoundException,
756 DuplicateNameException, GSSIOException, QuotaExceededException;
759 * Returns a list of All deleted files of a user.
761 * @param userId the ID of the User
762 * * @return the list of deleted file header objects
763 * @throws ObjectNotFoundException if the user cannot be found
765 public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException;
768 * Returns a list of All deleted root folders of a user.
770 * @param userId the ID of the User
771 * * @return the list of deleted file header objects
772 * @throws ObjectNotFoundException if the user cannot be found
774 public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
777 * Empty Trash by deleting all marked as deleted files and folders
779 * @throws ObjectNotFoundException if something goes wrong in the delete process
780 * @throws InsufficientPermissionsException if something goes wrong in the delete process
782 public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
785 * Restores All Trashed Items by undeleting all marked as deleted files and folders
787 * @throws ObjectNotFoundException if something goes wrong in the delete process
788 * @throws InsufficientPermissionsException
790 public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
793 * Search the system for a user with the specified username.
794 * If no such user is found, the method returns null.
796 * @param username the username to search for
797 * @return the User object with the specified username
799 public User findUser(String username);
802 * Create a new user with the specified name, username and e-mail address.
804 * @param username the username of the new user
805 * @param name the name of the new user
806 * @param mail the e-mail of the new user
807 * @param idp the IdP of the new user
808 * @param idpid the IdP identifier of the new user
809 * @return the newly-created User object
810 * @throws DuplicateNameException if a user with the same username already exists
811 * @throws ObjectNotFoundException if no username was provided
813 public User createUser(String username, String name, String mail, String idp, String idpid)
814 throws DuplicateNameException, ObjectNotFoundException;
817 * Updates the authentication token for the specified user.
819 * @param userId the ID of the user whose token should be updated
820 * @return the updated user
821 * @throws ObjectNotFoundException if the user could not be found
823 public User updateUserToken(Long userId) throws ObjectNotFoundException;
826 * Updates the policy acceptance flag for the specified user.
828 * @param userId the ID of the user whose flag should be updated
829 * @param isAccepted the new value of the flag
830 * @return the updated user
831 * @throws ObjectNotFoundException if the user could not be found
833 public User updateUserPolicyAcceptance(Long userId, boolean isAccepted) throws ObjectNotFoundException;
836 * Invalidates the authentication token for the specified user.
838 * @param userId the ID of the user whose token should be updated
839 * @throws ObjectNotFoundException if the user could not be found
841 public void invalidateUserToken(Long userId) throws ObjectNotFoundException;
844 * Retrieve folder user and group permissions
846 * @param userId the ID of the user whose token should be updated
847 * @param folderId the ID of the folder
848 * @return the Set of permissions from requested folder
849 * @throws ObjectNotFoundException if the user or folder could not be found
850 * @throws InsufficientPermissionsException
852 public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId)
853 throws ObjectNotFoundException, InsufficientPermissionsException;
856 * Retrieve file user and group permissions
858 * @param userId the ID of the user whose token should be updated
859 * @param fileId the ID of the folder
860 * @return the Set of permissions from requested folder
861 * @throws ObjectNotFoundException if the user or folder could not be found
862 * @throws InsufficientPermissionsException
864 public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId)
865 throws ObjectNotFoundException, InsufficientPermissionsException;
868 * Returns a list of all shared root folders of a user.
870 * @param userId the ID of the User
871 * @return the list of shared root folders
872 * @throws ObjectNotFoundException if the user cannot be found
874 public List<FolderDTO> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
877 * Returns a list of all shared files of a user that are not
878 * inside other shared folders.
880 * @param userId the ID of the User
881 * @return the list of shared files
882 * @throws ObjectNotFoundException if the user cannot be found
884 public List<FileHeaderDTO> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
887 * Returns a list of all shared files of a user.
889 * @param userId the ID of the User
890 * @return the list of shared files
891 * @throws ObjectNotFoundException if the user cannot be found
893 public List<FileHeaderDTO> getSharedFiles(Long userId) throws ObjectNotFoundException;
896 * Returns a list of all shared folders of a user.
898 * @param userId the ID of the User
899 * @return the list of shared folders
900 * @throws ObjectNotFoundException if the user cannot be found
902 public List<FolderDTO> getSharedFolders(Long userId) throws ObjectNotFoundException;
905 * Returns a list of all shared root folders of a user that calling
906 * user has at least read permissions.
908 * @param ownerId the ID of the User
909 * @return the list of shared root folders
910 * @param callingUserId
912 * @throws ObjectNotFoundException if the user cannot be found
914 public List<FolderDTO> getSharedRootFolders(Long ownerId, Long callingUserId)
915 throws ObjectNotFoundException;
918 * Returns a list of all shared files of a user that calling user has
919 * at least read permissions..
921 * @param ownerId the ID of the User
922 * @return the list of shared files
923 * @param callingUserId
924 * @throws ObjectNotFoundException if the user cannot be found
926 public List<FileHeaderDTO> getSharedFiles(Long ownerId, Long callingUserId)
927 throws ObjectNotFoundException;
930 * Remove a user member from a group
932 * @param userId the ID of the User owning the group
933 * @param groupId the ID of the requested group
934 * @param memberId the ID of the member to be removed
936 * @throws ObjectNotFoundException if the user or group was not found, with
937 * the exception message mentioning the precise problem
938 * @throws InsufficientPermissionsException
940 public void removeMemberFromGroup(Long userId, Long groupId, Long memberId)
941 throws ObjectNotFoundException, InsufficientPermissionsException;
944 * Retrieves the list of users sharing files to user identified by user id
946 * @return the List of users sharing files to user
947 * @throws ObjectNotFoundException
949 public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
956 * @return list of files that match query
957 * @throws ObjectNotFoundException if no user or query was specified
959 public List<FileHeader> searchFiles(Long userId, String query) throws ObjectNotFoundException;
962 * Creates a nonce for the specified user.
964 * @param userId the ID of the user
965 * @return the new nonce
966 * @throws ObjectNotFoundException if the user could not be found
968 public Nonce createNonce(Long userId) throws ObjectNotFoundException;
971 * Find the nonce object for the specified encoded nonce, that should be
972 * associated with the specified user.
974 * @param nonce the issued nonce in Base64 encoding
975 * @param userId the ID of the user for whom this nonce should have been issued
976 * @return the retrieved nonce object
977 * @throws ObjectNotFoundException if the nonce or user were not found
979 public Nonce getNonce(String nonce, Long userId) throws ObjectNotFoundException;
982 * Remove the specified nonce from the persistent store.
984 * @param id the ID of the nonce
985 * @throws ObjectNotFoundException if the specified nonce could not be found
987 public void removeNonce(Long id) throws ObjectNotFoundException;
990 * Activate the supplied nonce for the specified user.
992 * @param userId the ID of the user
993 * @param nonce the nonce to activate
994 * @param nonceExpiryDate the expiry date of the nonce
995 * @throws ObjectNotFoundException
997 public void activateUserNonce(Long userId, String nonce, Date nonceExpiryDate) throws ObjectNotFoundException;
1000 * Retrieves user statistics.
1002 * @param userId the ID of the user
1003 * @return the statistics
1004 * @throws ObjectNotFoundException
1007 public StatsDTO getUserStatistics(Long userId) throws ObjectNotFoundException;
1010 * Retrieves file versions
1012 * @param userId the ID of the user
1013 * @param fileId the ID of the file
1014 * @return the list of filebodies
1015 * @throws ObjectNotFoundException
1016 * @throws InsufficientPermissionsException
1019 public List<FileBodyDTO> getVersions(Long userId, Long fileId)
1020 throws ObjectNotFoundException, InsufficientPermissionsException;
1023 * Restore the file contents to the specified version.
1025 * @param userId the ID of the user
1026 * @param fileId the ID of the file
1027 * @param version the version number of the desired file contents
1028 * @throws ObjectNotFoundException if the user or file was not
1029 * found, with the exception message mentioning the precise problem
1030 * @throws InsufficientPermissionsException if the user does not have the
1031 * appropriate privileges
1032 * @throws QuotaExceededException if the user quota limit would be exceeded
1033 * @throws GSSIOException if there was an error while accessing the file contents
1035 public void restoreVersion(Long userId, Long fileId, int version)
1036 throws ObjectNotFoundException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
1039 * Removes all old file versions for specified file keeping only the current revision
1041 * @param userId the ID of the user
1042 * @param fileId the ID of the file
1044 * @throws ObjectNotFoundException
1045 * @throws InsufficientPermissionsException
1048 public void removeOldVersions(Long userId, Long fileId)
1049 throws ObjectNotFoundException, InsufficientPermissionsException;
1052 * It is used by the Solr mbean to rebuild the index.
1054 public String rebuildSolrIndex();
1057 * It is used by the Solr mbean to refresh the index. It does not delete anything just re-add everything in the index
1059 public String refreshSolrIndex();
1062 * Creates a new file with the specified owner, parent folder and name. The
1063 * new file has the same permissions as its parent folder. The file contents
1064 * are already uploaded outside of externalAPI and the uploaded file is used as a parameter.
1066 * @param userId the ID of the current user
1067 * @param folderId the ID of the parent folder
1068 * @param name the name of the new file
1069 * @param mimeType the MIME type of the file
1070 * @param fileSize the uploaded file size
1071 * @param filePath the uploaded file full path
1072 * @return The FileHeaderDTO created
1073 * @throws DuplicateNameException if the specified name already exists in
1074 * the parent folder, as either a folder or file
1075 * @throws ObjectNotFoundException if the user or parent folder was not
1076 * found, with the exception message mentioning the precise
1078 * @throws GSSIOException if there was an error while storing the file contents
1079 * @throws InsufficientPermissionsException
1080 * @throws QuotaExceededException
1082 public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
1083 throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
1084 InsufficientPermissionsException, QuotaExceededException;
1087 * Create a new FileBody with the supplied uploaded file as contents and make it the current body
1090 * @param userId the ID of the current user
1091 * @param fileId the ID of the file header object
1092 * @param mimeType the content type of the file
1093 * @param fileSize the uploaded file size
1094 * @param filePath the uploaded file full path
1095 * @return The FileHeaderDTO updated
1096 * @throws ObjectNotFoundException if the user or file was not found, with
1097 * the exception message mentioning the precise problem
1098 * @throws GSSIOException when an IO exception occurs
1099 * @throws InsufficientPermissionsException
1100 * @throws QuotaExceededException
1102 public FileHeaderDTO updateFileContents(Long userId, Long fileId, String mimeType,
1103 long fileSize, String filePath) throws ObjectNotFoundException, GSSIOException,
1104 InsufficientPermissionsException, QuotaExceededException;
1107 * Create a file based on inputstream without using transaction.
1112 * @throws IOException
1113 * @throws ObjectNotFoundException
1115 @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
1116 public File uploadFile(InputStream stream, Long userId)
1117 throws IOException, ObjectNotFoundException;
1119 public void createFileUploadProgress(Long userId, String filename,
1120 Long bytesTransfered, Long fileSize) throws ObjectNotFoundException;
1122 public FileUploadStatus getFileUploadStatus(Long userId, String fileName);
1124 public void removeFileUploadProgress(Long userId, String filename)
1125 throws ObjectNotFoundException;
1128 * Fetch the file body with the specified version number.
1130 * @param userId the ID of the current user
1131 * @param fileId the ID of the file header
1132 * @param version the version number
1133 * @return the file body
1134 * @throws ObjectNotFoundException if the user file or version
1136 * @throws InsufficientPermissionsException if the user does not
1137 * have enough privileges for reading this file
1139 public FileBodyDTO getFileVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException;
1142 * Search the system for a user with the specified email address.
1143 * If no such user is found, the method returns null.
1145 public User findUserByEmail(String email);
1148 * Update the user with the values from the supplied object.
1150 public void updateUser(User user);
1153 * Update accounting information for given user.
1155 * @param user The user to update
1156 * @param date Date of transaction
1157 * @param bandwidthDiff Bandwidth used; positive for addition,
1158 * negative for subtraction (e.g. to rollback)
1160 public void updateAccounting(User user, Date date, long bandwidthDiff);
1163 * Check if the user with the specified ID has permission to read the
1164 * folder with the supplied ID.
1166 public boolean canReadFolder(Long userId, Long folderId) throws ObjectNotFoundException;
1169 * Reset WebDAV password for given user.
1172 * @return the new password
1173 * @throws ObjectNotFoundException
1175 public String resetWebDAVPassword(Long userId) throws ObjectNotFoundException;
1178 * Find the invite for the specified invitation code.
1180 * @param code the invitation code
1181 * @return the Invitation or null if not found
1183 public Invitation findInvite(String code);
1186 * Create a new user in the connected IdP.
1188 * @param username the username of the new user
1189 * @param firstname the first name of the new user
1190 * @param lastname the last name of the new user
1191 * @param email the e-mail of the new user
1192 * @param password the password of the new user
1194 public void createLdapUser(String username, String firstname, String lastname, String email, String password);
1197 * Retrieves the available user classes.
1199 public List<UserClass> getUserClasses();
1202 * Upgrades the user class to the default "coupon bearer" class and marks
1203 * the provided coupon as used.
1205 * @param username the username of the user
1206 * @param code the coupon code
1207 * @return the new user class
1208 * @throws InvitationUsedException when trying to reuse an already used invitation
1209 * @throws ObjectNotFoundException if the user was not found
1211 public UserClass upgradeUserClass(String username, String code)
1212 throws ObjectNotFoundException, InvitationUsedException;
1215 * Retrieve the user class for coupon-bearing users.
1217 public UserClass getCouponUserClass();
1220 * Delete the actual file in the specified file system path.
1222 public void deleteActualFile(String path);
1225 * Update the userLogin with the values from the supplied object.
1227 public void addUserLogin(UserLogin userLogin);
1230 * Retrieves the user's current session login and the user's last login
1232 * @return a list of last two user logins
1233 * @throws ObjectNotFoundException
1235 public List<UserLogin> getLastUserLogins(Long userId) throws ObjectNotFoundException;
1238 * Posts the file specified by id to solr indexing server
1243 public void postFileToSolr(CommonsHttpSolrServer solr, Long id);
1249 UserDTO getUserByUserName(String username);
1255 FileLock saveOrUpdateLock(FileLock lock);
1260 void removeLock(FileLock lock);
1266 FileLock getLockByToken(String tokenId);
1272 FileLock getLockById(String id);
1279 * @throws DuplicateNameException
1280 * @throws ObjectNotFoundException
1281 * @throws GSSIOException
1282 * @throws InsufficientPermissionsException
1283 * @throws QuotaExceededException
1285 FileHeaderDTO createEmptyFile(Long userId, Long folderId, String name) throws DuplicateNameException, ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
1291 WebDavNonce saveOrUpdateWebDavNonce(WebDavNonce nonce);
1296 void removeWebDavNonce(WebDavNonce nonce);
1302 WebDavNonce getWebDavNonce(String tokenId);