- finished DTO removal (needs extensive functional testing). Kept DTO objects since...
authorfstamatelopoulos <devnull@localhost>
Wed, 22 Dec 2010 14:40:32 +0000 (16:40 +0200)
committerfstamatelopoulos <devnull@localhost>
Wed, 22 Dec 2010 14:40:32 +0000 (16:40 +0200)
- reverted removal of getDTO() and getUserDTO(), for the Admin App
- need to add the appropriate methods that return DTOs in AdminService in order to (a) build without errors, (b) have a working admin app

src/gr/ebs/gss/server/domain/FileHeader.java
src/gr/ebs/gss/server/ejb/ExternalAPI.java
src/gr/ebs/gss/server/ejb/ExternalAPIBean.java
src/gr/ebs/gss/server/ejb/ExternalAPIRemote.java
src/gr/ebs/gss/server/rest/GroupsHandler.java
src/gr/ebs/gss/server/rest/OthersHandler.java
src/gr/ebs/gss/server/rest/SharedHandler.java
src/gr/ebs/gss/server/rest/TrashHandler.java
src/gr/ebs/gss/server/rest/UserSearchHandler.java
test/gr/ebs/gss/server/ejb/ExternalAPITest.java
test/gr/ebs/gss/server/ejb/ScenarioTest.java

index 469e81a..4eaa493 100644 (file)
@@ -18,7 +18,7 @@
  */\r
 package gr.ebs.gss.server.domain;\r
 \r
-import gr.ebs.gss.server.domain.dto.UserDTO;\r
+import gr.ebs.gss.server.domain.dto.FileHeaderDTO;\r
 \r
 import java.io.Serializable;\r
 import java.io.UnsupportedEncodingException;\r
@@ -444,6 +444,34 @@ public final class FileHeader  implements Serializable{
        }\r
 \r
        /**\r
+        * Constructs and returns a DTO for this instance for use by remote clients\r
+        *\r
+        * @return FileHeaderDTO\r
+        */\r
+       public FileHeaderDTO getDTO() {\r
+               final FileHeaderDTO f = new FileHeaderDTO();\r
+               f.setId(id);\r
+               f.setName(name);\r
+               f.setPath(getPath());\r
+               f.setFolder(folder.getDTO());\r
+               f.setVersioned(versioned);\r
+               f.setVersion(currentBody.getVersion());\r
+               f.setOwner(owner.getDTO());\r
+               f.setFileSize(currentBody.getFileSize());\r
+               f.setOriginalFilename(currentBody.getOriginalFilename());\r
+               f.setOriginalFilenameEncoded(currentBody.getOriginalFilenameEncoded());\r
+               f.setMimeType(currentBody.getMimeType());\r
+               f.setDeleted(deleted);\r
+               f.setReadForAll(readForAll);\r
+               List<String> tags = new ArrayList<String>();\r
+               for (FileTag tag : fileTags)\r
+                       tags.add(tag.getTag());\r
+               f.setTags(tags);\r
+               f.setAuditInfo(auditInfo.getDTO());\r
+               return f;\r
+       }\r
+\r
+       /**\r
         * Checks if the specified user has permission to delete this file, by\r
         * checking if the user has write permission to this object.\r
         *\r
index b9c8c79..552c795 100644 (file)
@@ -34,10 +34,6 @@ import gr.ebs.gss.server.domain.Nonce;
 import gr.ebs.gss.server.domain.Permission;
 import gr.ebs.gss.server.domain.User;
 import gr.ebs.gss.server.domain.UserClass;
-import gr.ebs.gss.server.domain.dto.FileBodyDTO;
-import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
-import gr.ebs.gss.server.domain.dto.FolderDTO;
-import gr.ebs.gss.server.domain.dto.PermissionDTO;
 import gr.ebs.gss.server.domain.dto.StatsDTO;
 import gr.ebs.gss.server.domain.dto.UserDTO;
 
@@ -149,19 +145,19 @@ public interface ExternalAPI {
         *
         * @param userId the ID of the User
         * @param groupId the ID of the requested group
-        * @return List<UserDTO>
+        * @return List<User>
         * @throws ObjectNotFoundException if the user or group was not found, with
         *             the exception message mentioning the precise problem
         */
-       public List<UserDTO> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
+       public List<User> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
 
        /**
         * Returns a list of users matching the specified username
         *
         * @param username the username of the User
-        * @return List<UserDTO>
+        * @return List<User>
         */
-       public List<UserDTO> getUsersByUserNameLike(String username);
+       public List<User> getUsersByUserNameLike(String username);
 
        /**
         * Creates a new folder with the specified owner, parent folder and name.
@@ -204,34 +200,10 @@ public interface ExternalAPI {
         * @throws ObjectNotFoundException if the folder or user was not found
         * @throws InsufficientPermissionsException
         */
-       public List<FolderDTO> getSubfolders(Long userId, Long folderId)
+       public List<Folder> getSubfolders(Long userId, Long folderId)
                        throws ObjectNotFoundException, InsufficientPermissionsException;
 
        /**
-        * Retrieve the folder with the specified ID with subfolders.
-        *
-        * @param userId the ID of the current user
-        * @param folderId the ID of the folder to retrieve
-        * @return the folder found
-        * @throws ObjectNotFoundException if the folder or the user was not found
-        * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
-        */
-       public FolderDTO getFolderWithSubfolders(Long userId, Long folderId)
-                       throws ObjectNotFoundException, InsufficientPermissionsException;
-
-       /**
-        * Retrieve the folder with the specified ID with subfolders.
-        *
-        * @param userId the ID of the current user
-        * @param callingUserId the ID of the user requesting this operation
-        * @param folderId the ID of the folder to retrieve
-        * @return the folder found
-        * @throws ObjectNotFoundException if the folder or the user was not found
-        * @throws InsufficientPermissionsException if ther user does not have read permissions for folder
-        */
-       public FolderDTO getFolderWithSubfolders(Long userId, Long callingUserId, Long folderId)
-                       throws ObjectNotFoundException, InsufficientPermissionsException;
-       /**
         * Retrieve the subfolders of the specified folder that are shared to others.
         *
         * @param userId the ID of the current user
@@ -239,7 +211,7 @@ public interface ExternalAPI {
         * @return the list of subfolders found
         * @throws ObjectNotFoundException if the folder or user was not found
         */
-       public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
+       public List<Folder> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
 
        /**
         * Retrieve the subfolders of the specified folder that are shared to others.
@@ -250,7 +222,7 @@ public interface ExternalAPI {
         * @return the list of subfolders found
         * @throws ObjectNotFoundException if the folder or user was not found
         */
-       public List<FolderDTO> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException;
+       public List<Folder> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException;
        /**
         * Modifies the specified folder if the specified user has the appropriate
         * permission.
@@ -319,7 +291,7 @@ public interface ExternalAPI {
         * @param name the name of the new file
         * @param mimeType the MIME type of the file
         * @param stream the input stream with the file contents
-        * @return The FileHeaderDTO created
+        * @return The FileHeader created
         * @throws DuplicateNameException if the specified name already exists in
         *             the parent folder, as either a folder or file
         * @throws ObjectNotFoundException if the user or parent folder was not
@@ -329,7 +301,7 @@ public interface ExternalAPI {
         * @throws InsufficientPermissionsException
         * @throws QuotaExceededException
         */
-       public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType,
+       public FileHeader createFile(Long userId, Long folderId, String name, String mimeType,
                                InputStream stream) throws DuplicateNameException, ObjectNotFoundException,
                                GSSIOException, InsufficientPermissionsException, QuotaExceededException;
 
