Search in sources :

Example 96 with FsPath

use of diskCacheV111.util.FsPath in project dcache by dCache.

the class ChimeraNameSpaceProvider method removeExtendedAttribute.

public void removeExtendedAttribute(Subject subject, FsPath path, String name) throws CacheException {
    try {
        ExtendedInode target = pathToInode(subject, path.toString());
        if (!Subjects.isExemptFromNamespaceChecks(subject)) {
            FileAttributes attributes = getFileAttributesForPermissionHandler(target);
            if (target.isDirectory()) {
                if (_permissionHandler.canCreateFile(subject, attributes) != ACCESS_ALLOWED) {
                    throw new PermissionDeniedCacheException("Access denied");
                }
            } else {
                if (_permissionHandler.canWriteFile(subject, attributes) != ACCESS_ALLOWED) {
                    throw new PermissionDeniedCacheException("Access denied");
                }
            }
        }
        _fs.removeXattr(target, name);
    } catch (FileNotFoundChimeraFsException e) {
        throw new FileNotFoundCacheException("No such file " + path);
    } catch (NoXdataChimeraException e) {
        throw new NoAttributeCacheException("No attribute " + name + " for file " + path, e);
    } catch (ChimeraFsException e) {
        throw new CacheException("Failed to list extended attributes: " + Exceptions.messageOrClassName(e), e);
    }
}
Also used : FileNotFoundChimeraFsException(org.dcache.chimera.FileNotFoundChimeraFsException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) NoXdataChimeraException(org.dcache.chimera.NoXdataChimeraException) ChimeraFsException(org.dcache.chimera.ChimeraFsException) DirNotEmptyChimeraFsException(org.dcache.chimera.DirNotEmptyChimeraFsException) FileExistsChimeraFsException(org.dcache.chimera.FileExistsChimeraFsException) FileNotFoundChimeraFsException(org.dcache.chimera.FileNotFoundChimeraFsException) 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) NoAttributeCacheException(diskCacheV111.util.NoAttributeCacheException) FileAttributes(org.dcache.vehicles.FileAttributes)

Example 97 with FsPath

use of diskCacheV111.util.FsPath in project dcache by dCache.

the class PnfsManagerTest method testCancelUploadRecursively.

@Test
public void testCancelUploadRecursively() throws ChimeraFsException {
    FsPath root = FsPath.ROOT;
    FsPath path = FsPath.create("/test");
    PnfsCreateUploadPath create = new PnfsCreateUploadPath(Subjects.ROOT, Restrictions.none(), path, root, null, null, null, null, EnumSet.noneOf(CreateOption.class));
    _pnfsManager.createUploadPath(create);
    assertThat(create.getReturnCode(), is(0));
    _fs.createFile(create.getUploadPath().toString());
    _fs.mkdir(create.getUploadPath().parent() + "/bar");
    _fs.mkdir(create.getUploadPath().parent() + "/baz");
    _fs.createFile(create.getUploadPath().parent() + "/baz/baz");
    PnfsCancelUpload cancel = new PnfsCancelUpload(Subjects.ROOT, Restrictions.none(), create.getUploadPath(), path, EnumSet.noneOf(FileAttribute.class), "request aborted");
    _pnfsManager.cancelUpload(cancel);
    assertThat(cancel.getReturnCode(), is(0));
    assertNotExists(create.getUploadPath().toString());
    assertNotExists("/test");
}
Also used : PnfsCreateUploadPath(diskCacheV111.vehicles.PnfsCreateUploadPath) PnfsCancelUpload(diskCacheV111.vehicles.PnfsCancelUpload) CreateOption(org.dcache.namespace.CreateOption) FsPath(diskCacheV111.util.FsPath) FileAttribute(org.dcache.namespace.FileAttribute) Test(org.junit.Test)

Example 98 with FsPath

use of diskCacheV111.util.FsPath in project dcache by dCache.

the class Inotify method select.

@Override
public SelectionResult select(SelectionContext context, BiConsumer<String, JsonNode> receiver, JsonNode serialisedSelector) {
    try {
        InotifySelector selector = mapper.readerFor(InotifySelector.class).readValue(serialisedSelector);
        String clientPath = selector.getPath();
        FsPath dCachePath = pathMapper.asDcachePath(context.httpServletRequest(), clientPath, PermissionDeniedCacheException::new);
        selector.setFsPath(dCachePath);
        return selector.validationError().orElseGet(() -> select(context.channelId(), receiver, selector));
    } catch (PermissionDeniedCacheException e) {
        return SelectionResult.permissionDenied(e.getMessage());
    } catch (JsonMappingException e) {
        int index = e.getMessage().indexOf('\n');
        String msg = index == -1 ? e.getMessage() : e.getMessage().substring(0, index);
        return SelectionResult.badSelector("Bad selector value: %s", msg);
    } catch (IOException e) {
        return SelectionResult.badSelector("Unable to process selector: " + e.getMessage());
    }
}
Also used : PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) IOException(java.io.IOException) FsPath(diskCacheV111.util.FsPath)

Example 99 with FsPath

use of diskCacheV111.util.FsPath in project dcache by dCache.

the class RemoteNameSpaceProvider method listExtendedAttributes.

public Set<String> listExtendedAttributes(Subject subject, FsPath path) throws CacheException {
    PnfsListExtendedAttributesMessage message = new PnfsListExtendedAttributesMessage(path.toString());
    message.setSubject(subject);
    message.setRestriction(Restrictions.none());
    return _pnfs.request(message).getNames();
}
Also used : PnfsListExtendedAttributesMessage(diskCacheV111.vehicles.PnfsListExtendedAttributesMessage)

Example 100 with FsPath

use of diskCacheV111.util.FsPath in project dcache by dCache.

the class RemoteNameSpaceProvider method readExtendedAttribute.

public byte[] readExtendedAttribute(Subject subject, FsPath path, String name) throws CacheException {
    PnfsReadExtendedAttributesMessage message = new PnfsReadExtendedAttributesMessage(path.toString());
    message.addName(name);
    message.setSubject(subject);
    message.setRestriction(Restrictions.none());
    return _pnfs.request(message).getAllValues().get(name);
}
Also used : PnfsReadExtendedAttributesMessage(diskCacheV111.vehicles.PnfsReadExtendedAttributesMessage)

Aggregations

FsPath (diskCacheV111.util.FsPath)98 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)66 CacheException (diskCacheV111.util.CacheException)63 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)56 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)43 NotDirCacheException (diskCacheV111.util.NotDirCacheException)42 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)39 FileAttributes (org.dcache.vehicles.FileAttributes)32 PnfsHandler (diskCacheV111.util.PnfsHandler)26 NotFileCacheException (diskCacheV111.util.NotFileCacheException)25 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)23 FileAttribute (org.dcache.namespace.FileAttribute)22 MissingResourceCacheException (diskCacheV111.util.MissingResourceCacheException)21 FileCorruptedCacheException (diskCacheV111.util.FileCorruptedCacheException)20 Subject (javax.security.auth.Subject)17 Restriction (org.dcache.auth.attributes.Restriction)17 Test (org.junit.Test)17 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)15 SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)14 SRMException (org.dcache.srm.SRMException)14