2 * Copyright 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.soap;
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.dto.FileHeaderDTO;
27 import gr.ebs.gss.server.domain.dto.FolderDTO;
28 import gr.ebs.gss.server.domain.dto.GroupDTO;
29 import gr.ebs.gss.server.domain.dto.PermissionDTO;
30 import gr.ebs.gss.server.domain.dto.UserDTO;
32 import java.util.List;
35 import javax.activation.DataHandler;
36 import javax.ejb.Remote;
44 public interface WSAPIRemote {
49 * Search the system for a user with the specified username.
50 * If no such user is found, the method returns null.
52 * @param username the username to search for
53 * @return the User object with the specified username
55 public UserDTO getUser(String username);
58 * Returns the group with the specified ID.
60 * @param groupId The ID of the Group to be found
61 * @return The Group object
62 * @throws ObjectNotFoundException if the group cannot be found
64 public GroupDTO getGroup(Long groupId) throws ObjectNotFoundException;
67 * Retrieve the list of groups for a particular user.
69 * @param userId the ID of the User
70 * @return a List of Groups that belong to the specified User
71 * @throws ObjectNotFoundException if the user was not found
73 public GroupDTO[] getGroups(Long userId) throws ObjectNotFoundException;
76 * Returns a list of users for the specified group
78 * @param userId the ID of the User
79 * @param groupId the ID of the requested group
80 * @return List<UserDTO>
81 * @throws ObjectNotFoundException if the user or group was not found, with
82 * the exception message mentioning the precise problem
84 public UserDTO[] getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
87 * Creates a new group with the specified owner and name.
89 * @param userId the ID of the current user
90 * @param name the name of the new group
91 * @throws DuplicateNameException if the new group name already exists
92 * @throws ObjectNotFoundException if the user or group was not found, with
93 * the exception message mentioning the precise problem
95 public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
98 * Deletes the specified group in the specified user's namespace.
100 * @param userId the ID of the current user
101 * @param groupId the ID of the group to delete
102 * @throws ObjectNotFoundException if the user or group was not found, with
103 * the exception message mentioning the precise problem
104 * @throws InsufficientPermissionsException
106 public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
109 * Adds a user to the specified group
111 * @param userId the ID of the current user
112 * @param groupId the id of the new group
113 * @param userToAddId the id of the user to add
114 * @throws DuplicateNameException if the user already exists in group
115 * @throws ObjectNotFoundException if the user or group was not found, with
116 * the exception message mentioning the precise problem
117 * @throws InsufficientPermissionsException
119 public void addUserToGroup(Long userId, Long groupId, Long userToAddId) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
122 * Remove a user member from a group
124 * @param userId the ID of the User owning the group
125 * @param groupId the ID of the requested group
126 * @param memberId the ID of the member to be removed
128 * @throws ObjectNotFoundException if the user or group was not found, with
129 * the exception message mentioning the precise problem
130 * @throws InsufficientPermissionsException
132 public void removeMemberFromGroup(Long userId, Long groupId, Long memberId) throws ObjectNotFoundException, InsufficientPermissionsException;
137 * Retrieves the root folder for the specified user. The caller must ensure
138 * that the userId exists.
142 * @throws ObjectNotFoundException if no Folder or user was found
144 public FolderDTO getRootFolder(Long userId) throws ObjectNotFoundException;
147 * Retrieve the folder with the specified ID.
149 * @param userId the ID of the current user
150 * @param folderId the ID of the folder to retrieve
151 * @return the folder found
152 * @throws ObjectNotFoundException if the folder or the user was not found
153 * @throws InsufficientPermissionsException
155 public FolderDTO getFolder(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
158 * Creates a new folder with the specified owner, parent folder and name.
159 * New folder has the same permissions as its parent
164 * @throws DuplicateNameException if the specified name already exists in
165 * the parent folder, as either a folder or file
166 * @throws ObjectNotFoundException if the user or parent folder was not
167 * found, with the exception message mentioning the precise
169 * @throws InsufficientPermissionsException
171 public void createFolder(Long userId, Long parentId, String name) throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
174 * Deletes the specified folder if the specified user has the appropriate
179 * @throws InsufficientPermissionsException if the user does not have the
180 * appropriate privileges
181 * @throws ObjectNotFoundException if the user or folder was not found, with
182 * the exception message mentioning the precise problem
184 public void deleteFolder(Long userId, Long folderId) throws InsufficientPermissionsException, ObjectNotFoundException;
187 * Retrieve the subfolders of the specified folder.
189 * @param userId the ID of the current user
190 * @param folderId the ID of the folder to retrieve
191 * @return the list of subfolders found
192 * @throws ObjectNotFoundException if the folder or user was not found
193 * @throws InsufficientPermissionsException
195 public FolderDTO[] getSubfolders(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
198 * Modifies the specified folder if the specified user has the appropriate
201 * @param userId the ID of the current user
202 * @param folderId the ID of the folder to retrieve
204 * @throws InsufficientPermissionsException if the user does not have the
205 * appropriate privileges
206 * @throws ObjectNotFoundException if the user or folder was not found, with
207 * the exception message mentioning the precise problem
208 * @throws DuplicateNameException if the specified name already exists in
209 * the parent folder, as either a folder or file
211 public void modifyFolder(Long userId, Long folderId, String folderName) throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
214 * Copy the provided folder to the specified destination.
216 * @param userId the ID of the current user
217 * @param folderId the IF of the provided folder
218 * @param destId the ID of the destination folder
219 * @param destName the name of the new folder
220 * @throws ObjectNotFoundException if the user, folder or destination was not
221 * found, with the exception message mentioning the precise problem
222 * @throws DuplicateNameException if the specified name already exists in
223 * the destination folder, as either a folder or file
224 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
225 * appropriate privileges
226 * @throws GSSIOException
227 * @throws QuotaExceededException
229 public void copyFolder(Long userId, Long folderId, Long destId, String destName) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
234 * Move the provided folder and all its subfolders and files to the specified destination.
236 * @param userId the ID of the current user
237 * @param folderId the IF of the provided folder
238 * @param destId the ID of the destination folder
239 * @param destName the name of the new folder
240 * @throws ObjectNotFoundException if the user, folder or destination was not
241 * found, with the exception message mentioning the precise problem
242 * @throws DuplicateNameException if the specified name already exists in
243 * the destination folder, as either a folder or file
244 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
245 * appropriate privileges
246 * @throws GSSIOException
247 * @throws QuotaExceededException
249 public void moveFolder(Long userId, Long folderId, Long destId, String destName) throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
253 * Retrieve folder user and group permissions
255 * @param userId the ID of the user whose token should be updated
256 * @param folderId the ID of the folder
257 * @return the Set of permissions from requested folder
258 * @throws ObjectNotFoundException if the user or folder could not be found
259 * @throws InsufficientPermissionsException
261 public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
265 * update folder permissions
269 * @throws ObjectNotFoundException
270 * @throws InsufficientPermissionsException
272 public void setFolderPermissions(Long userId, Long folderId, Set<PermissionDTO> permissions) throws ObjectNotFoundException, InsufficientPermissionsException;
275 * Returns a list of all deleted root folders of a user.
277 * @param userId the ID of the User
278 * @return the list of deleted file header objects
279 * @throws ObjectNotFoundException if the user cannot be found
281 public FolderDTO[] getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
286 * Creates a new file with the specified owner, parent folder and name. The
287 * new file has the same permissions as its parent folder. The file contents
288 * are read from the input stream to a new File object.
290 * @param userId the ID of the current user
291 * @param folderId the ID of the parent folder
292 * @param name the name of the new file
293 * @param mimeType the MIME type of the file
294 * @param stream the input stream with the file contents
295 * @throws DuplicateNameException if the specified name already exists in
296 * the parent folder, as either a folder or file
297 * @throws ObjectNotFoundException if the user or parent folder was not
298 * found, with the exception message mentioning the precise
300 * @throws GSSIOException if there was an error while storing the file contents
301 * @throws InsufficientPermissionsException
302 * @throws QuotaExceededException
304 public void createFile(Long userId, Long folderId, String name, String mimeType, DataHandler stream) throws DuplicateNameException, ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
307 * Deletes the specified file in the specified user's namespace.
309 * @param userId the ID of the current user
310 * @param fileId the ID of the file to delete
311 * @throws ObjectNotFoundException if the user or file was not found, with
312 * the exception message mentioning the precise problem
313 * @throws InsufficientPermissionsException if the user does not have the
314 * appropriate privileges
316 public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
319 * Creates a new tag for the specified user and file.
321 * @param userId the creator of the tag
322 * @param fileHeaderId the file that is tagged
324 * @throws ObjectNotFoundException if the user or the file was not found
326 public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
329 * Returns all tags defined by the specified user
332 * @return Set<String>
333 * @throws ObjectNotFoundException if the user was null
335 public String[] getUserTags(final Long userId) throws ObjectNotFoundException;
338 * Updates name and tags for the specified file
343 * @param tagSet a String that contains tags separated by comma
344 * @throws ObjectNotFoundException
345 * @throws InsufficientPermissionsException
347 public void updateFile(Long userId, Long fileId, String name, String tagSet) throws ObjectNotFoundException, InsufficientPermissionsException;
350 * Retrieve the contents of the current body for the file
351 * with the specified FileHeader ID. The file contents
352 * are provided as an InputStream from which the caller can
353 * retrieve the raw bytes.
355 * @param userId the ID of the current user
356 * @param fileId the ID of the file to retrieve
357 * @return an InputStream from the current file body contents
358 * @throws ObjectNotFoundException if the file or the user was not found
359 * @throws InsufficientPermissionsException if the user does not have the
360 * appropriate privileges
362 public DataHandler getFileContents(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
365 * Retrieve the file with the specified ID.
367 * @param userId the ID of the current user
368 * @param fileId the ID of the file to retrieve
369 * @return the file found
370 * @throws ObjectNotFoundException if the file or the user was not found, with
371 * the exception message mentioning the precise problem
372 * @throws InsufficientPermissionsException
374 public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
379 * Create a new FileBody with the supplied contents and make it the current body
382 * @param userId the ID of the current user
383 * @param fileId the ID of the file header object
384 * @param mimeType the content type of the file
385 * @param resourceInputStream a stream of the file contents
386 * @throws ObjectNotFoundException if the user or file was not found, with
387 * the exception message mentioning the precise problem
388 * @throws GSSIOException if there was an error while storing the file contents
389 * @throws InsufficientPermissionsException
390 * @throws QuotaExceededException
392 public void updateFileContents(Long userId, Long fileId, String mimeType, DataHandler resourceInputStream) throws ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
395 * Copy the provided file to the specified destination.
397 * @param userId the ID of the current user
398 * @param fileId the IF of the provided file
399 * @param destId the ID of the destination folder
400 * @param destName the name of the new file
401 * @throws ObjectNotFoundException if the user, file or destination was not
402 * found, with the exception message mentioning the precise problem
403 * @throws GSSIOException if there was an error while accessing the file contents
404 * @throws DuplicateNameException if the specified name already exists in
405 * the destination folder, as either a folder or file
406 * @throws InsufficientPermissionsException
407 * @throws QuotaExceededException
409 public void copyFile(Long userId, Long fileId, Long destId, String destName) throws ObjectNotFoundException, DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
413 * move the provided file to the specified destination.
415 * @param userId the ID of the current user
416 * @param fileId the IF of the provided file
417 * @param destId the ID of the destination folder
418 * @param destName the name of the new file
419 * @throws InsufficientPermissionsException
420 * @throws ObjectNotFoundException if the user, file or destination was not
421 * found, with the exception message mentioning the precise problem
422 * @throws GSSIOException if there was an error while accessing the file contents
423 * @throws DuplicateNameException if the specified name already exists in
424 * the destination folder, as either a folder or file
425 * @throws QuotaExceededException
427 public void moveFile(Long userId, Long fileId, Long destId, String destName) throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException, GSSIOException, QuotaExceededException;
430 * Returns a list of all deleted files of a user.
432 * @param userId the ID of the User
433 * @return the list of deleted file header objects
434 * @throws ObjectNotFoundException if the user cannot be found
436 public FileHeaderDTO[] getDeletedFiles(Long userId) throws ObjectNotFoundException;
442 * Retrieve file user and group permissions
444 * @param userId the ID of the user whose token should be updated
445 * @param fileId the ID of the folder
446 * @return the Set of permissions from requested folder
447 * @throws ObjectNotFoundException if the user or folder could not be found
448 * @throws InsufficientPermissionsException
450 public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
454 * update file permissions
458 * @throws ObjectNotFoundException
459 * @throws InsufficientPermissionsException
461 public void setFilePermissions(Long userId, Long fileId, boolean readForAll, Set<PermissionDTO> permissions) throws ObjectNotFoundException, InsufficientPermissionsException;
466 * Returns a list of files contained in the folder specified by its id.
468 * @param userId the ID of the User
469 * @param folderId the ID of the folder containing the files
470 * @return the list of file header objects
471 * @throws ObjectNotFoundException if the user or the folder cannot be found
472 * @throws InsufficientPermissionsException
474 public FileHeaderDTO[] getFiles(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
479 * Marks the specified file as deleted in the specified user's namespace.
481 * @param userId the ID of the current user
482 * @param fileId the ID of the file to delete
483 * @throws ObjectNotFoundException if the user or file was not found, with
484 * the exception message mentioning the precise problem
485 * @throws InsufficientPermissionsException if the user does not have the
486 * appropriate privileges
488 public void moveFileToTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
491 * Marks the specified deleted file as undeleted in the specified user's namespace.
493 * @param userId the ID of the current user
494 * @param fileId the ID of the file to undelete
495 * @throws ObjectNotFoundException if the user or file was not found, with
496 * the exception message mentioning the precise problem
497 * @throws InsufficientPermissionsException
500 public void restoreFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
503 * Marks the specified folder as deleted in the specified user's namespace.
505 * @param userId the ID of the current user
506 * @param folderId the ID of the folder to delete
507 * @throws ObjectNotFoundException if the user or file was not found, with
508 * the exception message mentioning the precise problem
509 * @throws InsufficientPermissionsException if the user does not have the
510 * appropriate privileges
512 public void moveFolderToTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
515 * Marks the specified deleted folder as undeleted in the specified user's namespace.
517 * @param userId the ID of the current user
518 * @param folderId the ID of the folder to undelete
519 * @throws ObjectNotFoundException if the user or file was not found, with
520 * the exception message mentioning the precise problem
521 * @throws InsufficientPermissionsException
524 public void restoreFolderFromTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
527 * Empty Trash by deleting all marked as deleted files and folders
529 * @throws ObjectNotFoundException if something goes wrong in the delete process
530 * @throws InsufficientPermissionsException if something goes wrong in the delete process
532 public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
537 * Returns a list of All Shared root folders of a user.
539 * @param userId the ID of the User
540 * * @return the list of shared root folders
541 * @throws ObjectNotFoundException if the user cannot be found
543 public List<FolderDTO> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
546 * Returns a list of All Shared files of a user.
548 * @param userId the ID of the User
549 * * @return the list of shared files
550 * @throws ObjectNotFoundException if the user cannot be found
552 public List<FileHeaderDTO> getSharedFiles(Long userId) throws ObjectNotFoundException;
555 * Returns a list of All Shared root folders of a user that calling user has at least read permissions.
557 * @param ownerId the ID of the User
558 * @return the list of shared root folders
559 * @param callingUserId
561 * @throws ObjectNotFoundException if the user cannot be found
563 public List<FolderDTO> getSharedRootFoldersOfUser(Long ownerId, Long callingUserId) throws ObjectNotFoundException;
566 * Returns a list of All Shared files of a user that calling user has at least read permissions..
568 * @param ownerId the ID of the User
569 * @return the list of shared files
570 * @param callingUserId
571 * @throws ObjectNotFoundException if the user cannot be found
573 public List<FileHeaderDTO> getSharedFilesOfUser(Long ownerId, Long callingUserId) throws ObjectNotFoundException;
578 * Retrieves the list of users sharing files to user identified by user id
580 * @return the List of users sharing files to user
581 * @throws ObjectNotFoundException
583 public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
587 * Retrieve the subfolders of the specified folder that are shared to others.
589 * @param userId the ID of the current user
590 * @param folderId the ID of the folder to retrieve
591 * @return the list of subfolders found
592 * @throws ObjectNotFoundException if the folder or user was not found
594 public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;