Search in sources :

Example 1 with PnfsCommitUpload

use of diskCacheV111.vehicles.PnfsCommitUpload in project dcache by dCache.

the class XrootdTransferService method handleUploadDone.

private void handleUploadDone(NettyMover<XrootdProtocolInfo> mover) throws CacheException {
    try {
        EnumSet<CreateOption> options = EnumSet.noneOf(CreateOption.class);
        if (mover.getProtocolInfo().isOverwriteAllowed()) {
            options.add(CreateOption.OVERWRITE_EXISTING);
        }
        PnfsCommitUpload msg = new PnfsCommitUpload(mover.getSubject(), mover.getProtocolInfo().getRestriction(), FsPath.create(mover.getTransferPath()), FsPath.create(mover.getBillingPath()), options, EnumSet.of(PNFSID, SIZE, STORAGEINFO));
        pnfsStub.sendAndWait(msg);
    } catch (InterruptedException ex) {
        throw new CacheException("Operation interrupted", ex);
    } catch (NoRouteToCellException ex) {
        throw new CacheException("Internal communication failure", ex);
    }
}
Also used : CacheException(diskCacheV111.util.CacheException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) CreateOption(org.dcache.namespace.CreateOption) PnfsCommitUpload(diskCacheV111.vehicles.PnfsCommitUpload)

Example 2 with PnfsCommitUpload

use of diskCacheV111.vehicles.PnfsCommitUpload in project dcache by dCache.

the class Storage method putDone.

@Override
public void putDone(SRMUser user, String localTransferPath, URI surl, boolean overwrite) throws SRMException {
    try {
        Subject subject = asDcacheUser(user).getSubject();
        Restriction restriction = asDcacheUser(user).getRestriction();
        FsPath fullPath = getPath(surl);
        checkNonBrokenUpload(localTransferPath);
        EnumSet<CreateOption> options = EnumSet.noneOf(CreateOption.class);
        if (overwrite) {
            options.add(CreateOption.OVERWRITE_EXISTING);
        }
        PnfsCommitUpload msg = new PnfsCommitUpload(subject, restriction, FsPath.create(localTransferPath), fullPath, options, EnumSet.of(PNFSID, SIZE, STORAGEINFO));
        msg = _pnfsStub.sendAndWait(msg);
        DoorRequestInfoMessage infoMsg = new DoorRequestInfoMessage(getCellAddress());
        infoMsg.setSubject(subject);
        infoMsg.setBillingPath(fullPath.toString());
        infoMsg.setTransferPath(localTransferPath);
        infoMsg.setTransaction(CDC.getSession());
        infoMsg.setPnfsId(msg.getFileAttributes().getPnfsId());
        infoMsg.setResult(0, "");
        infoMsg.setFileSize(msg.getFileAttributes().getSizeIfPresent().orElse(0L));
        infoMsg.setStorageInfo(msg.getFileAttributes().getStorageInfo());
        Origin origin = Subjects.getOrigin(subject);
        if (origin != null) {
            infoMsg.setClient(origin.getAddress().getHostAddress());
        }
        _billingStub.notify(infoMsg);
    } catch (FileNotFoundCacheException e) {
        throw new SRMInvalidPathException(e.getMessage(), e);
    } catch (FileIsNewCacheException | FileCorruptedCacheException e) {
        throw new SRMException(e.getMessage(), e);
    } catch (PermissionDeniedCacheException e) {
        throw new SRMAuthorizationException("Permission denied.", e);
    } catch (FileExistsCacheException e) {
        throw new SRMDuplicationException(surl + " exists.", e);
    } catch (CacheException e) {
        throw new SRMInternalErrorException(e.getMessage(), e);
    } catch (InterruptedException e) {
        throw new SRMInternalErrorException("Operation interrupted", e);
    } catch (NoRouteToCellException e) {
        throw new SRMInternalErrorException("Internal communication failure", e);
    }
}
Also used : DoorRequestInfoMessage(diskCacheV111.vehicles.DoorRequestInfoMessage) Origin(org.dcache.auth.Origin) SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) CacheException(diskCacheV111.util.CacheException) FileCorruptedCacheException(diskCacheV111.util.FileCorruptedCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) SRMInvalidPathException(org.dcache.srm.SRMInvalidPathException) Subject(javax.security.auth.Subject) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) Restriction(org.dcache.auth.attributes.Restriction) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) SRMException(org.dcache.srm.SRMException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) FileCorruptedCacheException(diskCacheV111.util.FileCorruptedCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) CreateOption(org.dcache.namespace.CreateOption) PnfsCommitUpload(diskCacheV111.vehicles.PnfsCommitUpload) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) SRMDuplicationException(org.dcache.srm.SRMDuplicationException) FsPath(diskCacheV111.util.FsPath)

Example 3 with PnfsCommitUpload

use of diskCacheV111.vehicles.PnfsCommitUpload in project dcache by dCache.

the class PnfsManagerV3 method commitUpload.

void commitUpload(PnfsCommitUpload message) {
    try {
        checkRestriction(message, UPLOAD);
        FileAttributes attributes = _nameSpaceProvider.commitUpload(message.getSubject(), message.getUploadPath(), message.getPath(), message.getOptions(), message.getRequestedAttributes());
        message.setFileAttributes(attributes);
        message.setSucceeded();
    } catch (CacheException e) {
        message.setFailed(e.getRc(), e.getMessage());
    } catch (RuntimeException e) {
        LOGGER.error("Commit upload path failed", e);
        message.setFailed(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e);
    }
}
Also used : MissingResourceCacheException(diskCacheV111.util.MissingResourceCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) CacheException(diskCacheV111.util.CacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) PnfsSetFileAttributes(org.dcache.vehicles.PnfsSetFileAttributes) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) FileAttributes(org.dcache.vehicles.FileAttributes)

Aggregations

CacheException (diskCacheV111.util.CacheException)3 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)2 NotDirCacheException (diskCacheV111.util.NotDirCacheException)2 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)2 PnfsCommitUpload (diskCacheV111.vehicles.PnfsCommitUpload)2 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)2 CreateOption (org.dcache.namespace.CreateOption)2 FileCorruptedCacheException (diskCacheV111.util.FileCorruptedCacheException)1 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)1 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)1 FsPath (diskCacheV111.util.FsPath)1 InvalidMessageCacheException (diskCacheV111.util.InvalidMessageCacheException)1 MissingResourceCacheException (diskCacheV111.util.MissingResourceCacheException)1 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)1 DoorRequestInfoMessage (diskCacheV111.vehicles.DoorRequestInfoMessage)1 Subject (javax.security.auth.Subject)1 Origin (org.dcache.auth.Origin)1 Restriction (org.dcache.auth.attributes.Restriction)1 SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)1 SRMDuplicationException (org.dcache.srm.SRMDuplicationException)1