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());
}
}
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());
}
}
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());
}
}
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());
}
}
Aggregations