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.net.MalformedURLException;
44 import java.util.Date;
45 import java.util.List;
48 import javax.ejb.Local;
49 import javax.ejb.TransactionAttribute;
50 import javax.ejb.TransactionAttributeType;
52 import gr.ebs.gss.server.domain.WebDavNonce;
53 import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
54 import gr.ebs.gss.server.domain.dto.StatsDTO;
55 import gr.ebs.gss.server.domain.dto.UserDTO;
56 import org.apache.solr.client.solrj.SolrServerException;
57 import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
60 * The External API for GSS clients.
65 public interface ExternalAPI {
68 * Retrieves the root folder for the specified user. The caller must ensure
69 * that the userId exists.
73 * @throws ObjectNotFoundException if no Folder or user was found
75 public Folder getRootFolder(Long userId) throws ObjectNotFoundException;
78 * Retrieve the folder with the specified ID.
80 * @param userId the ID of the current user
81 * @param folderId the ID of the folder to retrieve
82 * @return the folder found
83 * @throws ObjectNotFoundException if the folder or the user was not found
84 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
86 public Folder getFolder(Long userId, Long folderId) throws ObjectNotFoundException,
87 InsufficientPermissionsException;
90 * Returns the user with the specified ID.
92 * @param userId The ID of the User to be found
93 * @return The User object
94 * @throws ObjectNotFoundException if the user cannot be found
96 public User getUser(Long userId) throws ObjectNotFoundException;
99 * Returns the user with the specified ID.
101 * @param userId The ID of the User to be found
102 * @return The User object
103 * @throws ObjectNotFoundException if the user cannot be found
105 public UserDTO getUserDTO(Long userId) throws ObjectNotFoundException;
108 * Returns the group with the specified ID.
110 * @param groupId The ID of the Group to be found
111 * @return The Group object
112 * @throws ObjectNotFoundException if the group cannot be found
114 public Group getGroup(Long groupId) throws ObjectNotFoundException;
117 * Returns the group with the specified name that belongs to the
120 * @param userId the ID of the user
121 * @param name the name of the group
122 * @return The Group object
123 * @throws ObjectNotFoundException if the group cannot be found
125 public Group getGroup(Long userId, String name) throws ObjectNotFoundException;
128 * Retrieve the list of groups for a particular user.
130 * @param userId the ID of the User
131 * @return a List of Groups that belong to the specified User
132 * @throws ObjectNotFoundException if the user was not found
134 public List<Group> getGroups(Long userId) throws ObjectNotFoundException;
137 * Returns a list of files contained in the folder specified by its id.
139 * @param userId the ID of the User
140 * @param folderId the ID of the folder containing the files
141 * @param ignoreDeleted
142 * @return the list of file header objects
143 * @throws ObjectNotFoundException if the user or the folder cannot be found
144 * @throws InsufficientPermissionsException
146 public List<FileHeader> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException,
147 InsufficientPermissionsException;
150 * Returns a list of users for the specified group
152 * @param userId the ID of the User
153 * @param groupId the ID of the requested group
155 * @throws ObjectNotFoundException if the user or group was not found, with
156 * the exception message mentioning the precise problem
158 public List<User> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
161 * Returns a list of users matching the specified username
163 * @param username the username of the User
166 public List<User> getUsersByUserNameLike(String username);
169 * Creates a new folder with the specified owner, parent folder and name.
170 * New folder has the same permissions as its parent
175 * @return the new folder
176 * @throws DuplicateNameException if the specified name already exists in
177 * the parent folder, as either a folder or file
178 * @throws ObjectNotFoundException if the user or parent folder was not
179 * found, with the exception message mentioning the precise
181 * @throws InsufficientPermissionsException
183 public Folder createFolder(Long userId, Long parentId, String name) throws DuplicateNameException,
184 ObjectNotFoundException, InsufficientPermissionsException;
187 * Deletes the specified folder, if the specified user has the appropriate
190 * @param userId the ID of the current user
191 * @param folderId the ID of the folder to delete
192 * @throws InsufficientPermissionsException if the user does not have the
193 * appropriate privileges
194 * @throws ObjectNotFoundException if the user or folder was not found, with
195 * the exception message mentioning the precise problem
197 public void deleteFolder(Long userId, Long folderId)
198 throws InsufficientPermissionsException, ObjectNotFoundException;
201 * Retrieve the subfolders of the specified folder.
203 * @param userId the ID of the current user
204 * @param folderId the ID of the folder to retrieve
205 * @return the list of subfolders found
206 * @throws ObjectNotFoundException if the folder or user was not found
207 * @throws InsufficientPermissionsException
209 public List<Folder> getSubfolders(Long userId, Long folderId)
210 throws ObjectNotFoundException, InsufficientPermissionsException;
213 * Retrieve the subfolders of the specified folder that are shared to others.
215 * @param userId the ID of the current user
216 * @param folderId the ID of the folder to retrieve
217 * @return the list of subfolders found
218 * @throws ObjectNotFoundException if the folder or user was not found
220 public List<Folder> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
223 * Retrieve the subfolders of the specified folder that are shared to others.
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 list of subfolders found
229 * @throws ObjectNotFoundException if the folder or user was not found
231 public List<Folder> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException;
233 * Modifies the specified folder if the specified user has the appropriate
236 * @param userId the ID of the current user
237 * @param folderId the ID of the folder to retrieve
241 * @return the updated folder
242 * @throws InsufficientPermissionsException if the user does not have the
243 * appropriate privileges
244 * @throws ObjectNotFoundException if the user or folder was not found, with
245 * the exception message mentioning the precise problem
246 * @throws DuplicateNameException if the specified name already exists in
247 * the parent folder, as either a folder or file
249 public Folder updateFolder(Long userId, Long folderId, String folderName,
251 Set<Permission> permissions)
252 throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
255 * Adds a user to the specified group
257 * @param userId the ID of the current user
258 * @param groupId the id of the new group
259 * @param userToAddId the id of the user to add
260 * @throws DuplicateNameException if the user already exists in group
261 * @throws ObjectNotFoundException if the user or group was not found, with
262 * the exception message mentioning the precise problem
263 * @throws InsufficientPermissionsException
265 public void addUserToGroup(Long userId, Long groupId, Long userToAddId)
266 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
269 * Creates a new group with the specified owner and name.
271 * @param userId the ID of the current user
272 * @param name the name of the new group
273 * @throws DuplicateNameException if the new group name already exists
274 * @throws ObjectNotFoundException if the user or group was not found, with
275 * the exception message mentioning the precise problem
277 public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
280 * Deletes the specified group in the specified user's namespace.
282 * @param userId the ID of the current user
283 * @param groupId the ID of the group to delete
284 * @throws ObjectNotFoundException if the user or group was not found, with
285 * the exception message mentioning the precise problem
286 * @throws InsufficientPermissionsException
288 public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
291 * Creates a new file with the specified owner, parent folder and name. The
292 * new file has the same permissions as its parent folder. The file contents
293 * are read from the input stream to a new File object.
295 * @param userId the ID of the current user
296 * @param folderId the ID of the parent folder
297 * @param name the name of the new file
298 * @param mimeType the MIME type of the file
299 * @param stream the input stream with the file contents
300 * @return The FileHeader created
301 * @throws DuplicateNameException if the specified name already exists in
302 * the parent folder, as either a folder or file
303 * @throws ObjectNotFoundException if the user or parent folder was not
304 * found, with the exception message mentioning the precise
306 * @throws GSSIOException if there was an error while storing the file contents
307 * @throws InsufficientPermissionsException
308 * @throws QuotaExceededException
310 public FileHeader createFile(Long userId, Long folderId, String name, String mimeType,
311 InputStream stream) throws DuplicateNameException, ObjectNotFoundException,
312 GSSIOException, InsufficientPermissionsException, QuotaExceededException;
315 * Deletes the specified file, provided the specified user has
316 * the necessary permissions.
318 * @param userId the ID of the current user
319 * @param fileId the ID of the file to delete
320 * @throws ObjectNotFoundException if the user or file was not found, with
321 * the exception message mentioning the precise problem
322 * @throws InsufficientPermissionsException if the user does not have the
323 * appropriate privileges
325 public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
328 * Creates a new tag for the specified user and file.
330 * @param userId the creator of the tag
331 * @param fileHeaderId the file that is tagged
333 * @throws ObjectNotFoundException if the user or the file was not found
335 public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
338 * Returns all tags defined by the specified user
341 * @return Set<String>
342 * @throws ObjectNotFoundException if the user was null
344 public Set<String> getUserTags(final Long userId) throws ObjectNotFoundException;
347 * Updates the attributes of the specified file.
352 * @param tagSet a String that contains tags separated by comma
353 * @param modificationDate the modification date
354 * @param versioned the new value of the versioned flag
357 * @throws DuplicateNameException
358 * @throws ObjectNotFoundException
359 * @throws InsufficientPermissionsException
361 public void updateFile(Long userId, Long fileId, String name, String tagSet,
362 Date modificationDate, Boolean versioned, Boolean readForAll,
363 Set<Permission> permissions)
364 throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
367 * Retrieve the contents of the current body for the file
368 * with the specified FileHeader ID. The file contents
369 * are provided as an InputStream from which the caller can
370 * retrieve the raw bytes.
372 * @param userId the ID of the current user
373 * @param fileId the ID of the file to retrieve
374 * @return an InputStream from the current file body contents
375 * @throws ObjectNotFoundException if the file or the user was not found
376 * @throws InsufficientPermissionsException if the user does not have the
377 * appropriate privileges
379 public InputStream getFileContents(Long userId, Long fileId)
380 throws ObjectNotFoundException, InsufficientPermissionsException;
383 * Retrieve the contents of the body identified by bodyId for the file
384 * with the specified FileHeader ID. The file contents
385 * are provided as an InputStream from which the caller can
386 * retrieve the raw bytes.
388 * @param userId the ID of the current user
389 * @param fileId the ID of the file to retrieve
390 * @param bodyId the body ID
391 * @return an InputStream from the current file body contents
392 * @throws ObjectNotFoundException if the file or the user was not found
393 * @throws InsufficientPermissionsException if the user does not have the
394 * appropriate privileges
396 public InputStream getFileContents(Long userId, Long fileId, Long bodyId)
397 throws ObjectNotFoundException, InsufficientPermissionsException;
400 * Retrieve the file with the specified ID.
402 * @param userId the ID of the current user
403 * @param fileId the ID of the file to retrieve
404 * @return the file found
405 * @throws ObjectNotFoundException if the file or the user was not found, with
406 * the exception message mentioning the precise problem
407 * @throws InsufficientPermissionsException
409 public FileHeader getFile(Long userId, Long fileId) throws ObjectNotFoundException,
410 InsufficientPermissionsException;
413 * Retrieve the filebody with the specified ID.
415 * @param userId the ID of the current user
416 * @param fileId the ID of the file to retrieve
417 * @param bodyId the ID of the body
418 * @return the file found
419 * @throws ObjectNotFoundException if the file or the user was not found, with
420 * the exception message mentioning the precise problem
421 * @throws InsufficientPermissionsException
423 public FileBody getFileBody(Long userId, Long fileId, Long bodyId)
424 throws ObjectNotFoundException, InsufficientPermissionsException;
427 * Get the resource (file or folder) at the specified path in
428 * the specified user's namespace. The returned object will be of type
429 * FileHeader or Folder.<p><strong>Note:</strong> this method does not
430 * receive the current user as a parameter, therefore it is unable to perform
431 * the necessary permission checks and should <strong>NOT</strong> be directly
432 * exposed to remote clients. It is the caller's responsibility to verify that
433 * the calling user has the required privileges for performing any subsequent
434 * action on the resource through one of the other ExternalAPI methods.
436 * @param ownerId the ID of the user owning the namespace
437 * @param path the absolute path in the user's namespace
438 * @param ignoreDeleted if true, resources that have been moved to the trash
440 * @throws ObjectNotFoundException if the user or resource was not found, with
441 * the exception message mentioning the precise problem
442 * @return the resource found
444 public Object getResourceAtPath(Long ownerId, String path, boolean ignoreDeleted)
445 throws ObjectNotFoundException;
448 * Copy the provided file to the specified destination.
450 * @param userId the ID of the current user
451 * @param fileId the IF of the provided file
452 * @param dest the path of the new resource
453 * @throws ObjectNotFoundException if the user, file or destination was not
454 * found, with the exception message mentioning the precise problem
455 * @throws DuplicateNameException if the specified name already exists in
456 * the destination folder, as either a folder or file
457 * @throws GSSIOException if there was an error while accessing the file contents
458 * @throws InsufficientPermissionsException
459 * @throws QuotaExceededException
461 public void copyFile(Long userId, Long fileId, String dest) throws ObjectNotFoundException,
462 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
465 * Copy the provided file to the specified destination.
467 * @param userId the ID of the current user
468 * @param ownerId the ID of the owner of the destination namespace
469 * @param fileId the IF of the provided file
470 * @param dest the path of the new resource
471 * @throws ObjectNotFoundException if the user, file or destination was not
472 * found, with the exception message mentioning the precise problem
473 * @throws DuplicateNameException if the specified name already exists in
474 * the destination folder, as either a folder or file
475 * @throws GSSIOException if there was an error while accessing the file contents
476 * @throws InsufficientPermissionsException
477 * @throws QuotaExceededException
479 public void copyFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException,
480 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
483 * Copy the provided file to the specified destination.
485 * @param userId the ID of the current user
486 * @param fileIds the IDs of the provided files
487 * @param destId the ID of the destination folder
488 * @throws ObjectNotFoundException if the user, file or destination was not
489 * found, with the exception message mentioning the precise problem
490 * @throws GSSIOException if there was an error while accessing the file contents
491 * @throws DuplicateNameException if the specified name already exists in
492 * the destination folder, as either a folder or file
493 * @throws InsufficientPermissionsException
494 * @throws QuotaExceededException
496 public void copyFiles(Long userId, List<Long> fileIds, Long destId)
497 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
498 InsufficientPermissionsException, QuotaExceededException;
501 * Copy the provided file to the specified destination.
503 * @param userId the ID of the current user
504 * @param fileId the IF of the provided file
505 * @param destId the ID of the destination folder
506 * @param destName the name of the new file
507 * @throws ObjectNotFoundException if the user, file or destination was not
508 * found, with the exception message mentioning the precise problem
509 * @throws GSSIOException if there was an error while accessing the file contents
510 * @throws DuplicateNameException if the specified name already exists in
511 * the destination folder, as either a folder or file
512 * @throws InsufficientPermissionsException
513 * @throws QuotaExceededException
515 public void copyFile(Long userId, Long fileId, Long destId, String destName)
516 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
517 InsufficientPermissionsException, QuotaExceededException;
520 * Copy the provided folder to the specified destination.
522 * @param userId the ID of the current user
523 * @param folderId the IF of the provided folder
524 * @param dest the path of the new folder
525 * @throws ObjectNotFoundException if the user, folder or destination was not
526 * found, with the exception message mentioning the precise problem
527 * @throws DuplicateNameException if the specified name already exists in
528 * the destination folder, as either a folder or file
529 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
530 * appropriate privileges
532 public void copyFolder(Long userId, Long folderId, String dest) throws ObjectNotFoundException,
533 DuplicateNameException, InsufficientPermissionsException;
536 * Copy the provided folder to the specified destination.
538 * @param userId the ID of the current user
539 * @param folderId the IF of the provided folder
540 * @param destId the ID of the destination folder
541 * @param destName the name of the new folder
542 * @throws ObjectNotFoundException if the user, folder or destination was not
543 * found, with the exception message mentioning the precise problem
544 * @throws DuplicateNameException if the specified name already exists in
545 * the destination folder, as either a folder or file
546 * @throws InsufficientPermissionsException InsufficientPermissionsException
547 * if the user does not have the appropriate privileges
549 public void copyFolder(Long userId, Long folderId, Long destId, String destName)
550 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
553 * Copy the provided folder and all its subfolders and files to the specified destination.
555 * @param userId the ID of the current user
556 * @param ownerId the ID of the owner of the destination namespace
557 * @param folderId the IF of the provided folder
558 * @param dest the path of the new folder
559 * @throws ObjectNotFoundException if the user, folder or destination was not
560 * found, with the exception message mentioning the precise problem
561 * @throws DuplicateNameException if the specified name already exists in
562 * the destination folder, as either a folder or file
563 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
564 * appropriate privileges
565 * @throws QuotaExceededException if the user quota limit would be exceeded
566 * @throws GSSIOException if there was an error while accessing the file contents
568 public void copyFolderStructureToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
569 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
572 * Copy the provided folder and all its subfolders and files to the specified destination.
574 * @param userId the ID of the current user
575 * @param folderId the IF of the provided folder
576 * @param destId the ID of the destination folder
577 * @param destName the name of the new folder
578 * @throws ObjectNotFoundException if the user, folder or destination was not
579 * found, with the exception message mentioning the precise problem
580 * @throws DuplicateNameException if the specified name already exists in
581 * the destination folder, as either a folder or file
582 * @throws InsufficientPermissionsException InsufficientPermissionsException
583 * if the user does not have the appropriate privileges
584 * @throws GSSIOException if there was an error while accessing the file contents
585 * @throws QuotaExceededException if the user quota limit would be exceeded
587 public void copyFolderStructure(Long userId, Long folderId, Long destId, String destName)
588 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
589 GSSIOException, QuotaExceededException;
592 * Marks the specified file as deleted in the specified user's namespace.
594 * @param userId the ID of the current user
595 * @param fileId the ID of the file to delete
596 * @throws ObjectNotFoundException if the user or file was not found, with
597 * the exception message mentioning the precise problem
598 * @throws InsufficientPermissionsException if the user does not have the
599 * appropriate privileges
601 public void moveFileToTrash(Long userId, Long fileId) throws ObjectNotFoundException,
602 InsufficientPermissionsException;
605 * Marks the specified deleted file as undeleted in the specified user's namespace.
607 * @param userId the ID of the current user
608 * @param fileId the ID of the file to undelete
609 * @throws ObjectNotFoundException if the user or file was not found, with
610 * the exception message mentioning the precise problem
611 * @throws InsufficientPermissionsException if the user does not have the
612 * appropriate privileges
615 public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
618 * Marks the specified folder as deleted in the specified user's namespace.
620 * @param userId the ID of the current user
621 * @param folderId the ID of the folder to delete
622 * @throws ObjectNotFoundException if the user or file was not found, with
623 * the exception message mentioning the precise problem
624 * @throws InsufficientPermissionsException if the user does not have the
625 * appropriate privileges
627 public void moveFolderToTrash(Long userId, Long folderId)
628 throws ObjectNotFoundException, InsufficientPermissionsException;
631 * Marks the specified deleted folder as undeleted in the specified user's namespace.
633 * @param userId the ID of the current user
634 * @param folderId the ID of the folder to undelete
635 * @throws ObjectNotFoundException if the user or file was not found, with
636 * the exception message mentioning the precise problem
637 * @throws InsufficientPermissionsException if the user does not have the
638 * appropriate privileges
641 public void removeFolderFromTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
644 * Move the provided folder and all its subfolders and files to the specified destination.
646 * @param userId the ID of the current user
647 * @param folderId the IF of the provided folder
648 * @param destId the ID of the destination folder
649 * @param destName the name of the new folder
650 * @throws ObjectNotFoundException if the user, folder or destination was not
651 * found, with the exception message mentioning the precise problem
652 * @throws DuplicateNameException if the specified name already exists in
653 * the destination folder, as either a folder or file
654 * @throws InsufficientPermissionsException if the user does not have the
655 * appropriate privileges
656 * @throws GSSIOException
657 * @throws QuotaExceededException
659 public void moveFolder(Long userId, Long folderId, Long destId, String destName)
660 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
661 GSSIOException, QuotaExceededException;
664 * Move the provided folder and all its subfolders and files to the specified destination.
666 * @param userId the ID of the current user
667 * @param ownerId the owner of the destination namespace
668 * @param folderId the IF of the provided folder
669 * @param dest the path of the new folder
670 * @throws ObjectNotFoundException if the user, folder or destination was not
671 * found, with the exception message mentioning the precise problem
672 * @throws DuplicateNameException if the specified name already exists in
673 * the destination folder, as either a folder or file
674 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
675 * appropriate privileges
676 * @throws GSSIOException
677 * @throws QuotaExceededException
679 public void moveFolderToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
680 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
683 * Move the provided file to the specified destination.
685 * @param userId the ID of the current user
686 * @param fileId the IF of the provided file
687 * @param destId the ID of the destination folder
688 * @param destName the name of the new file
689 * @throws InsufficientPermissionsException
690 * @throws ObjectNotFoundException if the user, file or destination was not
691 * found, with the exception message mentioning the precise problem
692 * @throws GSSIOException if there was an error while accessing the file contents
693 * @throws DuplicateNameException if the specified name already exists in
694 * the destination folder, as either a folder or file
695 * @throws QuotaExceededException
697 public void moveFile(Long userId, Long fileId, Long destId, String destName)
698 throws InsufficientPermissionsException, ObjectNotFoundException,
699 DuplicateNameException, GSSIOException, QuotaExceededException;
702 * Move the provided file to the specified destination.
704 * @param userId the ID of the current user
705 * @param ownerId the owner of the destination namespace
706 * @param fileId the IF of the provided file
707 * @param dest the path of the new file
708 * @throws InsufficientPermissionsException
709 * @throws ObjectNotFoundException if the user, file or destination was not
710 * found, with the exception message mentioning the precise problem
711 * @throws GSSIOException if there was an error while accessing the file contents
712 * @throws DuplicateNameException if the specified name already exists in
713 * the destination folder, as either a folder or file
714 * @throws QuotaExceededException
716 public void moveFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException, InsufficientPermissionsException, DuplicateNameException, GSSIOException, QuotaExceededException;
719 * move the provided file to the specified destination.
721 * @param userId the ID of the current user
722 * @param fileIds the IDs of the provided files
723 * @param destId the ID of the destination folder
724 * @throws InsufficientPermissionsException
725 * @throws ObjectNotFoundException if the user, file or destination was not
726 * found, with the exception message mentioning the precise problem
727 * @throws GSSIOException if there was an error while accessing the file contents
728 * @throws DuplicateNameException if the specified name already exists in
729 * the destination folder, as either a folder or file
730 * @throws QuotaExceededException
732 public void moveFiles(Long userId, List<Long> fileIds, Long destId)
733 throws InsufficientPermissionsException, ObjectNotFoundException,
734 DuplicateNameException, GSSIOException, QuotaExceededException;
737 * Returns a list of All deleted files of a user.
739 * @param userId the ID of the User
740 * * @return the list of deleted file header objects
741 * @throws ObjectNotFoundException if the user cannot be found
743 public List<FileHeader> getDeletedFiles(Long userId) throws ObjectNotFoundException;
746 * Returns a list of All deleted root folders of a user.
748 * @param userId the ID of the User
749 * * @return the list of deleted file header objects
750 * @throws ObjectNotFoundException if the user cannot be found
752 public List<Folder> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
755 * Empty Trash by deleting all marked as deleted files and folders
757 * @throws ObjectNotFoundException if something goes wrong in the delete process
758 * @throws InsufficientPermissionsException if something goes wrong in the delete process
760 public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
763 * Restores All Trashed Items by undeleting all marked as deleted files and folders
765 * @throws ObjectNotFoundException if something goes wrong in the delete process
766 * @throws InsufficientPermissionsException
768 public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
771 * Search the system for a user with the specified username.
772 * If no such user is found, the method returns null.
774 * @param username the username to search for
775 * @return the User object with the specified username
777 public User findUser(String username);
780 * Create a new user with the specified name, username and e-mail address.
782 * @param username the username of the new user
783 * @param name the name of the new user
784 * @param mail the e-mail of the new user
785 * @param idp the IdP of the new user
786 * @param idpid the IdP identifier of the new user
787 * @return the newly-created User object
788 * @throws DuplicateNameException if a user with the same username already exists
789 * @throws ObjectNotFoundException if no username was provided
791 public User createUser(String username, String name, String mail, String idp, String idpid, String homeOrg)
792 throws DuplicateNameException, ObjectNotFoundException;
795 * Updates the authentication token for the specified user.
797 * @param userId the ID of the user whose token should be updated
798 * @return the updated user
799 * @throws ObjectNotFoundException if the user could not be found
801 public User updateUserToken(Long userId) throws ObjectNotFoundException;
804 * Updates the policy acceptance flag for the specified user.
806 * @param userId the ID of the user whose flag should be updated
807 * @param isAccepted the new value of the flag
808 * @return the updated user
809 * @throws ObjectNotFoundException if the user could not be found
811 public User updateUserPolicyAcceptance(Long userId, boolean isAccepted) throws ObjectNotFoundException;
814 * Invalidates the authentication token for the specified user.
816 * @param userId the ID of the user whose token should be updated
817 * @throws ObjectNotFoundException if the user could not be found
819 public void invalidateUserToken(Long userId) throws ObjectNotFoundException;
822 * Retrieve folder user and group permissions
824 * @param userId the ID of the user whose token should be updated
825 * @param folderId the ID of the folder
826 * @return the Set of permissions from requested folder
827 * @throws ObjectNotFoundException if the user or folder could not be found
828 * @throws InsufficientPermissionsException
830 public Set<Permission> getFolderPermissions(Long userId, Long folderId)
831 throws ObjectNotFoundException, InsufficientPermissionsException;
834 * Retrieve file user and group permissions
836 * @param userId the ID of the user whose token should be updated
837 * @param fileId the ID of the folder
838 * @return the Set of permissions from requested folder
839 * @throws ObjectNotFoundException if the user or folder could not be found
840 * @throws InsufficientPermissionsException
842 public Set<Permission> getFilePermissions(Long userId, Long fileId)
843 throws ObjectNotFoundException, InsufficientPermissionsException;
846 * Returns a list of all shared root folders of a user.
848 * @param userId the ID of the User
849 * @return the list of shared root folders
850 * @throws ObjectNotFoundException if the user cannot be found
852 public List<Folder> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
855 * Returns a list of all shared files of a user that are not
856 * inside other shared folders.
858 * @param userId the ID of the User
859 * @return the list of shared files
860 * @throws ObjectNotFoundException if the user cannot be found
862 public List<FileHeader> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
865 * Returns a list of all shared files of a user.
867 * @param userId the ID of the User
868 * @return the list of shared files
869 * @throws ObjectNotFoundException if the user cannot be found
871 public List<FileHeader> getSharedFiles(Long userId) throws ObjectNotFoundException;
874 * Returns a list of all shared folders of a user.
876 * @param userId the ID of the User
877 * @return the list of shared folders
878 * @throws ObjectNotFoundException if the user cannot be found
880 public List<Folder> getSharedFolders(Long userId) throws ObjectNotFoundException;
883 * Returns a list of all shared root folders of a user that calling
884 * user has at least read permissions.
886 * @param ownerId the ID of the User
887 * @return the list of shared root folders
888 * @param callingUserId
890 * @throws ObjectNotFoundException if the user cannot be found
892 public List<Folder> getSharedRootFolders(Long ownerId, Long callingUserId)
893 throws ObjectNotFoundException;
896 * Returns a list of all shared files of a user that calling user has
897 * at least read permissions..
899 * @param ownerId the ID of the User
900 * @return the list of shared files
901 * @param callingUserId
902 * @throws ObjectNotFoundException if the user cannot be found
904 public List<FileHeader> getSharedFiles(Long ownerId, Long callingUserId)
905 throws ObjectNotFoundException;
908 * Remove a user member from a group
910 * @param userId the ID of the User owning the group
911 * @param groupId the ID of the requested group
912 * @param memberId the ID of the member to be removed
914 * @throws ObjectNotFoundException if the user or group was not found, with
915 * the exception message mentioning the precise problem
916 * @throws InsufficientPermissionsException
918 public void removeMemberFromGroup(Long userId, Long groupId, Long memberId)
919 throws ObjectNotFoundException, InsufficientPermissionsException;
922 * Retrieves the list of users sharing files to user identified by user id
924 * @return the List of users sharing files to user
925 * @throws ObjectNotFoundException
927 public List<User> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
934 * @return list of files that match query
935 * @throws ObjectNotFoundException if no user or query was specified
937 public List<FileHeader> searchFiles(Long userId, String query) throws ObjectNotFoundException;
940 * Creates a nonce for the specified user.
942 * @param userId the ID of the user
943 * @return the new nonce
944 * @throws ObjectNotFoundException if the user could not be found
946 public Nonce createNonce(Long userId) throws ObjectNotFoundException;
949 * Find the nonce object for the specified encoded nonce, that should be
950 * associated with the specified user.
952 * @param nonce the issued nonce in Base64 encoding
953 * @param userId the ID of the user for whom this nonce should have been issued
954 * @return the retrieved nonce object
955 * @throws ObjectNotFoundException if the nonce or user were not found
957 public Nonce getNonce(String nonce, Long userId) throws ObjectNotFoundException;
960 * Remove the specified nonce from the persistent store.
962 * @param id the ID of the nonce
963 * @throws ObjectNotFoundException if the specified nonce could not be found
965 public void removeNonce(Long id) throws ObjectNotFoundException;
968 * Activate the supplied nonce for the specified user.
970 * @param userId the ID of the user
971 * @param nonce the nonce to activate
972 * @param nonceExpiryDate the expiry date of the nonce
973 * @throws ObjectNotFoundException
975 public void activateUserNonce(Long userId, String nonce, Date nonceExpiryDate) throws ObjectNotFoundException;
978 * Retrieves user statistics.
980 * @param userId the ID of the user
981 * @return the statistics
982 * @throws ObjectNotFoundException
985 public StatsDTO getUserStatistics(Long userId) throws ObjectNotFoundException;
988 * Restore the file contents to the specified version.
990 * @param userId the ID of the user
991 * @param fileId the ID of the file
992 * @param version the version number of the desired file contents
993 * @throws ObjectNotFoundException if the user or file was not
994 * found, with the exception message mentioning the precise problem
995 * @throws InsufficientPermissionsException if the user does not have the
996 * appropriate privileges
997 * @throws QuotaExceededException if the user quota limit would be exceeded
998 * @throws GSSIOException if there was an error while accessing the file contents
1000 public void restoreVersion(Long userId, Long fileId, int version)
1001 throws ObjectNotFoundException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
1004 * Removes all old file versions for specified file keeping only the current revision
1006 * @param userId the ID of the user
1007 * @param fileId the ID of the file
1009 * @throws ObjectNotFoundException
1010 * @throws InsufficientPermissionsException
1013 public void removeOldVersions(Long userId, Long fileId)
1014 throws ObjectNotFoundException, InsufficientPermissionsException;
1017 * It is used by the Solr mbean to rebuild the index.
1019 public String rebuildSolrIndex();
1022 * It is used by the Solr mbean to refresh the index. It does not delete anything just re-add everything in the index
1024 public String refreshSolrIndex();
1027 * Creates a new file with the specified owner, parent folder and name. The
1028 * new file has the same permissions as its parent folder. The file contents
1029 * are already uploaded outside of externalAPI and the uploaded file is used as a parameter.
1031 * @param userId the ID of the current user
1032 * @param folderId the ID of the parent folder
1033 * @param name the name of the new file
1034 * @param mimeType the MIME type of the file
1035 * @param fileSize the uploaded file size
1036 * @param filePath the uploaded file full path
1037 * @return The FileHeader created
1038 * @throws DuplicateNameException if the specified name already exists in
1039 * the parent folder, as either a folder or file
1040 * @throws ObjectNotFoundException if the user or parent folder was not
1041 * found, with the exception message mentioning the precise
1043 * @throws GSSIOException if there was an error while storing the file contents
1044 * @throws InsufficientPermissionsException
1045 * @throws QuotaExceededException
1047 public FileHeader createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
1048 throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
1049 InsufficientPermissionsException, QuotaExceededException;
1052 * Create a new FileBody with the supplied uploaded file as contents and make it the current body
1055 * @param userId the ID of the current user
1056 * @param fileId the ID of the file header object
1057 * @param mimeType the content type of the file
1058 * @param fileSize the uploaded file size
1059 * @param filePath the uploaded file full path
1060 * @return The FileHeader updated
1061 * @throws ObjectNotFoundException if the user or file was not found, with
1062 * the exception message mentioning the precise problem
1063 * @throws GSSIOException when an IO exception occurs
1064 * @throws InsufficientPermissionsException
1065 * @throws QuotaExceededException
1067 public FileHeader updateFileContents(Long userId, Long fileId, String mimeType,
1068 long fileSize, String filePath) throws ObjectNotFoundException, GSSIOException,
1069 InsufficientPermissionsException, QuotaExceededException;
1072 * Create a file based on inputstream without using transaction.
1077 * @throws IOException
1078 * @throws ObjectNotFoundException
1080 @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
1081 public File uploadFile(InputStream stream, Long userId)
1082 throws IOException, ObjectNotFoundException;
1084 public void createFileUploadProgress(Long userId, String filename,
1085 Long bytesTransfered, Long fileSize) throws ObjectNotFoundException;
1087 public FileUploadStatus getFileUploadStatus(Long userId, String fileName);
1089 public void removeFileUploadProgress(Long userId, String filename)
1090 throws ObjectNotFoundException;
1093 * Fetch the file body with the specified version number.
1095 * @param userId the ID of the current user
1096 * @param fileId the ID of the file header
1097 * @param version the version number
1098 * @return the file body
1099 * @throws ObjectNotFoundException if the user file or version
1101 * @throws InsufficientPermissionsException if the user does not
1102 * have enough privileges for reading this file
1104 public FileBody getFileVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException;
1107 * Search the system for a user with the specified email address.
1108 * If no such user is found, the method returns null.
1110 public User findUserByEmail(String email);
1113 * Update the user with the values from the supplied object.
1115 public void updateUser(User user);
1118 * Update accounting information for given user.
1120 * @param user The user to update
1121 * @param date Date of transaction
1122 * @param bandwidthDiff Bandwidth used; positive for addition,
1123 * negative for subtraction (e.g. to rollback)
1125 public void updateAccounting(User user, Date date, long bandwidthDiff);
1128 * Check if the user with the specified ID has permission to read the
1129 * folder with the supplied ID.
1131 public boolean canReadFolder(Long userId, Long folderId) throws ObjectNotFoundException;
1134 * Reset WebDAV password for given user.
1137 * @return the new password
1138 * @throws ObjectNotFoundException
1140 public String resetWebDAVPassword(Long userId) throws ObjectNotFoundException;
1143 * Find the invite for the specified invitation code.
1145 * @param code the invitation code
1146 * @return the Invitation or null if not found
1148 public Invitation findInvite(String code);
1151 * Create a new user in the connected IdP.
1153 * @param username the username of the new user
1154 * @param firstname the first name of the new user
1155 * @param lastname the last name of the new user
1156 * @param email the e-mail of the new user
1157 * @param password the password of the new user
1159 public void createLdapUser(String username, String firstname, String lastname, String email, String password);
1162 * Retrieves the available user classes.
1164 public List<UserClass> getUserClasses();
1167 * Upgrades the user class to the default "coupon bearer" class and marks
1168 * the provided coupon as used.
1170 * @param username the username of the user
1171 * @param code the coupon code
1172 * @return the new user class
1173 * @throws InvitationUsedException when trying to reuse an already used invitation
1174 * @throws ObjectNotFoundException if the user was not found
1176 public UserClass upgradeUserClass(String username, String code)
1177 throws ObjectNotFoundException, InvitationUsedException;
1180 * Retrieve the user class for coupon-bearing users.
1182 public UserClass getCouponUserClass();
1185 * Delete the actual file in the specified file system path.
1187 public void deleteActualFile(String path);
1190 * Update the userLogin with the values from the supplied object.
1192 public void addUserLogin(UserLogin userLogin);
1195 * Retrieves the user's current session login and the user's last login
1197 * @return a list of last two user logins
1198 * @throws ObjectNotFoundException
1200 public List<UserLogin> getLastUserLogins(Long userId) throws ObjectNotFoundException;
1203 * Posts the file specified by id to solr indexing server
1207 public void postFileToSolr(Long id) throws IOException, SolrServerException, ObjectNotFoundException;
1211 * @throws ObjectNotFoundException
1213 public Folder expandFolder(Folder folder) throws ObjectNotFoundException;
1218 * @throws ObjectNotFoundException
1220 FileHeader expandFile(FileHeader folder) throws ObjectNotFoundException;
1225 * @throws ObjectNotFoundException
1227 Group expandGroup(Group folder) throws ObjectNotFoundException;
1233 User getUserByUserName(String username);
1239 FileLock saveOrUpdateLock(FileLock lock);
1244 void removeLock(FileLock lock);
1250 FileLock getLockByToken(String tokenId);
1256 FileLock getLockById(String id);
1263 * @throws DuplicateNameException
1264 * @throws ObjectNotFoundException
1265 * @throws GSSIOException
1266 * @throws InsufficientPermissionsException
1267 * @throws QuotaExceededException
1269 FileHeader createEmptyFile(Long userId, Long folderId, String name) throws DuplicateNameException, ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
1275 WebDavNonce saveOrUpdateWebDavNonce(WebDavNonce nonce);
1280 void removeWebDavNonce(WebDavNonce nonce);
1286 WebDavNonce getWebDavNonce(String tokenId);