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.FileUploadStatus;
28 import gr.ebs.gss.server.domain.Invitation;
29 import gr.ebs.gss.server.domain.Nonce;
30 import gr.ebs.gss.server.domain.User;
31 import gr.ebs.gss.server.domain.UserClass;
32 import gr.ebs.gss.server.domain.dto.FileBodyDTO;
33 import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
34 import gr.ebs.gss.server.domain.dto.FolderDTO;
35 import gr.ebs.gss.server.domain.dto.GroupDTO;
36 import gr.ebs.gss.server.domain.dto.PermissionDTO;
37 import gr.ebs.gss.server.domain.dto.StatsDTO;
38 import gr.ebs.gss.server.domain.dto.UserDTO;
41 import java.io.IOException;
42 import java.io.InputStream;
43 import java.net.MalformedURLException;
44 import java.util.Date;
45 import java.util.List;
48 import javax.ejb.Local;
49 import javax.ejb.TransactionAttribute;
50 import javax.ejb.TransactionAttributeType;
52 import org.apache.commons.configuration.Configuration;
53 import org.apache.solr.client.solrj.SolrServerException;
54 import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
57 * The External API for GSS clients.
62 public interface ExternalAPI {
65 * Retrieves the root folder for the specified user. The caller must ensure
66 * that the userId exists.
70 * @throws ObjectNotFoundException if no Folder or user was found
72 public FolderDTO getRootFolder(Long userId) throws ObjectNotFoundException;
75 * Retrieve the folder with the specified ID.
77 * @param userId the ID of the current user
78 * @param folderId the ID of the folder to retrieve
79 * @return the folder found
80 * @throws ObjectNotFoundException if the folder or the user was not found
81 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
83 public FolderDTO getFolder(Long userId, Long folderId) throws ObjectNotFoundException,
84 InsufficientPermissionsException;
87 * Returns the user with the specified ID.
89 * @param userId The ID of the User to be found
90 * @return The User object
91 * @throws ObjectNotFoundException if the user cannot be found
93 public User getUser(Long userId) throws ObjectNotFoundException;
96 * Returns the user with the specified ID.
98 * @param userId The ID of the User to be found
99 * @return The User object
100 * @throws ObjectNotFoundException if the user cannot be found
102 public UserDTO getUserDTO(Long userId) throws ObjectNotFoundException;
105 * Returns the group with the specified ID.
107 * @param groupId The ID of the Group to be found
108 * @return The Group object
109 * @throws ObjectNotFoundException if the group cannot be found
111 public GroupDTO getGroup(Long groupId) throws ObjectNotFoundException;
114 * Returns the group with the specified name that belongs to the
117 * @param userId the ID of the user
118 * @param name the name of the group
119 * @return The Group object
120 * @throws ObjectNotFoundException if the group cannot be found
122 public GroupDTO getGroup(Long userId, String name) throws ObjectNotFoundException;
125 * Retrieve the list of groups for a particular user.
127 * @param userId the ID of the User
128 * @return a List of Groups that belong to the specified User
129 * @throws ObjectNotFoundException if the user was not found
131 public List<GroupDTO> getGroups(Long userId) throws ObjectNotFoundException;
134 * Returns a list of files contained in the folder specified by its id.
136 * @param userId the ID of the User
137 * @param folderId the ID of the folder containing the files
138 * @param ignoreDeleted
139 * @return the list of file header objects
140 * @throws ObjectNotFoundException if the user or the folder cannot be found
141 * @throws InsufficientPermissionsException
143 public List<FileHeaderDTO> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException,
144 InsufficientPermissionsException;
147 * Returns a list of users for the specified group
149 * @param userId the ID of the User
150 * @param groupId the ID of the requested group
151 * @return List<UserDTO>
152 * @throws ObjectNotFoundException if the user or group was not found, with
153 * the exception message mentioning the precise problem
155 public List<UserDTO> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
158 * Returns a list of users matching the specified username
160 * @param username the username of the User
161 * @return List<UserDTO>
163 public List<UserDTO> getUsersByUserNameLike(String username);
166 * Creates a new folder with the specified owner, parent folder and name.
167 * New folder has the same permissions as its parent
172 * @return the new folder
173 * @throws DuplicateNameException if the specified name already exists in
174 * the parent folder, as either a folder or file
175 * @throws ObjectNotFoundException if the user or parent folder was not
176 * found, with the exception message mentioning the precise
178 * @throws InsufficientPermissionsException
180 public FolderDTO createFolder(Long userId, Long parentId, String name) throws DuplicateNameException,
181 ObjectNotFoundException, InsufficientPermissionsException;
184 * Deletes the specified folder, if the specified user has the appropriate
187 * @param userId the ID of the current user
188 * @param folderId the ID of the folder to delete
189 * @throws InsufficientPermissionsException if the user does not have the
190 * appropriate privileges
191 * @throws ObjectNotFoundException if the user or folder was not found, with
192 * the exception message mentioning the precise problem
194 public void deleteFolder(Long userId, Long folderId)
195 throws InsufficientPermissionsException, ObjectNotFoundException;
198 * Retrieve the subfolders of the specified folder.
200 * @param userId the ID of the current user
201 * @param folderId the ID of the folder to retrieve
202 * @return the list of subfolders found
203 * @throws ObjectNotFoundException if the folder or user was not found
204 * @throws InsufficientPermissionsException
206 public List<FolderDTO> getSubfolders(Long userId, Long folderId)
207 throws ObjectNotFoundException, InsufficientPermissionsException;
210 * Retrieve the folder with the specified ID with subfolders.
212 * @param userId the ID of the current user
213 * @param folderId the ID of the folder to retrieve
214 * @return the folder found
215 * @throws ObjectNotFoundException if the folder or the user was not found
216 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
218 public FolderDTO getFolderWithSubfolders(Long userId, Long folderId)
219 throws ObjectNotFoundException, InsufficientPermissionsException;
222 * Retrieve the folder with the specified ID with subfolders.
224 * @param userId the ID of the current user
225 * @param callingUserId the ID of the user requesting this operation
226 * @param folderId the ID of the folder to retrieve
227 * @return the folder found
228 * @throws ObjectNotFoundException if the folder or the user was not found
229 * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
231 public FolderDTO getFolderWithSubfolders(Long userId, Long callingUserId, Long folderId)
232 throws ObjectNotFoundException, InsufficientPermissionsException;
234 * Retrieve the subfolders of the specified folder that are shared to others.
236 * @param userId the ID of the current user
237 * @param folderId the ID of the folder to retrieve
238 * @return the list of subfolders found
239 * @throws ObjectNotFoundException if the folder or user was not found
241 public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
244 * Retrieve the subfolders of the specified folder that are shared to others.
246 * @param userId the ID of the current user
247 * @param callingUserId the id of the user requesting this operation
248 * @param folderId the ID of the folder to retrieve
249 * @return the list of subfolders found
250 * @throws ObjectNotFoundException if the folder or user was not found
252 public List<FolderDTO> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException;
254 * Modifies the specified folder if the specified user has the appropriate
257 * @param userId the ID of the current user
258 * @param folderId the ID of the folder to retrieve
262 * @return the updated folder
263 * @throws InsufficientPermissionsException if the user does not have the
264 * appropriate privileges
265 * @throws ObjectNotFoundException if the user or folder was not found, with
266 * the exception message mentioning the precise problem
267 * @throws DuplicateNameException if the specified name already exists in
268 * the parent folder, as either a folder or file
270 public FolderDTO updateFolder(Long userId, Long folderId, String folderName,
272 Set<PermissionDTO> permissions)
273 throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
276 * Adds a user to the specified group
278 * @param userId the ID of the current user
279 * @param groupId the id of the new group
280 * @param userToAddId the id of the user to add
281 * @throws DuplicateNameException if the user already exists in group
282 * @throws ObjectNotFoundException if the user or group was not found, with
283 * the exception message mentioning the precise problem
284 * @throws InsufficientPermissionsException
286 public void addUserToGroup(Long userId, Long groupId, Long userToAddId)
287 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
290 * Creates a new group with the specified owner and name.
292 * @param userId the ID of the current user
293 * @param name the name of the new group
294 * @throws DuplicateNameException if the new group name already exists
295 * @throws ObjectNotFoundException if the user or group was not found, with
296 * the exception message mentioning the precise problem
298 public void createGroup(Long userId, String name) throws ObjectNotFoundException, DuplicateNameException;
301 * Deletes the specified group in the specified user's namespace.
303 * @param userId the ID of the current user
304 * @param groupId the ID of the group to delete
305 * @throws ObjectNotFoundException if the user or group was not found, with
306 * the exception message mentioning the precise problem
307 * @throws InsufficientPermissionsException
309 public void deleteGroup(Long userId, Long groupId) throws ObjectNotFoundException, InsufficientPermissionsException;
312 * Creates a new file with the specified owner, parent folder and name. The
313 * new file has the same permissions as its parent folder. The file contents
314 * are read from the input stream to a new File object.
316 * @param userId the ID of the current user
317 * @param folderId the ID of the parent folder
318 * @param name the name of the new file
319 * @param mimeType the MIME type of the file
320 * @param stream the input stream with the file contents
321 * @return The FileHeaderDTO created
322 * @throws DuplicateNameException if the specified name already exists in
323 * the parent folder, as either a folder or file
324 * @throws ObjectNotFoundException if the user or parent folder was not
325 * found, with the exception message mentioning the precise
327 * @throws GSSIOException if there was an error while storing the file contents
328 * @throws InsufficientPermissionsException
329 * @throws QuotaExceededException
331 public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType,
332 InputStream stream) throws DuplicateNameException, ObjectNotFoundException,
333 GSSIOException, InsufficientPermissionsException, QuotaExceededException;
336 * Deletes the specified file, provided the specified user has
337 * the necessary permissions.
339 * @param userId the ID of the current user
340 * @param fileId the ID of the file to delete
341 * @throws ObjectNotFoundException if the user or file was not found, with
342 * the exception message mentioning the precise problem
343 * @throws InsufficientPermissionsException if the user does not have the
344 * appropriate privileges
346 public void deleteFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
349 * Deletes the specified file in the specified user's namespace.
351 * @param userId the ID of the current user
352 * @param fileIds the IDs of the files to delete
353 * @throws ObjectNotFoundException if the user or file was not found, with
354 * the exception message mentioning the precise problem
355 * @throws InsufficientPermissionsException if the user does not have the
356 * appropriate privileges
358 public void deleteFiles(Long userId, List<Long> fileIds)
359 throws ObjectNotFoundException, InsufficientPermissionsException;
362 * Creates a new tag for the specified user and file.
364 * @param userId the creator of the tag
365 * @param fileHeaderId the file that is tagged
367 * @throws ObjectNotFoundException if the user or the file was not found
369 public void createTag(Long userId, Long fileHeaderId, String tag) throws ObjectNotFoundException;
372 * Returns all tags defined by the specified user
375 * @return Set<String>
376 * @throws ObjectNotFoundException if the user was null
378 public Set<String> getUserTags(final Long userId) throws ObjectNotFoundException;
381 * Updates the attributes of the specified file.
386 * @param tagSet a String that contains tags separated by comma
387 * @param modificationDate the modification date
388 * @param versioned the new value of the versioned flag
391 * @throws DuplicateNameException
392 * @throws ObjectNotFoundException
393 * @throws InsufficientPermissionsException
395 public void updateFile(Long userId, Long fileId, String name, String tagSet,
396 Date modificationDate, Boolean versioned, Boolean readForAll,
397 Set<PermissionDTO> permissions)
398 throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
401 * Retrieve the contents of the current body for the file
402 * with the specified FileHeader ID. The file contents
403 * are provided as an InputStream from which the caller can
404 * retrieve the raw bytes.
406 * @param userId the ID of the current user
407 * @param fileId the ID of the file to retrieve
408 * @return an InputStream from the current file body contents
409 * @throws ObjectNotFoundException if the file or the user was not found
410 * @throws InsufficientPermissionsException if the user does not have the
411 * appropriate privileges
413 public InputStream getFileContents(Long userId, Long fileId)
414 throws ObjectNotFoundException, InsufficientPermissionsException;
417 * Retrieve the contents of the body identified by bodyId for the file
418 * with the specified FileHeader ID. The file contents
419 * are provided as an InputStream from which the caller can
420 * retrieve the raw bytes.
422 * @param userId the ID of the current user
423 * @param fileId the ID of the file to retrieve
424 * @param bodyId the body ID
425 * @return an InputStream from the current file body contents
426 * @throws ObjectNotFoundException if the file or the user was not found
427 * @throws InsufficientPermissionsException if the user does not have the
428 * appropriate privileges
430 public InputStream getFileContents(Long userId, Long fileId, Long bodyId)
431 throws ObjectNotFoundException, InsufficientPermissionsException;
434 * Retrieve the file with the specified ID.
436 * @param userId the ID of the current user
437 * @param fileId the ID of the file to retrieve
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 FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException,
444 InsufficientPermissionsException;
447 * Retrieve the filebody with the specified ID.
449 * @param userId the ID of the current user
450 * @param fileId the ID of the file to retrieve
451 * @param bodyId the ID of the body
452 * @return the file found
453 * @throws ObjectNotFoundException if the file or the user was not found, with
454 * the exception message mentioning the precise problem
455 * @throws InsufficientPermissionsException
457 public FileBodyDTO getFileBody(Long userId, Long fileId, Long bodyId)
458 throws ObjectNotFoundException, InsufficientPermissionsException;
461 * Get the resource (file or folder) at the specified path in
462 * the specified user's namespace. The returned object will be of type
463 * FileHeaderDTO or FolderDTO.<p><strong>Note:</strong> this method does not
464 * receive the current user as a parameter, therefore it is unable to perform
465 * the necessary permission checks and should <strong>NOT</strong> be directly
466 * exposed to remote clients. It is the caller's responsibility to verify that
467 * the calling user has the required privileges for performing any subsequent
468 * action on the resource through one of the other ExternalAPI methods.
470 * @param ownerId the ID of the user owning the namespace
471 * @param path the absolute path in the user's namespace
472 * @param ignoreDeleted if true, resources that have been moved to the trash
474 * @throws ObjectNotFoundException if the user or resource was not found, with
475 * the exception message mentioning the precise problem
476 * @return the resource found
478 public Object getResourceAtPath(Long ownerId, String path, boolean ignoreDeleted)
479 throws ObjectNotFoundException;
482 * Copy the provided file to the specified destination.
484 * @param userId the ID of the current user
485 * @param fileId the IF of the provided file
486 * @param dest the path of the new resource
487 * @throws ObjectNotFoundException if the user, file or destination was not
488 * found, with the exception message mentioning the precise problem
489 * @throws DuplicateNameException if the specified name already exists in
490 * the destination folder, as either a folder or file
491 * @throws GSSIOException if there was an error while accessing the file contents
492 * @throws InsufficientPermissionsException
493 * @throws QuotaExceededException
495 public void copyFile(Long userId, Long fileId, String dest) throws ObjectNotFoundException,
496 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
499 * Copy the provided file to the specified destination.
501 * @param userId the ID of the current user
502 * @param ownerId the ID of the owner of the destination namespace
503 * @param fileId the IF of the provided file
504 * @param dest the path of the new resource
505 * @throws ObjectNotFoundException if the user, file or destination was not
506 * found, with the exception message mentioning the precise problem
507 * @throws DuplicateNameException if the specified name already exists in
508 * the destination folder, as either a folder or file
509 * @throws GSSIOException if there was an error while accessing the file contents
510 * @throws InsufficientPermissionsException
511 * @throws QuotaExceededException
513 public void copyFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException,
514 DuplicateNameException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
517 * Copy the provided file to the specified destination.
519 * @param userId the ID of the current user
520 * @param fileIds the IDs of the provided files
521 * @param destId the ID of the destination folder
522 * @throws ObjectNotFoundException if the user, file or destination was not
523 * found, with the exception message mentioning the precise problem
524 * @throws GSSIOException if there was an error while accessing the file contents
525 * @throws DuplicateNameException if the specified name already exists in
526 * the destination folder, as either a folder or file
527 * @throws InsufficientPermissionsException
528 * @throws QuotaExceededException
530 public void copyFiles(Long userId, List<Long> fileIds, Long destId)
531 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
532 InsufficientPermissionsException, QuotaExceededException;
535 * Copy the provided file to the specified destination.
537 * @param userId the ID of the current user
538 * @param fileId the IF of the provided file
539 * @param destId the ID of the destination folder
540 * @param destName the name of the new file
541 * @throws ObjectNotFoundException if the user, file or destination was not
542 * found, with the exception message mentioning the precise problem
543 * @throws GSSIOException if there was an error while accessing the file contents
544 * @throws DuplicateNameException if the specified name already exists in
545 * the destination folder, as either a folder or file
546 * @throws InsufficientPermissionsException
547 * @throws QuotaExceededException
549 public void copyFile(Long userId, Long fileId, Long destId, String destName)
550 throws ObjectNotFoundException, DuplicateNameException, GSSIOException,
551 InsufficientPermissionsException, QuotaExceededException;
554 * Copy the provided folder to the specified destination.
556 * @param userId the ID of the current user
557 * @param folderId the IF of the provided folder
558 * @param dest the path of the new folder
559 * @throws ObjectNotFoundException if the user, folder or destination was not
560 * found, with the exception message mentioning the precise problem
561 * @throws DuplicateNameException if the specified name already exists in
562 * the destination folder, as either a folder or file
563 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
564 * appropriate privileges
566 public void copyFolder(Long userId, Long folderId, String dest) throws ObjectNotFoundException,
567 DuplicateNameException, InsufficientPermissionsException;
570 * Copy the provided folder to the specified destination.
572 * @param userId the ID of the current user
573 * @param folderId the IF of the provided folder
574 * @param destId the ID of the destination folder
575 * @param destName the name of the new folder
576 * @throws ObjectNotFoundException if the user, folder or destination was not
577 * found, with the exception message mentioning the precise problem
578 * @throws DuplicateNameException if the specified name already exists in
579 * the destination folder, as either a folder or file
580 * @throws InsufficientPermissionsException InsufficientPermissionsException
581 * if the user does not have the appropriate privileges
583 public void copyFolder(Long userId, Long folderId, Long destId, String destName)
584 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException;
587 * Copy the provided folder and all its subfolders and files to the specified destination.
589 * @param userId the ID of the current user
590 * @param ownerId the ID of the owner of the destination namespace
591 * @param folderId the IF of the provided folder
592 * @param dest the path of the new folder
593 * @throws ObjectNotFoundException if the user, folder or destination was not
594 * found, with the exception message mentioning the precise problem
595 * @throws DuplicateNameException if the specified name already exists in
596 * the destination folder, as either a folder or file
597 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
598 * appropriate privileges
599 * @throws QuotaExceededException if the user quota limit would be exceeded
600 * @throws GSSIOException if there was an error while accessing the file contents
602 public void copyFolderStructureToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
603 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
606 * Copy the provided folder and all its subfolders and files to the specified destination.
608 * @param userId the ID of the current user
609 * @param folderId the IF of the provided folder
610 * @param destId the ID of the destination folder
611 * @param destName the name of the new folder
612 * @throws ObjectNotFoundException if the user, folder or destination was not
613 * found, with the exception message mentioning the precise problem
614 * @throws DuplicateNameException if the specified name already exists in
615 * the destination folder, as either a folder or file
616 * @throws InsufficientPermissionsException InsufficientPermissionsException
617 * if the user does not have the appropriate privileges
618 * @throws GSSIOException if there was an error while accessing the file contents
619 * @throws QuotaExceededException if the user quota limit would be exceeded
621 public void copyFolderStructure(Long userId, Long folderId, Long destId, String destName)
622 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
623 GSSIOException, QuotaExceededException;
626 * Marks the specified file as deleted in the specified user's namespace.
628 * @param userId the ID of the current user
629 * @param fileId the ID of the file to delete
630 * @throws ObjectNotFoundException if the user or file was not found, with
631 * the exception message mentioning the precise problem
632 * @throws InsufficientPermissionsException if the user does not have the
633 * appropriate privileges
635 public void moveFileToTrash(Long userId, Long fileId) throws ObjectNotFoundException,
636 InsufficientPermissionsException;
639 * Marks the specified deleted file as undeleted in the specified user's namespace.
641 * @param userId the ID of the current user
642 * @param fileId the ID of the file to undelete
643 * @throws ObjectNotFoundException if the user or file was not found, with
644 * the exception message mentioning the precise problem
645 * @throws InsufficientPermissionsException if the user does not have the
646 * appropriate privileges
649 public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
652 * Marks the specified files as deleted in the specified user's namespace.
654 * @param userId the ID of the current user
655 * @param fileIds the IDs of the file to delete
656 * @throws ObjectNotFoundException if the user or file was not found, with
657 * the exception message mentioning the precise problem
658 * @throws InsufficientPermissionsException if the user does not have the
659 * appropriate privileges
661 public void moveFilesToTrash(Long userId, List<Long> fileIds)
662 throws ObjectNotFoundException, InsufficientPermissionsException;
665 * Marks the specified deleted files as undeleted in the specified user's namespace.
667 * @param userId the ID of the current user
668 * @param fileIds the IDs of the file to undelete
669 * @throws ObjectNotFoundException if the user or file was not found, with
670 * the exception message mentioning the precise problem
671 * @throws InsufficientPermissionsException if the user does not have the
672 * appropriate privileges
674 public void removeFilesFromTrash(Long userId, List<Long> fileIds) throws ObjectNotFoundException, InsufficientPermissionsException;
677 * Marks the specified folder as deleted in the specified user's namespace.
679 * @param userId the ID of the current user
680 * @param folderId the ID of the folder to delete
681 * @throws ObjectNotFoundException if the user or file was not found, with
682 * the exception message mentioning the precise problem
683 * @throws InsufficientPermissionsException if the user does not have the
684 * appropriate privileges
686 public void moveFolderToTrash(Long userId, Long folderId)
687 throws ObjectNotFoundException, InsufficientPermissionsException;
690 * Marks the specified deleted folder as undeleted in the specified user's namespace.
692 * @param userId the ID of the current user
693 * @param folderId the ID of the folder to undelete
694 * @throws ObjectNotFoundException if the user or file was not found, with
695 * the exception message mentioning the precise problem
696 * @throws InsufficientPermissionsException if the user does not have the
697 * appropriate privileges
700 public void removeFolderFromTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
703 * Move the provided folder and all its subfolders and files to the specified destination.
705 * @param userId the ID of the current user
706 * @param folderId the IF of the provided folder
707 * @param destId the ID of the destination folder
708 * @param destName the name of the new folder
709 * @throws ObjectNotFoundException if the user, folder or destination was not
710 * found, with the exception message mentioning the precise problem
711 * @throws DuplicateNameException if the specified name already exists in
712 * the destination folder, as either a folder or file
713 * @throws InsufficientPermissionsException if the user does not have the
714 * appropriate privileges
715 * @throws GSSIOException
716 * @throws QuotaExceededException
718 public void moveFolder(Long userId, Long folderId, Long destId, String destName)
719 throws ObjectNotFoundException, DuplicateNameException, InsufficientPermissionsException,
720 GSSIOException, QuotaExceededException;
723 * Move the provided folder and all its subfolders and files to the specified destination.
725 * @param userId the ID of the current user
726 * @param ownerId the owner of the destination namespace
727 * @param folderId the IF of the provided folder
728 * @param dest the path of the new folder
729 * @throws ObjectNotFoundException if the user, folder or destination was not
730 * found, with the exception message mentioning the precise problem
731 * @throws DuplicateNameException if the specified name already exists in
732 * the destination folder, as either a folder or file
733 * @throws InsufficientPermissionsException InsufficientPermissionsException if the user does not have the
734 * appropriate privileges
735 * @throws GSSIOException
736 * @throws QuotaExceededException
738 public void moveFolderToPath(Long userId, Long ownerId, Long folderId, String dest) throws ObjectNotFoundException,
739 DuplicateNameException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
742 * Move the provided file to the specified destination.
744 * @param userId the ID of the current user
745 * @param fileId the IF of the provided file
746 * @param destId the ID of the destination folder
747 * @param destName the name of the new file
748 * @throws InsufficientPermissionsException
749 * @throws ObjectNotFoundException if the user, file or destination was not
750 * found, with the exception message mentioning the precise problem
751 * @throws GSSIOException if there was an error while accessing the file contents
752 * @throws DuplicateNameException if the specified name already exists in
753 * the destination folder, as either a folder or file
754 * @throws QuotaExceededException
756 public void moveFile(Long userId, Long fileId, Long destId, String destName)
757 throws InsufficientPermissionsException, ObjectNotFoundException,
758 DuplicateNameException, GSSIOException, QuotaExceededException;
761 * Move the provided file to the specified destination.
763 * @param userId the ID of the current user
764 * @param ownerId the owner of the destination namespace
765 * @param fileId the IF of the provided file
766 * @param dest the path of the new file
767 * @throws InsufficientPermissionsException
768 * @throws ObjectNotFoundException if the user, file or destination was not
769 * found, with the exception message mentioning the precise problem
770 * @throws GSSIOException if there was an error while accessing the file contents
771 * @throws DuplicateNameException if the specified name already exists in
772 * the destination folder, as either a folder or file
773 * @throws QuotaExceededException
775 public void moveFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException, InsufficientPermissionsException, DuplicateNameException, GSSIOException, QuotaExceededException;
778 * move the provided file to the specified destination.
780 * @param userId the ID of the current user
781 * @param fileIds the IDs of the provided files
782 * @param destId the ID of the destination folder
783 * @throws InsufficientPermissionsException
784 * @throws ObjectNotFoundException if the user, file or destination was not
785 * found, with the exception message mentioning the precise problem
786 * @throws GSSIOException if there was an error while accessing the file contents
787 * @throws DuplicateNameException if the specified name already exists in
788 * the destination folder, as either a folder or file
789 * @throws QuotaExceededException
791 public void moveFiles(Long userId, List<Long> fileIds, Long destId)
792 throws InsufficientPermissionsException, ObjectNotFoundException,
793 DuplicateNameException, GSSIOException, QuotaExceededException;
796 * Returns a list of All deleted files of a user.
798 * @param userId the ID of the User
799 * * @return the list of deleted file header objects
800 * @throws ObjectNotFoundException if the user cannot be found
802 public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException;
805 * Returns a list of All deleted root folders of a user.
807 * @param userId the ID of the User
808 * * @return the list of deleted file header objects
809 * @throws ObjectNotFoundException if the user cannot be found
811 public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
814 * Empty Trash by deleting all marked as deleted files and folders
816 * @throws ObjectNotFoundException if something goes wrong in the delete process
817 * @throws InsufficientPermissionsException if something goes wrong in the delete process
819 public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
822 * Restores All Trashed Items by undeleting all marked as deleted files and folders
824 * @throws ObjectNotFoundException if something goes wrong in the delete process
825 * @throws InsufficientPermissionsException
827 public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException;
830 * Search the system for a user with the specified username.
831 * If no such user is found, the method returns null.
833 * @param username the username to search for
834 * @return the User object with the specified username
836 public User findUser(String username);
839 * Create a new user with the specified name, username and e-mail address.
841 * @param username the username of the new user
842 * @param name the name of the new user
843 * @param mail the e-mail of the new user
844 * @param idp the IdP of the new user
845 * @param idpid the IdP identifier of the new user
846 * @return the newly-created User object
847 * @throws DuplicateNameException if a user with the same username already exists
848 * @throws ObjectNotFoundException if no username was provided
850 public User createUser(String username, String name, String mail, String idp, String idpid)
851 throws DuplicateNameException, ObjectNotFoundException;
854 * Updates the authentication token for the specified user.
856 * @param userId the ID of the user whose token should be updated
857 * @return the updated user
858 * @throws ObjectNotFoundException if the user could not be found
860 public User updateUserToken(Long userId) throws ObjectNotFoundException;
863 * Updates the policy acceptance flag for the specified user.
865 * @param userId the ID of the user whose flag should be updated
866 * @param isAccepted the new value of the flag
867 * @return the updated user
868 * @throws ObjectNotFoundException if the user could not be found
870 public User updateUserPolicyAcceptance(Long userId, boolean isAccepted) throws ObjectNotFoundException;
873 * Invalidates the authentication token for the specified user.
875 * @param userId the ID of the user whose token should be updated
876 * @throws ObjectNotFoundException if the user could not be found
878 public void invalidateUserToken(Long userId) throws ObjectNotFoundException;
881 * Retrieve folder user and group permissions
883 * @param userId the ID of the user whose token should be updated
884 * @param folderId the ID of the folder
885 * @return the Set of permissions from requested folder
886 * @throws ObjectNotFoundException if the user or folder could not be found
887 * @throws InsufficientPermissionsException
889 public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId)
890 throws ObjectNotFoundException, InsufficientPermissionsException;
893 * Retrieve file user and group permissions
895 * @param userId the ID of the user whose token should be updated
896 * @param fileId the ID of the folder
897 * @return the Set of permissions from requested folder
898 * @throws ObjectNotFoundException if the user or folder could not be found
899 * @throws InsufficientPermissionsException
901 public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId)
902 throws ObjectNotFoundException, InsufficientPermissionsException;
905 * Returns a list of all shared root folders of a user.
907 * @param userId the ID of the User
908 * @return the list of shared root folders
909 * @throws ObjectNotFoundException if the user cannot be found
911 public List<FolderDTO> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
914 * Returns a list of all shared files of a user that are not
915 * inside other shared folders.
917 * @param userId the ID of the User
918 * @return the list of shared files
919 * @throws ObjectNotFoundException if the user cannot be found
921 public List<FileHeaderDTO> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
924 * Returns a list of all shared files of a user.
926 * @param userId the ID of the User
927 * @return the list of shared files
928 * @throws ObjectNotFoundException if the user cannot be found
930 public List<FileHeaderDTO> getSharedFiles(Long userId) throws ObjectNotFoundException;
933 * Returns a list of all shared folders of a user.
935 * @param userId the ID of the User
936 * @return the list of shared folders
937 * @throws ObjectNotFoundException if the user cannot be found
939 public List<FolderDTO> getSharedFolders(Long userId) throws ObjectNotFoundException;
942 * Returns a list of all shared root folders of a user that calling
943 * user has at least read permissions.
945 * @param ownerId the ID of the User
946 * @return the list of shared root folders
947 * @param callingUserId
949 * @throws ObjectNotFoundException if the user cannot be found
951 public List<FolderDTO> getSharedRootFolders(Long ownerId, Long callingUserId)
952 throws ObjectNotFoundException;
955 * Returns a list of all shared files of a user that calling user has
956 * at least read permissions..
958 * @param ownerId the ID of the User
959 * @return the list of shared files
960 * @param callingUserId
961 * @throws ObjectNotFoundException if the user cannot be found
963 public List<FileHeaderDTO> getSharedFiles(Long ownerId, Long callingUserId)
964 throws ObjectNotFoundException;
967 * Remove a user member from a group
969 * @param userId the ID of the User owning the group
970 * @param groupId the ID of the requested group
971 * @param memberId the ID of the member to be removed
973 * @throws ObjectNotFoundException if the user or group was not found, with
974 * the exception message mentioning the precise problem
975 * @throws InsufficientPermissionsException
977 public void removeMemberFromGroup(Long userId, Long groupId, Long memberId)
978 throws ObjectNotFoundException, InsufficientPermissionsException;
981 * Retrieves the list of users sharing files to user identified by user id
983 * @return the List of users sharing files to user
984 * @throws ObjectNotFoundException
986 public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
993 * @return list of files that match query
994 * @throws ObjectNotFoundException if no user or query was specified
996 public List<FileHeaderDTO> searchFiles(Long userId, String query) throws ObjectNotFoundException;
999 * Creates a nonce for the specified user.
1001 * @param userId the ID of the user
1002 * @return the new nonce
1003 * @throws ObjectNotFoundException if the user could not be found
1005 public Nonce createNonce(Long userId) throws ObjectNotFoundException;
1008 * Find the nonce object for the specified encoded nonce, that should be
1009 * associated with the specified user.
1011 * @param nonce the issued nonce in Base64 encoding
1012 * @param userId the ID of the user for whom this nonce should have been issued
1013 * @return the retrieved nonce object
1014 * @throws ObjectNotFoundException if the nonce or user were not found
1016 public Nonce getNonce(String nonce, Long userId) throws ObjectNotFoundException;
1019 * Remove the specified nonce from the persistent store.
1021 * @param id the ID of the nonce
1022 * @throws ObjectNotFoundException if the specified nonce could not be found
1024 public void removeNonce(Long id) throws ObjectNotFoundException;
1027 * Activate the supplied nonce for the specified user.
1029 * @param userId the ID of the user
1030 * @param nonce the nonce to activate
1031 * @param nonceExpiryDate the expiry date of the nonce
1032 * @throws ObjectNotFoundException
1034 public void activateUserNonce(Long userId, String nonce, Date nonceExpiryDate) throws ObjectNotFoundException;
1037 * Retrieves user statistics.
1039 * @param userId the ID of the user
1040 * @return the statistics
1041 * @throws ObjectNotFoundException
1044 public StatsDTO getUserStatistics(Long userId) throws ObjectNotFoundException;
1047 * Retrieves file versions
1049 * @param userId the ID of the user
1050 * @param fileId the ID of the file
1051 * @return the list of filebodies
1052 * @throws ObjectNotFoundException
1053 * @throws InsufficientPermissionsException
1056 public List<FileBodyDTO> getVersions(Long userId, Long fileId)
1057 throws ObjectNotFoundException, InsufficientPermissionsException;
1060 * Restore the file contents to the specified version.
1062 * @param userId the ID of the user
1063 * @param fileId the ID of the file
1064 * @param version the version number of the desired file contents
1065 * @throws ObjectNotFoundException if the user or file was not
1066 * found, with the exception message mentioning the precise problem
1067 * @throws InsufficientPermissionsException if the user does not have the
1068 * appropriate privileges
1069 * @throws QuotaExceededException if the user quota limit would be exceeded
1070 * @throws GSSIOException if there was an error while accessing the file contents
1072 public void restoreVersion(Long userId, Long fileId, int version)
1073 throws ObjectNotFoundException, InsufficientPermissionsException, GSSIOException, QuotaExceededException;
1076 * Remove file version identified by bodyId
1078 * @param userId the ID of the user
1079 * @param fileId the ID of the file
1080 * @param bodyId the ID of the body
1082 * @throws ObjectNotFoundException
1083 * @throws InsufficientPermissionsException
1086 public void removeVersion(Long userId, Long fileId, Long bodyId)
1087 throws ObjectNotFoundException, InsufficientPermissionsException;
1090 * Removes all old file versions for specified file keeping only the current revision
1092 * @param userId the ID of the user
1093 * @param fileId the ID of the file
1095 * @throws ObjectNotFoundException
1096 * @throws InsufficientPermissionsException
1099 public void removeOldVersions(Long userId, Long fileId)
1100 throws ObjectNotFoundException, InsufficientPermissionsException;
1103 * It is used by the Solr mbean to rebuild the index.
1105 public String rebuildSolrIndex();
1108 * It is used by the Solr mbean to refresh the index. It does not delete anything just re-add everything in the index
1110 public String refreshSolrIndex();
1113 * Creates a new file with the specified owner, parent folder and name. The
1114 * new file has the same permissions as its parent folder. The file contents
1115 * are already uploaded outside of externalAPI and the uploaded file is used as a parameter.
1117 * @param userId the ID of the current user
1118 * @param folderId the ID of the parent folder
1119 * @param name the name of the new file
1120 * @param mimeType the MIME type of the file
1121 * @param fileSize the uploaded file size
1122 * @param filePath the uploaded file full path
1123 * @return The FileHeaderDTO created
1124 * @throws DuplicateNameException if the specified name already exists in
1125 * the parent folder, as either a folder or file
1126 * @throws ObjectNotFoundException if the user or parent folder was not
1127 * found, with the exception message mentioning the precise
1129 * @throws GSSIOException if there was an error while storing the file contents
1130 * @throws InsufficientPermissionsException
1131 * @throws QuotaExceededException
1133 public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
1134 throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
1135 InsufficientPermissionsException, QuotaExceededException;
1138 * Create a new FileBody with the supplied uploaded file as contents and make it the current body
1141 * @param userId the ID of the current user
1142 * @param fileId the ID of the file header object
1143 * @param mimeType the content type of the file
1144 * @param fileSize the uploaded file size
1145 * @param filePath the uploaded file full path
1146 * @return The FileHeaderDTO updated
1147 * @throws ObjectNotFoundException if the user or file was not found, with
1148 * the exception message mentioning the precise problem
1149 * @throws GSSIOException when an IO exception occurs
1150 * @throws InsufficientPermissionsException
1151 * @throws QuotaExceededException
1153 public FileHeaderDTO updateFileContents(Long userId, Long fileId, String mimeType,
1154 long fileSize, String filePath) throws ObjectNotFoundException, GSSIOException,
1155 InsufficientPermissionsException, QuotaExceededException;
1158 * Create a file based on inputstream without using transaction.
1163 * @throws IOException
1164 * @throws ObjectNotFoundException
1166 @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
1167 public File uploadFile(InputStream stream, Long userId)
1168 throws IOException, ObjectNotFoundException;
1170 public void createFileUploadProgress(Long userId, String filename,
1171 Long bytesTransfered, Long fileSize) throws ObjectNotFoundException;
1173 public FileUploadStatus getFileUploadStatus(Long userId, String fileName);
1175 public void removeFileUploadProgress(Long userId, String filename)
1176 throws ObjectNotFoundException;
1179 * Fetch the file body with the specified version number.
1181 * @param userId the ID of the current user
1182 * @param fileId the ID of the file header
1183 * @param version the version number
1184 * @return the file body
1185 * @throws ObjectNotFoundException if the user file or version
1187 * @throws InsufficientPermissionsException if the user does not
1188 * have enough privileges for reading this file
1190 public FileBodyDTO getFileVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException;
1193 * Search the system for a user with the specified email address.
1194 * If no such user is found, the method returns null.
1196 public User findUserByEmail(String email);
1199 * Update the user with the values from the supplied object.
1201 public void updateUser(User user);
1204 * Update accounting information for given user.
1206 * @param user The user to update
1207 * @param date Date of transaction
1208 * @param bandwidthDiff Bandwidth used; positive for addition,
1209 * negative for subtraction (e.g. to rollback)
1211 public void updateAccounting(User user, Date date, long bandwidthDiff);
1214 * Check if the user with the specified ID has permission to read the
1215 * folder with the supplied ID.
1217 public boolean canReadFolder(Long userId, Long folderId) throws ObjectNotFoundException;
1220 * Reset WebDAV password for given user.
1223 * @return the new password
1224 * @throws ObjectNotFoundException
1226 public String resetWebDAVPassword(Long userId) throws ObjectNotFoundException;
1229 * Find the invite for the specified invitation code.
1231 * @param code the invitation code
1232 * @return the Invitation or null if not found
1234 public Invitation findInvite(String code);
1237 * Create a new user in the connected IdP.
1239 * @param username the username of the new user
1240 * @param firstname the first name of the new user
1241 * @param lastname the last name of the new user
1242 * @param email the e-mail of the new user
1243 * @param password the password of the new user
1245 public void createLdapUser(String username, String firstname, String lastname, String email, String password);
1248 * Retrieves the available user classes.
1250 public List<UserClass> getUserClasses();
1253 * Upgrades the user class to the default "coupon bearer" class and marks
1254 * the provided coupon as used.
1256 * @param username the username of the user
1257 * @param code the coupon code
1258 * @return the new user class
1259 * @throws InvitationUsedException when trying to reuse an already used invitation
1260 * @throws ObjectNotFoundException if the user was not found
1262 public UserClass upgradeUserClass(String username, String code)
1263 throws ObjectNotFoundException, InvitationUsedException;
1266 * Retrieve the user class for coupon-bearing users.
1268 public UserClass getCouponUserClass();
1271 * Delete the actual file in the specified file system path.
1273 public void deleteActualFile(String path);
1276 * Posts the file specified by id to solr indexing server
1281 public void postFileToSolr(CommonsHttpSolrServer solr, Long id);