*/\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
}\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
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;
*
* @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.
* @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
* @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.
* @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.
* @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
* @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;
* 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
* * @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.
* * @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
* @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
* @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.
* @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.
* @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
*
* @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;
/**
* @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;
/**
* @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
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
* @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
* @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
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;
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;
}
@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");
// 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
@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");
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;
}
}
@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;
}
@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)
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
} 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;
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);
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));
}
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));
}
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));
}
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));
}
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));
}
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));
}
}
@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
}
@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
* @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;
}
}
@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;
}
}
@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
}
@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)
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;
}
@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");
}
@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)
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
*
* @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.
* @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;
/**
* @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
* @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
* @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.
* 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
* * @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.
* * @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
* * @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.
*
* @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..
* @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
* @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
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;
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"));
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();
// 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());
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");
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
} 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 {
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;
// 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());
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());
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()).
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;
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());
}
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()).
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;
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)) {
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());
}
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()).
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;
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, "");
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;
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();
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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;
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;
}
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)) {
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());
}
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());
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());
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());
}
/**
- * 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);
public final void testGetUserNullId() {
try {
final ExternalAPIRemote service = getService();
- service.getUserDTO(null);
+ service.getUser(null);
Assert.fail();
} catch (final NamingException e) {
e.printStackTrace();
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();
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;
*/
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) {
//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);