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