use of org.dcache.namespace.FileType in project dcache by dCache.
the class MonitoringVfs method setattr.
@Override
public void setattr(Inode inode, Stat stat) throws IOException {
super.setattr(inode, stat);
FileType type = asFileType(super.getattr(inode).type());
toPnfsId(inode).ifPresent(id -> eventReceiver.notifySelfEvent(IN_ATTRIB, id, type));
findInNamespace(inode).forEach(l -> eventReceiver.notifyChildEvent(IN_ATTRIB, l.getParent(), l.getName(), type));
}
use of org.dcache.namespace.FileType in project dcache by dCache.
the class XrootdDoor method deleteFile.
/**
* Delete the file denoted by path from the namespace
*
* @param path The path of the file that is going to be deleted
* @throws CacheException Deletion of the file failed
* @throws PermissionDeniedCacheException Caller does not have permission to delete the file
*/
public void deleteFile(FsPath path, Subject subject, Restriction restriction) throws PermissionDeniedCacheException, CacheException {
PnfsHandler pnfsHandler = new PnfsHandler(_pnfs, subject, restriction);
if (!isWriteAllowed(path)) {
throw new PermissionDeniedCacheException("Write permission denied");
}
Set<FileType> allowedSet = EnumSet.of(FileType.REGULAR);
PnfsId pnfsId = pnfsHandler.deletePnfsEntry(path.toString(), allowedSet);
sendRemoveInfoToBilling(pnfsId, path, subject);
}
use of org.dcache.namespace.FileType in project dcache by dCache.
the class XrootdDoor method deleteDirectory.
/**
* Delete the directory denoted by path from the namespace
*
* @param path The path of the directory that is going to be deleted
* @throws CacheException
*/
public void deleteDirectory(FsPath path, Subject subject, Restriction restriction) throws CacheException {
PnfsHandler pnfsHandler = new PnfsHandler(_pnfs, subject, restriction);
if (!isWriteAllowed(path)) {
throw new PermissionDeniedCacheException("Write permission denied");
}
Set<FileType> allowedSet = EnumSet.of(FileType.DIR);
pnfsHandler.deletePnfsEntry(path.toString(), allowedSet);
}
use of org.dcache.namespace.FileType in project dcache by dCache.
the class ChimeraNameSpaceProvider method checkAllowed.
private void checkAllowed(Set<FileType> allowed, ExtendedInode inode) throws ChimeraFsException, NotDirCacheException, NotFileCacheException {
FileType type = inode.getFileType();
if (!allowed.contains(type)) {
StringBuilder sb = new StringBuilder("Path exists and has type ").append(type).append(", which is not ");
if (allowed.size() == 1) {
FileType allowedType = allowed.iterator().next();
sb.append(allowedType);
} else {
String description = allowed.stream().map(FileType::toString).collect(Collectors.joining(", ", "{", "}"));
sb.append("one of ").append(description);
}
if (allowed.contains(FileType.DIR)) {
throw new NotDirCacheException(sb.toString());
} else {
throw new NotFileCacheException(sb.toString());
}
}
}
use of org.dcache.namespace.FileType in project dcache by dCache.
the class MonitoringNameSpaceProvider method setFileAttributes.
@Override
public FileAttributes setFileAttributes(Subject subject, PnfsId target, FileAttributes attr, Set<FileAttribute> fetch) throws CacheException {
FileAttributes returnAttr = super.setFileAttributes(subject, target, attr, union(fetch, FILETYPE));
if (!attr.isUndefined(SIGNIFICANT_UPDATES)) {
FileType type = returnAttr.getFileType();
eventReceiver.notifySelfEvent(EventType.IN_ATTRIB, target, type);
notifyParents(target, EventType.IN_ATTRIB, type);
}
return returnAttr;
}
Aggregations