*/\r
private long fileSize;\r
\r
+ \r
+ public Long getId() {\r
+ return id;\r
+ }\r
+\r
/**\r
* Returns the version\r
*\r
header = newHeader;\r
}\r
\r
+ \r
+ public AuditInfo getAuditInfo() {\r
+ return auditInfo;\r
+ }\r
+\r
/**\r
* Retrieve the MIME type.\r
*\r
*/\r
package gr.ebs.gss.server.domain;\r
\r
-import gr.ebs.gss.server.domain.dto.FileHeaderDTO;\r
+import gr.ebs.gss.server.domain.dto.UserDTO;\r
\r
import java.io.Serializable;\r
import java.io.UnsupportedEncodingException;\r
}\r
\r
/**\r
+ * Retrieve the file tags as a list of strings.\r
+ *\r
+ * @return the list of file tag strings\r
+ */\r
+ public List<String> getFileTagsAsStrings() {\r
+ List<String> result = new ArrayList<String>();\r
+ for (FileTag ft : fileTags) {\r
+ result.add(ft.getTag());\r
+ }\r
+ return result;\r
+ }\r
+ \r
+ /**\r
* Retrieve the file tags.\r
*\r
* @return the list of file tags\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.client.exceptions.InvitationUsedException;
import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
import gr.ebs.gss.client.exceptions.QuotaExceededException;
+import gr.ebs.gss.server.domain.FileBody;
import gr.ebs.gss.server.domain.FileHeader;
import gr.ebs.gss.server.domain.FileUploadStatus;
+import gr.ebs.gss.server.domain.Folder;
+import gr.ebs.gss.server.domain.Group;
import gr.ebs.gss.server.domain.Invitation;
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;
* @return Folder
* @throws ObjectNotFoundException if no Folder or user was found
*/
- public FolderDTO getRootFolder(Long userId) throws ObjectNotFoundException;
+ public Folder getRootFolder(Long userId) throws ObjectNotFoundException;
/**
* Retrieve the folder with the specified ID.
* @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 getFolder(Long userId, Long folderId) throws ObjectNotFoundException,
+ public Folder getFolder(Long userId, Long folderId) throws ObjectNotFoundException,
InsufficientPermissionsException;
/**
* @return The Group object
* @throws ObjectNotFoundException if the group cannot be found
*/
- public GroupDTO getGroup(Long groupId) throws ObjectNotFoundException;
+ public Group getGroup(Long groupId) throws ObjectNotFoundException;
/**
* Returns the group with the specified name that belongs to the
* @return The Group object
* @throws ObjectNotFoundException if the group cannot be found
*/
- public GroupDTO getGroup(Long userId, String name) throws ObjectNotFoundException;
+ public Group getGroup(Long userId, String name) throws ObjectNotFoundException;
/**
* Retrieve the list of groups for a particular user.
* @return a List of Groups that belong to the specified User
* @throws ObjectNotFoundException if the user was not found
*/
- public List<GroupDTO> getGroups(Long userId) throws ObjectNotFoundException;
+ public List<Group> getGroups(Long userId) throws ObjectNotFoundException;
/**
* Returns a list of files contained in the folder specified by its id.
* @throws ObjectNotFoundException if the user or the folder cannot be found
* @throws InsufficientPermissionsException
*/
- public List<FileHeaderDTO> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException,
+ public List<FileHeader> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException,
InsufficientPermissionsException;
/**
* problem
* @throws InsufficientPermissionsException
*/
- public FolderDTO createFolder(Long userId, Long parentId, String name) throws DuplicateNameException,
+ public Folder createFolder(Long userId, Long parentId, String name) throws DuplicateNameException,
ObjectNotFoundException, InsufficientPermissionsException;
/**
* @throws DuplicateNameException if the specified name already exists in
* the parent folder, as either a folder or file
*/
- public FolderDTO updateFolder(Long userId, Long folderId, String folderName,
+ public Folder updateFolder(Long userId, Long folderId, String folderName,
Boolean readForAll,
- Set<PermissionDTO> permissions)
+ Set<Permission> permissions)
throws InsufficientPermissionsException, ObjectNotFoundException, DuplicateNameException;
/**
*/
public void updateFile(Long userId, Long fileId, String name, String tagSet,
Date modificationDate, Boolean versioned, Boolean readForAll,
- Set<PermissionDTO> permissions)
+ Set<Permission> permissions)
throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
/**
* the exception message mentioning the precise problem
* @throws InsufficientPermissionsException
*/
- public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException,
+ public FileHeader getFile(Long userId, Long fileId) throws ObjectNotFoundException,
InsufficientPermissionsException;
/**
* @throws ObjectNotFoundException if the user or folder could not be found
* @throws InsufficientPermissionsException
*/
- public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId)
+ public Set<Permission> getFolderPermissions(Long userId, Long folderId)
throws ObjectNotFoundException, InsufficientPermissionsException;
/**
* @throws ObjectNotFoundException if the user or folder could not be found
* @throws InsufficientPermissionsException
*/
- public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId)
+ public Set<Permission> getFilePermissions(Long userId, Long fileId)
throws ObjectNotFoundException, InsufficientPermissionsException;
/**
* @throws InsufficientPermissionsException
* @throws QuotaExceededException
*/
- public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
+ public FileHeader createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
InsufficientPermissionsException, QuotaExceededException;
* @throws InsufficientPermissionsException
* @throws QuotaExceededException
*/
- public FileHeaderDTO updateFileContents(Long userId, Long fileId, String mimeType,
+ public FileHeader updateFileContents(Long userId, Long fileId, String mimeType,
long fileSize, String filePath) throws ObjectNotFoundException, GSSIOException,
InsufficientPermissionsException, QuotaExceededException;
* @throws InsufficientPermissionsException if the user does not
* have enough privileges for reading this file
*/
- public FileBodyDTO getFileVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException;
+ public FileBody getFileVersion(Long userId, Long fileId, int version) throws ObjectNotFoundException, InsufficientPermissionsException;
/**
* Search the system for a user with the specified email address.
}
@Override
- public FolderDTO getRootFolder(Long userId) throws ObjectNotFoundException {
+ public Folder getRootFolder(Long userId) throws ObjectNotFoundException {
if (userId == null)
throw new ObjectNotFoundException("No user specified");
Folder folder = dao.getRootFolder(userId);
- return folder.getDTO();
+ return folder;
}
@Override
- public FolderDTO getFolder(final Long userId, final Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException {
+ public Folder getFolder(final Long userId, final Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException {
if (userId == null)
throw new ObjectNotFoundException("No user specified");
if (folderId == null)
// Check permissions
if (!folder.hasReadPermission(user))
throw new InsufficientPermissionsException("You don't have the permissions to read this folder");
- return folder.getDTO();
+ return folder;
}
@Override
}
@Override
- public GroupDTO getGroup(final Long groupId) throws ObjectNotFoundException {
+ public Group getGroup(final Long groupId) throws ObjectNotFoundException {
if (groupId == null)
throw new ObjectNotFoundException("No group specified");
final Group group = dao.getEntityById(Group.class, groupId);
- return group.getDTO();
+ return group;
}
@Override
- public GroupDTO getGroup(Long userId, String name) throws ObjectNotFoundException {
+ public Group getGroup(Long userId, String name) throws ObjectNotFoundException {
if (userId == null)
throw new ObjectNotFoundException("No user specified");
if (name == null)
List<Group> groups = user.getGroupsSpecified();
for (Group group: groups)
if (group.getName().equals(name))
- return group.getDTO();
+ return group;
throw new ObjectNotFoundException("Group " + name + " not found");
}
@Override
- public List<GroupDTO> getGroups(final Long userId) throws ObjectNotFoundException {
+ public List<Group> getGroups(final Long userId) throws ObjectNotFoundException {
if (userId == null)
throw new ObjectNotFoundException("No user specified");
final List<Group> groups = dao.getGroups(userId);
- final List<GroupDTO> result = new ArrayList<GroupDTO>();
- for (final Group g : groups)
- result.add(g.getDTO());
- return result;
+ return groups;
}
@Override
- public List<FileHeaderDTO> getFiles(Long userId, Long folderId, boolean ignoreDeleted)
+ public List<FileHeader> getFiles(Long userId, Long folderId, boolean ignoreDeleted)
throws ObjectNotFoundException, InsufficientPermissionsException {
// Validate.
if (userId == null)
Folder folder = dao.getEntityById(Folder.class, folderId);
if (!folder.hasReadPermission(user))
throw new InsufficientPermissionsException("You don't have the permissions to read this folder");
- // Do the actual work.
- List<FileHeaderDTO> result = new ArrayList<FileHeaderDTO>();
List<FileHeader> files = dao.getFiles(folderId, userId, ignoreDeleted);
- for (FileHeader f : files)
- result.add(f.getDTO());
- return result;
+ return files;
}
@Override
}
@Override
- public FolderDTO createFolder(Long userId, Long parentId, String name)
+ public Folder createFolder(Long userId, Long parentId, String name)
throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException {
// Validate.
if (userId == null)
* @param creator
* @return the new folder
*/
- private FolderDTO createFolder(String name, Folder parent, User creator) {
+ private Folder createFolder(String name, Folder parent, User creator) {
Folder folder = new Folder();
folder.setName(name);
if (parent != null) {
folder.setReadForAll(parent.isReadForAll());
dao.create(folder);
- return folder.getDTO();
+ return folder;
}
@Override
}
@Override
- public FolderDTO updateFolder(Long userId, Long folderId, String folderName,
+ public Folder updateFolder(Long userId, Long folderId, String folderName,
Boolean readForAll,
- Set<PermissionDTO> permissions)
+ Set<Permission> permissions)
throws InsufficientPermissionsException, ObjectNotFoundException,
DuplicateNameException {
folder.getAuditInfo().setModifiedBy(user);
dao.update(folder);
touchParentFolders(folder, user, new Date());
- return folder.getDTO();
+ return folder;
}
@Override
@Override
public void updateFile(Long userId, Long fileId, String name,
String tagSet, Date modificationDate, Boolean versioned,
- Boolean readForAll, Set<PermissionDTO> permissions)
+ Boolean readForAll, Set<Permission> permissions)
throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException {
if (userId == null)
throw new ObjectNotFoundException("No user specified");
}
@Override
- public FileHeaderDTO getFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException {
+ public FileHeader getFile(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException {
if (userId == null)
throw new ObjectNotFoundException("No user specified");
if (fileId == null)
final FileHeader file = dao.getEntityById(FileHeader.class, fileId);
if (!file.hasReadPermission(user) && !file.getFolder().hasReadPermission(user))
throw new InsufficientPermissionsException("You don't have the necessary permissions");
- return file.getDTO();
+ return file;
}
@Override
return getRootFolder(owner.getId());
// Store the last element, since it requires special handling.
String lastElement = pathElements.remove(pathElements.size() - 1);
- FolderDTO cursor = getRootFolder(owner.getId());
+ Folder cursor = getRootFolder(owner.getId());
// Traverse and verify the specified folder path.
for (String pathElement : pathElements) {
cursor = getFolder(cursor.getId(), pathElement);
// Use the lastElement to retrieve the actual resource.
Object resource = null;
try {
- FileHeaderDTO file = getFile(cursor.getId(), lastElement);
+ FileHeader file = getFile(cursor.getId(), lastElement);
if (ignoreDeleted && file.isDeleted())
throw new ObjectNotFoundException("Resource not found");
resource = file;
* found, with the exception message mentioning the precise
* problem
*/
- private FileHeaderDTO getFile(Long folderId, String name) throws ObjectNotFoundException {
+ private FileHeader getFile(Long folderId, String name) throws ObjectNotFoundException {
if (folderId == null)
throw new ObjectNotFoundException("No parent folder specified");
if (StringUtils.isEmpty(name))
throw new ObjectNotFoundException("No file specified");
FileHeader file = dao.getFile(folderId, name);
- return file.getDTO();
+ return file;
}
/**
* found, with the exception message mentioning the precise
* problem
*/
- private FolderDTO getFolder(Long parentId, String name) throws ObjectNotFoundException {
+ private Folder getFolder(Long parentId, String name) throws ObjectNotFoundException {
if (parentId == null)
throw new ObjectNotFoundException("No parent folder specified");
if (StringUtils.isEmpty(name))
throw new ObjectNotFoundException("No folder specified");
Folder folder = dao.getFolder(parentId, name);
- return folder.getDTO();
+ return folder;
}
private FileHeaderDTO updateFileContents(Long userId, Long fileId, String mimeType, InputStream resourceInputStream) throws ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException {
}
@Override
- public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException {
+ public Set<Permission> getFolderPermissions(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException {
if (userId == null)
throw new ObjectNotFoundException("No user specified");
if (folderId == null)
if(!folder.hasReadPermission(user))
throw new InsufficientPermissionsException("You don't have the necessary permissions");
Set<Permission> perms = folder.getPermissions();
- Set<PermissionDTO> result = new LinkedHashSet<PermissionDTO>();
+ Set<Permission> result = new LinkedHashSet<Permission>();
for (Permission perm : perms)
if (perm.getUser() != null && perm.getUser().getId().equals(folder.getOwner().getId()))
- result.add(perm.getDTO());
+ result.add(perm);
for (Permission perm : perms)
if (perm.getUser() != null && perm.getUser().getId().equals(folder.getOwner().getId())) {
} else
- result.add(perm.getDTO());
+ result.add(perm);
return result;
}
* @throws ObjectNotFoundException
* @throws InsufficientPermissionsException
*/
- private void setFolderPermissions(User user, Folder folder, Set<PermissionDTO> permissions) throws ObjectNotFoundException, InsufficientPermissionsException {
+ private void setFolderPermissions(User user, Folder folder, Set<Permission> permissions) throws ObjectNotFoundException, InsufficientPermissionsException {
if (permissions != null && !permissions.isEmpty()) {
User owner = folder.getOwner();
- PermissionDTO ownerPerm = null;
- for (PermissionDTO dto : permissions)
- if (dto.getUser() != null && dto.getUser().getId().equals(owner.getId())) {
- ownerPerm = dto;
+ Permission ownerPerm = null;
+ for (Permission perm : permissions)
+ if (perm.getUser() != null && perm.getUser().getId().equals(owner.getId())) {
+ ownerPerm = perm;
break;
}
if (ownerPerm == null || !ownerPerm.hasRead() || !ownerPerm.hasWrite() || !ownerPerm.hasModifyACL())
for (Permission perm: folder.getPermissions())
dao.delete(perm);
folder.getPermissions().clear();
- for (PermissionDTO dto : permissions) {
+ for (Permission p : permissions) {
// Skip 'empty' permission entries.
- if (!dto.getRead() && !dto.getWrite() && !dto.getModifyACL()) continue;
- folder.addPermission(getPermission(dto));
+ if (!p.getRead() && !p.getWrite() && !p.getModifyACL()) continue;
+ folder.addPermission(getPermission(p));
}
dao.update(folder);
for (FileHeader file : folder.getFiles()) {
}
}
- private Permission getPermission(PermissionDTO dto) throws ObjectNotFoundException {
+ private Permission getPermission(Permission perm) throws ObjectNotFoundException {
Permission res = new Permission();
- if (dto.getGroup() != null)
- res.setGroup(dao.getEntityById(Group.class, dto.getGroup().getId()));
- else if (dto.getUser() != null)
- if (dto.getUser().getId() == null)
- res.setUser(dao.getUser(dto.getUser().getUsername()));
+ if (perm.getGroup() != null)
+ res.setGroup(dao.getEntityById(Group.class, perm.getGroup().getId()));
+ else if (perm.getUser() != null)
+ if (perm.getUser().getId() == null)
+ res.setUser(dao.getUser(perm.getUser().getUsername()));
else
- res.setUser(dao.getEntityById(User.class, dto.getUser().getId()));
- res.setRead(dto.hasRead());
- res.setWrite(dto.hasWrite());
- res.setModifyACL(dto.hasModifyACL());
+ res.setUser(dao.getEntityById(User.class, perm.getUser().getId()));
+ res.setRead(perm.hasRead());
+ res.setWrite(perm.hasWrite());
+ res.setModifyACL(perm.hasModifyACL());
return res;
}
}
@Override
- public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException {
+ public Set<Permission> getFilePermissions(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException {
if (userId == null)
throw new ObjectNotFoundException("No user specified");
if (fileId == null)
if(!folder.hasReadPermission(user))
throw new InsufficientPermissionsException("You don't have the necessary permissions");
Set<Permission> perms = folder.getPermissions();
- Set<PermissionDTO> result = new LinkedHashSet<PermissionDTO>();
+ Set<Permission> result = new LinkedHashSet<Permission>();
for (Permission perm : perms)
if (perm.getUser() != null && perm.getUser().getId().equals(folder.getOwner().getId()))
- result.add(perm.getDTO());
+ result.add(perm);
for (Permission perm : perms)
if (perm.getUser() != null && perm.getUser().getId().equals(folder.getOwner().getId())) {
} else
- result.add(perm.getDTO());
+ result.add(perm);
return result;
}
* @throws InsufficientPermissionsException
*/
private void setFilePermissions(FileHeader file,
- Set<PermissionDTO> permissions)
+ Set<Permission> permissions)
throws ObjectNotFoundException, InsufficientPermissionsException {
if (permissions != null && !permissions.isEmpty()) {
- PermissionDTO ownerPerm = null;
- for (PermissionDTO dto : permissions)
- if (dto.getUser() != null && dto.getUser().getId().equals(file.getOwner().getId())) {
- ownerPerm = dto;
+ Permission ownerPerm = null;
+ for (Permission perm : permissions)
+ if (perm.getUser() != null && perm.getUser().getId().equals(file.getOwner().getId())) {
+ ownerPerm = perm;
break;
}
if (ownerPerm == null || !ownerPerm.hasRead() || !ownerPerm.hasWrite() || !ownerPerm.hasModifyACL())
for (Permission perm: file.getPermissions())
dao.delete(perm);
file.getPermissions().clear();
- for (PermissionDTO dto : permissions) {
+ for (Permission perm : permissions) {
// Skip 'empty' permission entries.
- if (!dto.getRead() && !dto.getWrite() && !dto.getModifyACL()) continue;
- file.addPermission(getPermission(dto));
+ if (!perm.getRead() && !perm.getWrite() && !perm.getModifyACL()) continue;
+ file.addPermission(getPermission(perm));
}
dao.flush();
}
}
@Override
- public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
+ public FileHeader createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
InsufficientPermissionsException, QuotaExceededException {
// Validate.
dao.flush();
indexFile(file.getId(), false);
- return file.getDTO();
+ return file;
}
@Override
- public FileHeaderDTO updateFileContents(Long userId, Long fileId, String mimeType, long fileSize, String filePath) throws ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException {
+ public FileHeader updateFileContents(Long userId, Long fileId, String mimeType, long fileSize, String filePath) throws ObjectNotFoundException, GSSIOException, InsufficientPermissionsException, QuotaExceededException {
if (userId == null)
throw new ObjectNotFoundException("No user specified");
if (fileId == null)
touchParentFolders(parent, owner, new Date());
indexFile(fileId, false);
- return file.getDTO();
+ return file;
}
/**
}
@Override
- public FileBodyDTO getFileVersion(Long userId, Long fileId, int version)
+ public FileBody getFileVersion(Long userId, Long fileId, int version)
throws ObjectNotFoundException, InsufficientPermissionsException {
if (userId == null)
throw new ObjectNotFoundException("No user specified");
if (!file.hasReadPermission(user) && !file.getFolder().hasReadPermission(user))
throw new InsufficientPermissionsException("You don't have the necessary permissions");
FileBody body = dao.getFileVersion(fileId, version);
- return body.getDTO();
+ return body;
}
@Override
import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
import gr.ebs.gss.client.exceptions.QuotaExceededException;
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.Permission;
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.GroupDTO;
import gr.ebs.gss.server.domain.dto.PermissionDTO;
import gr.ebs.gss.server.domain.dto.UserDTO;
* @return Folder
* @throws ObjectNotFoundException if no Folder or user was found
*/
- public FolderDTO getRootFolder(Long userId) throws ObjectNotFoundException;
+ public Folder getRootFolder(Long userId) throws ObjectNotFoundException;
/**
* Retrieve the folder with the specified ID.
* @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 getFolder(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
+ public Folder getFolder(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
/**
* Returns the user with the specified ID.
* @return The Group object
* @throws ObjectNotFoundException if the group cannot be found
*/
- public GroupDTO getGroup(Long groupId) throws ObjectNotFoundException;
+ public Group getGroup(Long groupId) throws ObjectNotFoundException;
/**
* Retrieve the list of groups for a particular user.
* @return a List of Groups that belong to the specified User
* @throws ObjectNotFoundException if the user was not found
*/
- public List<GroupDTO> getGroups(Long userId) throws ObjectNotFoundException;
+ public List<Group> getGroups(Long userId) throws ObjectNotFoundException;
/**
* Returns a list of files contained in the folder specified by its id.
* @throws ObjectNotFoundException if the user or the folder cannot be found
* @throws InsufficientPermissionsException
*/
- public List<FileHeaderDTO> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException, InsufficientPermissionsException;
+ public List<FileHeader> getFiles(Long userId, Long folderId, boolean ignoreDeleted) throws ObjectNotFoundException, InsufficientPermissionsException;
/**
* Returns a list of users for the specified group
* problem
* @throws InsufficientPermissionsException
*/
- public FolderDTO createFolder(Long userId, Long parentId, String name) throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
+ public Folder createFolder(Long userId, Long parentId, String name) throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
/**
* Deletes the specified folder if the specified user has the appropriate
* @throws DuplicateNameException if the specified name already exists in
* the parent folder, as either a folder or file
*/
- public FolderDTO updateFolder(Long userId, Long folderId, String folderName,
+ public Folder updateFolder(Long userId, Long folderId, String folderName,
Boolean readForAll,
- Set<PermissionDTO> permissions)
+ Set<Permission> permissions)
throws InsufficientPermissionsException, ObjectNotFoundException,
DuplicateNameException;
*/
public void updateFile(Long userId, Long fileId, String name, String tagSet,
Date modificationDate, Boolean versioned, Boolean readForAll,
- Set<PermissionDTO> permissions)
+ Set<Permission> permissions)
throws DuplicateNameException, ObjectNotFoundException, InsufficientPermissionsException;
/**
* @throws ObjectNotFoundException if the user or folder could not be found
* @throws InsufficientPermissionsException
*/
- public Set<PermissionDTO> getFolderPermissions(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
+ public Set<Permission> getFolderPermissions(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException;
/**
* Retrieve file user and group permissions
* @throws ObjectNotFoundException if the user or folder could not be found
* @throws InsufficientPermissionsException
*/
- public Set<PermissionDTO> getFilePermissions(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
+ public Set<Permission> getFilePermissions(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
/**
* Returns a list of All Shared root folders of a user.
* * @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.
import gr.ebs.gss.client.exceptions.QuotaExceededException;
import gr.ebs.gss.client.exceptions.RpcException;
import gr.ebs.gss.server.Login;
+import gr.ebs.gss.server.domain.FileBody;
+import gr.ebs.gss.server.domain.FileHeader;
import gr.ebs.gss.server.domain.FileUploadStatus;
+import gr.ebs.gss.server.domain.Folder;
+import gr.ebs.gss.server.domain.Group;
+import gr.ebs.gss.server.domain.Permission;
import gr.ebs.gss.server.domain.User;
-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.ejb.ExternalAPI;
import gr.ebs.gss.server.ejb.TransactionHelper;
import gr.ebs.gss.server.webdav.Range;
User owner = getOwner(req);
boolean exists = true;
Object resource = null;
- FileHeaderDTO file = null;
- FolderDTO folder = null;
+ FileHeader file = null;
+ Folder folder = null;
try {
resource = getService().getResourceAtPath(owner.getId(), path, false);
} catch (ObjectNotFoundException e) {
return;
}
- if (resource instanceof FolderDTO)
- folder = (FolderDTO) resource;
+ if (resource instanceof Folder)
+ folder = (Folder) resource;
else
- file = (FileHeaderDTO) resource; // Note that file will be null, if (!exists).
+ file = (FileHeader) resource; // Note that file will be null, if (!exists).
// Now it's time to perform the deferred authentication check.
// Since regular signature checking was already performed,
// Fetch the version to retrieve, if specified.
String verStr = req.getParameter(VERSION_PARAM);
int version = 0;
- FileBodyDTO oldBody = null;
+ FileBody oldBody = null;
if (verStr != null && file != null)
try {
version = Integer.valueOf(verStr);
boolean expectJSON = false;
if (file != null) {
- contentType = version>0 ? oldBody.getMimeType() : file.getMimeType();
+ contentType = version>0 ? oldBody.getMimeType() : file.getCurrentBody().getMimeType();
if (contentType == null) {
contentType = context.getMimeType(file.getName());
- file.setMimeType(contentType);
+ file.getCurrentBody().setMimeType(contentType);
}
} else { // folder != null
String accept = req.getHeader("Accept");
return;
}
// Get content length.
- contentLength = version>0 ? oldBody.getFileSize() : file.getFileSize();
+ contentLength = version>0 ? oldBody.getFileSize() : file.getCurrentBody().getFileSize();
// Special case for zero length files, which would cause a
// (silent) ISE when setting the output buffer size.
if (contentLength == 0L)
* Return the filename of the specified file properly formatted for
* including in the Content-Disposition header.
*/
- private String getDispositionFilename(FileHeaderDTO file) throws UnsupportedEncodingException {
+ private String getDispositionFilename(FileHeader file) throws UnsupportedEncodingException {
return URLEncoder.encode(file.getName(),"UTF-8").replaceAll("\\+", "%20");
}
* @throws IOException if an I/O error occurs
*/
private void serveProgress(HttpServletRequest req, HttpServletResponse resp,
- String parameter, User user, FileHeaderDTO file) throws IOException {
+ String parameter, User user, FileHeader file) throws IOException {
String filename = file == null ? parameter : file.getName();
try {
FileUploadStatus status = getService().getFileUploadStatus(user.getId(), filename);
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, path);
return;
}
- if (resource instanceof FolderDTO) {
+ if (resource instanceof Folder) {
resp.sendError(HttpServletResponse.SC_CONFLICT);
return;
}
try {
- final FileHeaderDTO file = (FileHeaderDTO) resource;
+ final FileHeader file = (FileHeader) resource;
final int oldVersion = Integer.parseInt(version);
new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
User owner = getOwner(request);
boolean exists = true;
Object resource = null;
- FileHeaderDTO file = null;
+ FileHeader file = null;
try {
resource = getService().getResourceAtPath(owner.getId(), path, false);
} catch (ObjectNotFoundException e) {
}
if (exists)
- if (resource instanceof FileHeaderDTO) {
- file = (FileHeaderDTO) resource;
+ if (resource instanceof FileHeader) {
+ file = (FileHeader) resource;
if (file.isDeleted()) {
response.sendError(HttpServletResponse.SC_CONFLICT, file.getName() + " is in the trash");
return;
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, path);
return;
}
- if (!(parent instanceof FolderDTO)) {
+ if (!(parent instanceof Folder)) {
response.sendError(HttpServletResponse.SC_CONFLICT);
return;
}
- final FolderDTO folder = (FolderDTO) parent;
+ final Folder folderLocal = (Folder) parent;
final String fileName = getLastElement(path);
if (!isValidResourceName(fileName)) {
} catch (IOException ex) {
throw new GSSIOException(ex, false);
}
- FileHeaderDTO fileDTO = null;
+ FileHeader fileLocal = null;
final File upf = uploadedFile;
- final FileHeaderDTO f = file;
+ final FileHeader f = file;
final User u = user;
if (file == null)
- fileDTO = new TransactionHelper<FileHeaderDTO>().tryExecute(new Callable<FileHeaderDTO>() {
+ fileLocal = new TransactionHelper<FileHeader>().tryExecute(new Callable<FileHeader>() {
@Override
- public FileHeaderDTO call() throws Exception {
- return getService().createFile(u.getId(), folder.getId(), fileName, contentType, upf.getCanonicalFile().length(), upf.getAbsolutePath());
+ public FileHeader call() throws Exception {
+ return getService().createFile(u.getId(), folderLocal.getId(), fileName, contentType, upf.getCanonicalFile().length(), upf.getAbsolutePath());
}
});
else
- fileDTO = new TransactionHelper<FileHeaderDTO>().tryExecute(new Callable<FileHeaderDTO>() {
+ fileLocal = new TransactionHelper<FileHeader>().tryExecute(new Callable<FileHeader>() {
@Override
- public FileHeaderDTO call() throws Exception {
+ public FileHeader call() throws Exception {
return getService().updateFileContents(u.getId(), f.getId(), contentType, upf.getCanonicalFile().length(), upf.getAbsolutePath());
}
});
- updateAccounting(owner, new Date(), fileDTO.getFileSize());
+ updateAccounting(owner, new Date(), fileLocal.getCurrentBody().getFileSize());
getService().removeFileUploadProgress(user.getId(), fileName);
}
}
try {
final User dOwner = destOwner;
final String dest = destination;
- if (resource instanceof FolderDTO) {
- final FolderDTO folder = (FolderDTO) resource;
+ if (resource instanceof Folder) {
+ final Folder folderLocal = (Folder) resource;
new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
@Override
public Void call() throws Exception {
- getService().moveFolderToPath(user.getId(), dOwner.getId(), folder.getId(), dest);
+ getService().moveFolderToPath(user.getId(), dOwner.getId(), folderLocal.getId(), dest);
return null;
}
});
} else {
- final FileHeaderDTO file = (FileHeaderDTO) resource;
+ final FileHeader fileLocal = (FileHeader) resource;
new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
@Override
public Void call() throws Exception {
- getService().moveFileToPath(user.getId(), dOwner.getId(), file.getId(), dest);
+ getService().moveFileToPath(user.getId(), dOwner.getId(), fileLocal.getId(), dest);
return null;
}
});
try {
final User dOwner = destOwner;
final String dest = destination;
- if (resource instanceof FolderDTO) {
- final FolderDTO folder = (FolderDTO) resource;
+ if (resource instanceof Folder) {
+ final Folder folderLocal = (Folder) resource;
new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
@Override
public Void call() throws Exception {
- getService().copyFolderStructureToPath(user.getId(), dOwner.getId(), folder.getId(), dest);
+ getService().copyFolderStructureToPath(user.getId(), dOwner.getId(), folderLocal.getId(), dest);
return null;
}
});
} else {
- final FileHeaderDTO file = (FileHeaderDTO) resource;
+ final FileHeader fileLocal = (FileHeader) resource;
new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
@Override
public Void call() throws Exception {
- getService().copyFileToPath(user.getId(), dOwner.getId(), file.getId(), dest);
+ getService().copyFileToPath(user.getId(), dOwner.getId(), fileLocal.getId(), dest);
return null;
}
});
}
try {
- if (resource instanceof FolderDTO) {
- final FolderDTO folder = (FolderDTO) resource;
+ if (resource instanceof Folder) {
+ final Folder folderLocal = (Folder) resource;
new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
@Override
public Void call() throws Exception {
- getService().moveFolderToTrash(user.getId(), folder.getId());
+ getService().moveFolderToTrash(user.getId(), folderLocal.getId());
return null;
}
});
} else {
- final FileHeaderDTO file = (FileHeaderDTO) resource;
+ final FileHeader fileLocal = (FileHeader) resource;
new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
@Override
public Void call() throws Exception {
- getService().moveFileToTrash(user.getId(), file.getId());
+ getService().moveFileToTrash(user.getId(), fileLocal.getId());
return null;
}
});
}
try {
- if (resource instanceof FolderDTO) {
- final FolderDTO folder = (FolderDTO) resource;
+ if (resource instanceof Folder) {
+ final Folder folderLocal = (Folder) resource;
new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
@Override
public Void call() throws Exception {
- getService().removeFolderFromTrash(user.getId(), folder.getId());
+ getService().removeFolderFromTrash(user.getId(), folderLocal.getId());
return null;
}
});
} else {
- final FileHeaderDTO file = (FileHeaderDTO) resource;
+ final FileHeader fileLocal = (FileHeader) resource;
new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
@Override
public Void call() throws Exception {
- getService().removeFileFromTrash(user.getId(), file.getId());
+ getService().removeFileFromTrash(user.getId(), fileLocal.getId());
return null;
}
});
json = new JSONObject(input.toString());
if (logger.isDebugEnabled())
logger.debug("JSON update: " + json);
- if (resource instanceof FolderDTO) {
- final FolderDTO folder = (FolderDTO) resource;
+ if (resource instanceof Folder) {
+ final Folder folderLocal = (Folder) resource;
String name = json.optString("name");
if (!isValidResourceName(name)) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
JSONArray permissions = json.optJSONArray("permissions");
- Set<PermissionDTO> perms = null;
+ Set<Permission> perms = null;
if (permissions != null)
perms = parsePermissions(user, permissions);
Boolean readForAll = null;
if (!name.isEmpty() || permissions != null || readForAll != null) {
final String fName = name.isEmpty()? null: name;
final Boolean freadForAll = readForAll;
- final Set<PermissionDTO> fPerms = perms;
- FolderDTO folderUpdated = new TransactionHelper<FolderDTO>().tryExecute(new Callable<FolderDTO>() {
+ final Set<Permission> fPerms = perms;
+ Folder folderUpdated = new TransactionHelper<Folder>().tryExecute(new Callable<Folder>() {
@Override
- public FolderDTO call() throws Exception {
- return getService().updateFolder(user.getId(), folder.getId(), fName, freadForAll, fPerms);
+ public Folder call() throws Exception {
+ return getService().updateFolder(user.getId(), folderLocal.getId(), fName, freadForAll, fPerms);
}
});
resp.getWriter().println(getNewUrl(req, folderUpdated));
}
} else {
- final FileHeaderDTO file = (FileHeaderDTO) resource;
+ final FileHeader fileLocal = (FileHeader) resource;
String name = null;
if (json.opt("name") != null)
name = json.optString("name");
tags = t.toString();
}
JSONArray permissions = json.optJSONArray("permissions");
- Set<PermissionDTO> perms = null;
+ Set<Permission> perms = null;
if (permissions != null)
perms = parsePermissions(user, permissions);
Boolean readForAll = null;
final Date mDate = modificationDate != null? new Date(modificationDate): null;
final Boolean fVersioned = versioned;
final Boolean fReadForAll = readForAll;
- final Set<PermissionDTO> fPerms = perms;
+ final Set<Permission> fPerms = perms;
new TransactionHelper<Object>().tryExecute(new Callable<Object>() {
@Override
public Object call() throws Exception {
- getService().updateFile(user.getId(), file.getId(),
+ getService().updateFile(user.getId(), fileLocal.getId(),
fName, fTags, mDate, fVersioned,
fReadForAll, fPerms);
return null;
/**
* Returns the new URL of an updated folder.
*/
- private String getNewUrl(HttpServletRequest req, FolderDTO folder) throws UnsupportedEncodingException {
+ private String getNewUrl(HttpServletRequest req, Folder folder) throws UnsupportedEncodingException {
String parentUrl = URLDecoder.decode(getContextPath(req, true),"UTF-8");
String fpath = URLDecoder.decode(getRelativePath(req), "UTF-8");
if (parentUrl.indexOf(fpath) != -1)
/**
* Helper method to convert a JSON array of permissions into a set of
- * PermissionDTO objects.
+ * Permission objects.
*
* @param user the current user
* @param permissions the JSON array to parse
* @throws ObjectNotFoundException if the user could not be found
* @throws UnsupportedEncodingException
*/
- private Set<PermissionDTO> parsePermissions(User user, JSONArray permissions)
+ private Set<Permission> parsePermissions(User user, JSONArray permissions)
throws JSONException, RpcException, ObjectNotFoundException, UnsupportedEncodingException {
if (permissions == null)
return null;
- Set<PermissionDTO> perms = new HashSet<PermissionDTO>();
+ Set<Permission> perms = new HashSet<Permission>();
for (int i = 0; i < permissions.length(); i++) {
JSONObject j = permissions.getJSONObject(i);
- PermissionDTO perm = new PermissionDTO();
+ Permission perm = new Permission();
perm.setModifyACL(j.optBoolean("modifyACL"));
perm.setRead(j.optBoolean("read"));
perm.setWrite(j.optBoolean("write"));
User u = getService().findUser(permUser);
if (u == null)
throw new ObjectNotFoundException("User " + permUser + " not found");
- perm.setUser(u.getDTO());
+ perm.setUser(u);
}
// 31/8/2009: Add optional groupUri which takes priority if it exists
String permGroupUri = j.optString("groupUri");
User u = getService().findUser(usr);
if (u == null)
throw new ObjectNotFoundException("User " + permUser + " not found");
- GroupDTO g = getService().getGroup(u.getId(), grp);
+ Group g = getService().getGroup(u.getId(), grp);
perm.setGroup(g);
}
else if (!permGroup.isEmpty()) {
- GroupDTO g = getService().getGroup(user.getId(), permGroup);
+ Group g = getService().getGroup(user.getId(), permGroup);
perm.setGroup(g);
}
if (permUser.isEmpty() && permGroupUri.isEmpty() && permGroup.isEmpty())
return;
}
try {
- if (parent instanceof FolderDTO) {
- final FolderDTO folder = (FolderDTO) parent;
- FolderDTO newFolder = new TransactionHelper<FolderDTO>().tryExecute(new Callable<FolderDTO>() {
+ if (parent instanceof Folder) {
+ final Folder folderLocal = (Folder) parent;
+ Folder newFolder = new TransactionHelper<Folder>().tryExecute(new Callable<Folder>() {
@Override
- public FolderDTO call() throws Exception {
- return getService().createFolder(user.getId(), folder.getId(), folderName);
+ public Folder call() throws Exception {
+ return getService().createFolder(user.getId(), folderLocal.getId(), folderName);
}
});
User owner = getOwner(req);
boolean exists = true;
Object resource = null;
- FileHeaderDTO file = null;
+ FileHeader fileLocal = null;
try {
resource = getService().getResourceAtPath(owner.getId(), path, false);
} catch (ObjectNotFoundException e) {
}
if (exists)
- if (resource instanceof FileHeaderDTO)
- file = (FileHeaderDTO) resource;
+ if (resource instanceof FileHeader)
+ fileLocal = (FileHeader) resource;
else {
resp.sendError(HttpServletResponse.SC_CONFLICT, path + " is a folder");
return;
resourceInputStream = req.getInputStream();
try {
- FolderDTO folder = null;
+ Folder folderLocal = null;
Object parent = getService().getResourceAtPath(owner.getId(), getParentPath(path), true);
- if (!(parent instanceof FolderDTO)) {
+ if (!(parent instanceof Folder)) {
resp.sendError(HttpServletResponse.SC_CONFLICT);
return;
}
- folder = (FolderDTO) parent;
+ folderLocal = (Folder) parent;
final String name = getLastElement(path);
final String mimeType = context.getMimeType(name);
File uploadedFile = null;
} catch (IOException ex) {
throw new GSSIOException(ex, false);
}
- FileHeaderDTO fileDTO = null;
+ FileHeader fileTemp = null;
final File uploadedf = uploadedFile;
- final FolderDTO parentf = folder;
- final FileHeaderDTO f = file;
+ final Folder parentf = folderLocal;
+ final FileHeader f = fileLocal;
if (exists)
- fileDTO = new TransactionHelper<FileHeaderDTO>().tryExecute(new Callable<FileHeaderDTO>() {
+ fileTemp = new TransactionHelper<FileHeader>().tryExecute(new Callable<FileHeader>() {
@Override
- public FileHeaderDTO call() throws Exception {
+ public FileHeader call() throws Exception {
return getService().updateFileContents(user.getId(), f.getId(), mimeType, uploadedf.getCanonicalFile().length(), uploadedf.getAbsolutePath());
}
});
else
- fileDTO = new TransactionHelper<FileHeaderDTO>().tryExecute(new Callable<FileHeaderDTO>() {
+ fileTemp = new TransactionHelper<FileHeader>().tryExecute(new Callable<FileHeader>() {
@Override
- public FileHeaderDTO call() throws Exception {
+ public FileHeader call() throws Exception {
return getService().createFile(user.getId(), parentf.getId(), name, mimeType, uploadedf.getCanonicalFile().length(), uploadedf.getAbsolutePath());
}
});
- updateAccounting(owner, new Date(), fileDTO.getFileSize());
- getService().removeFileUploadProgress(user.getId(), fileDTO.getName());
+ updateAccounting(owner, new Date(), fileTemp.getCurrentBody().getFileSize());
+ getService().removeFileUploadProgress(user.getId(), fileTemp.getName());
} catch(ObjectNotFoundException e) {
result = false;
} catch (RpcException e) {
return;
}
- FolderDTO folder = null;
- FileHeaderDTO file = null;
- if (object instanceof FolderDTO)
- folder = (FolderDTO) object;
+ Folder folderLocal = null;
+ FileHeader fileLocal = null;
+ if (object instanceof Folder)
+ folderLocal = (Folder) object;
else
- file = (FileHeaderDTO) object;
+ fileLocal = (FileHeader) object;
- if (file != null)
+ if (fileLocal != null)
try {
- final FileHeaderDTO f = file;
+ final FileHeader f = fileLocal;
new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
@Override
public Void call() throws Exception {
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
- else if (folder != null)
+ else if (folderLocal != null)
try {
- final FolderDTO fo = folder;
+ final Folder fo = folderLocal;
new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
@Override
public Void call() throws Exception {
* @throws InsufficientPermissionsException if the user does not have
* the necessary privileges to read the directory
*/
- private InputStream renderJson(User user, FolderDTO folder) throws IOException,
+ private InputStream renderJson(User user, Folder folder) throws IOException,
ServletException, InsufficientPermissionsException {
JSONObject json = new JSONObject();
try {
json.put("parent", j);
}
List<JSONObject> subfolders = new ArrayList<JSONObject>();
- for (FolderDTO f: folder.getSubfolders())
+ for (Folder f: folder.getSubfolders())
if (!f.isDeleted()) {
JSONObject j = new JSONObject();
j.put("name", f.getName()).
}
json.put("folders", subfolders);
List<JSONObject> files = new ArrayList<JSONObject>();
- List<FileHeaderDTO> fileHeaders = getService().getFiles(user.getId(), folder.getId(), false);
- for (FileHeaderDTO f: fileHeaders) {
+ List<FileHeader> fileHeaders = getService().getFiles(user.getId(), folder.getId(), false);
+ 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("content", f.getMimeType()).
- put("size", f.getFileSize()).
+ put("version", f.getCurrentBody().getVersion()).
+ put("content", f.getCurrentBody().getMimeType()).
+ put("size", f.getCurrentBody().getFileSize()).
put("creationDate", f.getAuditInfo().getCreationDate().getTime()).
put("path", f.getFolder().getPath()).
put("uri", getApiRoot() + f.getURI());
files.add(j);
}
json.put("files", files);
- Set<PermissionDTO> perms = getService().getFolderPermissions(user.getId(), folder.getId());
+ Set<Permission> perms = getService().getFolderPermissions(user.getId(), folder.getId());
json.put("permissions", renderJson(perms));
} catch (JSONException e) {
throw new ServletException(e);
* @throws InsufficientPermissionsException
* @throws ObjectNotFoundException
*/
- private String renderJsonMetadata(User user, FolderDTO folder)
+ private String renderJsonMetadata(User user, Folder folder)
throws ServletException, InsufficientPermissionsException {
// Check if the user has read permission.
try {
* @throws InsufficientPermissionsException if the user does not have
* the necessary privileges to read the directory
*/
- private String renderJson(User user, FileHeaderDTO file, FileBodyDTO oldBody)
+ private String renderJson(User user, FileHeader file, FileBody oldBody)
throws ServletException, InsufficientPermissionsException {
JSONObject json = new JSONObject();
try {
json.put("name", URLEncoder.encode(file.getName(),"UTF-8")).
put("owner", file.getOwner().getUsername()).
put("versioned", file.isVersioned()).
- put("version", oldBody != null ? oldBody.getVersion() : file.getVersion()).
+ put("version", oldBody != null ? oldBody.getVersion() : file.getCurrentBody().getVersion()).
put("readForAll", file.isReadForAll()).
- put("tags", renderJson(file.getTags())).
+ put("tags", renderJson(file.getFileTagsAsStrings())).
put("path", file.getFolder().getPath()).
put("uri", getApiRoot() + file.getURI()).
put("deleted", file.isDeleted());
put("creationDate", file.getAuditInfo().getCreationDate().getTime()).
put("modifiedBy", file.getAuditInfo().getModifiedBy().getUsername()).
put("modificationDate", file.getAuditInfo().getModificationDate().getTime()).
- put("content", file.getMimeType()).
- put("size", file.getFileSize());
- Set<PermissionDTO> perms = getService().getFilePermissions(user.getId(), file.getId());
+ put("content", file.getCurrentBody().getMimeType()).
+ put("size", file.getCurrentBody().getFileSize());
+ Set<Permission> perms = getService().getFilePermissions(user.getId(), file.getId());
json.put("permissions", renderJson(perms));
} catch (JSONException e) {
throw new ServletException(e);
* @throws JSONException
* @throws UnsupportedEncodingException
*/
- private JSONArray renderJson(Set<PermissionDTO> permissions) throws JSONException, UnsupportedEncodingException {
+ private JSONArray renderJson(Set<Permission> permissions) throws JSONException, UnsupportedEncodingException {
JSONArray perms = new JSONArray();
- for (PermissionDTO p: permissions) {
+ for (Permission p: permissions) {
JSONObject permission = new JSONObject();
permission.put("read", p.hasRead()).put("write", p.hasWrite()).put("modifyACL", p.hasModifyACL());
if (p.getUser() != null)
permission.put("user", p.getUser().getUsername());
if (p.getGroup() != null) {
- GroupDTO group = p.getGroup();
+ Group group = p.getGroup();
permission.put("groupUri", getApiRoot() + group.getOwner().getUsername() + PATH_GROUPS + "/" + URLEncoder.encode(group.getName(),"UTF-8"));
permission.put("group", URLEncoder.encode(p.getGroup().getName(),"UTF-8"));
}
* @throws IOException
* @throws ServletException
*/
- private InputStream renderHtml(String contextPath, String path, FolderDTO folder, User user)
+ private InputStream renderHtml(String contextPath, String path, Folder folder, User user)
throws IOException, ServletException {
String name = folder.getName();
// Prepare a writer to a buffered area
boolean shade = false;
Iterator iter = folder.getSubfolders().iterator();
while (iter.hasNext()) {
- FolderDTO subf = (FolderDTO) iter.next();
+ Folder subf = (Folder) iter.next();
if(subf.isReadForAll() && !subf.isDeleted()){
String resourceName = subf.getName();
if (resourceName.equalsIgnoreCase("WEB-INF") || resourceName.equalsIgnoreCase("META-INF"))
}
}
- List<FileHeaderDTO> files;
+ List<FileHeader> files;
try {
files = getService().getFiles(user.getId(), folder.getId(), true);
} catch (ObjectNotFoundException e) {
} catch (RpcException e) {
throw new ServletException(e.getMessage());
}
- for (FileHeaderDTO file : files)
+ for (FileHeader file : files)
//Display only file resources that are marked as public and are not deleted
if(file.isReadForAll() && !file.isDeleted()){
String resourceName = file.getName();
sb.append("</tt></a></td>\r\n");
sb.append("<td align=\"right\"><tt>");
- sb.append(renderSize(file.getFileSize()));
+ sb.append(renderSize(file.getCurrentBody().getFileSize()));
sb.append("</tt></td>\r\n");
sb.append("<td align=\"right\"><tt>");
import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
import gr.ebs.gss.client.exceptions.QuotaExceededException;
import gr.ebs.gss.client.exceptions.RpcException;
+import gr.ebs.gss.server.domain.AuditInfo;
+import gr.ebs.gss.server.domain.FileBody;
+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.AuditInfoDTO;
import gr.ebs.gss.server.domain.dto.FileBodyDTO;
import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
import gr.ebs.gss.server.domain.dto.FolderDTO;
return;
}
parseProperties(req, generatedXML, currentPath, type, properties, object);
- if (object instanceof FolderDTO && depth > 0) {
- FolderDTO folder = (FolderDTO) object;
+ if (object instanceof Folder && depth > 0) {
+ Folder folderLocal = (Folder) object;
// Retrieve the subfolders.
- List subfolders = folder.getSubfolders();
+ List subfolders = folderLocal.getSubfolders();
Iterator iter = subfolders.iterator();
while (iter.hasNext()) {
- FolderDTO f = (FolderDTO) iter.next();
+ Folder f = (Folder) iter.next();
String newPath = currentPath;
if (!newPath.endsWith("/"))
newPath += "/";
stackBelow.push(newPath);
}
// Retrieve the files.
- List<FileHeaderDTO> files;
+ List<FileHeader> files;
try {
- files = getService().getFiles(user.getId(), folder.getId(), true);
+ files = getService().getFiles(user.getId(), folderLocal.getId(), true);
} catch (ObjectNotFoundException e) {
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, path);
return;
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, path);
return;
}
- for (FileHeaderDTO file : files) {
+ for (FileHeader file : files) {
String newPath = currentPath;
if (!newPath.endsWith("/"))
newPath += "/";
String path = getRelativePath(req);
boolean exists = true;
Object resource = null;
- FileHeaderDTO file = null;
+ FileHeader file = null;
try {
resource = getService().getResourceAtPath(user.getId(), path, true);
} catch (ObjectNotFoundException e) {
}
if (exists)
- if (resource instanceof FileHeaderDTO)
- file = (FileHeaderDTO) resource;
+ if (resource instanceof FileHeader)
+ file = (FileHeader) resource;
else {
resp.sendError(HttpServletResponse.SC_CONFLICT);
return;
try {
Object parent = getService().getResourceAtPath(user.getId(), getParentPath(path), true);
- if (!(parent instanceof FolderDTO)) {
+ if (!(parent instanceof Folder)) {
resp.sendError(HttpServletResponse.SC_CONFLICT);
return;
}
- final FolderDTO folder = (FolderDTO) parent;
+ final Folder folderLocal = (Folder) parent;
final String name = getLastElement(path);
final String mimeType = getServletContext().getMimeType(name);
File uploadedFile = null;
throw new GSSIOException(ex, false);
}
// FIXME: Add attributes
- FileHeaderDTO fileDTO = null;
- final FileHeaderDTO f = file;
+ FileHeader fileLocal = null;
+ final FileHeader f = file;
final File uf = uploadedFile;
if (exists)
- fileDTO = new TransactionHelper<FileHeaderDTO>().tryExecute(new Callable<FileHeaderDTO>() {
+ fileLocal = new TransactionHelper<FileHeader>().tryExecute(new Callable<FileHeader>() {
@Override
- public FileHeaderDTO call() throws Exception {
+ public FileHeader call() throws Exception {
return getService().updateFileContents(user.getId(), f.getId(), mimeType, uf.length(), uf.getAbsolutePath());
}
});
else
- fileDTO = new TransactionHelper<FileHeaderDTO>().tryExecute(new Callable<FileHeaderDTO>() {
+ fileLocal = new TransactionHelper<FileHeader>().tryExecute(new Callable<FileHeader>() {
@Override
- public FileHeaderDTO call() throws Exception {
- return getService().createFile(user.getId(), folder.getId(), name, mimeType, uf.length(), uf.getAbsolutePath());
+ public FileHeader call() throws Exception {
+ return getService().createFile(user.getId(), folderLocal.getId(), name, mimeType, uf.length(), uf.getAbsolutePath());
}
});
- updateAccounting(user, new Date(), fileDTO.getFileSize());
+ updateAccounting(user, new Date(), fileLocal.getCurrentBody().getFileSize());
} catch (ObjectNotFoundException e) {
result = false;
} catch (InsufficientPermissionsException e) {
String lockTokenStr = req.getServletPath() + "-" + lock.type + "-" + lock.scope + "-" + req.getUserPrincipal() + "-" + lock.depth + "-" + lock.owner + "-" + lock.tokens + "-" + lock.expiresAt + "-" + System.currentTimeMillis() + "-" + secret;
String lockToken = md5Encoder.encode(md5Helper.digest(lockTokenStr.getBytes()));
- if (exists && object instanceof FolderDTO && lock.depth == INFINITY)
+ if (exists && object instanceof Folder && lock.depth == INFINITY)
// Locking a collection (and all its member resources)
lock.tokens.addElement(lockToken);
else {
return;
}
try {
- if (parent instanceof FolderDTO) {
- final FolderDTO folder = (FolderDTO) parent;
+ if (parent instanceof Folder) {
+ final Folder folderLocal = (Folder) parent;
new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
@Override
public Void call() throws Exception {
- getService().createFolder(user.getId(), folder.getId(), getLastElement(path));
+ getService().createFolder(user.getId(), folderLocal.getId(), getLastElement(path));
return null;
}
});
if (path.toUpperCase().startsWith("/WEB-INF") || path.toUpperCase().startsWith("/META-INF"))
return;
- FolderDTO folder = null;
- FileHeaderDTO file = null;
- if (resource instanceof FolderDTO)
- folder = (FolderDTO) resource;
+ Folder folderLocal = null;
+ FileHeader fileLocal = null;
+ if (resource instanceof Folder)
+ folderLocal = (Folder) resource;
else
- file = (FileHeaderDTO) resource;
+ fileLocal = (FileHeader) resource;
// Retrieve the creation date.
long creation = 0;
- if (folder != null)
- creation = folder.getAuditInfo().getCreationDate().getTime();
+ if (folderLocal != null)
+ creation = folderLocal.getAuditInfo().getCreationDate().getTime();
else
- creation = file.getAuditInfo().getCreationDate().getTime();
+ creation = fileLocal.getAuditInfo().getCreationDate().getTime();
// Retrieve the modification date.
long modification = 0;
- if (folder != null)
- modification = folder.getAuditInfo().getCreationDate().getTime();
+ if (folderLocal != null)
+ modification = folderLocal.getAuditInfo().getCreationDate().getTime();
else
- modification = file.getAuditInfo().getCreationDate().getTime();
+ modification = fileLocal.getAuditInfo().getCreationDate().getTime();
generatedXML.writeElement(null, "D:response", XMLWriter.OPENING);
String status = new String("HTTP/1.1 " + WebdavStatus.SC_OK + " " + WebdavStatus.getStatusText(WebdavStatus.SC_OK));
href += path.substring(1);
else
href += path;
- if (folder != null && !href.endsWith("/"))
+ if (folderLocal != null && !href.endsWith("/"))
href += "/";
generatedXML.writeText(rewriteUrl(href));
generatedXML.writeElement(null, "D:displayname", XMLWriter.OPENING);
generatedXML.writeData(resourceName);
generatedXML.writeElement(null, "D:displayname", XMLWriter.CLOSING);
- if (file != null) {
+ if (fileLocal != null) {
generatedXML.writeProperty(null, "D:getlastmodified", FastHttpDateFormat.formatDate(modification, null));
- generatedXML.writeProperty(null, "D:getcontentlength", String.valueOf(file.getFileSize()));
- String contentType = file.getMimeType();
+ generatedXML.writeProperty(null, "D:getcontentlength", String.valueOf(fileLocal.getCurrentBody().getFileSize()));
+ String contentType = fileLocal.getCurrentBody().getMimeType();
if (contentType != null)
generatedXML.writeProperty(null, "D:getcontenttype", contentType);
- generatedXML.writeProperty(null, "D:getetag", getETag(file, null));
+ generatedXML.writeProperty(null, "D:getetag", getETag(fileLocal, null));
generatedXML.writeElement(null, "D:resourcetype", XMLWriter.NO_CONTENT);
} else {
generatedXML.writeElement(null, "D:resourcetype", XMLWriter.OPENING);
generatedXML.writeElement(null, "D:creationdate", XMLWriter.NO_CONTENT);
generatedXML.writeElement(null, "D:displayname", XMLWriter.NO_CONTENT);
- if (file != null) {
+ if (fileLocal != null) {
generatedXML.writeElement(null, "D:getcontentlanguage", XMLWriter.NO_CONTENT);
generatedXML.writeElement(null, "D:getcontentlength", XMLWriter.NO_CONTENT);
generatedXML.writeElement(null, "D:getcontenttype", XMLWriter.NO_CONTENT);
generatedXML.writeData(resourceName);
generatedXML.writeElement(null, "D:displayname", XMLWriter.CLOSING);
} else if (property.equals("D:getcontentlanguage")) {
- if (folder != null)
+ if (folderLocal != null)
propertiesNotFound.addElement(property);
else
generatedXML.writeElement(null, "D:getcontentlanguage", XMLWriter.NO_CONTENT);
} else if (property.equals("D:getcontentlength")) {
- if (folder != null)
+ if (folderLocal != null)
propertiesNotFound.addElement(property);
else
- generatedXML.writeProperty(null, "D:getcontentlength", String.valueOf(file.getFileSize()));
+ generatedXML.writeProperty(null, "D:getcontentlength", String.valueOf(fileLocal.getCurrentBody().getFileSize()));
} else if (property.equals("D:getcontenttype")) {
- if (folder != null)
+ if (folderLocal != null)
propertiesNotFound.addElement(property);
else
// XXX Once we properly store the MIME type in the
// file,
// retrieve it from there.
- generatedXML.writeProperty(null, "D:getcontenttype", getServletContext().getMimeType(file.getName()));
+ generatedXML.writeProperty(null, "D:getcontenttype", getServletContext().getMimeType(fileLocal.getName()));
} else if (property.equals("D:getetag")) {
- if (folder != null)
+ if (folderLocal != null)
propertiesNotFound.addElement(property);
else
- generatedXML.writeProperty(null, "D:getetag", getETag(file, null));
+ generatedXML.writeProperty(null, "D:getetag", getETag(fileLocal, null));
} else if (property.equals("D:getlastmodified")) {
- if (folder != null)
+ if (folderLocal != null)
propertiesNotFound.addElement(property);
else
generatedXML.writeProperty(null, "D:getlastmodified", FastHttpDateFormat.formatDate(modification, null));
} else if (property.equals("D:resourcetype")) {
- if (folder != null) {
+ if (folderLocal != null) {
generatedXML.writeElement(null, "D:resourcetype", XMLWriter.OPENING);
generatedXML.writeElement(null, "D:collection", XMLWriter.NO_CONTENT);
generatedXML.writeElement(null, "D:resourcetype", XMLWriter.CLOSING);
/**
* Get the ETag associated with a file.
*
- * @param file the FileHeaderDTO object for this file
+ * @param file the FileHeader object for this file
* @param oldBody the old version of the file, if requested
* @return a string containing the ETag
*/
- protected String getETag(FileHeaderDTO file, FileBodyDTO oldBody) {
+ protected String getETag(FileHeader file, FileBody oldBody) {
if (oldBody == null)
- return "\"" + file.getFileSize() + "-" + file.getAuditInfo().getModificationDate().getTime() + "\"";
+ return "\"" + file.getCurrentBody().getFileSize() + "-" + file.getAuditInfo().getModificationDate().getTime() + "\"";
return "\"" + oldBody.getFileSize() + "-" + oldBody.getAuditInfo().getModificationDate().getTime() + "\"";
}
methodsAllowed.append(", PROPPATCH, COPY, MOVE, LOCK, UNLOCK");
methodsAllowed.append(", PROPFIND");
- if (!(object instanceof FolderDTO))
+ if (!(object instanceof Folder))
methodsAllowed.append(", PUT");
return methodsAllowed;
User user = getUser(req);
User owner = getOwner(req);
- FileHeaderDTO oldResource = null;
+ FileHeader oldResource = null;
try {
Object obj = getService().getResourceAtPath(owner.getId(), path, true);
- if (obj instanceof FileHeaderDTO)
- oldResource = (FileHeaderDTO) obj;
+ if (obj instanceof FileHeader)
+ oldResource = (FileHeader) obj;
} catch (ObjectNotFoundException e) {
// Do nothing.
}
User user = getUser(req);
boolean exists = true;
Object resource = null;
- FileHeaderDTO file = null;
- FolderDTO folder = null;
+ FileHeader file = null;
+ Folder folder = null;
try {
resource = getService().getResourceAtPath(user.getId(), path, true);
} catch (ObjectNotFoundException e) {
return;
}
- if (resource instanceof FolderDTO)
- folder = (FolderDTO) resource;
+ if (resource instanceof Folder)
+ folder = (Folder) resource;
else
- file = (FileHeaderDTO) resource;
+ file = (FileHeader) resource;
// If the resource is not a collection, and the resource path
// ends with "/" or "\", return NOT FOUND
// Find content type.
String contentType = null;
if (file != null) {
- contentType = file.getMimeType();
+ contentType = file.getCurrentBody().getMimeType();
if (contentType == null) {
contentType = getServletContext().getMimeType(file.getName());
- file.setMimeType(contentType);
+ file.getCurrentBody().setMimeType(contentType);
}
} else
contentType = "text/html;charset=UTF-8";
// Last-Modified header
resp.setHeader("Last-Modified", getLastModifiedHttp(file.getAuditInfo()));
// Get content length
- contentLength = file.getFileSize();
+ contentLength = file.getCurrentBody().getFileSize();
// Special case for zero length files, which would cause a
// (silent) ISE when setting the output buffer size
if (contentLength == 0L)
* @param auditInfo the audit info for the specified resource
* @return the last modified date in HTTP format
*/
- protected String getLastModifiedHttp(AuditInfoDTO auditInfo) {
+ protected String getLastModifiedHttp(AuditInfo auditInfo) {
Date modifiedDate = auditInfo.getModificationDate();
if (modifiedDate == null)
modifiedDate = auditInfo.getCreationDate();
* @return Vector of ranges
* @throws IOException
*/
- protected ArrayList parseRange(HttpServletRequest request, HttpServletResponse response, FileHeaderDTO file, FileBodyDTO oldBody) throws IOException {
+ protected ArrayList parseRange(HttpServletRequest request, HttpServletResponse response, FileHeader file, FileBody oldBody) throws IOException {
// Checking If-Range
String headerValue = request.getHeader("If-Range");
if (headerValue != null) {
return FULL;
}
- long fileLength = oldBody == null ? file.getFileSize() : oldBody.getFileSize();
+ long fileLength = oldBody == null ? file.getCurrentBody().getFileSize() : oldBody.getFileSize();
if (fileLength == 0)
return null;
* @throws IOException
*/
protected boolean checkIfHeaders(HttpServletRequest request, HttpServletResponse response,
- FileHeaderDTO file, FileBodyDTO oldBody) throws IOException {
+ FileHeader file, FileBody oldBody) throws IOException {
// TODO : Checking the WebDAV If header
return checkIfMatch(request, response, file, oldBody) &&
checkIfModifiedSince(request, response, file, oldBody) &&
* @throws IOException
*/
private boolean checkIfMatch(HttpServletRequest request, HttpServletResponse response,
- FileHeaderDTO file, FileBodyDTO oldBody) throws IOException {
+ FileHeader file, FileBody oldBody) throws IOException {
String eTag = getETag(file, oldBody);
String headerValue = request.getHeader("If-Match");
if (headerValue != null)
* processing is stopped
*/
private boolean checkIfModifiedSince(HttpServletRequest request,
- HttpServletResponse response, FileHeaderDTO file, FileBodyDTO oldBody) {
+ HttpServletResponse response, FileHeader file, FileBody oldBody) {
try {
long headerValue = request.getDateHeader("If-Modified-Since");
long lastModified = oldBody == null ?
* @throws IOException
*/
private boolean checkIfNoneMatch(HttpServletRequest request,
- HttpServletResponse response, FileHeaderDTO file, FileBodyDTO oldBody)
+ HttpServletResponse response, FileHeader file, FileBody oldBody)
throws IOException {
String eTag = getETag(file, oldBody);
String headerValue = request.getHeader("If-None-Match");
* @throws IOException
*/
private boolean checkIfUnmodifiedSince(HttpServletRequest request,
- HttpServletResponse response, FileHeaderDTO file, FileBodyDTO oldBody)
+ HttpServletResponse response, FileHeader file, FileBody oldBody)
throws IOException {
try {
long lastModified = oldBody == null ?
* @throws InsufficientPermissionsException
* @throws ObjectNotFoundException
*/
- protected void copy(FileHeaderDTO file, InputStream is, ServletOutputStream ostream,
- HttpServletRequest req, FileBodyDTO oldBody) throws IOException,
+ protected void copy(FileHeader file, InputStream is, ServletOutputStream ostream,
+ HttpServletRequest req, FileBody oldBody) throws IOException,
ObjectNotFoundException, InsufficientPermissionsException, RpcException {
IOException exception = null;
InputStream resourceInputStream = null;
* @throws InsufficientPermissionsException
* @throws ObjectNotFoundException
*/
- protected void copy(FileHeaderDTO file, InputStream is, PrintWriter writer,
- HttpServletRequest req, FileBodyDTO oldBody) throws IOException,
+ protected void copy(FileHeader file, InputStream is, PrintWriter writer,
+ HttpServletRequest req, FileBody oldBody) throws IOException,
ObjectNotFoundException, InsufficientPermissionsException, RpcException {
IOException exception = null;
* @throws InsufficientPermissionsException
* @throws ObjectNotFoundException
*/
- protected void copy(FileHeaderDTO file, PrintWriter writer, Iterator ranges,
- String contentType, HttpServletRequest req, FileBodyDTO oldBody)
+ protected void copy(FileHeader file, PrintWriter writer, Iterator ranges,
+ String contentType, HttpServletRequest req, FileBody oldBody)
throws IOException, ObjectNotFoundException, InsufficientPermissionsException, RpcException {
User user = getUser(req);
IOException exception = null;
* @throws InsufficientPermissionsException
* @throws ObjectNotFoundException
*/
- protected void copy(FileHeaderDTO file, ServletOutputStream ostream, Range range,
- HttpServletRequest req, FileBodyDTO oldBody) throws IOException,
+ protected void copy(FileHeader file, ServletOutputStream ostream, Range range,
+ HttpServletRequest req, FileBody oldBody) throws IOException,
ObjectNotFoundException, InsufficientPermissionsException, RpcException {
IOException exception = null;
User user = getUser(req);
* @throws InsufficientPermissionsException
* @throws ObjectNotFoundException
*/
- protected void copy(FileHeaderDTO file, PrintWriter writer, Range range,
- HttpServletRequest req, FileBodyDTO oldBody) throws IOException,
+ protected void copy(FileHeader file, PrintWriter writer, Range range,
+ HttpServletRequest req, FileBody oldBody) throws IOException,
ObjectNotFoundException, InsufficientPermissionsException, RpcException {
IOException exception = null;
User user = getUser(req);
* @throws InsufficientPermissionsException
* @throws ObjectNotFoundException
*/
- protected void copy(FileHeaderDTO file, ServletOutputStream ostream,
+ protected void copy(FileHeader file, ServletOutputStream ostream,
Iterator ranges, String contentType, HttpServletRequest req,
- FileBodyDTO oldBody) throws IOException, ObjectNotFoundException,
+ FileBody oldBody) throws IOException, ObjectNotFoundException,
InsufficientPermissionsException, RpcException {
IOException exception = null;
User user = getUser(req);
* @throws IOException
* @throws ServletException
*/
- private InputStream renderHtml(String contextPath, String path, FolderDTO folder, HttpServletRequest req) throws IOException, ServletException {
+ private InputStream renderHtml(String contextPath, String path, Folder folder, HttpServletRequest req) throws IOException, ServletException {
String name = folder.getName();
// Prepare a writer to a buffered area
ByteArrayOutputStream stream = new ByteArrayOutputStream();
boolean shade = false;
Iterator iter = folder.getSubfolders().iterator();
while (iter.hasNext()) {
- FolderDTO subf = (FolderDTO) iter.next();
+ Folder subf = (Folder) iter.next();
String resourceName = subf.getName();
if (resourceName.equalsIgnoreCase("WEB-INF") || resourceName.equalsIgnoreCase("META-INF"))
continue;
sb.append("</tr>\r\n");
}
- List<FileHeaderDTO> files;
+ List<FileHeader> files;
try {
User user = getUser(req);
files = getService().getFiles(user.getId(), folder.getId(), true);
} catch (RpcException e) {
throw new ServletException(e.getMessage());
}
- for (FileHeaderDTO file : files) {
- String resourceName = file.getName();
+ for (FileHeader fileLocal : files) {
+ String resourceName = fileLocal.getName();
if (resourceName.equalsIgnoreCase("WEB-INF") || resourceName.equalsIgnoreCase("META-INF"))
continue;
sb.append("</tt></a></td>\r\n");
sb.append("<td align=\"right\"><tt>");
- sb.append(renderSize(file.getFileSize()));
+ sb.append(renderSize(fileLocal.getCurrentBody().getFileSize()));
sb.append("</tt></td>\r\n");
sb.append("<td align=\"right\"><tt>");
- sb.append(getLastModifiedHttp(file.getAuditInfo()));
+ sb.append(getLastModifiedHttp(fileLocal.getAuditInfo()));
sb.append("</tt></td>\r\n");
sb.append("</tr>\r\n");
} catch (ObjectNotFoundException e) {
}
- if (object instanceof FolderDTO) {
- final FolderDTO folder = (FolderDTO) object;
+ if (object instanceof Folder) {
+ final Folder folderLocal = (Folder) object;
try {
final String des = dest;
new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
@Override
public Void call() throws Exception {
- getService().copyFolder(user.getId(), folder.getId(), des);
+ getService().copyFolder(user.getId(), folderLocal.getId(), des);
return null;
}
});
if (!dest.endsWith("/"))
newDest += "/";
// Recursively copy the subfolders.
- Iterator iter = folder.getSubfolders().iterator();
+ Iterator iter = folderLocal.getSubfolders().iterator();
while (iter.hasNext()) {
- FolderDTO subf = (FolderDTO) iter.next();
+ Folder subf = (Folder) iter.next();
String resourceName = subf.getName();
copyResource(errorList, newSource + resourceName, newDest + resourceName, req);
}
// Recursively copy the files.
- List<FileHeaderDTO> files;
- files = getService().getFiles(user.getId(), folder.getId(), true);
- for (FileHeaderDTO file : files) {
+ List<FileHeader> files;
+ files = getService().getFiles(user.getId(), folderLocal.getId(), true);
+ for (FileHeader file : files) {
String resourceName = file.getName();
copyResource(errorList, newSource + resourceName, newDest + resourceName, req);
}
return false;
}
- } else if (object instanceof FileHeaderDTO) {
- final FileHeaderDTO file = (FileHeaderDTO) object;
+ } else if (object instanceof FileHeader) {
+ final FileHeader fileLocal = (FileHeader) object;
try {
final String des = dest;
new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
@Override
public Void call() throws Exception {
- getService().copyFile(user.getId(), file.getId(), des);
+ getService().copyFile(user.getId(), fileLocal.getId(), des);
return null;
}
});
return false;
}
- FolderDTO folder = null;
- FileHeaderDTO file = null;
- if (object instanceof FolderDTO)
- folder = (FolderDTO) object;
+ Folder folderLocal = null;
+ FileHeader fileLocal = null;
+ if (object instanceof Folder)
+ folderLocal = (Folder) object;
else
- file = (FileHeaderDTO) object;
+ fileLocal = (FileHeader) object;
- if (file != null)
+ if (fileLocal != null)
try {
- final FileHeaderDTO f = file;
+ final FileHeader f = fileLocal;
new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
@Override
public Void call() throws Exception {
resp.sendError(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
return false;
}
- else if (folder != null) {
+ else if (folderLocal != null) {
Hashtable<String, Integer> errorList = new Hashtable<String, Integer>();
- deleteCollection(req, folder, path, errorList);
+ deleteCollection(req, folderLocal, path, errorList);
try {
- final FolderDTO f = folder;
+ final Folder f = folderLocal;
new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
@Override
public Void call() throws Exception {
* @param path Path to the collection to be deleted
* @param errorList Contains the list of the errors which occurred
*/
- private void deleteCollection(HttpServletRequest req, FolderDTO folder, String path, Hashtable<String, Integer> errorList) {
+ private void deleteCollection(HttpServletRequest req, Folder folder, String path, Hashtable<String, Integer> errorList) {
if (logger.isDebugEnabled())
logger.debug("Delete:" + path);
Iterator iter = folder.getSubfolders().iterator();
while (iter.hasNext()) {
- FolderDTO subf = (FolderDTO) iter.next();
+ Folder subf = (Folder) iter.next();
String childName = path;
if (!childName.equals("/"))
childName += "/";
try {
final User user = getUser(req);
Object object = getService().getResourceAtPath(user.getId(), childName, true);
- FolderDTO childFolder = null;
- FileHeaderDTO childFile = null;
- if (object instanceof FolderDTO)
- childFolder = (FolderDTO) object;
+ Folder childFolder = null;
+ FileHeader childFile = null;
+ if (object instanceof Folder)
+ childFolder = (Folder) object;
else
- childFile = (FileHeaderDTO) object;
+ childFile = (FileHeader) object;
if (childFolder != null) {
- final FolderDTO cf = childFolder;
+ final Folder cf = childFolder;
deleteCollection(req, childFolder, childName, errorList);
new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
@Override
}
});
} else if (childFile != null) {
- final FileHeaderDTO cf = childFile;
+ final FileHeader cf = childFile;
new TransactionHelper<Void>().tryExecute(new Callable<Void>() {
@Override
public Void call() throws Exception {
* processing is stopped
*/
public boolean checkIfModifiedSince(HttpServletRequest request,
- HttpServletResponse response, FolderDTO folder) {
+ HttpServletResponse response, Folder folder) {
try {
long headerValue = request.getDateHeader("If-Modified-Since");
long lastModified = folder.getAuditInfo().getModificationDate().getTime();