Revision a0b9d31e

b/src/gr/ebs/gss/server/ejb/ExternalAPI.java
648 648
	public void removeFileFromTrash(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException;
649 649

  
650 650
	/**
651
	 * Marks  the specified files as deleted in the specified user's namespace.
652
	 *
653
	 * @param userId the ID of the current user
654
	 * @param fileIds the IDs of the file to delete
655
	 * @throws ObjectNotFoundException if the user or file was not found, with
656
	 *             the exception message mentioning the precise problem
657
	 * @throws InsufficientPermissionsException if the user does not have the
658
	 *             appropriate privileges
659
	 */
660
	public void moveFilesToTrash(Long userId, List<Long> fileIds)
661
			throws ObjectNotFoundException, InsufficientPermissionsException;
662

  
663
	/**
664 651
	 * Marks  the specified deleted files as undeleted in the specified user's namespace.
665 652
	 *
666 653
	 * @param userId the ID of the current user
b/src/gr/ebs/gss/server/ejb/ExternalAPIBean.java
19 19
package gr.ebs.gss.server.ejb;
20 20

  
21 21
import static gr.ebs.gss.server.configuration.GSSConfigurationFactory.getConfiguration;
22

  
23
import gr.ebs.gss.admin.client.ui.UsersTable;
22 24
import gr.ebs.gss.client.exceptions.DuplicateNameException;
23 25
import gr.ebs.gss.client.exceptions.GSSIOException;
24 26
import gr.ebs.gss.client.exceptions.InsufficientPermissionsException;
......
1143 1145
		if (parent == null)
1144 1146
			throw new ObjectNotFoundException("The specified file has no parent folder");
1145 1147
		User user = dao.getEntityById(User.class, userId);
1146
		if (!file.hasDeletePermission(user))
1147
			throw new InsufficientPermissionsException("User " + user.getId() + " cannot delete file " + file.getName() + "(" + file.getId() + ")");
1148

  
1149
		file.setDeleted(true);
1150
		dao.update(file);
1151
		touchParentFolders(parent, user, new Date());
1148
        trashFile(user, file);
1149
        touchParentFolders(parent, user, new Date());
1152 1150
	}
1153 1151

  
1152
    private void trashFile(User user, FileHeader file) throws InsufficientPermissionsException {
1153
        if (!file.hasDeletePermission(user))
1154
            throw new InsufficientPermissionsException("User " + user.getId() + " cannot delete file " + file.getName() + "(" + file.getId() + ")");
1155

  
1156
        file.setDeleted(true);
1157
    }
1158

  
1154 1159
	@Override
1155 1160
	public void moveFileToPath(Long userId, Long ownerId, Long fileId, String dest) throws ObjectNotFoundException, InsufficientPermissionsException, QuotaExceededException {
1156 1161
		if (userId == null)
......
1332 1337

  
1333 1338
	@Override
1334 1339
	public void moveFolderToTrash(Long userId, Long folderId) throws ObjectNotFoundException, InsufficientPermissionsException {
1335
		if (userId == null)
1336
			throw new ObjectNotFoundException("No user specified");
1337
		if (folderId == null)
1338
			throw new ObjectNotFoundException("No folder specified");
1339
		Folder folder = dao.getEntityById(Folder.class, folderId);
1340
		User user = dao.getEntityById(User.class, userId);
1341
		if (!folder.hasDeletePermission(user))
1342
			throw new InsufficientPermissionsException("You don't have the necessary permissions");
1343
		folder.setDeleted(true);
1344
		dao.update(folder);
1345
		touchParentFolders(folder, user, new Date());
1346
		for (FileHeader file : folder.getFiles())
1347
			moveFileToTrash(userId, file.getId());
1348
		for (Folder subFolder : folder.getSubfolders())
1349
			moveFolderToTrash(userId, subFolder.getId());
1350

  
1351
	}
1340
        if (userId == null)
1341
            throw new ObjectNotFoundException("No user specified");
1342
        if (folderId == null)
1343
            throw new ObjectNotFoundException("No folder specified");
1344
        Folder folder = dao.getEntityById(Folder.class, folderId);
1345
        User user = dao.getEntityById(User.class, userId);
1346
        trashFolder(user, folder);
1347
        touchParentFolders(folder, user, new Date());
1348
	}
1349

  
1350
    private void trashFolder(User user, Folder folder) throws ObjectNotFoundException, InsufficientPermissionsException {
1351
        if (!folder.hasDeletePermission(user))
1352
            throw new InsufficientPermissionsException("You don't have the necessary permissions");
1353
        folder.setDeleted(true);
1354
        for (FileHeader file : folder.getFiles())
1355
            trashFile(user, file);
1356
        for (Folder subFolder : folder.getSubfolders())
1357
            trashFolder(user, subFolder);
1358
    }
1352 1359

  
1353 1360
	@Override
1354 1361
	public void removeFolderFromTrash(Long userId, Long folderId)
......
1935 1942
	}
1936 1943

  
1937 1944
	@Override
1938
	public void moveFilesToTrash(Long userId, List<Long> fileIds) throws ObjectNotFoundException, InsufficientPermissionsException {
1939
		for(Long l : fileIds)
1940
			moveFileToTrash(userId, l);
1941

  
1942
	}
1943

  
1944
	@Override
1945 1945
	public void removeFilesFromTrash(Long userId, List<Long> fileIds) throws ObjectNotFoundException, InsufficientPermissionsException {
1946 1946
		for(Long l : fileIds)
1947 1947
			removeFileFromTrash(userId, l);

Also available in: Unified diff