Search in sources :

Example 1 with PnfsDeleteEntryMessage

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

the class RemoteNameSpaceProviderTests method shouldSucceedWhenDeletingEntryByPath.

@Test
public void shouldSucceedWhenDeletingEntryByPath() throws Exception {
    givenSuccessfulResponse();
    _namespace.deleteEntry(ROOT, EnumSet.allOf(FileType.class), "/path/to/entry", EnumSet.noneOf(FileAttribute.class));
    PnfsDeleteEntryMessage sent = getSingleSendAndWaitMessage(PnfsDeleteEntryMessage.class);
    assertThat(sent.getReplyRequired(), is(true));
    assertThat(sent.getSubject(), is(ROOT));
    assertThat(sent.getPnfsPath(), is("/path/to/entry"));
    assertThat(sent.getPnfsId(), nullValue());
}
Also used : FileType(org.dcache.namespace.FileType) PnfsDeleteEntryMessage(diskCacheV111.vehicles.PnfsDeleteEntryMessage) FileAttribute(org.dcache.namespace.FileAttribute) Test(org.junit.Test)

Example 2 with PnfsDeleteEntryMessage

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

the class DeleteFileJob method doRun.

@Override
protected void doRun() {
    if (attributes.getFileType() == FileType.DIR && isSkipDirs()) {
        return;
    }
    PnfsDeleteEntryMessage msg = new PnfsDeleteEntryMessage(attributes.getPnfsId(), path.toString(), TYPES, ATTRIBUTES);
    try {
        msg = pnfsHandler.request(msg);
    } catch (CacheException e) {
        setError(e);
        return;
    }
    Serializable error = msg.getErrorObject();
    if (error != null) {
        setError(error);
    } else {
        setState(State.COMPLETED);
    }
}
Also used : Serializable(java.io.Serializable) CacheException(diskCacheV111.util.CacheException) PnfsDeleteEntryMessage(diskCacheV111.vehicles.PnfsDeleteEntryMessage)

Example 3 with PnfsDeleteEntryMessage

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

the class RemoveFileCompanion method removeFile.

public static void removeFile(Subject subject, Restriction restriction, String path, RemoveFileCallback callbacks, CellStub pnfsStub, CellStub billingStub, CellAddressCore address, Executor executor) {
    RemoveFileCompanion companion = new RemoveFileCompanion(subject, path, callbacks, address, billingStub);
    PnfsDeleteEntryMessage message = new PnfsDeleteEntryMessage(path, EnumSet.of(LINK, REGULAR));
    message.setSubject(subject);
    message.setRestriction(restriction);
    CellStub.addCallback(pnfsStub.send(message), companion, executor);
}
Also used : PnfsDeleteEntryMessage(diskCacheV111.vehicles.PnfsDeleteEntryMessage)

Example 4 with PnfsDeleteEntryMessage

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

the class PnfsManagerV3 method deleteEntry.

