2 * Copyright 2007, 2008, 2009 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.ObjectNotFoundException;
25 import gr.ebs.gss.client.exceptions.QuotaExceededException;
26 import gr.ebs.gss.server.domain.FileHeader;
27 import gr.ebs.gss.server.domain.Folder;
28 import gr.ebs.gss.server.domain.Group;
29 import gr.ebs.gss.server.domain.Permission;
30 import gr.ebs.gss.server.domain.User;
32 import java.io.InputStream;
33 import java.util.Date;
34 import java.util.List;
37 import javax.ejb.Remote;
40 * The External API for GSS clients.
45 public interface ExternalAPIRemote {
48 * Retrieves the root folder for the specified user. The caller must ensure
49 * that the userId exists.
53 * @throws ObjectNotFoundException if no Folder or user was found
55 public Folder getRootFolder(Long userId) throws ObjectNotFoundException;
58 * Retrieve the folder with the specified ID.
60 * @param userId the ID of the current user
61 * @param folderId the ID of the folder to retrieve
62 * @return the folder found
63 * @throws ObjectNotFoundException if the folder or the user was not found
64 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
66 public Folder getFolder(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
69 * Returns the user with the specified ID.
71 * @param userId The ID of the User to be found
72 * @return The User object
73 * @throws ObjectNotFoundException if the user cannot be found
75 public User getUser(Long userId) throws ObjectNotFoundException;
78 * Returns the group with the specified ID.
80 * @param groupId The ID of the Group to be found
81 * @return The Group object
82 * @throws ObjectNotFoundException if the group cannot be found
84 public Group getGroup(Long groupId) throws ObjectNotFoundException;
87 * Retrieve the list of groups for a particular user.
89 * @param userId the ID of the User
90 * @return a List of Groups that belong to the specified User
91 * @throws ObjectNotFoundException if the user was not found
93 public List<Group> getGroups(Long userId) throws ObjectNotFoundException;
96 * Returns a list of files contained in the folder specified by its id.
98 * @param userId the ID of the User
99 * @param folderId the ID of the folder containing the files
100 * @param ignoreDeleted
101 * @return the list of file header objects
102 * @throws ObjectNotFoundException if the user or the folder cannot be found
103 * @throws InsufficientPermissionsException
105 public List<FileHeader> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException, InsufficientPermissionsException;
108 * Returns a list of users for the specified group
110 * @param userId the ID of the User
111 * @param groupId the ID of the requested group
113 * @throws ObjectNotFoundException if the user or group was not found, with
114 * the exception message mentioning the precise problem
116 public List<User> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
119 * Returns a list of users for the specified username
121 * @param username the username of the User
124 public List<User> getUsersByUserNameLike(String username);
127 * Creates a new folder with the specified owner, parent folder and name.
128 * New folder has the same permissions as its parent
133 * @return the new folder
134 * @throws DuplicateNameException if the specified name already exists in
135 * the parent folder, as either a folder or file
136 * @throws ObjectNotFoundException if the user or parent folder was not
137 * found, with the exception message mentioning the precise
139 * @throws InsufficientPermissionsException
141 public Folder createFolder(Long userId, Long parentId, String name) throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
144 * Deletes the specified folder if the specified user has the appropriate
149 * @throws InsufficientPermissionsException if the user does not have the
150 * appropriate privileges
151 * @throws ObjectNotFoundException if the user or folder was not found, with
152 * the exception message mentioning the precise problem
154 public void deleteFolder(Long userId, Long folderId) throws InsufficientPermissionsException, ObjectNotFoundException;
157 * Retrieve the subfolders of the specified folder.
159 * @param userId the ID of the current user
160 * @param folderId the ID of the folder to retrieve
161 * @return the list of subfolders found
162 * @throws ObjectNotFoundException if the folder or user was not found
163 * @throws InsufficientPermissionsException
165 public List<Folder> getSubfolders(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
169 * Retrieve the subfolders of the specified folder that are shared to others.
171 * @param userId the ID of the current user
172 * @param folderId the ID of the folder to retrieve
173 * @return the list of subfolders found
174 * @throws ObjectNotFoundException if the folder or user was not found
176 public List<Folder> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
179 * Modifies the specified folder if the specified user has the appropriate
182 * @param userId the ID of the current user
183 * @param folderId the ID of the folder to retrieve
187 * @return the updated folder
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
192 * @throws DuplicateNameException if the specified name already exists in
193 * the parent folder, as either a folder or file
195 public Folder updateFolder(Long userId, Long folderId, String folderName,
197 Set<Permission> permissions)
198 throws InsufficientPermissionsException, ObjectNotFoundException,
199 DuplicateNameException;
202 * Adds a user to the specified group
204 * @param userId the ID of the current user
205 * @param groupId the id of the new group
206 * @param userToAddId the id of the user to add
207 * @throws DuplicateNameException if the user already exists in group
208 * @throws ObjectNotFoundException if the user or group was not found, with
209 * the exception message mentioning the precise problem
210 * @throws InsufficientPermissionsException
212 public void addUserToGroup(Long userId, Long groupId, Long userToAddId) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
215 * Creates a new group with the specified owner and name.
217 * @param userId the ID of the current user
218 * @param name the name of the new group
219 * @throws DuplicateNameException if the new group name already exists
220 * @throws ObjectNotFoundException if the user or group was not found, with
221 * the exception message mentioning the precise problem
223 public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
226 * Deletes the specified group in the specified user's namespace.
228 * @param userId the ID of the current user
229 * @param groupId the ID of the group to delete
230 * @throws ObjectNotFoundException if the user or group was not found, with
231 * the exception message mentioning the precise problem
232 * @throws InsufficientPermissionsException
234 public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
237 * Creates a new file with the specified owner, parent folder and name. The
238 * new file has the same permissions as its parent folder. The file contents
239 * are read from the input stream to a new File object.
241 * @param userId the ID of the current user
242 * @param folderId the ID of the parent folder
243 * @param name the name of the new file
244 * @param mimeType the MIME type of the file
245 * @param stream the input stream with the file contents
246 * @return The FileHeader created
247 * @throws DuplicateNameException if the specified name already exists in
248 * the parent folder, as either a folder or file
249 * @throws ObjectNotFoundException if the user or parent folder was not
250 * found, with the exception message mentioning the precise
252 * @throws GSSIOException if there was an error while storing the file contents
253 * @throws InsufficientPermissionsException
255 public FileHeader createFile(Long userId, Long folderId, String name, String mimeType, InputStream stream) throws DuplicateNameException, ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
258 * Deletes the specified file in the specified user's namespace.
260 * @param userId the ID of the current user
261 * @param fileId the ID of the file to delete
262 * @throws ObjectNotFoundException if the user or file was not found, with
263 * the exception message mentioning the precise problem
264 * @throws InsufficientPermissionsException if the user does not have the
265 * appropriate privileges
267 public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
270 * Creates a new tag for the specified user and file.
272 * @param userId the creator of the tag
273 * @param fileHeaderId the file that is tagged
275 * @throws ObjectNotFoundException if the user or the file was not found
277 public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
280 * Returns all tags defined by the specified user
283 * @return Set<String>
284 * @throws ObjectNotFoundException if the user was null
286 public Set<String> getUserTags(final Long userId) throws ObjectNotFoundException;
289 * Updates the attributes of the specified file.
294 * @param tagSet a String that contains tags separated by comma
295 * @param modificationDate the modification date
296 * @param versioned the new value of the versioned flag
299 * @throws DuplicateNameException
300 * @throws ObjectNotFoundException
301 * @throws InsufficientPermissionsException
303 public void updateFile(Long userId, Long fileId, String name, String tagSet,
304 Date modificationDate, Boolean versioned, Boolean readForAll,
305 Set<Permission> permissions)
306 throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
309 * Retrieve the contents of the current body for the file
310 * with the specified FileHeader ID. The file contents
311 * are provided as an InputStream from which the caller can
312 * retrieve the raw bytes.
314 * @param userId the ID of the current user
315 * @param fileId the ID of the file to retrieve
316 * @return an InputStream from the current file body contents
317 * @throws ObjectNotFoundException if the file or the user was not found
318 * @throws InsufficientPermissionsException if the user does not have the
319 * appropriate privileges
321 public InputStream getFileContents(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
324 * Retrieve the file with the specified ID.
326 * @param userId the ID of the current user
327 * @param fileId the ID of the file to retrieve
328 * @return the file found
329 * @throws ObjectNotFoundException if the file or the user was not found, with
330 * the exception message mentioning the precise problem
331 * @throws InsufficientPermissionsException
333 public FileHeader getFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
336 * Get the resource (file or folder) at the specified path in
337 * the specified user's namespace. The returned object will be of type
338 * FileHeader or Folder.<p><strong>Note:</strong> this method does not
339 * receive the current user as a parameter, therefore it is unable to perform
340 * the necessary permission checks and should <strong>NOT</strong> be directly
341 * exposed to remote clients. It is the caller's responsibility to verify that
342 * the calling user has the required privileges for performing any subsequent
343 * action on the resource through one of the other ExternalAPI methods.
345 * @param ownerId the ID of the user owning the namespace
346 * @param path the absolute path in the user's namespace
347 * @param ignoreDeleted if true, resources that have been moved to the trash
349 * @throws ObjectNotFoundException if the user or resource was not found, with
350 * the exception message mentioning the precise problem
351 * @return the resource found
353 public Object getResourceAtPath(Long ownerId, String path, boolean ignoreDeleted)
354 throws ObjectNotFoundException;
357 * Copy the provided file to the specified destination.
359 * @param userId the ID of the current user
360 * @param fileId the IF of the provided file
361 * @param dest the path to the destination folder
362 * @throws ObjectNotFoundException if the user, file or destination was not
363 * found, with the exception message mentioning the precise problem
364 * @throws GSSIOException if there was an error while accessing the file contents
365 * @throws DuplicateNameException if the specified name already exists in
366 * the destination folder, as either a folder or file
367 * @throws InsufficientPermissionsException
369 public void copyFile(Long userId, Long fileId, String dest) throws ObjectNotFoundException, DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
372 * Copy the provided file to the specified destination.
374 * @param userId the ID of the current user
375 * @param fileId the IF of the provided file
376 * @param destId the ID of the destination folder
377 * @param destName the name of the new file
378 * @throws ObjectNotFoundException if the user, file or destination was not
379 * found, with the exception message mentioning the precise problem
380 * @throws GSSIOException if there was an error while accessing the file contents
381 * @throws DuplicateNameException if the specified name already exists in
382 * the destination folder, as either a folder or file
383 * @throws InsufficientPermissionsException
385 public void copyFile(Long userId, Long fileId, Long destId, String destName) throws ObjectNotFoundException, DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
388 * Copy the provided folder to the specified destination.
390 * @param userId the ID of the current user
391 * @param folderId the IF of the provided folder
392 * @param dest the path to the destination folder
393 * @throws ObjectNotFoundException if the user, folder or destination was not
394 * found, with the exception message mentioning the precise problem
395 * @throws DuplicateNameException if the specified name already exists in
396 * the destination folder, as either a folder or file
397 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
398 * appropriate privileges
400 public void copyFolder(Long userId, Long folderId, String dest) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException, QuotaExceededException;
403 * Copy the provided folder to the specified destination.
405 * @param userId the ID of the current user
406 * @param folderId the IF of the provided folder
407 * @param destId the ID of the destination folder
408 * @param destName the name of the new folder
409 * @throws ObjectNotFoundException if the user, folder or destination was not
410 * found, with the exception message mentioning the precise problem
411 * @throws DuplicateNameException if the specified name already exists in
412 * the destination folder, as either a folder or file
413 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
414 * appropriate privileges
416 public void copyFolder(Long userId, Long folderId, Long destId, String destName) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException, QuotaExceededException;
419 * Copy the provided folder and all its subfolders and files to the specified destination.
421 * @param userId the ID of the current user
422 * @param folderId the IF of the provided folder
423 * @param destId the ID of the destination folder
424 * @param destName the name of the new folder
425 * @throws ObjectNotFoundException if the user, folder or destination was not
426 * found, with the exception message mentioning the precise problem
427 * @throws DuplicateNameException if the specified name already exists in
428 * the destination folder, as either a folder or file
429 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
430 * appropriate privileges
431 * @throws GSSIOException
433 public void copyFolderStructure(Long userId, Long folderId, Long destId, String destName) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,GSSIOException, QuotaExceededException;
436 * Marks the specified file as deleted in the specified user's namespace.
438 * @param userId the ID of the current user
439 * @param fileId the ID of the file to delete
440 * @throws ObjectNotFoundException if the user or file was not found, with
441 * the exception message mentioning the precise problem
442 * @throws InsufficientPermissionsException if the user does not have the
443 * appropriate privileges
445 public void moveFileToTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
448 * Marks the specified deleted file as undeleted in the specified user's namespace.
450 * @param userId the ID of the current user
451 * @param fileId the ID of the file to undelete
452 * @throws ObjectNotFoundException if the user or file was not found, with
453 * the exception message mentioning the precise problem
454 * @throws InsufficientPermissionsException if the user does not have the
455 * appropriate privileges
457 public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
460 * Marks the specified folder as deleted in the specified user's namespace.
462 * @param userId the ID of the current user
463 * @param folderId the ID of the folder to delete
464 * @throws ObjectNotFoundException if the user or file was not found, with
465 * the exception message mentioning the precise problem
466 * @throws InsufficientPermissionsException if the user does not have the
467 * appropriate privileges
469 public void moveFolderToTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
472 * Marks the specified deleted folder as undeleted in the specified user's namespace.
474 * @param userId the ID of the current user
475 * @param folderId the ID of the folder to undelete
476 * @throws ObjectNotFoundException if the user or file was not found, with
477 * the exception message mentioning the precise problem
478 * @throws InsufficientPermissionsException if the user does not have the
479 * appropriate privileges
481 public void removeFolderFromTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
484 * Move the provided folder and all its subfolders and files to the specified destination.
486 * @param userId the ID of the current user
487 * @param folderId the IF of the provided folder
488 * @param destId the ID of the destination folder
489 * @param destName the name of the new folder
490 * @throws ObjectNotFoundException if the user, folder or destination was not
491 * found, with the exception message mentioning the precise problem
492 * @throws DuplicateNameException if the specified name already exists in
493 * the destination folder, as either a folder or file
494 * @throws InsufficientPermissionsException if the user does not have the
495 * appropriate privileges
496 * @throws GSSIOException
498 public void moveFolder(Long userId, Long folderId, Long destId, String destName) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
501 * move 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 InsufficientPermissionsException
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
514 public void moveFile(Long userId, Long fileId, Long destId, String destName) throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException, GSSIOException, QuotaExceededException;
517 * Returns a list of All deleted files of a user.
519 * @param userId the ID of the User
520 * * @return the list of deleted file header objects
521 * @throws ObjectNotFoundException if the user cannot be found
523 public List<FileHeader> getDeletedFiles(Long userId) throws ObjectNotFoundException;
526 * Returns a list of All deleted root folders of a user.
528 * @param userId the ID of the User
529 * * @return the list of deleted file header objects
530 * @throws ObjectNotFoundException if the user cannot be found
532 public List<Folder> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
535 * Empty Trash by deleting all marked as deleted files and folders
537 * @throws ObjectNotFoundException if something goes wrong in the delete process
538 * @throws InsufficientPermissionsException if something goes wrong in the delete process
540 public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
543 * Restores All Trashed Items by undeleting all marked as deleted files and folders
545 * @throws ObjectNotFoundException if something goes wrong in the delete process
546 * @throws InsufficientPermissionsException if the user does not have the
547 * appropriate privileges
549 public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
552 * Search the system for a user with the specified username.
553 * If no such user is found, the method returns null.
555 * @param username the username to search for
556 * @return the User object with the specified username
558 public User findUser(String username);
561 * Create a new user with the specified name, username and e-mail address.
563 * @param username the username of the new user
564 * @param name the full name of the new user
565 * @param mail the e-mail of the new user
566 * @param idp the IdP of the new user
567 * @param idpid the IdP ID of the new user
568 * @return the newly-created User object
569 * @throws DuplicateNameException if a user with the same username already exists
570 * @throws ObjectNotFoundException if no username was provided
572 public User createUser(String username, String name, String mail,
573 String idp, String idpid, String homeOrg) throws DuplicateNameException,
574 ObjectNotFoundException;
577 * Updates the authentication token for the specified user.
579 * @param userId the ID of the user whose token should be updated
580 * @return the updated user
581 * @throws ObjectNotFoundException if the user could not be found
583 public User updateUserToken(Long userId) throws ObjectNotFoundException;
586 * Invalidates the authentication token for the specified user.
588 * @param userId the ID of the user whose token should be updated
589 * @throws ObjectNotFoundException if the user could not be found
591 public void invalidateUserToken(Long userId) throws ObjectNotFoundException;
594 * Retrieve folder user and group permissions
596 * @param userId the ID of the user whose token should be updated
597 * @param folderId the ID of the folder
598 * @return the Set of permissions from requested folder
599 * @throws ObjectNotFoundException if the user or folder could not be found
600 * @throws InsufficientPermissionsException
602 public Set<Permission> getFolderPermissions(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
605 * Retrieve file user and group permissions
607 * @param userId the ID of the user whose token should be updated
608 * @param fileId the ID of the folder
609 * @return the Set of permissions from requested folder
610 * @throws ObjectNotFoundException if the user or folder could not be found
611 * @throws InsufficientPermissionsException
613 public Set<Permission> getFilePermissions(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
616 * Returns a list of All Shared root folders of a user.
618 * @param userId the ID of the User
619 * * @return the list of shared root folders
620 * @throws ObjectNotFoundException if the user cannot be found
622 public List<Folder> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
625 * Returns a list of All Shared files of a user.
627 * @param userId the ID of the User
628 * * @return the list of shared files
629 * @throws ObjectNotFoundException if the user cannot be found
631 public List<FileHeader> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
634 * Returns a list of All Shared root folders of a user that calling user has at least read permissions.
636 * @param ownerId the ID of the User
637 * @return the list of shared root folders
638 * @param callingUserId
640 * @throws ObjectNotFoundException if the user cannot be found
642 public List<Folder> getSharedRootFolders(Long ownerId, Long callingUserId) throws ObjectNotFoundException;
645 * Returns a list of All Shared files of a user that calling user has at least read permissions..
647 * @param ownerId the ID of the User
648 * @return the list of shared files
649 * @param callingUserId
650 * @throws ObjectNotFoundException if the user cannot be found
652 public List<FileHeader> getSharedFiles(Long ownerId, Long callingUserId) throws ObjectNotFoundException;
655 * Remove a user member from a group
657 * @param userId the ID of the User owning the group
658 * @param groupId the ID of the requested group
659 * @param memberId the ID of the member to be removed
661 * @throws ObjectNotFoundException if the user or group was not found, with
662 * the exception message mentioning the precise problem
663 * @throws InsufficientPermissionsException
665 public void removeMemberFromGroup(Long userId, Long groupId, Long memberId) throws ObjectNotFoundException, InsufficientPermissionsException;
668 * Retrieves the list of users sharing files to user identified by user id
670 * @return the List of users sharing files to user
671 * @throws ObjectNotFoundException
673 public List<User> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
680 * @return list of files that match query
681 * @throws ObjectNotFoundException
683 public List<FileHeader> searchFiles(Long userId, String query) throws ObjectNotFoundException;
686 * It is used by the Solr mbean to rebuild the index.
688 public String rebuildSolrIndex();
691 * Search the system for a user with the specified email address.
692 * If no such user is found, the method returns null.
694 public User findUserByEmail(String email);
697 * Update the user with the values from the supplied object.
699 public void updateUser(User user);
702 * Check if the user with the specified ID has permission to read the
703 * folder with the supplied ID.
705 public boolean canReadFolder(Long userId, Long folderId) throws ObjectNotFoundException;