Search in sources :

Example 1 with FileType

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));
}
Also used : FileType(org.dcache.namespace.FileType)

Example 2 with FileType

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);
}
Also used : PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) FileType(org.dcache.namespace.FileType) PnfsId(diskCacheV111.util.PnfsId) PnfsHandler(diskCacheV111.util.PnfsHandler)

Example 3 with FileType

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);
}
Also used : PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) FileType(org.dcache.namespace.FileType) PnfsHandler(diskCacheV111.util.PnfsHandler)

Example 4 with FileType

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());
        }
    }
}
Also used : NotFileCacheException(diskCacheV111.util.NotFileCacheException) FileType(org.dcache.namespace.FileType) NotDirCacheException(diskCacheV111.util.NotDirCacheException)

Example 5 with FileType

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;
}
Also used : FileType(org.dcache.namespace.FileType) FileAttributes(org.dcache.vehicles.FileAttributes)

Aggregations

FileType (org.dcache.namespace.FileType)16 PnfsId (diskCacheV111.util.PnfsId)10 FileAttributes (org.dcache.vehicles.FileAttributes)7 FileAttribute (org.dcache.namespace.FileAttribute)6 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)4 CacheException (diskCacheV111.util.CacheException)3 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)3 NotDirCacheException (diskCacheV111.util.NotDirCacheException)3 PnfsGetFileAttributes (org.dcache.vehicles.PnfsGetFileAttributes)3 Test (org.junit.Test)3 InvalidMessageCacheException (diskCacheV111.util.InvalidMessageCacheException)2 MissingResourceCacheException (diskCacheV111.util.MissingResourceCacheException)2 NotFileCacheException (diskCacheV111.util.NotFileCacheException)2 PnfsHandler (diskCacheV111.util.PnfsHandler)2 IOException (java.io.IOException)2 Subject (javax.security.auth.Subject)2 FsInode (org.dcache.chimera.FsInode)2 Inode (org.dcache.nfs.vfs.Inode)2 PnfsSetFileAttributes (org.dcache.vehicles.PnfsSetFileAttributes)2 Hasher (com.google.common.hash.Hasher)1