public void deleteEntry(PnfsDeleteEntryMessage pnfsMessage) {
    String path = pnfsMessage.getPnfsPath();
    PnfsId pnfsId = pnfsMessage.getPnfsId();
    Subject subject = pnfsMessage.getSubject();
    Set<FileType> allowed = pnfsMessage.getAllowedFileTypes();
    Set<FileAttribute> requested = pnfsMessage.getRequestedAttributes();
    try {
        if (path == null && pnfsId == null) {
            throw new InvalidMessageCacheException("pnfsid or path have to be defined for PnfsDeleteEntryMessage");
        }
        checkMask(pnfsMessage);
        checkRestriction(pnfsMessage, DELETE);
        FileAttributes attributes;
        if (path != null) {
            LOGGER.info("delete PNFS entry for {}", path);
            if (pnfsId != null) {
                attributes = _nameSpaceProvider.deleteEntry(subject, allowed, pnfsId, path, requested);
            } else {
                requested.add(PNFSID);
                attributes = _nameSpaceProvider.deleteEntry(subject, allowed, path, requested);
                pnfsMessage.setPnfsId(attributes.getPnfsId());
            }
        } else {
            LOGGER.info("delete PNFS entry for {}", pnfsId);
            attributes = _nameSpaceProvider.deleteEntry(subject, allowed, pnfsId, requested);
        }
        pnfsMessage.setFileAttributes(attributes);
        pnfsMessage.setSucceeded();
    } catch (FileNotFoundCacheException e) {
        pnfsMessage.setFailed(CacheException.FILE_NOT_FOUND, e.getMessage());
    } catch (CacheException e) {
        LOGGER.warn("Failed to delete entry: {}", e.getMessage());
        pnfsMessage.setFailed(e.getRc(), e.getMessage());
    } catch (RuntimeException e) {
        LOGGER.error("Failed to delete entry", e);
        pnfsMessage.setFailed(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e);
    }
}
Also used : FileType(org.dcache.namespace.FileType) MissingResourceCacheException(diskCacheV111.util.MissingResourceCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) CacheException(diskCacheV111.util.CacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) PnfsId(diskCacheV111.util.PnfsId) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) PnfsSetFileAttributes(org.dcache.vehicles.PnfsSetFileAttributes) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) FileAttributes(org.dcache.vehicles.FileAttributes) Subject(javax.security.auth.Subject) FileAttribute(org.dcache.namespace.FileAttribute)

Example 5 with PnfsDeleteEntryMessage

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

the class RemoteNameSpaceProviderTests method shouldSucceedWhenDeletingEntryByPnfsid.

@Test
public void shouldSucceedWhenDeletingEntryByPnfsid() throws Exception {
    givenSuccessfulResponse();
    _namespace.deleteEntry(ROOT, EnumSet.allOf(FileType.class), A_PNFSID, EnumSet.noneOf(FileAttribute.class));
    PnfsDeleteEntryMessage sent = getSingleSendAndWaitMessage(PnfsDeleteEntryMessage.class);
    assertThat(sent.getReplyRequired(), is(true));
    assertThat(sent.getSubject(), is(ROOT));
    assertThat(sent.getPnfsPath(), nullValue());
    assertThat(sent.getPnfsId(), is(A_PNFSID));
}
Also used : FileType(org.dcache.namespace.FileType) PnfsDeleteEntryMessage(diskCacheV111.vehicles.PnfsDeleteEntryMessage) FileAttribute(org.dcache.namespace.FileAttribute) Test(org.junit.Test)

Aggregations

PnfsDeleteEntryMessage (diskCacheV111.vehicles.PnfsDeleteEntryMessage)7 FileAttribute (org.dcache.namespace.FileAttribute)4 FileType (org.dcache.namespace.FileType)3 PnfsGetFileAttributes (org.dcache.vehicles.PnfsGetFileAttributes)3 Test (org.junit.Test)3 CacheException (diskCacheV111.util.CacheException)2 PnfsCreateEntryMessage (diskCacheV111.vehicles.PnfsCreateEntryMessage)2 FileAttributes (org.dcache.vehicles.FileAttributes)2 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)1 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)1 InvalidMessageCacheException (diskCacheV111.util.InvalidMessageCacheException)1 MissingResourceCacheException (diskCacheV111.util.MissingResourceCacheException)1 NotDirCacheException (diskCacheV111.util.NotDirCacheException)1 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)1 PnfsId (diskCacheV111.util.PnfsId)1 PoolIoFileMessage (diskCacheV111.vehicles.PoolIoFileMessage)1 PoolMgrSelectPoolMsg (diskCacheV111.vehicles.PoolMgrSelectPoolMsg)1 Serializable (java.io.Serializable)1 Subject (javax.security.auth.Subject)1 PnfsSetFileAttributes (org.dcache.vehicles.PnfsSetFileAttributes)1