Search in sources :

Example 1 with DirNotEmptyChimeraFsException

use of org.dcache.chimera.DirNotEmptyChimeraFsException in project dcache by dCache.

the class ChimeraNameSpaceProvider method deleteEntry.

@Override
public FileAttributes deleteEntry(Subject subject, Set<FileType> allowed, String path, Set<FileAttribute> attr) throws CacheException {
    try {
        File filePath = new File(path);
        String parentPath = filePath.getParent();
        if (parentPath == null) {
            throw new CacheException("Cannot delete file system root.");
        }
        ExtendedInode parent = pathToInode(subject, parentPath);
        String name = filePath.getName();
        ExtendedInode inode = parent.inodeOf(name, STAT);
        checkAllowed(allowed, inode);
        if (!Subjects.isExemptFromNamespaceChecks(subject) && !canDelete(subject, parent, inode)) {
            throw new PermissionDeniedCacheException("Access denied: " + path);
        }
        _fs.remove(parent, name, inode);
        return getFileAttributes(inode, attr);
    } catch (FileNotFoundChimeraFsException fnf) {
        throw new FileNotFoundCacheException("No such file or directory: " + path);
    } catch (DirNotEmptyChimeraFsException e) {
        throw new CacheException("Directory is not empty: " + path);
    } catch (IOException e) {
        throw new CacheException(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e.getMessage());
    }
}
Also used : FileNotFoundChimeraFsException(org.dcache.chimera.FileNotFoundChimeraFsException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) LockedCacheException(diskCacheV111.util.LockedCacheException) AttributeExistsCacheException(diskCacheV111.util.AttributeExistsCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) NotFileCacheException(diskCacheV111.util.NotFileCacheException) CacheException(diskCacheV111.util.CacheException) NoAttributeCacheException(diskCacheV111.util.NoAttributeCacheException) FileCorruptedCacheException(diskCacheV111.util.FileCorruptedCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) DirNotEmptyChimeraFsException(org.dcache.chimera.DirNotEmptyChimeraFsException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) File(java.io.File)

Example 2 with DirNotEmptyChimeraFsException

use of org.dcache.chimera.DirNotEmptyChimeraFsException in project dcache by dCache.

the class ChimeraNameSpaceProvider method deleteEntry.

@Override
public FileAttributes deleteEntry(Subject subject, Set<FileType> allowed, PnfsId pnfsId, Set<FileAttribute> attr) throws CacheException {
    try {
        ExtendedInode inode = new ExtendedInode(_fs, pnfsId, STAT);
        checkAllowed(allowed, inode);
        if (!Subjects.isExemptFromNamespaceChecks(subject) && !canDelete(subject, inode.getParent(), inode)) {
            throw new PermissionDeniedCacheException("Access denied: " + pnfsId);
        }
        _fs.remove(inode);
        return getFileAttributes(inode, attr);
    } catch (FileNotFoundChimeraFsException fnf) {
        throw new FileNotFoundCacheException("No such file or directory: " + pnfsId);
    } catch (DirNotEmptyChimeraFsException e) {
        throw new CacheException("Directory is not empty: " + pnfsId);
    } catch (IOException e) {
        throw new CacheException(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e.getMessage());
    }
}
Also used : FileNotFoundChimeraFsException(org.dcache.chimera.FileNotFoundChimeraFsException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) LockedCacheException(diskCacheV111.util.LockedCacheException) AttributeExistsCacheException(diskCacheV111.util.AttributeExistsCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) NotFileCacheException(diskCacheV111.util.NotFileCacheException) CacheException(diskCacheV111.util.CacheException) NoAttributeCacheException(diskCacheV111.util.NoAttributeCacheException) FileCorruptedCacheException(diskCacheV111.util.FileCorruptedCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) DirNotEmptyChimeraFsException(org.dcache.chimera.DirNotEmptyChimeraFsException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException)

Example 3 with DirNotEmptyChimeraFsException

use of org.dcache.chimera.DirNotEmptyChimeraFsException in project dcache by dCache.

the class ChimeraNameSpaceProvider method deleteEntry.