@@ -455,13 +427,13 @@ public interface ExternalAPI {
         *                      the exception message mentioning the precise problem
         * @throws InsufficientPermissionsException
         */
-       public FileBodyDTO getFileBody(Long userId, Long fileId, Long bodyId)
+       public FileBody getFileBody(Long userId, Long fileId, Long bodyId)
                        throws ObjectNotFoundException, InsufficientPermissionsException;
 
        /**
         * Get the resource (file or folder) at the specified path in
         * the specified user's namespace. The returned object will be of type
-        * FileHeaderDTO or FolderDTO.<p><strong>Note:</strong> this method does not
+        * FileHeader or Folder.<p><strong>Note:</strong> this method does not
         * receive the current user as a parameter, therefore it is unable to perform
         * the necessary permission checks and should <strong>NOT</strong> be directly
         * exposed to remote clients. It is the caller's responsibility to verify that
@@ -800,7 +772,7 @@ public interface ExternalAPI {
         *       * @return the list of deleted file header objects
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException;
+       public List<FileHeader> getDeletedFiles(Long userId) throws ObjectNotFoundException;
 
        /**
         * Returns a list of All deleted root folders of a user.
@@ -809,7 +781,7 @@ public interface ExternalAPI {
         *       * @return the list of deleted file header objects
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
+       public List<Folder> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
 
        /**
         * Empty Trash by deleting all marked as deleted files and folders
@@ -909,7 +881,7 @@ public interface ExternalAPI {
         * @return the list of shared root folders
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FolderDTO> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
+       public List<Folder> getSharedRootFolders(Long userId) throws ObjectNotFoundException;
 
        /**
         * Returns a list of all shared files of a user that are not
@@ -919,7 +891,7 @@ public interface ExternalAPI {
         * @return the list of shared files
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FileHeaderDTO> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
+       public List<FileHeader> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
 
        /**
         * Returns a list of all shared files of a user.
@@ -928,7 +900,7 @@ public interface ExternalAPI {
         * @return the list of shared files
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FileHeaderDTO> getSharedFiles(Long userId) throws ObjectNotFoundException;
+       public List<FileHeader> getSharedFiles(Long userId) throws ObjectNotFoundException;
 
        /**
         * Returns a list of all shared folders of a user.
@@ -937,7 +909,7 @@ public interface ExternalAPI {
         * @return the list of shared folders
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FolderDTO> getSharedFolders(Long userId) throws ObjectNotFoundException;
+       public List<Folder> getSharedFolders(Long userId) throws ObjectNotFoundException;
 
        /**
         * Returns a list of all shared root folders of a user that calling
@@ -949,7 +921,7 @@ public interface ExternalAPI {
         *
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FolderDTO> getSharedRootFolders(Long ownerId, Long callingUserId)
+       public List<Folder> getSharedRootFolders(Long ownerId, Long callingUserId)
                        throws ObjectNotFoundException;
 
        /**
@@ -961,7 +933,7 @@ public interface ExternalAPI {
         * @param callingUserId
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FileHeaderDTO> getSharedFiles(Long ownerId, Long callingUserId)
+       public List<FileHeader> getSharedFiles(Long ownerId, Long callingUserId)
                        throws ObjectNotFoundException;
 
        /**
@@ -984,7 +956,7 @@ public interface ExternalAPI {
         * @return the List of users sharing files to user
         * @throws ObjectNotFoundException
         */
-       public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
+       public List<User> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
 
        /**
         * Search Files
@@ -1045,19 +1017,6 @@ public interface ExternalAPI {
        public StatsDTO getUserStatistics(Long userId) throws ObjectNotFoundException;
 
        /**
-        * Retrieves file versions
-        *
-        * @param userId the ID of the user
-        * @param fileId the ID of the file
-        * @return the list of filebodies
-        * @throws ObjectNotFoundException
-        * @throws InsufficientPermissionsException
-        *
-        */
-       public List<FileBodyDTO> getVersions(Long userId, Long fileId)
-                       throws ObjectNotFoundException, InsufficientPermissionsException;
-
-       /**
         * Restore the file contents to the specified version.
         *
         * @param userId the ID of the user
@@ -1121,7 +1080,7 @@ public interface ExternalAPI {
         * @param mimeType the MIME type of the file
         * @param fileSize the uploaded file size
         * @param filePath the uploaded file full path
-        * @return The FileHeaderDTO created
+        * @return The FileHeader created
         * @throws DuplicateNameException if the specified name already exists in
         *             the parent folder, as either a folder or file
         * @throws ObjectNotFoundException if the user or parent folder was not
@@ -1144,7 +1103,7 @@ public interface ExternalAPI {
         * @param mimeType the content type of the file
         * @param fileSize the uploaded file size
         * @param filePath the uploaded file full path
-        * @return The FileHeaderDTO updated
+        * @return The FileHeader updated
         * @throws ObjectNotFoundException if the user or file was not found, with
         *                      the exception message mentioning the precise problem
         * @throws GSSIOException when an IO exception occurs
index 84d4f34..8297c9f 100644 (file)
@@ -37,11 +37,6 @@ import gr.ebs.gss.server.domain.Nonce;
 import gr.ebs.gss.server.domain.Permission;
 import gr.ebs.gss.server.domain.User;
 import gr.ebs.gss.server.domain.UserClass;
-import gr.ebs.gss.server.domain.dto.FileBodyDTO;
-import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
-import gr.ebs.gss.server.domain.dto.FolderDTO;
-import gr.ebs.gss.server.domain.dto.GroupDTO;
-import gr.ebs.gss.server.domain.dto.PermissionDTO;
 import gr.ebs.gss.server.domain.dto.StatsDTO;
 import gr.ebs.gss.server.domain.dto.UserDTO;
 
@@ -57,7 +52,6 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Random;
@@ -233,7 +227,7 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
        }
 
        @Override
-       public List<UserDTO> getUsers(final Long userId, final Long groupId) throws ObjectNotFoundException {
+       public List<User> getUsers(final Long userId, final Long groupId) throws ObjectNotFoundException {
                // Validate.
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
@@ -242,10 +236,7 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
 
                // Do the actual work.
                final List<User> users = dao.getUsers(groupId);
-               final List<UserDTO> result = new ArrayList<UserDTO>();
-               for (final User u : users)
-                       result.add(u.getDTO());
-               return result;
+               return users;
        }
 
        @Override
@@ -375,7 +366,7 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
 
        @Override
        @SuppressWarnings("unchecked")
-       public List<FolderDTO> getSubfolders(Long userId, Long folderId)
+       public List<Folder> getSubfolders(Long userId, Long folderId)
                        throws ObjectNotFoundException, InsufficientPermissionsException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
@@ -385,11 +376,11 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
                Folder folder = dao.getEntityById(Folder.class, folderId);
                if (!folder.hasReadPermission(user))
                        throw new InsufficientPermissionsException("You don't have the permissions to read this folder");
-               List<FolderDTO> result = new ArrayList<FolderDTO>();
+               List<Folder> result = new ArrayList<Folder>();
                if (folder.hasReadPermission(user))
                        for (Folder f : folder.getSubfolders())
                                if (f.hasReadPermission(user) && !f.isDeleted())
-                                       result.add(f.getDTO());
+                                       result.add(f);
                return result;
        }
 
@@ -491,7 +482,7 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
        }
 
        @Override
-       public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, InputStream stream)
+       public FileHeader createFile(Long userId, Long folderId, String name, String mimeType, InputStream stream)
                        throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
                        InsufficientPermissionsException, QuotaExceededException {
                File file = null;
@@ -780,7 +771,7 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
        }
 
        @Override
-       public FileBodyDTO getFileBody(Long userId, Long fileId, Long bodyId) throws ObjectNotFoundException, InsufficientPermissionsException {
+       public FileBody getFileBody(Long userId, Long fileId, Long bodyId) throws ObjectNotFoundException, InsufficientPermissionsException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                if (fileId == null)
@@ -790,7 +781,7 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
                if (!file.hasReadPermission(user) && !file.getFolder().hasReadPermission(user))
                        throw new InsufficientPermissionsException("You don't have the necessary permissions");
                FileBody body = dao.getEntityById(FileBody.class, bodyId);
-               return body.getDTO();
+               return body;
        }
 
        @Override
@@ -828,7 +819,7 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
                } catch (ObjectNotFoundException e) {
                        // Perhaps the requested resource is not a file, so
                        // check for folders as well.
-                       FolderDTO folder = getFolder(cursor.getId(), lastElement);
+                       Folder folder = getFolder(cursor.getId(), lastElement);
                        if (ignoreDeleted && folder.isDeleted())
                                throw new ObjectNotFoundException("Resource not found");
                        resource = folder;
@@ -878,7 +869,7 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
                return folder;
        }
 
-       private FileHeaderDTO updateFileContents(Long userId, Long fileId, String mimeType, InputStream resourceInputStream) throws ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException {
+       private FileHeader updateFileContents(Long userId, Long fileId, String mimeType, InputStream resourceInputStream) throws ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException {
                File file = null;
                try {
                        file = uploadFile(resourceInputStream, userId);
@@ -899,9 +890,9 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
                        throw new ObjectNotFoundException("No destination specified");
 
                Object destination = getResourceAtPath(userId, getParentPath(dest), true);
-               if (!(destination instanceof FolderDTO))
+               if (!(destination instanceof Folder))
                        throw new ObjectNotFoundException("Destination parent folder not found");
-               FolderDTO parent = (FolderDTO) destination;
+               Folder parent = (Folder) destination;
                copyFile(userId, fileId, parent.getId(), getLastElement(dest));
        }
 
@@ -917,9 +908,9 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
                        throw new ObjectNotFoundException("No destination specified");
 
                Object destination = getResourceAtPath(ownerId, getParentPath(dest), true);
-               if (!(destination instanceof FolderDTO))
+               if (!(destination instanceof Folder))
                        throw new ObjectNotFoundException("Destination parent folder not found");
-               FolderDTO parent = (FolderDTO) destination;
+               Folder parent = (Folder) destination;
                copyFile(userId, fileId, parent.getId(), getLastElement(dest));
        }
 
@@ -976,9 +967,9 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
                        throw new ObjectNotFoundException("No destination specified");
 
                Object destination = getResourceAtPath(userId, getParentPath(dest), true);
-               if (!(destination instanceof FolderDTO))
+               if (!(destination instanceof Folder))
                        throw new ObjectNotFoundException("Destination folder not found");
-               FolderDTO parent = (FolderDTO) destination;
+               Folder parent = (Folder) destination;
                copyFolder(userId, folderId, parent.getId(), getLastElement(dest));
        }
 
@@ -1012,9 +1003,9 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
                        throw new ObjectNotFoundException("No destination specified");
 
                Object destination = getResourceAtPath(ownerId, getParentPath(dest), true);
-               if (!(destination instanceof FolderDTO))
+               if (!(destination instanceof Folder))
                        throw new ObjectNotFoundException("Destination folder not found");
-               FolderDTO parent = (FolderDTO) destination;
+               Folder parent = (Folder) destination;
                copyFolderStructure(userId, folderId, parent.getId(), getLastElement(dest));
        }
 
@@ -1135,9 +1126,9 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
                        throw new ObjectNotFoundException("No destination specified");
 
                Object destination = getResourceAtPath(ownerId, getParentPath(dest), true);
-               if (!(destination instanceof FolderDTO))
+               if (!(destination instanceof Folder))
                        throw new ObjectNotFoundException("Destination parent folder not found");
-               FolderDTO parent = (FolderDTO) destination;
+               Folder parent = (Folder) destination;
                moveFile(userId, fileId, parent.getId(), getLastElement(dest));
        }
 
@@ -1203,9 +1194,9 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
                        throw new ObjectNotFoundException("No destination specified");
 
                Object destination = getResourceAtPath(ownerId, getParentPath(dest), true);
-               if (!(destination instanceof FolderDTO))
+               if (!(destination instanceof Folder))
                        throw new ObjectNotFoundException("Destination parent folder not found");
-               FolderDTO parent = (FolderDTO) destination;
+               Folder parent = (Folder) destination;
                moveFolder(userId, folderId, parent.getId(), getLastElement(dest));
        }
 
@@ -1266,17 +1257,14 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
        }
 
        @Override
-       public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException {
+       public List<FileHeader> getDeletedFiles(Long userId) throws ObjectNotFoundException {
                // Validate.
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
 
                // Do the actual work.
-               final List<FileHeaderDTO> result = new ArrayList<FileHeaderDTO>();
                final List<FileHeader> files = dao.getDeletedFiles(userId);
-               for (final FileHeader f : files)
-                       result.add(f.getDTO());
-               return result;
+               return files;
        }
 
        @Override
@@ -1344,32 +1332,29 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
        }
 
        @Override
-       public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException {
+       public List<Folder> getDeletedRootFolders(Long userId) throws ObjectNotFoundException {
                List<Folder> folders = dao.getDeletedRootFolders(userId);
-               List<FolderDTO> result = new ArrayList<FolderDTO>();
-               for (Folder folder : folders)
-                       result.add(folder.getDTO());
-               return result;
+               return folders;
        }
 
        @Override
        public void emptyTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException {
-               List<FolderDTO> deletedRootFolders = getDeletedRootFolders(userId);
-               for (FolderDTO fdto : deletedRootFolders)
-                       deleteFolder(userId, fdto.getId());
-               List<FileHeaderDTO> deletedFiles = getDeletedFiles(userId);
-               for (FileHeaderDTO filedto : deletedFiles)
-                       deleteFile(userId, filedto.getId());
+               List<Folder> deletedRootFolders = getDeletedRootFolders(userId);
+               for (Folder folder : deletedRootFolders)
+                       deleteFolder(userId, folder.getId());
+               List<FileHeader> deletedFiles = getDeletedFiles(userId);
+               for (FileHeader file : deletedFiles)
+                       deleteFile(userId, file.getId());
        }
 
        @Override
        public void restoreTrash(Long userId) throws ObjectNotFoundException, InsufficientPermissionsException {
-               List<FolderDTO> deletedRootFolders = getDeletedRootFolders(userId);
-               for (FolderDTO fdto : deletedRootFolders)
-                       removeFolderFromTrash(userId, fdto.getId());
-               List<FileHeaderDTO> deletedFiles = getDeletedFiles(userId);
-               for (FileHeaderDTO filedto : deletedFiles)
-                       removeFileFromTrash(userId, filedto.getId());
+               List<Folder> deletedRootFolders = getDeletedRootFolders(userId);
+               for (Folder folder : deletedRootFolders)
+                       removeFolderFromTrash(userId, folder.getId());
+               List<FileHeader> deletedFiles = getDeletedFiles(userId);
+               for (FileHeader file : deletedFiles)
+                       removeFileFromTrash(userId, file.getId());
        }
 
        @Override
@@ -1536,12 +1521,9 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
         * @see gr.ebs.gss.server.ejb.ExternalAPI#getUsersByUserNameLike(java.lang.String)
         */
        @Override
-       public List<UserDTO> getUsersByUserNameLike(String username) {
+       public List<User> getUsersByUserNameLike(String username) {
                List<User> users = dao.getUsersByUserNameLike(username);
-               List<UserDTO> result = new ArrayList<UserDTO>();
-               for (User u : users)
-                       result.add(u.getDTO());
-               return result;
+               return users;
 
        }
 
@@ -1575,15 +1557,15 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
        }
 
        @Override
-       public List<FolderDTO> getSharedRootFolders(Long userId) throws ObjectNotFoundException {
+       public List<Folder> getSharedRootFolders(Long userId) throws ObjectNotFoundException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                List<Folder> folders = dao.getSharedRootFolders(userId);
-               List<FolderDTO> result = new ArrayList<FolderDTO>();
+               List<Folder> result = new ArrayList<Folder>();
                for (Folder f : folders) {
-                       FolderDTO dto = f.getDTO();
-                       dto.setSubfolders(getSharedSubfolders(userId, f.getId()));
-                       result.add(dto);
+                       Folder lf = f;
+                       lf.setSubfolders(getSharedSubfolders(userId, f.getId()));
+                       result.add(lf);
                }
                return result;
        }
@@ -1607,16 +1589,16 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
        }
 
        @Override
