Search in sources :

Example 11 with FsPath

use of diskCacheV111.util.FsPath 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 12 with FsPath

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

the class XrootdRedirectHandler method doOnDirList.

@Override
protected XrootdResponse<DirListRequest> doOnDirList(ChannelHandlerContext ctx, DirListRequest request) throws XrootdException {
    try {
        String listPath = request.getPath();
        if (listPath.isEmpty()) {
            throw new XrootdException(kXR_ArgMissing, "no source path specified");
        }
        _log.info("Listing directory {}", listPath);
        FsPath fullListPath = createFullPath(listPath);
        if (!_door.isReadAllowed(fullListPath)) {
            throw new PermissionDeniedCacheException("Permission denied.");
        }
        LoginSessionInfo loginSessionInfo = sessionInfo();
        Subject subject = loginSessionInfo.getSubject();
        Restriction restriction = loginSessionInfo.getRestriction();
        if (request.isDirectoryStat()) {
            _door.listPath(fullListPath, subject, restriction, new StatListCallback(request, subject, restriction, fullListPath, ctx), _door.getRequiredAttributesForFileStatus());
        } else {
            _door.listPath(fullListPath, subject, restriction, new ListCallback(request, ctx), EnumSet.noneOf(FileAttribute.class));
        }
        return null;
    } catch (PermissionDeniedCacheException e) {
        throw xrootdException(e);
    }
}
Also used : Restriction(org.dcache.auth.attributes.Restriction) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) XrootdException(org.dcache.xrootd.core.XrootdException) Subject(javax.security.auth.Subject) FsPath(diskCacheV111.util.FsPath) FileAttribute(org.dcache.namespace.FileAttribute)

Example 13 with FsPath

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

the class DcacheResourceFactory method deleteFile.

/**
 * Deletes a file.
 */
public void deleteFile(FileAttributes attributes, FsPath path) throws CacheException {
    PnfsHandler pnfs = roleAwarePnfsHandler();
    pnfs.deletePnfsEntry(attributes.getPnfsId(), path.toString(), EnumSet.of(REGULAR, LINK), EnumSet.noneOf(FileAttribute.class));
    sendRemoveInfoToBilling(attributes, path);
}
Also used : PnfsHandler(diskCacheV111.util.PnfsHandler) FileAttribute(org.dcache.namespace.FileAttribute)

Example 14 with FsPath

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

the class DcacheResourceFactory method deleteDirectory.

/**
 * Deletes a directory.
 */
public void deleteDirectory(PnfsId pnfsid, FsPath path) throws CacheException {
    PnfsHandler pnfs = roleAwarePnfsHandler();
    pnfs.deletePnfsEntry(pnfsid, path.toString(), EnumSet.of(DIR), EnumSet.noneOf(FileAttribute.class));
}
Also used : PnfsHandler(diskCacheV111.util.PnfsHandler) FileAttribute(org.dcache.namespace.FileAttribute)

Example 15 with FsPath

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

the class DcacheResourceFactory method readExtendedAttributes.

Map<String, byte[]> readExtendedAttributes(FsPath path, Collection<String> names) throws CacheException {
    PnfsReadExtendedAttributesMessage message = new PnfsReadExtendedAttributesMessage(path.toString());
    names.forEach(message::addName);
    return _pnfs.request(message).getAllValues();
}
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