2 * Copyright 2007, 2008, 2009, 2010 Electronic Business Systems Ltd.
4 * This file is part of GSS.
6 * GSS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
19 package gr.ebs.gss.server.ejb;
21 import gr.ebs.gss.client.exceptions.DuplicateNameException;
22 import gr.ebs.gss.client.exceptions.GSSIOException;
23 import gr.ebs.gss.client.exceptions.InsufficientPermissionsException;
24 import gr.ebs.gss.client.exceptions.InvitationUsedException;
25 import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
26 import gr.ebs.gss.client.exceptions.QuotaExceededException;
27 import gr.ebs.gss.server.domain.FileBody;
28 import gr.ebs.gss.server.domain.FileHeader;
29 import gr.ebs.gss.server.domain.FileLock;
30 import gr.ebs.gss.server.domain.FileUploadStatus;
31 import gr.ebs.gss.server.domain.Folder;
32 import gr.ebs.gss.server.domain.Group;
33 import gr.ebs.gss.server.domain.Invitation;
34 import gr.ebs.gss.server.domain.Nonce;
35 import gr.ebs.gss.server.domain.Permission;
36 import gr.ebs.gss.server.domain.User;
37 import gr.ebs.gss.server.domain.UserClass;
38 import gr.ebs.gss.server.domain.UserLogin;
41 import java.io.IOException;
42 import java.io.InputStream;
43 import java.util.Date;
44 import java.util.List;
47 import javax.ejb.Local;
48 import javax.ejb.TransactionAttribute;
49 import javax.ejb.TransactionAttributeType;
51 import gr.ebs.gss.server.domain.WebDavNonce;
52 import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
53 import gr.ebs.gss.server.domain.dto.StatsDTO;
54 import gr.ebs.gss.server.domain.dto.UserDTO;
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 Folder 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 Folder 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 Group 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 Group 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<Group> 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<FileHeader> 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
153 * @throws ObjectNotFoundException if the user or group was not found, with
154 * the exception message mentioning the precise problem
156 public List<User> 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
164 public List<User> 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 Folder 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<Folder> getSubfolders(Long userId, Long folderId)
208 throws ObjectNotFoundException, InsufficientPermissionsException;
211 * Retrieve the subfolders of the specified folder that are shared to others.
213 * @param userId the ID of the current user
214 * @param folderId the ID of the folder to retrieve
215 * @return the list of subfolders found
216 * @throws ObjectNotFoundException if the folder or user was not found
218 public List<Folder> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
221 * Retrieve the subfolders of the specified folder that are shared to others.
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 list of subfolders found
227 * @throws ObjectNotFoundException if the folder or user was not found
229 public List<Folder> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException;
231 * Modifies the specified folder if the specified user has the appropriate
234 * @param userId the ID of the current user
235 * @param folderId the ID of the folder to retrieve
239 * @return the updated folder
240 * @throws InsufficientPermissionsException if the user does not have the
241 * appropriate privileges
242 * @throws ObjectNotFoundException if the user or folder was not found, with
243 * the exception message mentioning the precise problem
244 * @throws DuplicateNameException if the specified name already exists in
245 * the parent folder, as either a folder or file
247 public Folder updateFolder(Long userId, Long folderId, String folderName,
249 Set<Permission> permissions)
250 throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
253 * Adds a user to the specified group
255 * @param userId the ID of the current user
256 * @param groupId the id of the new group
257 * @param userToAddId the id of the user to add
258 * @throws DuplicateNameException if the user already exists in group
259 * @throws ObjectNotFoundException if the user or group was not found, with
260 * the exception message mentioning the precise problem
261 * @throws InsufficientPermissionsException
263 public void addUserToGroup(Long userId, Long groupId, Long userToAddId)
264 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
267 * Creates a new group with the specified owner and name.
269 * @param userId the ID of the current user
270 * @param name the name of the new group
271 * @throws DuplicateNameException if the new group name already exists
272 * @throws ObjectNotFoundException if the user or group was not found, with
273 * the exception message mentioning the precise problem
275 public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
278 * Deletes the specified group in the specified user's namespace.
280 * @param userId the ID of the current user
281 * @param groupId the ID of the group to delete
282 * @throws ObjectNotFoundException if the user or group was not found, with
283 * the exception message mentioning the precise problem
284 * @throws InsufficientPermissionsException
286 public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
289 * Creates a new file with the specified owner, parent folder and name. The
290 * new file has the same permissions as its parent folder. The file contents
291 * are read from the input stream to a new File object.
293 * @param userId the ID of the current user
294 * @param folderId the ID of the parent folder
295 * @param name the name of the new file
296 * @param mimeType the MIME type of the file
297 * @param stream the input stream with the file contents
298 * @return The FileHeader created
299 * @throws DuplicateNameException if the specified name already exists in
300 * the parent folder, as either a folder or file
301 * @throws ObjectNotFoundException if the user or parent folder was not
302 * found, with the exception message mentioning the precise
304 * @throws GSSIOException if there was an error while storing the file contents
305 * @throws InsufficientPermissionsException
306 * @throws QuotaExceededException
308 public FileHeader createFile(Long userId, Long folderId, String name, String mimeType,
309 InputStream stream) throws DuplicateNameException, ObjectNotFoundException,
310 GSSIOException, InsufficientPermissionsException, QuotaExceededException;
313 * Deletes the specified file, provided the specified user has
314 * the necessary permissions.
316 * @param userId the ID of the current user
317 * @param fileId the ID of the file to delete
318 * @throws ObjectNotFoundException if the user or file was not found, with
319 * the exception message mentioning the precise problem
320 * @throws InsufficientPermissionsException if the user does not have the
321 * appropriate privileges
323 public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
326 * Creates a new tag for the specified user and file.
328 * @param userId the creator of the tag
329 * @param fileHeaderId the file that is tagged
331 * @throws ObjectNotFoundException if the user or the file was not found
333 public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
336 * Returns all tags defined by the specified user
339 * @return Set<String>
340 * @throws ObjectNotFoundException if the user was null
342 public Set<String> getUserTags(final Long userId) throws ObjectNotFoundException;
345 * Updates the attributes of the specified file.
350 * @param tagSet a String that contains tags separated by comma
351 * @param modificationDate the modification date
352 * @param versioned the new value of the versioned flag
355 * @throws DuplicateNameException
356 * @throws ObjectNotFoundException
357 * @throws InsufficientPermissionsException
359 public void updateFile(Long userId, Long fileId, String name, String tagSet,
360 Date modificationDate, Boolean versioned, Boolean readForAll,
361 Set<Permission> permissions)
362 throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
365 * Retrieve the contents of the current body for the file
366 * with the specified FileHeader ID. The file contents
367 * are provided as an InputStream from which the caller can
368 * retrieve the raw bytes.
370 * @param userId the ID of the current user
371 * @param fileId the ID of the file to retrieve
372 * @return an InputStream from the current file body contents
373 * @throws ObjectNotFoundException if the file or the user was not found
374 * @throws InsufficientPermissionsException if the user does not have the
375 * appropriate privileges
377 public InputStream getFileContents(Long userId, Long fileId)
378 throws ObjectNotFoundException, InsufficientPermissionsException;
381 * Retrieve the contents of the body identified by bodyId for the file
382 * with the specified FileHeader ID. The file contents
383 * are provided as an InputStream from which the caller can
384 * retrieve the raw bytes.
386 * @param userId the ID of the current user
387 * @param fileId the ID of the file to retrieve
388 * @param bodyId the body ID
389 * @return an InputStream from the current file body contents
390 * @throws ObjectNotFoundException if the file or the user was not found
391 * @throws InsufficientPermissionsException if the user does not have the
392 * appropriate privileges
394 public InputStream getFileContents(Long userId, Long fileId, Long bodyId)
395 throws ObjectNotFoundException, InsufficientPermissionsException;
398 * Retrieve the file with the specified ID.
400 * @param userId the ID of the current user
401 * @param fileId the ID of the file to retrieve
402 * @return the file found
403 * @throws ObjectNotFoundException if the file or the user was not found, with
404 * the exception message mentioning the precise problem
405 * @throws InsufficientPermissionsException
407 public FileHeader getFile(Long userId, Long fileId) throws ObjectNotFoundException,
408 InsufficientPermissionsException;
411 * Retrieve the filebody with the specified ID.
413 * @param userId the ID of the current user
414 * @param fileId the ID of the file to retrieve
415 * @param bodyId the ID of the body
416 * @return the file found
417 * @throws ObjectNotFoundException if the file or the user was not found, with
418 * the exception message mentioning the precise problem
419 * @throws InsufficientPermissionsException
421 public FileBody getFileBody(Long userId, Long fileId, Long bodyId)
422 throws ObjectNotFoundException, InsufficientPermissionsException;
425 * Get the resource (file or folder) at the specified path in
426 * the specified user's namespace. The returned object will be of type
427 * FileHeader or Folder.<p><strong>Note:</strong> this method does not
428 * receive the current user as a parameter, therefore it is unable to perform
429 * the necessary permission checks and should <strong>NOT</strong> be directly
430 * exposed to remote clients. It is the caller's responsibility to verify that
431 * the calling user has the required privileges for performing any subsequent
432 * action on the resource through one of the other ExternalAPI methods.
434 * @param ownerId the ID of the user owning the namespace
435 * @param path the absolute path in the user's namespace
436 * @param ignoreDeleted if true, resources that have been moved to the trash
438 * @throws ObjectNotFoundException if the user or resource was not found, with
439 * the exception message mentioning the precise problem
440 * @return the resource found
442 public Object getResourceAtPath(Long ownerId, String path, boolean ignoreDeleted)
443 throws ObjectNotFoundException;
446 * Copy the provided file to the specified destination.
448 * @param userId the ID of the current user
449 * @param fileId the IF of the provided file
450 * @param dest the path of the new resource
451 * @throws ObjectNotFoundException if the user, file or destination was not
452 * found, with the exception message mentioning the precise problem
453 * @throws DuplicateNameException if the specified name already exists in
454 * the destination folder, as either a folder or file
455 * @throws GSSIOException if there was an error while accessing the file contents
456 * @throws InsufficientPermissionsException
457 * @throws QuotaExceededException
459 public void copyFile(Long userId, Long fileId, String dest) throws ObjectNotFoundException,
460 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
463 * Copy the provided file to the specified destination.
465 * @param userId the ID of the current user
466 * @param ownerId the ID of the owner of the destination namespace
467 * @param fileId the IF of the provided file
468 * @param dest the path of the new resource
469 * @throws ObjectNotFoundException if the user, file or destination was not
470 * found, with the exception message mentioning the precise problem
471 * @throws DuplicateNameException if the specified name already exists in
472 * the destination folder, as either a folder or file
473 * @throws GSSIOException if there was an error while accessing the file contents
474 * @throws InsufficientPermissionsException
475 * @throws QuotaExceededException
477 public void copyFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException,
478 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
481 * Copy the provided file to the specified destination.
483 * @param userId the ID of the current user
484 * @param fileIds the IDs of the provided files
485 * @param destId the ID of the destination folder
486 * @throws ObjectNotFoundException if the user, file or destination was not
487 * found, with the exception message mentioning the precise problem
488 * @throws GSSIOException if there was an error while accessing the file contents
489 * @throws DuplicateNameException if the specified name already exists in
490 * the destination folder, as either a folder or file
491 * @throws InsufficientPermissionsException
492 * @throws QuotaExceededException
494 public void copyFiles(Long userId, List<Long> fileIds, Long destId)
495 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
496 InsufficientPermissionsException, QuotaExceededException;
499 * Copy the provided file to the specified destination.
501 * @param userId the ID of the current user
502 * @param fileId the IF of the provided file
503 * @param destId the ID of the destination folder
504 * @param destName the name of the new file
505 * @throws ObjectNotFoundException if the user, file or destination was not
506 * found, with the exception message mentioning the precise problem
507 * @throws GSSIOException if there was an error while accessing the file contents
508 * @throws DuplicateNameException if the specified name already exists in
509 * the destination folder, as either a folder or file
510 * @throws InsufficientPermissionsException
511 * @throws QuotaExceededException
513 public void copyFile(Long userId, Long fileId, Long destId, String destName)
514 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
515 InsufficientPermissionsException, QuotaExceededException;
518 * Copy the provided folder to the specified destination.
520 * @param userId the ID of the current user
521 * @param folderId the IF of the provided folder
522 * @param dest the path of the new folder
523 * @throws ObjectNotFoundException if the user, folder or destination was not
524 * found, with the exception message mentioning the precise problem
525 * @throws DuplicateNameException if the specified name already exists in
526 * the destination folder, as either a folder or file
527 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
528 * appropriate privileges
530 public void copyFolder(Long userId, Long folderId, String dest) throws ObjectNotFoundException,
531 DuplicateNameException, InsufficientPermissionsException;
534 * Copy the provided folder to the specified destination.
536 * @param userId the ID of the current user
537 * @param folderId the IF of the provided folder
538 * @param destId the ID of the destination folder
539 * @param destName the name of the new folder
540 * @throws ObjectNotFoundException if the user, folder or destination was not
541 * found, with the exception message mentioning the precise problem
542 * @throws DuplicateNameException if the specified name already exists in
543 * the destination folder, as either a folder or file
544 * @throws InsufficientPermissionsException InsufficientPermissionsException
545 * if the user does not have the appropriate privileges
547 public void copyFolder(Long userId, Long folderId, Long destId, String destName)
548 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
551 * Copy the provided folder and all its subfolders and files to the specified destination.
553 * @param userId the ID of the current user
554 * @param ownerId the ID of the owner of the destination namespace
555 * @param folderId the IF of the provided folder
556 * @param dest the path of the new folder
557 * @throws ObjectNotFoundException if the user, folder or destination was not
558 * found, with the exception message mentioning the precise problem
559 * @throws DuplicateNameException if the specified name already exists in
560 * the destination folder, as either a folder or file
561 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
562 * appropriate privileges
563 * @throws QuotaExceededException if the user quota limit would be exceeded
564 * @throws GSSIOException if there was an error while accessing the file contents
566 public void copyFolderStructureToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
567 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
570 * Copy the provided folder and all its subfolders and files to the specified destination.
572 * @param userId the ID of the current user
573 * @param folderId the IF of the provided folder
574 * @param destId the ID of the destination folder
575 * @param destName the name of the new folder
576 * @throws ObjectNotFoundException if the user, folder or destination was not
577 * found, with the exception message mentioning the precise problem
578 * @throws DuplicateNameException if the specified name already exists in
579 * the destination folder, as either a folder or file
580 * @throws InsufficientPermissionsException InsufficientPermissionsException
581 * if the user does not have the appropriate privileges
582 * @throws GSSIOException if there was an error while accessing the file contents
583 * @throws QuotaExceededException if the user quota limit would be exceeded
585 public void copyFolderStructure(Long userId, Long folderId, Long destId, String destName)
586 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
587 GSSIOException, QuotaExceededException;
590 * Marks the specified file as deleted in the specified user's namespace.
592 * @param userId the ID of the current user
593 * @param fileId the ID of the file to delete
594 * @throws ObjectNotFoundException if the user or file was not found, with
595 * the exception message mentioning the precise problem
596 * @throws InsufficientPermissionsException if the user does not have the
597 * appropriate privileges
599 public void moveFileToTrash(Long userId, Long fileId) throws ObjectNotFoundException,
600 InsufficientPermissionsException;
603 * Marks the specified deleted file as undeleted in the specified user's namespace.
605 * @param userId the ID of the current user
606 * @param fileId the ID of the file to undelete
607 * @throws ObjectNotFoundException if the user or file was not found, with
608 * the exception message mentioning the precise problem
609 * @throws InsufficientPermissionsException if the user does not have the
610 * appropriate privileges
613 public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
616 * Marks the specified folder as deleted in the specified user's namespace.
618 * @param userId the ID of the current user
619 * @param folderId the ID of the folder to delete
620 * @throws ObjectNotFoundException if the user or file was not found, with
621 * the exception message mentioning the precise problem
622 * @throws InsufficientPermissionsException if the user does not have the
623 * appropriate privileges
625 public void moveFolderToTrash(Long userId, Long folderId)
626 throws ObjectNotFoundException, InsufficientPermissionsException;
629 * Marks the specified deleted folder as undeleted in the specified user's namespace.
631 * @param userId the ID of the current user
632 * @param folderId the ID of the folder to undelete
633 * @throws ObjectNotFoundException if the user or file was not found, with
634 * the exception message mentioning the precise problem
635 * @throws InsufficientPermissionsException if the user does not have the
636 * appropriate privileges
639 public void removeFolderFromTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
642 * Move the provided folder and all its subfolders and files to the specified destination.
644 * @param userId the ID of the current user
645 * @param folderId the IF of the provided folder
646 * @param destId the ID of the destination folder
647 * @param destName the name of the new folder
648 * @throws ObjectNotFoundException if the user, folder or destination was not
649 * found, with the exception message mentioning the precise problem
650 * @throws DuplicateNameException if the specified name already exists in
651 * the destination folder, as either a folder or file
652 * @throws InsufficientPermissionsException if the user does not have the
653 * appropriate privileges
654 * @throws GSSIOException
655 * @throws QuotaExceededException
657 public void moveFolder(Long userId, Long folderId, Long destId, String destName)
658 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
659 GSSIOException, QuotaExceededException;
662 * Move the provided folder and all its subfolders and files to the specified destination.
664 * @param userId the ID of the current user
665 * @param ownerId the owner of the destination namespace
666 * @param folderId the IF of the provided folder
667 * @param dest the path of the new folder
668 * @throws ObjectNotFoundException if the user, folder or destination was not
669 * found, with the exception message mentioning the precise problem
670 * @throws DuplicateNameException if the specified name already exists in
671 * the destination folder, as either a folder or file
672 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
673 * appropriate privileges
674 * @throws GSSIOException
675 * @throws QuotaExceededException
677 public void moveFolderToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
678 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
681 * Move the provided file to the specified destination.
683 * @param userId the ID of the current user
684 * @param fileId the IF of the provided file
685 * @param destId the ID of the destination folder
686 * @param destName the name of the new file
687 * @throws InsufficientPermissionsException
688 * @throws ObjectNotFoundException if the user, file or destination was not
689 * found, with the exception message mentioning the precise problem
690 * @throws GSSIOException if there was an error while accessing the file contents
691 * @throws DuplicateNameException if the specified name already exists in
692 * the destination folder, as either a folder or file
693 * @throws QuotaExceededException
695 public void moveFile(Long userId, Long fileId, Long destId, String destName)
696 throws InsufficientPermissionsException, ObjectNotFoundException,
697 DuplicateNameException, GSSIOException, QuotaExceededException;
700 * Move the provided file to the specified destination.
702 * @param userId the ID of the current user
703 * @param ownerId the owner of the destination namespace
704 * @param fileId the IF of the provided file
705 * @param dest the path of the new file
706 * @throws InsufficientPermissionsException
707 * @throws ObjectNotFoundException if the user, file or destination was not
708 * found, with the exception message mentioning the precise problem
709 * @throws GSSIOException if there was an error while accessing the file contents
710 * @throws DuplicateNameException if the specified name already exists in
711 * the destination folder, as either a folder or file
712 * @throws QuotaExceededException
714 public void moveFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException, InsufficientPermissionsException, DuplicateNameException, GSSIOException, QuotaExceededException;
717 * move the provided file to the specified destination.
719 * @param userId the ID of the current user
720 * @param fileIds the IDs of the provided files
721 * @param destId the ID of the destination folder
722 * @throws InsufficientPermissionsException
723 * @throws ObjectNotFoundException if the user, file or destination was not
724 * found, with the exception message mentioning the precise problem
725 * @throws GSSIOException if there was an error while accessing the file contents
726 * @throws DuplicateNameException if the specified name already exists in
727 * the destination folder, as either a folder or file
728 * @throws QuotaExceededException
730 public void moveFiles(Long userId, List<Long> fileIds, Long destId)
731 throws InsufficientPermissionsException, ObjectNotFoundException,
732 DuplicateNameException, GSSIOException, QuotaExceededException;
735 * Returns a list of All deleted files of a user.
737 * @param userId the ID of the User
738 * * @return the list of deleted file header objects
739 * @throws ObjectNotFoundException if the user cannot be found
741 public List<FileHeader> getDeletedFiles(Long userId) throws ObjectNotFoundException;
744 * Returns a list of All deleted root folders of a user.
746 * @param userId the ID of the User
747 * * @return the list of deleted file header objects
748 * @throws ObjectNotFoundException if the user cannot be found
750 public List<Folder> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
753 * Empty Trash by deleting all marked as deleted files and folders
755 * @throws ObjectNotFoundException if something goes wrong in the delete process
756 * @throws InsufficientPermissionsException if something goes wrong in the delete process
758 public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
761 * Restores All Trashed Items by undeleting all marked as deleted files and folders
763 * @throws ObjectNotFoundException if something goes wrong in the delete process
764 * @throws InsufficientPermissionsException
766 public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
769 * Search the system for a user with the specified username.
770 * If no such user is found, the method returns null.
772 * @param username the username to search for
773 * @return the User object with the specified username
775 public User findUser(String username);
778 * Create a new user with the specified name, username and e-mail address.
780 * @param username the username of the new user
781 * @param name the name of the new user
782 * @param mail the e-mail of the new user
783 * @param idp the IdP of the new user
784 * @param idpid the IdP identifier of the new user
785 * @return the newly-created User object
786 * @throws DuplicateNameException if a user with the same username already exists
787 * @throws ObjectNotFoundException if no username was provided
789 public User createUser(String username, String name, String mail, String idp, String idpid)
790 throws DuplicateNameException, ObjectNotFoundException;
793 * Updates the authentication token for the specified user.
795 * @param userId the ID of the user whose token should be updated
796 * @return the updated user
797 * @throws ObjectNotFoundException if the user could not be found
799 public User updateUserToken(Long userId) throws ObjectNotFoundException;
802 * Updates the policy acceptance flag for the specified user.
804 * @param userId the ID of the user whose flag should be updated
805 * @param isAccepted the new value of the flag
806 * @return the updated user
807 * @throws ObjectNotFoundException if the user could not be found
809 public User updateUserPolicyAcceptance(Long userId, boolean isAccepted) throws ObjectNotFoundException;
812 * Invalidates the authentication token for the specified user.
814 * @param userId the ID of the user whose token should be updated
815 * @throws ObjectNotFoundException if the user could not be found
817 public void invalidateUserToken(Long userId) throws ObjectNotFoundException;
820 * Retrieve folder user and group permissions
822 * @param userId the ID of the user whose token should be updated
823 * @param folderId the ID of the folder
824 * @return the Set of permissions from requested folder
825 * @throws ObjectNotFoundException if the user or folder could not be found
826 * @throws InsufficientPermissionsException
828 public Set<Permission> getFolderPermissions(Long userId, Long folderId)
829 throws ObjectNotFoundException, InsufficientPermissionsException;
832 * Retrieve file user and group permissions
834 * @param userId the ID of the user whose token should be updated
835 * @param fileId the ID of the folder
836 * @return the Set of permissions from requested folder
837 * @throws ObjectNotFoundException if the user or folder could not be found
838 * @throws InsufficientPermissionsException
840 public Set<Permission> getFilePermissions(Long userId, Long fileId)
841 throws ObjectNotFoundException, InsufficientPermissionsException;
844 * Returns a list of all shared root folders of a user.
846 * @param userId the ID of the User
847 * @return the list of shared root folders
848 * @throws ObjectNotFoundException if the user cannot be found
850 public List<Folder> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
853 * Returns a list of all shared files of a user that are not
854 * inside other shared folders.
856 * @param userId the ID of the User
857 * @return the list of shared files
858 * @throws ObjectNotFoundException if the user cannot be found
860 public List<FileHeader> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
863 * Returns a list of all shared files of a user.
865 * @param userId the ID of the User
866 * @return the list of shared files
867 * @throws ObjectNotFoundException if the user cannot be found
869 public List<FileHeader> getSharedFiles(Long userId) throws ObjectNotFoundException;
872 * Returns a list of all shared folders of a user.
874 * @param userId the ID of the User
875 * @return the list of shared folders
876 * @throws ObjectNotFoundException if the user cannot be found
878 public List<Folder> getSharedFolders(Long userId) throws ObjectNotFoundException;
881 * Returns a list of all shared root folders of a user that calling
882 * user has at least read permissions.
884 * @param ownerId the ID of the User
885 * @return the list of shared root folders
886 * @param callingUserId
888 * @throws ObjectNotFoundException if the user cannot be found
890 public List<Folder> getSharedRootFolders(Long ownerId, Long callingUserId)
891 throws ObjectNotFoundException;
894 * Returns a list of all shared files of a user that calling user has
895 * at least read permissions..
897 * @param ownerId the ID of the User
898 * @return the list of shared files
899 * @param callingUserId
900 * @throws ObjectNotFoundException if the user cannot be found
902 public List<FileHeader> getSharedFiles(Long ownerId, Long callingUserId)
903 throws ObjectNotFoundException;
906 * Remove a user member from a group
908 * @param userId the ID of the User owning the group
909 * @param groupId the ID of the requested group
910 * @param memberId the ID of the member to be removed
912 * @throws ObjectNotFoundException if the user or group was not found, with
913 * the exception message mentioning the precise problem
914 * @throws InsufficientPermissionsException
916 public void removeMemberFromGroup(Long userId, Long groupId, Long memberId)
917 throws ObjectNotFoundException, InsufficientPermissionsException;
920 * Retrieves the list of users sharing files to user identified by user id
922 * @return the List of users sharing files to user
923 * @throws ObjectNotFoundException
925 public List<User> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
932 * @return list of files that match query
933 * @throws ObjectNotFoundException if no user or query was specified
935 public List<FileHeader> searchFiles(Long userId, String query) throws ObjectNotFoundException;
938 * Creates a nonce for the specified user.
940 * @param userId the ID of the user
941 * @return the new nonce
942 * @throws ObjectNotFoundException if the user could not be found
944 public Nonce createNonce(Long userId) throws ObjectNotFoundException;
947 * Find the nonce object for the specified encoded nonce, that should be
948 * associated with the specified user.
950 * @param nonce the issued nonce in Base64 encoding
951 * @param userId the ID of the user for whom this nonce should have been issued
952 * @return the retrieved nonce object
953 * @throws ObjectNotFoundException if the nonce or user were not found
955 public Nonce getNonce(String nonce, Long userId) throws ObjectNotFoundException;
958 * Remove the specified nonce from the persistent store.
960 * @param id the ID of the nonce
961 * @throws ObjectNotFoundException if the specified nonce could not be found
963 public void removeNonce(Long id) throws ObjectNotFoundException;
966 * Activate the supplied nonce for the specified user.
968 * @param userId the ID of the user
969 * @param nonce the nonce to activate
970 * @param nonceExpiryDate the expiry date of the nonce
971 * @throws ObjectNotFoundException
973 public void activateUserNonce(Long userId, String nonce, Date nonceExpiryDate) throws ObjectNotFoundException;
976 * Retrieves user statistics.
978 * @param userId the ID of the user
979 * @return the statistics
980 * @throws ObjectNotFoundException
983 public StatsDTO getUserStatistics(Long userId) throws ObjectNotFoundException;
986 * Restore the file contents to the specified version.
988 * @param userId the ID of the user
989 * @param fileId the ID of the file
990 * @param version the version number of the desired file contents
991 * @throws ObjectNotFoundException if the user or file was not
992 * found, with the exception message mentioning the precise problem
993 * @throws InsufficientPermissionsException if the user does not have the
994 * appropriate privileges
995 * @throws QuotaExceededException if the user quota limit would be exceeded
996 * @throws GSSIOException if there was an error while accessing the file contents
998 public void restoreVersion(Long userId, Long fileId, int version)
999 throws ObjectNotFoundException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
1002 * Removes all old file versions for specified file keeping only the current revision
1004 * @param userId the ID of the user
1005 * @param fileId the ID of the file
1007 * @throws ObjectNotFoundException
1008 * @throws InsufficientPermissionsException
1011 public void removeOldVersions(Long userId, Long fileId)
1012 throws ObjectNotFoundException, InsufficientPermissionsException;
1015 * It is used by the Solr mbean to rebuild the index.
1017 public String rebuildSolrIndex();
1020 * It is used by the Solr mbean to refresh the index. It does not delete anything just re-add everything in the index
1022 public String refreshSolrIndex();
1025 * Creates a new file with the specified owner, parent folder and name. The
1026 * new file has the same permissions as its parent folder. The file contents
1027 * are already uploaded outside of externalAPI and the uploaded file is used as a parameter.
1029 * @param userId the ID of the current user
1030 * @param folderId the ID of the parent folder
1031 * @param name the name of the new file
1032 * @param mimeType the MIME type of the file
1033 * @param fileSize the uploaded file size
1034 * @param filePath the uploaded file full path
1035 * @return The FileHeader created
1036 * @throws DuplicateNameException if the specified name already exists in
1037 * the parent folder, as either a folder or file
1038 * @throws ObjectNotFoundException if the user or parent folder was not
1039 * found, with the exception message mentioning the precise
1041 * @throws GSSIOException if there was an error while storing the file contents
1042 * @throws InsufficientPermissionsException
1043 * @throws QuotaExceededException
1045 public FileHeader createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
1046 throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
1047 InsufficientPermissionsException, QuotaExceededException;
1050 * Create a new FileBody with the supplied uploaded file as contents and make it the current body
1053 * @param userId the ID of the current user
1054 * @param fileId the ID of the file header object
1055 * @param mimeType the content type of the file
1056 * @param fileSize the uploaded file size
1057 * @param filePath the uploaded file full path
1058 * @return The FileHeader updated
1059 * @throws ObjectNotFoundException if the user or file was not found, with
1060 * the exception message mentioning the precise problem
1061 * @throws GSSIOException when an IO exception occurs
1062 * @throws InsufficientPermissionsException
1063 * @throws QuotaExceededException
1065 public FileHeader updateFileContents(Long userId, Long fileId, String mimeType,
1066 long fileSize, String filePath) throws ObjectNotFoundException, GSSIOException,
1067 InsufficientPermissionsException, QuotaExceededException;
1070 * Create a file based on inputstream without using transaction.
1075 * @throws IOException
1076 * @throws ObjectNotFoundException
1078 @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
1079 public File uploadFile(InputStream stream, Long userId)
1080 throws IOException, ObjectNotFoundException;
1082 public void createFileUploadProgress(Long userId, String filename,
1083 Long bytesTransfered, Long fileSize) throws ObjectNotFoundException;
1085 public FileUploadStatus getFileUploadStatus(Long userId, String fileName);
1087 public void removeFileUploadProgress(Long userId, String filename)
1088 throws ObjectNotFoundException;
1091 * Fetch the file body with the specified version number.
1093 * @param userId the ID of the current user
1094 * @param fileId the ID of the file header
1095 * @param version the version number
1096 * @return the file body
1097 * @throws ObjectNotFoundException if the user file or version
1099 * @throws InsufficientPermissionsException if the user does not
1100 * have enough privileges for reading this file
1102 public FileBody getFileVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException;
1105 * Search the system for a user with the specified email address.
1106 * If no such user is found, the method returns null.
1108 public User findUserByEmail(String email);
1111 * Update the user with the values from the supplied object.
1113 public void updateUser(User user);
1116 * Update accounting information for given user.
1118 * @param user The user to update
1119 * @param date Date of transaction
1120 * @param bandwidthDiff Bandwidth used; positive for addition,
1121 * negative for subtraction (e.g. to rollback)
1123 public void updateAccounting(User user, Date date, long bandwidthDiff);
1126 * Check if the user with the specified ID has permission to read the
1127 * folder with the supplied ID.
1129 public boolean canReadFolder(Long userId, Long folderId) throws ObjectNotFoundException;
1132 * Reset WebDAV password for given user.
1135 * @return the new password
1136 * @throws ObjectNotFoundException
1138 public String resetWebDAVPassword(Long userId) throws ObjectNotFoundException;
1141 * Find the invite for the specified invitation code.
1143 * @param code the invitation code
1144 * @return the Invitation or null if not found
1146 public Invitation findInvite(String code);
1149 * Create a new user in the connected IdP.
1151 * @param username the username of the new user
1152 * @param firstname the first name of the new user
1153 * @param lastname the last name of the new user
1154 * @param email the e-mail of the new user
1155 * @param password the password of the new user
1157 public void createLdapUser(String username, String firstname, String lastname, String email, String password);
1160 * Retrieves the available user classes.
1162 public List<UserClass> getUserClasses();
1165 * Upgrades the user class to the default "coupon bearer" class and marks
1166 * the provided coupon as used.
1168 * @param username the username of the user
1169 * @param code the coupon code
1170 * @return the new user class
1171 * @throws InvitationUsedException when trying to reuse an already used invitation
1172 * @throws ObjectNotFoundException if the user was not found
1174 public UserClass upgradeUserClass(String username, String code)
1175 throws ObjectNotFoundException, InvitationUsedException;
1178 * Retrieve the user class for coupon-bearing users.
1180 public UserClass getCouponUserClass();
1183 * Delete the actual file in the specified file system path.
1185 public void deleteActualFile(String path);
1188 * Update the userLogin with the values from the supplied object.
1190 public void addUserLogin(UserLogin userLogin);
1193 * Retrieves the user's current session login and the user's last login
1195 * @return a list of last two user logins
1196 * @throws ObjectNotFoundException
1198 public List<UserLogin> getLastUserLogins(Long userId) throws ObjectNotFoundException;
1201 * Posts the file specified by id to solr indexing server
1206 public void postFileToSolr(CommonsHttpSolrServer solr, Long id);
1210 * @throws ObjectNotFoundException
1212 public Folder expandFolder(Folder folder) throws ObjectNotFoundException;
1217 * @throws ObjectNotFoundException
1219 FileHeader expandFile(FileHeader folder) throws ObjectNotFoundException;
1224 * @throws ObjectNotFoundException
1226 Group expandGroup(Group folder) throws ObjectNotFoundException;
1232 User getUserByUserName(String username);
1238 FileLock saveOrUpdateLock(FileLock lock);
1243 void removeLock(FileLock lock);
1249 FileLock getLockByToken(String tokenId);
1255 FileLock getLockById(String id);
1262 * @throws DuplicateNameException
1263 * @throws ObjectNotFoundException
1264 * @throws GSSIOException
1265 * @throws InsufficientPermissionsException
1266 * @throws QuotaExceededException
1268 FileHeader createEmptyFile(Long userId, Long folderId, String name) throws DuplicateNameException, ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
1274 WebDavNonce saveOrUpdateWebDavNonce(WebDavNonce nonce);
1279 void removeWebDavNonce(WebDavNonce nonce);
1285 WebDavNonce getWebDavNonce(String tokenId);
1288 * Returns a user that matches the given full username
1290 * @param username the username of the User
1293 public UserDTO getUserByUserName(String username);