-       public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException {
+       public List<User> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException {
                List<User> users = dao.getUsersSharingFoldersForUser(userId);
                List<User> usersFiles = dao.getUsersSharingFilesForUser(userId);
-               List<UserDTO> res = new ArrayList<UserDTO>();
+               List<User> result = new ArrayList<User>();
                for (User u : users)
-                       res.add(u.getDTO());
+                       result.add(u);
                for(User fu : usersFiles)
                        if(!users.contains(fu))
-                               res.add(fu.getDTO());
-               return res;
+                               result.add(fu);
+               return result;
        }
 
        @Override
@@ -1677,86 +1659,74 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
        }
 
        @Override
-       public List<FileHeaderDTO> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException {
+       public List<FileHeader> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                List<FileHeader> files = dao.getSharedFilesNotInSharedFolders(userId);
-               List<FileHeaderDTO> result = new ArrayList<FileHeaderDTO>();
-               for (FileHeader f : files)
-                       result.add(f.getDTO());
-               return result;
+               return files;
        }
 
        @Override
-       public List<FileHeaderDTO> getSharedFiles(Long userId) throws ObjectNotFoundException {
+       public List<FileHeader> getSharedFiles(Long userId) throws ObjectNotFoundException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                List<FileHeader> files = dao.getSharedFiles(userId);
-               List<FileHeaderDTO> result = new ArrayList<FileHeaderDTO>();
-               for (FileHeader f : files)
-                       result.add(f.getDTO());
-               return result;
+               return files;
        }
 
        @Override
