Search in sources :

Example 1 with StatxResponse

use of org.dcache.xrootd.protocol.messages.StatxResponse in project dcache by dCache.

the class XrootdRedirectHandler method doOnStatx.

@Override
protected XrootdResponse<StatxRequest> doOnStatx(ChannelHandlerContext ctx, StatxRequest req) throws XrootdException {
    if (req.getPaths().length == 0) {
        throw new XrootdException(kXR_ArgMissing, "no paths specified");
    }
    try {
        FsPath[] paths = new FsPath[req.getPaths().length];
        for (int i = 0; i < paths.length; i++) {
            paths[i] = createFullPath(req.getPaths()[i]);
        }
        LoginSessionInfo loginSessionInfo = sessionInfo();
        Subject subject = loginSessionInfo.getSubject();
        Restriction restriction = loginSessionInfo.getRestriction();
        return new StatxResponse(req, _door.getMultipleFileStatuses(paths, subject, restriction));
    } catch (TimeoutCacheException e) {
        throw xrootdException(e.getRc(), "Internal timeout");
    } catch (PermissionDeniedCacheException e) {
        throw xrootdException(e);
    } catch (CacheException e) {
        throw xrootdException(e.getRc(), String.format("Failed to open file (%s [%d])", e.getMessage(), e.getRc()));
    }
}
Also used : Restriction(org.dcache.auth.attributes.Restriction) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) NotFileCacheException(diskCacheV111.util.NotFileCacheException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) CacheException(diskCacheV111.util.CacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) StatxResponse(org.dcache.xrootd.protocol.messages.StatxResponse) XrootdException(org.dcache.xrootd.core.XrootdException) Subject(javax.security.auth.Subject) FsPath(diskCacheV111.util.FsPath) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException)

Example 2 with StatxResponse

use of org.dcache.xrootd.protocol.messages.StatxResponse in project xrootd4j by dCache.

the class DataServerHandler method doOnStatx.

@Override
protected StatxResponse doOnStatx(ChannelHandlerContext ctx, StatxRequest req) throws XrootdException {
    if (req.getPaths().length == 0) {
        throw new XrootdException(kXR_ArgMissing, "no paths specified");
    }
    String[] paths = req.getPaths();
    String[] opaques = req.getOpaques();
    int[] flags = new int[paths.length];
    for (int i = 0; i < paths.length; i++) {
        File file = getFile(paths[i]);
        if (!file.exists()) {
            flags[i] = kXR_other;
        } else {
            flags[i] = getFileStatusFlagsOf(file);
        }
    }
    return new StatxResponse(req, flags);
}
Also used : StatxResponse(org.dcache.xrootd.protocol.messages.StatxResponse) XrootdException(org.dcache.xrootd.core.XrootdException) RandomAccessFile(java.io.RandomAccessFile) XrootdProtocol.kXR_NotFile(org.dcache.xrootd.protocol.XrootdProtocol.kXR_NotFile) File(java.io.File)

Aggregations

XrootdException (org.dcache.xrootd.core.XrootdException)2 StatxResponse (org.dcache.xrootd.protocol.messages.StatxResponse)2 CacheException (diskCacheV111.util.CacheException)1 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)1 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)1 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)1 FsPath (diskCacheV111.util.FsPath)1 NotFileCacheException (diskCacheV111.util.NotFileCacheException)1 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)1 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)1 File (java.io.File)1 RandomAccessFile (java.io.RandomAccessFile)1 Subject (javax.security.auth.Subject)1 Restriction (org.dcache.auth.attributes.Restriction)1 XrootdProtocol.kXR_NotFile (org.dcache.xrootd.protocol.XrootdProtocol.kXR_NotFile)1