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