@Override
public FileAttributes deleteEntry(Subject subject, Set<FileType> allowed, PnfsId pnfsId, String path, Set<FileAttribute> attr) throws CacheException {
    try {
        File filePath = new File(path);
        String parentPath = filePath.getParent();
        if (parentPath == null) {
            throw new CacheException("Cannot delete file system root.");
        }
        ExtendedInode parent = pathToInode(subject, parentPath);
        String name = filePath.getName();
        ExtendedInode inode = parent.inodeOf(name, STAT);
        if (!inode.getPnfsId().equals(pnfsId)) {
            throw new FileNotFoundCacheException("PNFSID does not correspond to provided file.");
        }
        checkAllowed(allowed, inode);
        if (!Subjects.isExemptFromNamespaceChecks(subject) && !canDelete(subject, parent, inode)) {
            throw new PermissionDeniedCacheException("Access denied: " + path);
        }
        _fs.remove(parent, name, inode);
        return getFileAttributes(inode, attr);
    } catch (FileNotFoundChimeraFsException fnf) {
        throw new FileNotFoundCacheException("No such file or directory: " + path);
    } catch (DirNotEmptyChimeraFsException e) {
        throw new CacheException("Directory is not empty: " + path);
    } catch (IOException e) {
        throw new CacheException(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e.getMessage());
    }
}
Also used : FileNotFoundChimeraFsException(org.dcache.chimera.FileNotFoundChimeraFsException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) LockedCacheException(diskCacheV111.util.LockedCacheException) AttributeExistsCacheException(diskCacheV111.util.AttributeExistsCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) NotFileCacheException(diskCacheV111.util.NotFileCacheException) CacheException(diskCacheV111.util.CacheException) NoAttributeCacheException(diskCacheV111.util.NoAttributeCacheException) FileCorruptedCacheException(diskCacheV111.util.FileCorruptedCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) DirNotEmptyChimeraFsException(org.dcache.chimera.DirNotEmptyChimeraFsException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) File(java.io.File)

Example 4 with DirNotEmptyChimeraFsException

use of org.dcache.chimera.DirNotEmptyChimeraFsException in project dcache by dCache.

the class ChimeraVfs method move.

@Override
public boolean move(Inode src, String oldName, Inode dest, String newName) throws IOException {
    FsInode from = toFsInode(src);
    FsInode to = toFsInode(dest);
    try {
        return _fs.rename(_fs.inodeOf(from, oldName, NO_STAT), from, oldName, to, newName);
    } catch (NotDirChimeraException e) {
        throw new NotDirException("not a directory");
    } catch (FileExistsChimeraFsException e) {
        throw new ExistException("destination exists");
    } catch (DirNotEmptyChimeraFsException e) {
        throw new NotEmptyException("directory exist and not empty");
    } catch (FileNotFoundChimeraFsException e) {
        throw new NoEntException("file not found");
    } catch (PermissionDeniedChimeraFsException e) {
        throw new PermException(e.getMessage());
    }
}
Also used : FileNotFoundChimeraFsException(org.dcache.chimera.FileNotFoundChimeraFsException) NotDirException(org.dcache.nfs.status.NotDirException) PermissionDeniedChimeraFsException(org.dcache.chimera.PermissionDeniedChimeraFsException) NotDirChimeraException(org.dcache.chimera.NotDirChimeraException) FsInode(org.dcache.chimera.FsInode) NoEntException(org.dcache.nfs.status.NoEntException) PermException(org.dcache.nfs.status.PermException) NotEmptyException(org.dcache.nfs.status.NotEmptyException) DirNotEmptyChimeraFsException(org.dcache.chimera.DirNotEmptyChimeraFsException) ExistException(org.dcache.nfs.status.ExistException) FileExistsChimeraFsException(org.dcache.chimera.FileExistsChimeraFsException)

Aggregations

DirNotEmptyChimeraFsException (org.dcache.chimera.DirNotEmptyChimeraFsException)4 FileNotFoundChimeraFsException (org.dcache.chimera.FileNotFoundChimeraFsException)4 AttributeExistsCacheException (diskCacheV111.util.AttributeExistsCacheException)3 CacheException (diskCacheV111.util.CacheException)3 FileCorruptedCacheException (diskCacheV111.util.FileCorruptedCacheException)3 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)3 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)3 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)3 InvalidMessageCacheException (diskCacheV111.util.InvalidMessageCacheException)3 LockedCacheException (diskCacheV111.util.LockedCacheException)3 NoAttributeCacheException (diskCacheV111.util.NoAttributeCacheException)3 NotDirCacheException (diskCacheV111.util.NotDirCacheException)3 NotFileCacheException (diskCacheV111.util.NotFileCacheException)3 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)3 IOException (java.io.IOException)3 UncheckedIOException (java.io.UncheckedIOException)3 File (java.io.File)2 FileExistsChimeraFsException (org.dcache.chimera.FileExistsChimeraFsException)1 FsInode (org.dcache.chimera.FsInode)1 NotDirChimeraException (org.dcache.chimera.NotDirChimeraException)1