-       public List<FolderDTO> getSharedFolders(Long userId) throws ObjectNotFoundException {
+       public List<Folder> getSharedFolders(Long userId) throws ObjectNotFoundException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                List<Folder> folders = dao.getSharedFolders(userId);
-               List<FolderDTO> result = new ArrayList<FolderDTO>();
-               for (Folder f : folders)
-                       result.add(f.getDTO());
-               return result;
+               return folders;
        }
 
        @Override
-       public List<FileHeaderDTO> getSharedFiles(Long ownerId, Long callingUserId) throws ObjectNotFoundException {
+       public List<FileHeader> getSharedFiles(Long ownerId, Long callingUserId) throws ObjectNotFoundException {
                if (ownerId == null)
                        throw new ObjectNotFoundException("No owner specified");
                if (callingUserId == null)
                        throw new ObjectNotFoundException("No calling user specified");
                List<FileHeader> folders = dao.getSharedFiles(ownerId, callingUserId);
-               List<FileHeaderDTO> result = new ArrayList<FileHeaderDTO>();
-               for (FileHeader f : folders)
-                       result.add(f.getDTO());
-               return result;
+               return folders;
        }
 
        @Override
-       public List<FolderDTO> getSharedRootFolders(Long ownerId, Long callingUserId) throws ObjectNotFoundException {
+       public List<Folder> getSharedRootFolders(Long ownerId, Long callingUserId) throws ObjectNotFoundException {
                if (ownerId == null)
                        throw new ObjectNotFoundException("No owner specified");
                if (callingUserId == null)
                        throw new ObjectNotFoundException("No calling user specified");
                List<Folder> folders = dao.getSharedRootFolders(ownerId, callingUserId);
-               List<FolderDTO> result = new ArrayList<FolderDTO>();
+               List<Folder> result = new ArrayList<Folder>();
                for (Folder f : folders) {
-                       FolderDTO dto = f.getDTO();
-                       dto.setSubfolders(getSharedSubfolders(ownerId, callingUserId, f.getId()));
-                       result.add(dto);
+                       Folder lf = f;
+                       lf.setSubfolders(getSharedSubfolders(ownerId, callingUserId, f.getId()));
+                       result.add(lf);
                }
                return result;
 
        }
 
        @Override
-       public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException {
+       public List<Folder> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                if (folderId == null)
                        throw new ObjectNotFoundException("No folder specified");
                User user = dao.getEntityById(User.class, userId);
                Folder folder = dao.getEntityById(Folder.class, folderId);
-               List<FolderDTO> result = new ArrayList<FolderDTO>();
+               List<Folder> result = new ArrayList<Folder>();
                if (folder.isShared(user) || folder.isReadForAll())
                        for (Folder f : folder.getSubfolders())
                                if ((f.isShared(user) || f.isReadForAll()) && !f.isDeleted())
-                                       result.add(f.getDTO());
+                                       result.add(f);
                return result;
        }
 
        @Override
-       public List<FolderDTO> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException {
+       public List<Folder> getSharedSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
                if (callingUserId == null)
@@ -1765,13 +1735,13 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
                        throw new ObjectNotFoundException("No folder specified");
                User user = dao.getEntityById(User.class, callingUserId);
                Folder folder = dao.getEntityById(Folder.class, folderId);
-               List<FolderDTO> result = new ArrayList<FolderDTO>();
+               List<Folder> result = new ArrayList<Folder>();
                if (folder.isSharedForOtherUser(user))
                        for (Folder f : folder.getSubfolders())
                                if (f.isSharedForOtherUser(user) && !f.isDeleted()){
-                                       FolderDTO dto = f.getDTO();
-                                       dto.setSubfolders(getSharedSubfolders(userId, callingUserId, dto.getId()));
-                                       result.add(dto);
+                                       Folder lf = f;
+                                       lf.setSubfolders(getSharedSubfolders(userId, callingUserId, lf.getId()));
+                                       result.add(lf);
                                }
                return result;
 
@@ -1959,22 +1929,6 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
        }
 
        @Override
-       public List<FileBodyDTO> getVersions(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException {
-               if (userId == null)
-                       throw new ObjectNotFoundException("No user specified");
-               if (fileId == null)
-                       throw new ObjectNotFoundException("No file specified");
-               User user = dao.getEntityById(User.class, userId);
-               FileHeader header = dao.getEntityById(FileHeader.class, fileId);
-               if(!header.hasReadPermission(user))
-                       throw new InsufficientPermissionsException("You don't have the necessary permissions");
-               List<FileBodyDTO> result = new LinkedList<FileBodyDTO>();
-               for(int i = header.getBodies().size()-1 ; i>=0; i--)
-                       result.add(header.getBodies().get(i).getDTO());
-               return result;
-       }
-
-       @Override
        public void removeVersion(Long userId, Long fileId, Long bodyId) throws ObjectNotFoundException, InsufficientPermissionsException {
                if (userId == null)
                        throw new ObjectNotFoundException("No user specified");
@@ -2404,44 +2358,6 @@ public class ExternalAPIBean implements ExternalAPI, ExternalAPIRemote {
        }
 
        @Override
-       public FolderDTO getFolderWithSubfolders(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException {
-               if (userId == null)
-                       throw new ObjectNotFoundException("No user specified");
-               if (folderId == null)
-                       throw new ObjectNotFoundException("No folder specified");
-               final User user = dao.getEntityById(User.class, userId);
-               final Folder folder = dao.getEntityById(Folder.class, folderId);
-               // Check permissions
-               if (!folder.hasReadPermission(user))
-                       throw new InsufficientPermissionsException("You don't have the permissions to read this folder");
-               List<FolderDTO> subfolders = new ArrayList<FolderDTO>();
-               if (folder.hasReadPermission(user))
-                       for (Folder f : folder.getSubfolders())
-                               if (f.hasReadPermission(user) && !f.isDeleted())
-                                       subfolders.add(f.getDTO());
-               FolderDTO result = folder.getDTO();
-               result.setSubfolders(subfolders);
-               return folder.getDTO();
-       }
-
-       @Override
-       public FolderDTO getFolderWithSubfolders(Long userId, Long callingUserId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException {
-               if (userId == null)
-                       throw new ObjectNotFoundException("No user specified");
-               if (folderId == null)
-                       throw new ObjectNotFoundException("No folder specified");
-               User user = dao.getEntityById(User.class, callingUserId);
-               Folder folder = dao.getEntityById(Folder.class, folderId);
-               // Check permissions
-               if (!folder.hasReadPermission(user))
-                       throw new InsufficientPermissionsException("You don't have the permissions to read this folder");
-
-               FolderDTO result = folder.getDTO();
-               result.setSubfolders(getSharedSubfolders(userId, callingUserId, folder.getId()));
-               return result;
-       }
-
-       @Override
        public FileBody getFileVersion(Long userId, Long fileId, int version)
                        throws ObjectNotFoundException, InsufficientPermissionsException {
                if (userId == null)
index cc40540..e41a20f 100644 (file)
@@ -79,15 +79,6 @@ public interface ExternalAPIRemote {
        public User getUser(Long userId) throws ObjectNotFoundException;
 
        /**
-        * Returns the user with the specified ID.
-        *
-        * @param userId The ID of the User to be found
-        * @return The User object
-        * @throws ObjectNotFoundException if the user cannot be found
-        */
-       public UserDTO getUserDTO(Long userId) throws ObjectNotFoundException;
-
-       /**
         * Returns the group with the specified ID.
         *
         * @param groupId The ID of the Group to be found
@@ -122,19 +113,19 @@ public interface ExternalAPIRemote {
         *
         * @param userId the ID of the User
         * @param groupId the ID of the requested group
-        * @return List<UserDTO>
+        * @return List<User>
         * @throws ObjectNotFoundException if the user or group was not found, with
         *             the exception message mentioning the precise problem
         */
-       public List<UserDTO> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
+       public List<User> getUsers(Long userId, Long groupId) throws ObjectNotFoundException;
 
        /**
         * Returns a list of users for the specified username
         *
         * @param username the username of the User
-        * @return List<UserDTO>
+        * @return List<User>
         */
-       public List<UserDTO> getUsersByUserNameLike(String username);
+       public List<User> getUsersByUserNameLike(String username);
 
        /**
         * Creates a new folder with the specified owner, parent folder and name.
@@ -175,7 +166,7 @@ public interface ExternalAPIRemote {
         * @throws ObjectNotFoundException if the folder or user was not found
         * @throws InsufficientPermissionsException
         */
-       public List<FolderDTO> getSubfolders(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
+       public List<Folder> getSubfolders(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
 
 
        /**
@@ -186,7 +177,7 @@ public interface ExternalAPIRemote {
         * @return the list of subfolders found
         * @throws ObjectNotFoundException if the folder or user was not found
         */
-       public List<FolderDTO> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
+       public List<Folder> getSharedSubfolders(Long userId, Long folderId) throws ObjectNotFoundException;
 
        /**
         * Modifies the specified folder if the specified user has the appropriate
@@ -256,7 +247,7 @@ public interface ExternalAPIRemote {
         * @param name the name of the new file
         * @param mimeType the MIME type of the file
         * @param stream the input stream with the file contents
-        * @return The FileHeaderDTO created
+        * @return The FileHeader created
         * @throws DuplicateNameException if the specified name already exists in
         *             the parent folder, as either a folder or file
         * @throws ObjectNotFoundException if the user or parent folder was not
@@ -265,7 +256,7 @@ public interface ExternalAPIRemote {
         * @throws GSSIOException if there was an error while storing the file contents
         * @throws InsufficientPermissionsException
         */
-       public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, InputStream stream) throws DuplicateNameException, ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
+       public FileHeader createFile(Long userId, Long folderId, String name, String mimeType, InputStream stream) throws DuplicateNameException, ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException;
 
        /**
         * Deletes the specified file in the specified user's namespace.
@@ -343,12 +334,12 @@ public interface ExternalAPIRemote {
         *                      the exception message mentioning the precise problem
         * @throws InsufficientPermissionsException
         */
-       public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
+       public FileHeader getFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
 
        /**
         * Get the resource (file or folder) at the specified path in
         * the specified user's namespace. The returned object will be of type
-        * FileHeaderDTO or FolderDTO.<p><strong>Note:</strong> this method does not
+        * FileHeader or Folder.<p><strong>Note:</strong> this method does not
         * receive the current user as a parameter, therefore it is unable to perform
         * the necessary permission checks and should <strong>NOT</strong> be directly
         * exposed to remote clients. It is the caller's responsibility to verify that
@@ -533,7 +524,7 @@ public interface ExternalAPIRemote {
         *       * @return the list of deleted file header objects
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FileHeaderDTO> getDeletedFiles(Long userId) throws ObjectNotFoundException;
+       public List<FileHeader> getDeletedFiles(Long userId) throws ObjectNotFoundException;
 
        /**
         * Returns a list of All deleted root folders of a user.
@@ -542,7 +533,7 @@ public interface ExternalAPIRemote {
         *       * @return the list of deleted file header objects
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FolderDTO> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
+       public List<Folder> getDeletedRootFolders(Long userId) throws ObjectNotFoundException;
 
        /**
         * Empty Trash by deleting all marked as deleted files and folders
@@ -641,7 +632,7 @@ public interface ExternalAPIRemote {
         *       * @return the list of shared files
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FileHeaderDTO> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
+       public List<FileHeader> getSharedFilesNotInSharedFolders(Long userId) throws ObjectNotFoundException;
 
        /**
         * Returns a list of All Shared root folders of a user that calling user has at least read permissions.
@@ -652,7 +643,7 @@ public interface ExternalAPIRemote {
         *
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FolderDTO> getSharedRootFolders(Long ownerId, Long callingUserId) throws ObjectNotFoundException;
+       public List<Folder> getSharedRootFolders(Long ownerId, Long callingUserId) throws ObjectNotFoundException;
 
        /**
         * Returns a list of All Shared  files of a user that calling user has at least read permissions..
@@ -662,7 +653,7 @@ public interface ExternalAPIRemote {
         * @param callingUserId
         * @throws ObjectNotFoundException if the user cannot be found
         */
-       public List<FileHeaderDTO> getSharedFiles(Long ownerId, Long callingUserId) throws ObjectNotFoundException;
+       public List<FileHeader> getSharedFiles(Long ownerId, Long callingUserId) throws ObjectNotFoundException;
 
        /**
         * Remove a user member from a group
@@ -683,7 +674,7 @@ public interface ExternalAPIRemote {
         * @return the List of users sharing files to user
         * @throws ObjectNotFoundException
         */
-       public List<UserDTO> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
+       public List<User> getUsersSharingFoldersForUser(Long userId) throws ObjectNotFoundException;
 
        /**
         * Indexes the file meta-data and contents. It actually sends the info to be indexed to a message queue
index bfbe658..432b1e2 100644 (file)
@@ -22,6 +22,7 @@ import gr.ebs.gss.client.exceptions.DuplicateNameException;
 import gr.ebs.gss.client.exceptions.InsufficientPermissionsException;
 import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
 import gr.ebs.gss.client.exceptions.RpcException;
+import gr.ebs.gss.server.domain.Group;
 import gr.ebs.gss.server.domain.User;
 import gr.ebs.gss.server.domain.dto.GroupDTO;
 import gr.ebs.gss.server.domain.dto.UserDTO;
@@ -76,9 +77,9 @@ public class GroupsHandler extends RequestHandler {
        if (path.equals("/"))
                        // Request to serve all groups
                try {
-               List<GroupDTO> groups = getService().getGroups(owner.getId());
+               List<Group> groups = getService().getGroups(owner.getId());
                JSONArray json = new JSONArray();
-               for (GroupDTO group: groups) {
+               for (Group group: groups) {
                        JSONObject j = new JSONObject();
                        j.put("name", group.getName()).
                                put("uri", parentUrl + URLEncoder.encode(group.getName(),"UTF-8"));
@@ -111,8 +112,8 @@ public class GroupsHandler extends RequestHandler {
                                if (logger.isDebugEnabled())
                                        logger.debug("Serving member " + path.substring(slash + 1) +
                                                                " from group " + path.substring(0, slash));
-                               GroupDTO group = getService().getGroup(owner.getId(), URLDecoder.decode(path.substring(0, slash),"UTF-8"));
-                               for (UserDTO u: group.getMembers())
+                               Group group = getService().getGroup(owner.getId(), URLDecoder.decode(path.substring(0, slash),"UTF-8"));
+                               for (User u: group.getMembers())
                                        if (u.getUsername().equals(path.substring(slash + 1))) {
                                                // Build the proper parent URL
                                                String pathInfo = req.getPathInfo();
@@ -127,9 +128,9 @@ public class GroupsHandler extends RequestHandler {
                                // Request to serve group
                                if (logger.isDebugEnabled())
                                        logger.debug("Serving group " + path);
-                               GroupDTO group = getService().getGroup(owner.getId(), URLDecoder.decode(path,"UTF-8"));
+                               Group group = getService().getGroup(owner.getId(), URLDecoder.decode(path,"UTF-8"));
                                JSONArray json = new JSONArray();
-                               for (UserDTO u: group.getMembers())
+                               for (User u: group.getMembers())
                                        json.put(parentUrl + u.getUsername());
 
                                sendJson(req, resp, json.toString());
@@ -203,7 +204,7 @@ public class GroupsHandler extends RequestHandler {
                        if (logger.isDebugEnabled())
                                logger.debug("Adding member " + username +
                                                        " to group " + path);
-                       final GroupDTO group = getService().getGroup(owner.getId(), URLDecoder.decode(path,"UTF-8"));
+                       final Group group = getService().getGroup(owner.getId(), URLDecoder.decode(path,"UTF-8"));
                        final User member = getService().findUser(username);
                        if (member == null) {
                                resp.sendError(HttpServletResponse.SC_NOT_FOUND, "User " + username + " not found");
@@ -270,8 +271,8 @@ public class GroupsHandler extends RequestHandler {
                        if (logger.isDebugEnabled())
                                logger.debug("Removing member " + path.substring(slash + 1) +
                                                        " from group " + path.substring(0, slash));
-                       final GroupDTO group = getService().getGroup(owner.getId(), URLDecoder.decode(path.substring(0, slash),"UTF-8"));
-                       for (final UserDTO u: group.getMembers())
+                       final Group group = getService().getGroup(owner.getId(), URLDecoder.decode(path.substring(0, slash),"UTF-8"));
+                       for (final User u: group.getMembers())
                                if (u.getUsername().equals(path.substring(slash + 1)))
                                        new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
                                                @Override
@@ -283,7 +284,7 @@ public class GroupsHandler extends RequestHandler {
                } else {
                        if (logger.isDebugEnabled())
                                logger.debug("Removing group " + path);
-                               final GroupDTO group = getService().getGroup(owner.getId(), URLDecoder.decode(path,"UTF-8"));
+                               final Group group = getService().getGroup(owner.getId(), URLDecoder.decode(path,"UTF-8"));
                                new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
                                        @Override
                                        public Void call() throws Exception {
index 8543c84..36c46e2 100644 (file)
@@ -20,10 +20,10 @@ package gr.ebs.gss.server.rest;
 
 import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
 import gr.ebs.gss.client.exceptions.RpcException;
+import gr.ebs.gss.server.domain.FileHeader;
+import gr.ebs.gss.server.domain.Folder;
 import gr.ebs.gss.server.domain.User;
 import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
-import gr.ebs.gss.server.domain.dto.FolderDTO;
-import gr.ebs.gss.server.domain.dto.UserDTO;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -74,8 +74,8 @@ public class OthersHandler extends RequestHandler {
                        // Request to retrieve the other users who have shared resources to this user
                        JSONArray json = new JSONArray();
 
-               List<UserDTO> others = getService().getUsersSharingFoldersForUser(owner.getId());
-                       for (UserDTO u: others) {
+               List<User> others = getService().getUsersSharingFoldersForUser(owner.getId());
+                       for (User u: others) {
                                JSONObject j = new JSONObject();
                                j.put("username", u.getUsername()).
                                        put("uri", parentUrl + u.getUsername());
@@ -108,8 +108,8 @@ public class OthersHandler extends RequestHandler {
                        JSONObject json = new JSONObject();
 
                                List<JSONObject> subfolders = new ArrayList<JSONObject>();
-               List<FolderDTO> folders = getService().getSharedRootFolders(other.getId(), owner.getId());
-                       for (FolderDTO f: folders) {
+               List<Folder> folders = getService().getSharedRootFolders(other.getId(), owner.getId());
+                       for (Folder f: folders) {
                                JSONObject j = new JSONObject();
                                j.put("name", f.getName()).
                                        put("uri", getApiRoot() + f.getURI());
@@ -118,15 +118,15 @@ public class OthersHandler extends RequestHandler {
                        json.put("folders", subfolders);
 
                List<JSONObject> files = new ArrayList<JSONObject>();
-               List<FileHeaderDTO> fileHeaders = getService().getSharedFiles(other.getId(), owner.getId());
-               for (FileHeaderDTO f: fileHeaders) {
+               List<FileHeader> fileHeaders = getService().getSharedFiles(other.getId(), owner.getId());
+               for (FileHeader f: fileHeaders) {
                        JSONObject j = new JSONObject();
                                j.put("name", f.getName()).
                                        put("owner", f.getOwner().getUsername()).
                                        put("deleted", f.isDeleted()).
-                                       put("version", f.getVersion()).
-                                       put("size", f.getFileSize()).
-                                       put("content", f.getMimeType()).
+                                       put("version", f.getCurrentBody().getVersion()).
+                                       put("size", f.getCurrentBody().getFileSize()).
+                                       put("content", f.getCurrentBody().getMimeType()).
                                        put("creationDate", f.getAuditInfo().getCreationDate().getTime()).
                                        put("modificationDate", f.getAuditInfo().getModificationDate().getTime()).
                                        put("path", f.getFolder().getPath()).
index b2b5d23..55f1193 100644 (file)
@@ -21,9 +21,10 @@ package gr.ebs.gss.server.rest;
 import gr.ebs.gss.client.exceptions.InsufficientPermissionsException;
 import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
 import gr.ebs.gss.client.exceptions.RpcException;
+import gr.ebs.gss.server.domain.FileHeader;
+import gr.ebs.gss.server.domain.Folder;
 import gr.ebs.gss.server.domain.User;
 import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
-import gr.ebs.gss.server.domain.dto.FolderDTO;
 
 import java.io.IOException;
 import java.net.URLEncoder;
@@ -73,8 +74,8 @@ public class SharedHandler extends RequestHandler {
                        JSONObject json = new JSONObject();
 
                                List<JSONObject> subfolders = new ArrayList<JSONObject>();
-               List<FolderDTO> folders = getService().getSharedRootFolders(owner.getId());
-               for (FolderDTO f: folders) {
+               List<Folder> folders = getService().getSharedRootFolders(owner.getId());
+               for (Folder f: folders) {
                                JSONObject j = new JSONObject();
                                j.put("name", f.getName()).
                                        put("uri", getApiRoot() + f.getURI());
@@ -84,16 +85,16 @@ public class SharedHandler extends RequestHandler {
                        }
                        json.put("folders", subfolders);
 
-               List<FileHeaderDTO> fileHeaders = getService().getSharedFilesNotInSharedFolders(owner.getId());
+               List<FileHeader> fileHeaders = getService().getSharedFilesNotInSharedFolders(owner.getId());
                List<JSONObject> files = new ArrayList<JSONObject>();
-               for (FileHeaderDTO f: fileHeaders) {
+               for (FileHeader f: fileHeaders) {
                        JSONObject j = new JSONObject();
                                j.put("name", f.getName()).
                                        put("owner", f.getOwner().getUsername()).
                                        put("deleted", f.isDeleted()).
-                                       put("version", f.getVersion()).
-                                       put("size", f.getFileSize()).
-                                       put("content", f.getMimeType()).
+                                       put("version", f.getCurrentBody().getVersion()).
+                                       put("size", f.getCurrentBody().getFileSize()).
+                                       put("content", f.getCurrentBody().getMimeType()).
                                        put("path", f.getFolder().getPath()).
                                        put("creationDate", f.getAuditInfo().getCreationDate().getTime()).
                                        put("modificationDate", f.getAuditInfo().getModificationDate().getTime()).
index 281dbc4..aeb3a23 100644 (file)
@@ -21,6 +21,8 @@ package gr.ebs.gss.server.rest;
 import gr.ebs.gss.client.exceptions.InsufficientPermissionsException;
 import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
 import gr.ebs.gss.client.exceptions.RpcException;
+import gr.ebs.gss.server.domain.FileHeader;
+import gr.ebs.gss.server.domain.Folder;
 import gr.ebs.gss.server.domain.User;
 import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
 import gr.ebs.gss.server.domain.dto.FolderDTO;
@@ -71,8 +73,8 @@ public class TrashHandler extends RequestHandler {
                        return;
        }
 
-       List<FileHeaderDTO> files = null;
-               List<FolderDTO> folders = null;
+       List<FileHeader> files = null;
+               List<Folder> folders = null;
        User user = getUser(req);
        User owner = getOwner(req);
        if (!owner.equals(user)) {
@@ -99,7 +101,7 @@ public class TrashHandler extends RequestHandler {
                JSONObject json = new JSONObject();
        try {
                List<JSONObject> trashFolders = new ArrayList<JSONObject>();
-               for (FolderDTO f: folders) {
+               for (Folder f: folders) {
                        JSONObject j = new JSONObject();
                        j.put("name", f.getName()).
                                put("uri", getApiRoot() + f.getURI());
@@ -109,14 +111,14 @@ public class TrashHandler extends RequestHandler {
                }
                json.put("folders", trashFolders);
                List<JSONObject> trashFiles = new ArrayList<JSONObject>();
-               for (FileHeaderDTO f: files) {
+               for (FileHeader f: files) {
                        JSONObject j = new JSONObject();
                                j.put("name", f.getName()).
                                        put("owner", f.getOwner().getUsername()).
                                        put("deleted", f.isDeleted()).
-                                       put("version", f.getVersion()).
-                                       put("size", f.getFileSize()).
-                                       put("content", f.getMimeType()).
+                                       put("version", f.getCurrentBody().getVersion()).
+                                       put("size", f.getCurrentBody().getFileSize()).
+                                       put("content", f.getCurrentBody().getMimeType()).
                                        put("path", f.getFolder().getPath()).
                                        put("creationDate", f.getAuditInfo().getCreationDate().getTime()).
                                        put("modificationDate", f.getAuditInfo().getModificationDate().getTime()).
index 79e0d7f..914aee8 100644 (file)
@@ -19,7 +19,7 @@
 package gr.ebs.gss.server.rest;
 
 import gr.ebs.gss.client.exceptions.RpcException;
-import gr.ebs.gss.server.domain.dto.UserDTO;
+import gr.ebs.gss.server.domain.User;
 
 import java.io.IOException;
 import java.util.List;
@@ -73,8 +73,8 @@ public class UserSearchHandler extends RequestHandler {
 
                        if (mustEndWithAt && !path.endsWith("@"))
                                path += '@';
-                               List<UserDTO> users = getService().getUsersByUserNameLike(path.substring(1));
-                       for (UserDTO u: users) {
+                               List<User> users = getService().getUsersByUserNameLike(path.substring(1));
+                       for (User u: users) {
                                        // Build the proper parent URL
                                        String pathInfo = req.getPathInfo();
                                        String parentUrl = contextPath.replaceFirst(pathInfo, "");
index b632d5a..334db10 100644 (file)
@@ -22,10 +22,10 @@ import static gr.ebs.gss.server.configuration.GSSConfigurationFactory.getConfigu
 import gr.ebs.gss.client.exceptions.DuplicateNameException;
 import gr.ebs.gss.client.exceptions.InsufficientPermissionsException;
 import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
-import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
-import gr.ebs.gss.server.domain.dto.FolderDTO;
-import gr.ebs.gss.server.domain.dto.GroupDTO;
-import gr.ebs.gss.server.domain.dto.UserDTO;
+import gr.ebs.gss.server.domain.FileHeader;
+import gr.ebs.gss.server.domain.Folder;
+import gr.ebs.gss.server.domain.Group;
+import gr.ebs.gss.server.domain.User;
 
 import java.util.Hashtable;
 import java.util.Iterator;
@@ -81,7 +81,7 @@ public class ExternalAPITest extends TestCase {
        public final void testGetRootFolderNormal() {
                try {
                        final ExternalAPIRemote service = getService();
-                       final FolderDTO f = service.getRootFolder(Long.valueOf(1));
+                       final Folder f = service.getRootFolder(Long.valueOf(1));
                        Assert.assertNotNull(f);
                } catch (final Exception e) {
                        e.printStackTrace();
@@ -152,7 +152,7 @@ public class ExternalAPITest extends TestCase {
        public final void testGetFilesNormal() {
                try {
                        final ExternalAPIRemote service = getService();
-                       final List<FileHeaderDTO> files = service.getFiles(new Long(1L), Long.valueOf(1), true);
+                       final List<FileHeader> files = service.getFiles(new Long(1L), Long.valueOf(1), true);
                        Assert.assertNotNull(files);
                        Assert.assertFalse(files.isEmpty());
                } catch (final Exception e) {
@@ -170,7 +170,7 @@ public class ExternalAPITest extends TestCase {
        public final void testGetFilesWithEmptyFolder() {
                try {
                        final ExternalAPIRemote service = getService();
-                       final List<FileHeaderDTO> files = service.getFiles(new Long(1L), Long.valueOf(2), true);
+                       final List<FileHeader> files = service.getFiles(new Long(1L), Long.valueOf(2), true);
                        Assert.assertNotNull(files);
                        Assert.assertTrue(files.isEmpty());
                } catch (final Exception e) {
@@ -207,7 +207,7 @@ public class ExternalAPITest extends TestCase {
        public final void testGetFilesWithNonExistentFolder() {
                try {
                        final ExternalAPIRemote service = getService();
-                       final List<FileHeaderDTO> files = service.getFiles(new Long(1L), Long.valueOf(-1), true);
+                       final List<FileHeader> files = service.getFiles(new Long(1L), Long.valueOf(-1), true);
                        Assert.assertNotNull(files);
                        Assert.assertTrue(files.isEmpty());
                } catch (final Exception e) {
@@ -223,7 +223,7 @@ public class ExternalAPITest extends TestCase {
        public final void testGetGroupsNormal() {
                try {
                        final ExternalAPIRemote service = getService();
-                       final List<GroupDTO> groups = service.getGroups(Long.valueOf(1));
+                       final List<Group> groups = service.getGroups(Long.valueOf(1));
                        Assert.assertNotNull(groups);
                        Assert.assertFalse(groups.isEmpty());
                } catch (final Exception e) {
@@ -239,7 +239,7 @@ public class ExternalAPITest extends TestCase {
        public final void testGetGroupsForUserWithNoGroups() {
                try {
                        final ExternalAPIRemote service = getService();
-                       final List<GroupDTO> groups = service.getGroups(Long.valueOf(2));
+                       final List<Group> groups = service.getGroups(Long.valueOf(2));
                        Assert.assertNotNull(groups);
                        Assert.assertTrue(groups.isEmpty());
                } catch (final Exception e) {
@@ -272,7 +272,7 @@ public class ExternalAPITest extends TestCase {
        public final void testGetGroupsForNonExistentUser() {
                try {
                        final ExternalAPIRemote service = getService();
-                       final List<GroupDTO> groups = service.getGroups(Long.valueOf(-1));
+                       final List<Group> groups = service.getGroups(Long.valueOf(-1));
                        Assert.assertNotNull(groups);
                        Assert.assertTrue(groups.isEmpty());
                } catch (final Exception e) {
@@ -288,7 +288,7 @@ public class ExternalAPITest extends TestCase {
        public final void testGetUsersNormal() {
                try {
                        final ExternalAPIRemote service = getService();
-                       final List<UserDTO> users = service.getUsers(Long.valueOf(1), Long.valueOf(1));
+                       final List<User> users = service.getUsers(Long.valueOf(1), Long.valueOf(1));
                        Assert.assertNotNull(users);
                        Assert.assertFalse(users.isEmpty());
                } catch (final Exception e) {
@@ -304,7 +304,7 @@ public class ExternalAPITest extends TestCase {
        public final void testGetUsersForEmptyGroup() {
                try {
                        final ExternalAPIRemote service = getService();
-                       final List<UserDTO> users = service.getUsers(Long.valueOf(1L), Long.valueOf(2));
+                       final List<User> users = service.getUsers(Long.valueOf(1L), Long.valueOf(2));
                        Assert.assertNotNull(users);
                        Assert.assertTrue(users.isEmpty());
                } catch (final Exception e) {
@@ -320,7 +320,7 @@ public class ExternalAPITest extends TestCase {
        public final void testGetUsersNonExistentGroup() {
                try {
                        final ExternalAPIRemote service = getService();
-                       final List<UserDTO> users = service.getUsers(Long.valueOf(1L), Long.valueOf(-1));
+                       final List<User> users = service.getUsers(Long.valueOf(1L), Long.valueOf(-1));
                        Assert.assertNotNull(users);
                        Assert.assertTrue(users.isEmpty());
                } catch (final Exception e) {
@@ -361,7 +361,7 @@ public class ExternalAPITest extends TestCase {
                                final Iterator i = rootSubfolders.iterator();
                                ok = true;
                                while (i.hasNext()) {
-                                       final FolderDTO f = (FolderDTO) i.next();
+                                       final Folder f = (Folder) i.next();
                                        if (f.getName().equals(name)) {
                                                name = name + "!";
                                                ok = false;
@@ -372,7 +372,7 @@ public class ExternalAPITest extends TestCase {
                        service.createFolder(Long.valueOf(1), Long.valueOf(1), name);
                        final Iterator i = service.getRootFolder(Long.valueOf(1)).getSubfolders().iterator();
                        while (i.hasNext()) {
-                               final FolderDTO f = (FolderDTO) i.next();
+                               final Folder f = (Folder) i.next();
                                if (f.getName().equals(name))
                                        return;
                        }
@@ -392,7 +392,7 @@ public class ExternalAPITest extends TestCase {
                try {
                        final ExternalAPIRemote service = getService();
                        final List rootSubfolders = service.getRootFolder(Long.valueOf(1)).getSubfolders();
-                       service.createFolder(Long.valueOf(1), Long.valueOf(1), ((FolderDTO) rootSubfolders.get(0)).getName());
+                       service.createFolder(Long.valueOf(1), Long.valueOf(1), ((Folder) rootSubfolders.get(0)).getName());
                        Assert.fail();
                } catch (final Exception e) {
                        if (!(e instanceof DuplicateNameException)) {
@@ -503,7 +503,7 @@ public class ExternalAPITest extends TestCase {
                        final ExternalAPIRemote service = getService();
                        final Iterator i = service.getRootFolder(Long.valueOf(1)).getSubfolders().iterator();
                        while (i.hasNext()) {
-                               final FolderDTO f = (FolderDTO) i.next();
+                               final Folder f = (Folder) i.next();
                                if (f.getName().equals(name))
                                        service.deleteFolder(Long.valueOf(1), f.getId());
                        }
@@ -527,7 +527,7 @@ public class ExternalAPITest extends TestCase {
                                service.createFolder(Long.valueOf(1), Long.valueOf(1), name);
                                final Iterator i = service.getRootFolder(Long.valueOf(1)).getSubfolders().iterator();
                                while (i.hasNext()) {
-                                       final FolderDTO f = (FolderDTO) i.next();
+                                       final Folder f = (Folder) i.next();
                                        if (f.getName().equals(name)) {
                                                folderId = f.getId();
                                                service.deleteFolder(null, f.getId());
@@ -561,7 +561,7 @@ public class ExternalAPITest extends TestCase {
                                service.createFolder(Long.valueOf(1), Long.valueOf(1), name);
                                final Iterator i = service.getRootFolder(Long.valueOf(1)).getSubfolders().iterator();
                                while (i.hasNext()) {
-                                       final FolderDTO f = (FolderDTO) i.next();
+                                       final Folder f = (Folder) i.next();
                                        if (f.getName().equals(name)) {
                                                folderId = f.getId();
                                                service.deleteFolder(Long.valueOf(-1), f.getId());
@@ -631,7 +631,7 @@ public class ExternalAPITest extends TestCase {
                                service.createFolder(Long.valueOf(1), Long.valueOf(1), name);
                                final Iterator i = service.getRootFolder(Long.valueOf(1)).getSubfolders().iterator();
                                while (i.hasNext()) {
-                                       final FolderDTO f = (FolderDTO) i.next();
+                                       final Folder f = (Folder) i.next();
                                        if (f.getName().equals(name)) {
                                                folderId = f.getId();
                                                service.deleteFolder(Long.valueOf(2), f.getId());
@@ -652,12 +652,12 @@ public class ExternalAPITest extends TestCase {
        }
 
        /**
-        * Tests {@link ExternalAPIBean#getUserDTO(Long)} with normal parameters
+        * Tests {@link ExternalAPIBean#getUser(Long)} with normal parameters
         */
        public final void testGetUserNormal() {
                try {
                        final ExternalAPIRemote service = getService();
-                       final UserDTO user = service.getUserDTO(Long.valueOf(1));
+                       final User user = service.getUser(Long.valueOf(1));
                        assertNotNull(user);
                        assertNotNull(user.getId());
                        assertEquals(user.getId().longValue(), 1L);
@@ -673,7 +673,7 @@ public class ExternalAPITest extends TestCase {
        public final void testGetUserNullId() {
                try {
                        final ExternalAPIRemote service = getService();
-                       service.getUserDTO(null);
+                       service.getUser(null);
                        Assert.fail();
                } catch (final NamingException e) {
                        e.printStackTrace();
@@ -692,7 +692,7 @@ public class ExternalAPITest extends TestCase {
        public final void testGetUserNonExistentId() {
                try {
                        final ExternalAPIRemote service = getService();
-                       service.getUserDTO(Long.valueOf(-1));
+                       service.getUser(Long.valueOf(-1));
                        Assert.fail();
                } catch (final NamingException e) {
                        e.printStackTrace();
index c75ccf3..bbfd4fa 100644 (file)
@@ -21,6 +21,8 @@ package gr.ebs.gss.server.ejb;
 import static gr.ebs.gss.server.configuration.GSSConfigurationFactory.getConfiguration;
 import gr.ebs.gss.client.exceptions.InsufficientPermissionsException;
 import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
+import gr.ebs.gss.server.domain.Folder;
+import gr.ebs.gss.server.domain.Permission;
 import gr.ebs.gss.server.domain.User;
 import gr.ebs.gss.server.domain.dto.FolderDTO;
 import gr.ebs.gss.server.domain.dto.PermissionDTO;
@@ -102,10 +104,10 @@ public class ScenarioTest extends TestCase {
         */
        public void testGetRootFolder() {
                try {
-                       FolderDTO root = getService().getRootFolder(user1.getId());
+                       Folder root = getService().getRootFolder(user1.getId());
                        Assert.assertNotNull(root);
-                       List<FolderDTO> subfolders = getService().getSubfolders(user1.getId(), root.getId());
-                       for(FolderDTO f : subfolders)
+                       List<Folder> subfolders = getService().getSubfolders(user1.getId(), root.getId());
+                       for(Folder f : subfolders)
                                getService().deleteFolder(user1.getId(), f.getId());
 
                } catch (Exception e) {
@@ -118,30 +120,30 @@ public class ScenarioTest extends TestCase {
        //test create folder , folder permissions, copySharedFolders
        public void testFolderOperations(){
                try{
-                       FolderDTO root = getService().getRootFolder(user1.getId());
+                       Folder root = getService().getRootFolder(user1.getId());
                        Assert.assertNotNull(root);
                        getService().createFolder(user1.getId(), root.getId(), "subfolder1");
-                       List<FolderDTO> subfolders = getService().getSubfolders(user1.getId(), root.getId());
+                       List<Folder> subfolders = getService().getSubfolders(user1.getId(), root.getId());
                        Assert.assertTrue(subfolders.size() == 1);
-                       FolderDTO subFolder1 = subfolders.get(0);
+                       Folder subFolder1 = subfolders.get(0);
                        getService().createFolder(user1.getId(), subFolder1.getId(), "subfolder2");
-                       PermissionDTO permission = new PermissionDTO();
-                       permission.setUser(user2.getDTO());
+                       Permission permission = new Permission();
+                       permission.setUser(user2);
                        permission.setRead(true);
                        permission.setWrite(true);
-                       Set<PermissionDTO> perms = getService().getFolderPermissions(user1.getId(), subFolder1.getId());
+                       Set<Permission> perms = getService().getFolderPermissions(user1.getId(), subFolder1.getId());
                        perms.add(permission);
                        getService().updateFolder(user1.getId(), subFolder1.getId(), null, subFolder1.isReadForAll(), perms);
-                       List<FolderDTO> sharedFolders = getService().getSharedRootFolders(user1.getId());
+                       List<Folder> sharedFolders = getService().getSharedRootFolders(user1.getId());
                        assertTrue(sharedFolders.size() == 1 && sharedFolders.get(0).getId().equals(subFolder1.getId()));
-                       List<FolderDTO> sharedForUser2 = getService().getSharedRootFolders(user1.getId(), user2.getId());
+                       List<Folder> sharedForUser2 = getService().getSharedRootFolders(user1.getId(), user2.getId());
                        assertTrue(sharedFolders.get(0).getId().equals(sharedForUser2.get(0).getId()));
 
-                       FolderDTO root2 = getService().getRootFolder(user2.getId());
+                       Folder root2 = getService().getRootFolder(user2.getId());
                        getService().copyFolderStructure(user2.getId(), subFolder1.getId(), root2.getId(), subFolder1.getName());
-                       List<FolderDTO> subfolders2 = getService().getSubfolders(user2.getId(), root2.getId());
+                       List<Folder> subfolders2 = getService().getSubfolders(user2.getId(), root2.getId());
                        Assert.assertTrue(subfolders2.size() == 1);
-                       FolderDTO subFolder2 = subfolders2.get(0);
+                       Folder subFolder2 = subfolders2.get(0);
                        assertTrue(subFolder2.getSubfolders().get(0).getName().equals("subfolder2"));
                        perms.remove(permission);
                        getService().updateFolder(user1.getId(), subFolder1.getId(), null, subFolder1.isReadForAll(), perms);