2 * Copyright 2007, 2008, 2009, 2010 Electronic Business Systems Ltd.
4 * This file is part of GSS.
6 * GSS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
19 package gr.ebs.gss.server.ejb;
21 import gr.ebs.gss.client.exceptions.DuplicateNameException;
22 import gr.ebs.gss.client.exceptions.GSSIOException;
23 import gr.ebs.gss.client.exceptions.InsufficientPermissionsException;
24 import gr.ebs.gss.client.exceptions.InvitationUsedException;
25 import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
26 import gr.ebs.gss.client.exceptions.QuotaExceededException;
27 import gr.ebs.gss.server.domain.FileHeader;
28 import gr.ebs.gss.server.domain.FileUploadStatus;
29 import gr.ebs.gss.server.domain.Invitation;
30 import gr.ebs.gss.server.domain.Nonce;
31 import gr.ebs.gss.server.domain.User;
32 import gr.ebs.gss.server.domain.UserClass;
33 import gr.ebs.gss.server.domain.UserLogin;
34 import gr.ebs.gss.server.domain.dto.FileBodyDTO;
35 import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
36 import gr.ebs.gss.server.domain.dto.FolderDTO;
37 import gr.ebs.gss.server.domain.dto.GroupDTO;
38 import gr.ebs.gss.server.domain.dto.PermissionDTO;
39 import gr.ebs.gss.server.domain.dto.StatsDTO;
40 import gr.ebs.gss.server.domain.dto.UserDTO;
43 import java.io.IOException;
44 import java.io.InputStream;
45 import java.util.Date;
46 import java.util.List;
49 import javax.ejb.Local;
50 import javax.ejb.TransactionAttribute;
51 import javax.ejb.TransactionAttributeType;
53 import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
56 * The External API for GSS clients.
61 public interface ExternalAPI {
64 * Retrieves the root folder for the specified user. The caller must ensure
65 * that the userId exists.
69 * @throws ObjectNotFoundException if no Folder or user was found
71 public FolderDTO getRootFolder(Long userId) throws ObjectNotFoundException;
74 * Retrieve the folder with the specified ID.
76 * @param userId the ID of the current user
77 * @param folderId the ID of the folder to retrieve
78 * @return the folder found
79 * @throws ObjectNotFoundException if the folder or the user was not found
80 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
82 public FolderDTO getFolder(Long userId, Long folderId) throws ObjectNotFoundException,
83 InsufficientPermissionsException;
86 * Returns the user with the specified ID.
88 * @param userId The ID of the User to be found
89 * @return The User object
90 * @throws ObjectNotFoundException if the user cannot be found
92 public User getUser(Long userId) throws ObjectNotFoundException;
95 * Returns the user with the specified ID.
97 * @param userId The ID of the User to be found
98 * @return The User object
99 * @throws ObjectNotFoundException if the user cannot be found
101 public UserDTO getUserDTO(Long userId) throws ObjectNotFoundException;
104 * Returns the group with the specified ID.
106 * @param groupId The ID of the Group to be found
107 * @return The Group object
108 * @throws ObjectNotFoundException if the group cannot be found
110 public GroupDTO getGroup(Long groupId) throws ObjectNotFoundException;
113 * Returns the group with the specified name that belongs to the
116 * @param userId the ID of the user
117 * @param name the name of the group
118 * @return The Group object
119 * @throws ObjectNotFoundException if the group cannot be found
121 public GroupDTO getGroup(Long userId, String name) throws ObjectNotFoundException;
124 * Retrieve the list of groups for a particular user.
126 * @param userId the ID of the User
127 * @return a List of Groups that belong to the specified User
128 * @throws ObjectNotFoundException if the user was not found
130 public List<GroupDTO> getGroups(Long userId) throws ObjectNotFoundException;
133 * Returns a list of files contained in the folder specified by its id.
135 * @param userId the ID of the User
136 * @param folderId the ID of the folder containing the files
137 * @param ignoreDeleted
138 * @return the list of file header objects
139 * @throws ObjectNotFoundException if the user or the folder cannot be found
140 * @throws InsufficientPermissionsException
142 public List<FileHeaderDTO> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException,
143 InsufficientPermissionsException;
146 * Returns a list of users for the specified group
148 * @param userId the ID of the User
149 * @param groupId the ID of the requested group
150 * @return List<UserDTO>
151 * @throws ObjectNotFoundException if the user or group was not found, with
152 * the exception message mentioning the precise problem
154 public List<UserDTO> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
157 * Returns a list of users matching the specified username
159 * @param username the username of the User
160 * @return List<UserDTO>
162 public List<UserDTO> getUsersByUserNameLike(String username);
165 * Creates a new folder with the specified owner, parent folder and name.
166 * New folder has the same permissions as its parent
171 * @return the new folder
172 * @throws DuplicateNameException if the specified name already exists in
173 * the parent folder, as either a folder or file
174 * @throws ObjectNotFoundException if the user or parent folder was not
175 * found, with the exception message mentioning the precise
177 * @throws InsufficientPermissionsException
179 public FolderDTO createFolder(Long userId, Long parentId, String name) throws DuplicateNameException,
180 ObjectNotFoundException, InsufficientPermissionsException;
183 * Deletes the specified folder, if the specified user has the appropriate
186 * @param userId the ID of the current user
187 * @param folderId the ID of the folder to delete
188 * @throws InsufficientPermissionsException if the user does not have the
189 * appropriate privileges
190 * @throws ObjectNotFoundException if the user or folder was not found, with
191 * the exception message mentioning the precise problem
193 public void deleteFolder(Long userId, Long folderId)
194 throws InsufficientPermissionsException, ObjectNotFoundException;
197 * Retrieve the subfolders of the specified folder.
199 * @param userId the ID of the current user
200 * @param folderId the ID of the folder to retrieve
201 * @return the list of subfolders found
202 * @throws ObjectNotFoundException if the folder or user was not found
203 * @throws InsufficientPermissionsException
205 public List<FolderDTO> getSubfolders(Long userId, Long folderId)
206 throws ObjectNotFoundException, InsufficientPermissionsException;
209 * Retrieve the folder with the specified ID with subfolders.
211 * @param userId the ID of the current user
212 * @param folderId the ID of the folder to retrieve
213 * @return the folder found
214 * @throws ObjectNotFoundException if the folder or the user was not found
215 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
217 public FolderDTO getFolderWithSubfolders(Long userId, Long folderId)
218 throws ObjectNotFoundException, InsufficientPermissionsException;
221 * Retrieve the folder with the specified ID with subfolders.
223 * @param userId the ID of the current user
224 * @param callingUserId the ID of the user requesting this operation
225 * @param folderId the ID of the folder to retrieve
226 * @return the folder found
227 * @throws ObjectNotFoundException if the folder or the user was not found
228 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
230 public FolderDTO getFolderWithSubfolders(Long userId, Long callingUserId, Long folderId)
231 throws ObjectNotFoundException, InsufficientPermissionsException;
233 * Retrieve the subfolders of the specified folder that are shared to others.
235 * @param userId the ID of the current user
236 * @param folderId the ID of the folder to retrieve
237 * @return the list of subfolders found
238 * @throws ObjectNotFoundException if the folder or user was not found
240 public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
243 * Retrieve the subfolders of the specified folder that are shared to others.
245 * @param userId the ID of the current user
246 * @param callingUserId the id of the user requesting this operation
247 * @param folderId the ID of the folder to retrieve
248 * @return the list of subfolders found
249 * @throws ObjectNotFoundException if the folder or user was not found
251 public List<FolderDTO> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException;
253 * Modifies the specified folder if the specified user has the appropriate
256 * @param userId the ID of the current user
257 * @param folderId the ID of the folder to retrieve
261 * @return the updated folder
262 * @throws InsufficientPermissionsException if the user does not have the
263 * appropriate privileges
264 * @throws ObjectNotFoundException if the user or folder was not found, with
265 * the exception message mentioning the precise problem
266 * @throws DuplicateNameException if the specified name already exists in
267 * the parent folder, as either a folder or file
269 public FolderDTO updateFolder(Long userId, Long folderId, String folderName,
271 Set<PermissionDTO> permissions)
272 throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
275 * Adds a user to the specified group
277 * @param userId the ID of the current user
278 * @param groupId the id of the new group
279 * @param userToAddId the id of the user to add
280 * @throws DuplicateNameException if the user already exists in group
281 * @throws ObjectNotFoundException if the user or group was not found, with
282 * the exception message mentioning the precise problem
283 * @throws InsufficientPermissionsException
285 public void addUserToGroup(Long userId, Long groupId, Long userToAddId)
286 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
289 * Creates a new group with the specified owner and name.
291 * @param userId the ID of the current user
292 * @param name the name of the new group
293 * @throws DuplicateNameException if the new group name already exists
294 * @throws ObjectNotFoundException if the user or group was not found, with
295 * the exception message mentioning the precise problem
297 public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
300 * Deletes the specified group in the specified user's namespace.
302 * @param userId the ID of the current user
303 * @param groupId the ID of the group to delete
304 * @throws ObjectNotFoundException if the user or group was not found, with
305 * the exception message mentioning the precise problem
306 * @throws InsufficientPermissionsException
308 public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
311 * Creates a new file with the specified owner, parent folder and name. The
312 * new file has the same permissions as its parent folder. The file contents
313 * are read from the input stream to a new File object.
315 * @param userId the ID of the current user
316 * @param folderId the ID of the parent folder
317 * @param name the name of the new file
318 * @param mimeType the MIME type of the file
319 * @param stream the input stream with the file contents
320 * @return The FileHeaderDTO created
321 * @throws DuplicateNameException if the specified name already exists in
322 * the parent folder, as either a folder or file
323 * @throws ObjectNotFoundException if the user or parent folder was not
324 * found, with the exception message mentioning the precise
326 * @throws GSSIOException if there was an error while storing the file contents
327 * @throws InsufficientPermissionsException
328 * @throws QuotaExceededException
330 public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType,
331 InputStream stream) throws DuplicateNameException, ObjectNotFoundException,
332 GSSIOException, InsufficientPermissionsException, QuotaExceededException;
335 * Deletes the specified file, provided the specified user has
336 * the necessary permissions.
338 * @param userId the ID of the current user
339 * @param fileId the ID of the file to delete
340 * @throws ObjectNotFoundException if the user or file was not found, with
341 * the exception message mentioning the precise problem
342 * @throws InsufficientPermissionsException if the user does not have the
343 * appropriate privileges
345 public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
348 * Creates a new tag for the specified user and file.
350 * @param userId the creator of the tag
351 * @param fileHeaderId the file that is tagged
353 * @throws ObjectNotFoundException if the user or the file was not found
355 public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
358 * Returns all tags defined by the specified user
361 * @return Set<String>
362 * @throws ObjectNotFoundException if the user was null
364 public Set<String> getUserTags(final Long userId) throws ObjectNotFoundException;
367 * Updates the attributes of the specified file.
372 * @param tagSet a String that contains tags separated by comma
373 * @param modificationDate the modification date
374 * @param versioned the new value of the versioned flag
377 * @throws DuplicateNameException
378 * @throws ObjectNotFoundException
379 * @throws InsufficientPermissionsException
381 public void updateFile(Long userId, Long fileId, String name, String tagSet,
382 Date modificationDate, Boolean versioned, Boolean readForAll,
383 Set<PermissionDTO> permissions)
384 throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
387 * Retrieve the contents of the current body for the file
388 * with the specified FileHeader ID. The file contents
389 * are provided as an InputStream from which the caller can
390 * retrieve the raw bytes.
392 * @param userId the ID of the current user
393 * @param fileId the ID of the file to retrieve
394 * @return an InputStream from the current file body contents
395 * @throws ObjectNotFoundException if the file or the user was not found
396 * @throws InsufficientPermissionsException if the user does not have the
397 * appropriate privileges
399 public InputStream getFileContents(Long userId, Long fileId)
400 throws ObjectNotFoundException, InsufficientPermissionsException;
403 * Retrieve the contents of the body identified by bodyId for the file
404 * with the specified FileHeader ID. The file contents
405 * are provided as an InputStream from which the caller can
406 * retrieve the raw bytes.
408 * @param userId the ID of the current user
409 * @param fileId the ID of the file to retrieve
410 * @param bodyId the body ID
411 * @return an InputStream from the current file body contents
412 * @throws ObjectNotFoundException if the file or the user was not found
413 * @throws InsufficientPermissionsException if the user does not have the
414 * appropriate privileges
416 public InputStream getFileContents(Long userId, Long fileId, Long bodyId)
417 throws ObjectNotFoundException, InsufficientPermissionsException;
420 * Retrieve the file with the specified ID.
422 * @param userId the ID of the current user
423 * @param fileId the ID of the file to retrieve
424 * @return the file found
425 * @throws ObjectNotFoundException if the file or the user was not found, with
426 * the exception message mentioning the precise problem
427 * @throws InsufficientPermissionsException
429 public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException,
430 InsufficientPermissionsException;
433 * Retrieve the filebody with the specified ID.
435 * @param userId the ID of the current user
436 * @param fileId the ID of the file to retrieve
437 * @param bodyId the ID of the body
438 * @return the file found
439 * @throws ObjectNotFoundException if the file or the user was not found, with
440 * the exception message mentioning the precise problem
441 * @throws InsufficientPermissionsException
443 public FileBodyDTO getFileBody(Long userId, Long fileId, Long bodyId)
444 throws ObjectNotFoundException, InsufficientPermissionsException;
447 * Get the resource (file or folder) at the specified path in
448 * the specified user's namespace. The returned object will be of type
449 * FileHeaderDTO or FolderDTO.<p><strong>Note:</strong> this method does not
450 * receive the current user as a parameter, therefore it is unable to perform
451 * the necessary permission checks and should <strong>NOT</strong> be directly
452 * exposed to remote clients. It is the caller's responsibility to verify that
453 * the calling user has the required privileges for performing any subsequent
454 * action on the resource through one of the other ExternalAPI methods.
456 * @param ownerId the ID of the user owning the namespace
457 * @param path the absolute path in the user's namespace
458 * @param ignoreDeleted if true, resources that have been moved to the trash
460 * @throws ObjectNotFoundException if the user or resource was not found, with
461 * the exception message mentioning the precise problem
462 * @return the resource found
464 public Object getResourceAtPath(Long ownerId, String path, boolean ignoreDeleted)
465 throws ObjectNotFoundException;
468 * Copy the provided file to the specified destination.
470 * @param userId the ID of the current user
471 * @param fileId the IF of the provided file
472 * @param dest the path of the new resource
473 * @throws ObjectNotFoundException if the user, file or destination was not
474 * found, with the exception message mentioning the precise problem
475 * @throws DuplicateNameException if the specified name already exists in
476 * the destination folder, as either a folder or file
477 * @throws GSSIOException if there was an error while accessing the file contents
478 * @throws InsufficientPermissionsException
479 * @throws QuotaExceededException
481 public void copyFile(Long userId, Long fileId, String dest) throws ObjectNotFoundException,
482 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
485 * Copy the provided file to the specified destination.
487 * @param userId the ID of the current user
488 * @param ownerId the ID of the owner of the destination namespace
489 * @param fileId the IF of the provided file
490 * @param dest the path of the new resource
491 * @throws ObjectNotFoundException if the user, file or destination was not
492 * found, with the exception message mentioning the precise problem
493 * @throws DuplicateNameException if the specified name already exists in
494 * the destination folder, as either a folder or file
495 * @throws GSSIOException if there was an error while accessing the file contents
496 * @throws InsufficientPermissionsException
497 * @throws QuotaExceededException
499 public void copyFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException,
500 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
503 * Copy the provided file to the specified destination.
505 * @param userId the ID of the current user
506 * @param fileIds the IDs of the provided files
507 * @param destId the ID of the destination folder
508 * @throws ObjectNotFoundException if the user, file or destination was not
509 * found, with the exception message mentioning the precise problem
510 * @throws GSSIOException if there was an error while accessing the file contents
511 * @throws DuplicateNameException if the specified name already exists in
512 * the destination folder, as either a folder or file
513 * @throws InsufficientPermissionsException
514 * @throws QuotaExceededException
516 public void copyFiles(Long userId, List<Long> fileIds, Long destId)
517 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
518 InsufficientPermissionsException, QuotaExceededException;
521 * Copy the provided file to the specified destination.
523 * @param userId the ID of the current user
524 * @param fileId the IF of the provided file
525 * @param destId the ID of the destination folder
526 * @param destName the name of the new file
527 * @throws ObjectNotFoundException if the user, file or destination was not
528 * found, with the exception message mentioning the precise problem
529 * @throws GSSIOException if there was an error while accessing the file contents
530 * @throws DuplicateNameException if the specified name already exists in
531 * the destination folder, as either a folder or file
532 * @throws InsufficientPermissionsException
533 * @throws QuotaExceededException
535 public void copyFile(Long userId, Long fileId, Long destId, String destName)
536 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
537 InsufficientPermissionsException, QuotaExceededException;
540 * Copy the provided folder to the specified destination.
542 * @param userId the ID of the current user
543 * @param folderId the IF of the provided folder
544 * @param dest the path of the new folder
545 * @throws ObjectNotFoundException if the user, folder or destination was not
546 * found, with the exception message mentioning the precise problem
547 * @throws DuplicateNameException if the specified name already exists in
548 * the destination folder, as either a folder or file
549 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
550 * appropriate privileges
552 public void copyFolder(Long userId, Long folderId, String dest) throws ObjectNotFoundException,
553 DuplicateNameException, InsufficientPermissionsException;
556 * Copy the provided folder to the specified destination.
558 * @param userId the ID of the current user
559 * @param folderId the IF of the provided folder
560 * @param destId the ID of the destination folder
561 * @param destName the name of the new folder
562 * @throws ObjectNotFoundException if the user, folder or destination was not
563 * found, with the exception message mentioning the precise problem
564 * @throws DuplicateNameException if the specified name already exists in
565 * the destination folder, as either a folder or file
566 * @throws InsufficientPermissionsException InsufficientPermissionsException
567 * if the user does not have the appropriate privileges
569 public void copyFolder(Long userId, Long folderId, Long destId, String destName)
570 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
573 * Copy the provided folder and all its subfolders and files to the specified destination.
575 * @param userId the ID of the current user
576 * @param ownerId the ID of the owner of the destination namespace
577 * @param folderId the IF of the provided folder
578 * @param dest the path of the new folder
579 * @throws ObjectNotFoundException if the user, folder or destination was not
580 * found, with the exception message mentioning the precise problem
581 * @throws DuplicateNameException if the specified name already exists in
582 * the destination folder, as either a folder or file
583 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
584 * appropriate privileges
585 * @throws QuotaExceededException if the user quota limit would be exceeded
586 * @throws GSSIOException if there was an error while accessing the file contents
588 public void copyFolderStructureToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
589 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
592 * Copy the provided folder and all its subfolders and files to the specified destination.
594 * @param userId the ID of the current user
595 * @param folderId the IF of the provided folder
596 * @param destId the ID of the destination folder
597 * @param destName the name of the new folder
598 * @throws ObjectNotFoundException if the user, folder or destination was not
599 * found, with the exception message mentioning the precise problem
600 * @throws DuplicateNameException if the specified name already exists in
601 * the destination folder, as either a folder or file
602 * @throws InsufficientPermissionsException InsufficientPermissionsException
603 * if the user does not have the appropriate privileges
604 * @throws GSSIOException if there was an error while accessing the file contents
605 * @throws QuotaExceededException if the user quota limit would be exceeded
607 public void copyFolderStructure(Long userId, Long folderId, Long destId, String destName)
608 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
609 GSSIOException, QuotaExceededException;
612 * Marks the specified file as deleted in the specified user's namespace.
614 * @param userId the ID of the current user
615 * @param fileId the ID of the file to delete
616 * @throws ObjectNotFoundException if the user or file was not found, with
617 * the exception message mentioning the precise problem
618 * @throws InsufficientPermissionsException if the user does not have the
619 * appropriate privileges
621 public void moveFileToTrash(Long userId, Long fileId) throws ObjectNotFoundException,
622 InsufficientPermissionsException;
625 * Marks the specified deleted file as undeleted in the specified user's namespace.
627 * @param userId the ID of the current user
628 * @param fileId the ID of the file to undelete
629 * @throws ObjectNotFoundException if the user or file was not found, with
630 * the exception message mentioning the precise problem
631 * @throws InsufficientPermissionsException if the user does not have the
632 * appropriate privileges
635 public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
638 * Marks the specified folder as deleted in the specified user's namespace.
640 * @param userId the ID of the current user
641 * @param folderId the ID of the folder to delete
642 * @throws ObjectNotFoundException if the user or file was not found, with
643 * the exception message mentioning the precise problem
644 * @throws InsufficientPermissionsException if the user does not have the
645 * appropriate privileges
647 public void moveFolderToTrash(Long userId, Long folderId)
648 throws ObjectNotFoundException, InsufficientPermissionsException;
651 * Marks the specified deleted folder as undeleted in the specified user's namespace.
653 * @param userId the ID of the current user
654 * @param folderId the ID of the folder to undelete
655 * @throws ObjectNotFoundException if the user or file was not found, with
656 * the exception message mentioning the precise problem
657 * @throws InsufficientPermissionsException if the user does not have the
658 * appropriate privileges
661 public void removeFolderFromTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
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 folderId the IF of the provided folder
668 * @param destId the ID of the destination folder
669 * @param destName the name 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 if the user does not have the
675 * appropriate privileges
676 * @throws GSSIOException
677 * @throws QuotaExceededException
679 public void moveFolder(Long userId, Long folderId, Long destId, String destName)
680 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
681 GSSIOException, QuotaExceededException;
684 * Move the provided folder and all its subfolders and files to the specified destination.
686 * @param userId the ID of the current user
687 * @param ownerId the owner of the destination namespace
688 * @param folderId the IF of the provided folder
689 * @param dest the path of the new folder
690 * @throws ObjectNotFoundException if the user, folder or destination was not
691 * found, with the exception message mentioning the precise problem
692 * @throws DuplicateNameException if the specified name already exists in
693 * the destination folder, as either a folder or file
694 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
695 * appropriate privileges
696 * @throws GSSIOException
697 * @throws QuotaExceededException
699 public void moveFolderToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
700 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
703 * Move the provided file to the specified destination.
705 * @param userId the ID of the current user
706 * @param fileId the IF of the provided file
707 * @param destId the ID of the destination folder
708 * @param destName the name of the new file
709 * @throws InsufficientPermissionsException
710 * @throws ObjectNotFoundException if the user, file or destination was not
711 * found, with the exception message mentioning the precise problem
712 * @throws GSSIOException if there was an error while accessing the file contents
713 * @throws DuplicateNameException if the specified name already exists in
714 * the destination folder, as either a folder or file
715 * @throws QuotaExceededException
717 public void moveFile(Long userId, Long fileId, Long destId, String destName)
718 throws InsufficientPermissionsException, ObjectNotFoundException,
719 DuplicateNameException, GSSIOException, QuotaExceededException;
722 * Move the provided file to the specified destination.
724 * @param userId the ID of the current user
725 * @param ownerId the owner of the destination namespace
726 * @param fileId the IF of the provided file
727 * @param dest the path of the new file
728 * @throws InsufficientPermissionsException
729 * @throws ObjectNotFoundException if the user, file or destination was not
730 * found, with the exception message mentioning the precise problem
731 * @throws GSSIOException if there was an error while accessing the file contents
732 * @throws DuplicateNameException if the specified name already exists in
733 * the destination folder, as either a folder or file
734 * @throws QuotaExceededException
736 public void moveFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException, InsufficientPermissionsException, DuplicateNameException, GSSIOException, QuotaExceededException;
739 * move the provided file to the specified destination.
741 * @param userId the ID of the current user
742 * @param fileIds the IDs of the provided files
743 * @param destId the ID of the destination folder
744 * @throws InsufficientPermissionsException
745 * @throws ObjectNotFoundException if the user, file or destination was not
746 * found, with the exception message mentioning the precise problem
747 * @throws GSSIOException if there was an error while accessing the file contents
748 * @throws DuplicateNameException if the specified name already exists in
749 * the destination folder, as either a folder or file
750 * @throws QuotaExceededException
752 public void moveFiles(Long userId, List<Long> fileIds, Long destId)
753 throws InsufficientPermissionsException, ObjectNotFoundException,
754 DuplicateNameException, GSSIOException, QuotaExceededException;
757 * Returns a list of All deleted files of a user.
759 * @param userId the ID of the User
760 * * @return the list of deleted file header objects
761 * @throws ObjectNotFoundException if the user cannot be found
763 public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException;
766 * Returns a list of All deleted root folders of a user.
768 * @param userId the ID of the User
769 * * @return the list of deleted file header objects
770 * @throws ObjectNotFoundException if the user cannot be found
772 public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
775 * Empty Trash by deleting all marked as deleted files and folders
777 * @throws ObjectNotFoundException if something goes wrong in the delete process
778 * @throws InsufficientPermissionsException if something goes wrong in the delete process
780 public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
783 * Restores All Trashed Items by undeleting all marked as deleted files and folders
785 * @throws ObjectNotFoundException if something goes wrong in the delete process
786 * @throws InsufficientPermissionsException
788 public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
791 * Search the system for a user with the specified username.
792 * If no such user is found, the method returns null.
794 * @param username the username to search for
795 * @return the User object with the specified username
797 public User findUser(String username);
800 * Create a new user with the specified name, username and e-mail address.
802 * @param username the username of the new user
803 * @param name the name of the new user
804 * @param mail the e-mail of the new user
805 * @param idp the IdP of the new user
806 * @param idpid the IdP identifier of the new user
807 * @return the newly-created User object
808 * @throws DuplicateNameException if a user with the same username already exists
809 * @throws ObjectNotFoundException if no username was provided
811 public User createUser(String username, String name, String mail, String idp, String idpid)
812 throws DuplicateNameException, ObjectNotFoundException;
815 * Updates the authentication token for the specified user.
817 * @param userId the ID of the user whose token should be updated
818 * @return the updated user
819 * @throws ObjectNotFoundException if the user could not be found
821 public User updateUserToken(Long userId) throws ObjectNotFoundException;
824 * Updates the policy acceptance flag for the specified user.
826 * @param userId the ID of the user whose flag should be updated
827 * @param isAccepted the new value of the flag
828 * @return the updated user
829 * @throws ObjectNotFoundException if the user could not be found
831 public User updateUserPolicyAcceptance(Long userId, boolean isAccepted) throws ObjectNotFoundException;
834 * Invalidates the authentication token for the specified user.
836 * @param userId the ID of the user whose token should be updated
837 * @throws ObjectNotFoundException if the user could not be found
839 public void invalidateUserToken(Long userId) throws ObjectNotFoundException;
842 * Retrieve folder user and group permissions
844 * @param userId the ID of the user whose token should be updated
845 * @param folderId the ID of the folder
846 * @return the Set of permissions from requested folder
847 * @throws ObjectNotFoundException if the user or folder could not be found
848 * @throws InsufficientPermissionsException
850 public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId)
851 throws ObjectNotFoundException, InsufficientPermissionsException;
854 * Retrieve file user and group permissions
856 * @param userId the ID of the user whose token should be updated
857 * @param fileId the ID of the folder
858 * @return the Set of permissions from requested folder
859 * @throws ObjectNotFoundException if the user or folder could not be found
860 * @throws InsufficientPermissionsException
862 public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId)
863 throws ObjectNotFoundException, InsufficientPermissionsException;
866 * Returns a list of all shared root folders of a user.
868 * @param userId the ID of the User
869 * @return the list of shared root folders
870 * @throws ObjectNotFoundException if the user cannot be found
872 public List<FolderDTO> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
875 * Returns a list of all shared files of a user that are not
876 * inside other shared folders.
878 * @param userId the ID of the User
879 * @return the list of shared files
880 * @throws ObjectNotFoundException if the user cannot be found
882 public List<FileHeaderDTO> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
885 * Returns a list of all shared files of a user.
887 * @param userId the ID of the User
888 * @return the list of shared files
889 * @throws ObjectNotFoundException if the user cannot be found
891 public List<FileHeaderDTO> getSharedFiles(Long userId) throws ObjectNotFoundException;
894 * Returns a list of all shared folders of a user.
896 * @param userId the ID of the User
897 * @return the list of shared folders
898 * @throws ObjectNotFoundException if the user cannot be found
900 public List<FolderDTO> getSharedFolders(Long userId) throws ObjectNotFoundException;
903 * Returns a list of all shared root folders of a user that calling
904 * user has at least read permissions.
906 * @param ownerId the ID of the User
907 * @return the list of shared root folders
908 * @param callingUserId
910 * @throws ObjectNotFoundException if the user cannot be found
912 public List<FolderDTO> getSharedRootFolders(Long ownerId, Long callingUserId)
913 throws ObjectNotFoundException;
916 * Returns a list of all shared files of a user that calling user has
917 * at least read permissions..
919 * @param ownerId the ID of the User
920 * @return the list of shared files
921 * @param callingUserId
922 * @throws ObjectNotFoundException if the user cannot be found
924 public List<FileHeaderDTO> getSharedFiles(Long ownerId, Long callingUserId)
925 throws ObjectNotFoundException;
928 * Remove a user member from a group
930 * @param userId the ID of the User owning the group
931 * @param groupId the ID of the requested group
932 * @param memberId the ID of the member to be removed
934 * @throws ObjectNotFoundException if the user or group was not found, with
935 * the exception message mentioning the precise problem
936 * @throws InsufficientPermissionsException
938 public void removeMemberFromGroup(Long userId, Long groupId, Long memberId)
939 throws ObjectNotFoundException, InsufficientPermissionsException;
942 * Retrieves the list of users sharing files to user identified by user id
944 * @return the List of users sharing files to user
945 * @throws ObjectNotFoundException
947 public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
954 * @return list of files that match query
955 * @throws ObjectNotFoundException if no user or query was specified
957 public List<FileHeader> searchFiles(Long userId, String query) throws ObjectNotFoundException;
960 * Creates a nonce for the specified user.
962 * @param userId the ID of the user
963 * @return the new nonce
964 * @throws ObjectNotFoundException if the user could not be found
966 public Nonce createNonce(Long userId) throws ObjectNotFoundException;
969 * Find the nonce object for the specified encoded nonce, that should be
970 * associated with the specified user.
972 * @param nonce the issued nonce in Base64 encoding
973 * @param userId the ID of the user for whom this nonce should have been issued
974 * @return the retrieved nonce object
975 * @throws ObjectNotFoundException if the nonce or user were not found
977 public Nonce getNonce(String nonce, Long userId) throws ObjectNotFoundException;
980 * Remove the specified nonce from the persistent store.
982 * @param id the ID of the nonce
983 * @throws ObjectNotFoundException if the specified nonce could not be found
985 public void removeNonce(Long id) throws ObjectNotFoundException;
988 * Activate the supplied nonce for the specified user.
990 * @param userId the ID of the user
991 * @param nonce the nonce to activate
992 * @param nonceExpiryDate the expiry date of the nonce
993 * @throws ObjectNotFoundException
995 public void activateUserNonce(Long userId, String nonce, Date nonceExpiryDate) throws ObjectNotFoundException;
998 * Retrieves user statistics.
1000 * @param userId the ID of the user
1001 * @return the statistics
1002 * @throws ObjectNotFoundException
1005 public StatsDTO getUserStatistics(Long userId) throws ObjectNotFoundException;
1008 * Retrieves file versions
1010 * @param userId the ID of the user
1011 * @param fileId the ID of the file
1012 * @return the list of filebodies
1013 * @throws ObjectNotFoundException
1014 * @throws InsufficientPermissionsException
1017 public List<FileBodyDTO> getVersions(Long userId, Long fileId)
1018 throws ObjectNotFoundException, InsufficientPermissionsException;
1021 * Restore the file contents to the specified version.
1023 * @param userId the ID of the user
1024 * @param fileId the ID of the file
1025 * @param version the version number of the desired file contents
1026 * @throws ObjectNotFoundException if the user or file was not
1027 * found, with the exception message mentioning the precise problem
1028 * @throws InsufficientPermissionsException if the user does not have the
1029 * appropriate privileges
1030 * @throws QuotaExceededException if the user quota limit would be exceeded
1031 * @throws GSSIOException if there was an error while accessing the file contents
1033 public void restoreVersion(Long userId, Long fileId, int version)
1034 throws ObjectNotFoundException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
1037 * Removes all old file versions for specified file keeping only the current revision
1039 * @param userId the ID of the user
1040 * @param fileId the ID of the file
1042 * @throws ObjectNotFoundException
1043 * @throws InsufficientPermissionsException
1046 public void removeOldVersions(Long userId, Long fileId)
1047 throws ObjectNotFoundException, InsufficientPermissionsException;
1050 * It is used by the Solr mbean to rebuild the index.
1052 public String rebuildSolrIndex();
1055 * It is used by the Solr mbean to refresh the index. It does not delete anything just re-add everything in the index
1057 public String refreshSolrIndex();
1060 * Creates a new file with the specified owner, parent folder and name. The
1061 * new file has the same permissions as its parent folder. The file contents
1062 * are already uploaded outside of externalAPI and the uploaded file is used as a parameter.
1064 * @param userId the ID of the current user
1065 * @param folderId the ID of the parent folder
1066 * @param name the name of the new file
1067 * @param mimeType the MIME type of the file
1068 * @param fileSize the uploaded file size
1069 * @param filePath the uploaded file full path
1070 * @return The FileHeaderDTO created
1071 * @throws DuplicateNameException if the specified name already exists in
1072 * the parent folder, as either a folder or file
1073 * @throws ObjectNotFoundException if the user or parent folder was not
1074 * found, with the exception message mentioning the precise
1076 * @throws GSSIOException if there was an error while storing the file contents
1077 * @throws InsufficientPermissionsException
1078 * @throws QuotaExceededException
1080 public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
1081 throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
1082 InsufficientPermissionsException, QuotaExceededException;
1085 * Create a new FileBody with the supplied uploaded file as contents and make it the current body
1088 * @param userId the ID of the current user
1089 * @param fileId the ID of the file header object
1090 * @param mimeType the content type of the file
1091 * @param fileSize the uploaded file size
1092 * @param filePath the uploaded file full path
1093 * @return The FileHeaderDTO updated
1094 * @throws ObjectNotFoundException if the user or file was not found, with
1095 * the exception message mentioning the precise problem
1096 * @throws GSSIOException when an IO exception occurs
1097 * @throws InsufficientPermissionsException
1098 * @throws QuotaExceededException
1100 public FileHeaderDTO updateFileContents(Long userId, Long fileId, String mimeType,
1101 long fileSize, String filePath) throws ObjectNotFoundException, GSSIOException,
1102 InsufficientPermissionsException, QuotaExceededException;
1105 * Create a file based on inputstream without using transaction.
1110 * @throws IOException
1111 * @throws ObjectNotFoundException
1113 @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
1114 public File uploadFile(InputStream stream, Long userId)
1115 throws IOException, ObjectNotFoundException;
1117 public void createFileUploadProgress(Long userId, String filename,
1118 Long bytesTransfered, Long fileSize) throws ObjectNotFoundException;
1120 public FileUploadStatus getFileUploadStatus(Long userId, String fileName);
1122 public void removeFileUploadProgress(Long userId, String filename)
1123 throws ObjectNotFoundException;
1126 * Fetch the file body with the specified version number.
1128 * @param userId the ID of the current user
1129 * @param fileId the ID of the file header
1130 * @param version the version number
1131 * @return the file body
1132 * @throws ObjectNotFoundException if the user file or version
1134 * @throws InsufficientPermissionsException if the user does not
1135 * have enough privileges for reading this file
1137 public FileBodyDTO getFileVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException;
1140 * Search the system for a user with the specified email address.
1141 * If no such user is found, the method returns null.
1143 public User findUserByEmail(String email);
1146 * Update the user with the values from the supplied object.
1148 public void updateUser(User user);
1151 * Update accounting information for given user.
1153 * @param user The user to update
1154 * @param date Date of transaction
1155 * @param bandwidthDiff Bandwidth used; positive for addition,
1156 * negative for subtraction (e.g. to rollback)
1158 public void updateAccounting(User user, Date date, long bandwidthDiff);
1161 * Check if the user with the specified ID has permission to read the
1162 * folder with the supplied ID.
1164 public boolean canReadFolder(Long userId, Long folderId) throws ObjectNotFoundException;
1167 * Reset WebDAV password for given user.
1170 * @return the new password
1171 * @throws ObjectNotFoundException
1173 public String resetWebDAVPassword(Long userId) throws ObjectNotFoundException;
1176 * Find the invite for the specified invitation code.
1178 * @param code the invitation code
1179 * @return the Invitation or null if not found
1181 public Invitation findInvite(String code);
1184 * Create a new user in the connected IdP.
1186 * @param username the username of the new user
1187 * @param firstname the first name of the new user
1188 * @param lastname the last name of the new user
1189 * @param email the e-mail of the new user
1190 * @param password the password of the new user
1192 public void createLdapUser(String username, String firstname, String lastname, String email, String password);
1195 * Retrieves the available user classes.
1197 public List<UserClass> getUserClasses();
1200 * Upgrades the user class to the default "coupon bearer" class and marks
1201 * the provided coupon as used.
1203 * @param username the username of the user
1204 * @param code the coupon code
1205 * @return the new user class
1206 * @throws InvitationUsedException when trying to reuse an already used invitation
1207 * @throws ObjectNotFoundException if the user was not found
1209 public UserClass upgradeUserClass(String username, String code)
1210 throws ObjectNotFoundException, InvitationUsedException;
1213 * Retrieve the user class for coupon-bearing users.
1215 public UserClass getCouponUserClass();
1218 * Delete the actual file in the specified file system path.
1220 public void deleteActualFile(String path);
1223 * Update the userLogin with the values from the supplied object.
1225 public void addUserLogin(UserLogin userLogin);
1228 * Retrieves the user's current session login and the user's last login
1230 * @return a list of last two user logins
1231 * @throws ObjectNotFoundException
1233 public List<UserLogin> getLastUserLogins(Long userId) throws ObjectNotFoundException;
1236 * Posts the file specified by id to solr indexing server
1241 public void postFileToSolr(CommonsHttpSolrServer solr, Long id);
1247 UserDTO getUserByUserName(String username);