本文整理汇总了Java中org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent类的典型用法代码示例。如果您正苦于以下问题:Java IFileDeleteEvent类的具体用法?Java IFileDeleteEvent怎么用?Java IFileDeleteEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IFileDeleteEvent类属于org.hive2hive.core.events.framework.interfaces.file包,在下文中一共展示了IFileDeleteEvent类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onFileDelete
import org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent; //导入依赖的package包/类
/**
* This handler is for remote delete events and is called by the network when
* a file has been definitely deleted. Besides forwarding the event to the core,
* this method publishes a {@link org.peerbox.app.manager.file.messages.RemoteFileDeletedMessage
* RemoteFileDeletedMessage} to notify the GUI.
*/
@Override
@Handler
public void onFileDelete(final IFileDeleteEvent fileEvent) {
if(cleanupRunning){
pendingEvents.add(fileEvent.getFile().toPath());
return;
}
final Path path = fileEvent.getFile().toPath();
logger.debug("onFileDelete: {}", path);
final FileComponent file = fileTree.getOrCreateFileComponent(path, fileEvent.isFile(), this);
file.getAction().handleRemoteDeleteEvent();
FileInfo fileHelper = new FileInfo(file);
messageBus.publish(new RemoteFileDeletedMessage(fileHelper));
}
示例2: testRemoteDeleteLocalExists_Folder_NoNewFile
import org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent; //导入依赖的package包/类
@Test
public void testRemoteDeleteLocalExists_Folder_NoNewFile() throws Exception {
Path folderPath = Paths.get(basePath.toString(), "folder");
FileInfo folderInfo = new FileInfo(folderPath, true);
Path filePath = folderPath.resolve("file.txt");
FileInfo fileInfo = new FileInfo(filePath, false, "hash1");
remoteDatabase.put(folderPath, folderInfo);
remoteDatabase.put(filePath, fileInfo);
localDatabase.put(folderPath, folderInfo);
localDatabase.put(filePath, fileInfo);
local.put(folderPath, folderInfo);
local.put(filePath, fileInfo);
listSync.sync(local, localDatabase, remote, remoteDatabase);
Mockito.verify(fileEventManager, Mockito.times(2)).onFileDelete(Matchers.any(IFileDeleteEvent.class));
Mockito.verifyNoMoreInteractions(fileEventManager);
}
示例3: testFileDeleteEvent
import org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent; //导入依赖的package包/类
@Test
public void testFileDeleteEvent() throws NoPeerConnectionException, IOException, NoSessionException {
// upload a file from machine A
File file = createAndAddFile(rootA, clientA);
// clear past events of upload
waitForNumberOfEvents(1);
listener.getEvents().clear();
// delete the file
UseCaseTestUtil.deleteFile(clientA, file);
// wait for event
waitForNumberOfEvents(1);
// check event type
List<IFileEvent> events = listener.getEvents();
assertEventType(events, IFileDeleteEvent.class);
// check paths
assertTrue(events.size() == 1);
IFileEvent ev = events.get(0);
assertTrue(ev.isFile());
assertFalse(ev.isFolder());
assertEqualsRelativePaths(file, ev.getFile());
assertFalse(ev.getFile().exists());
}
示例4: testEmptyFolderDeleteEvent
import org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent; //导入依赖的package包/类
@Test
public void testEmptyFolderDeleteEvent() throws NoPeerConnectionException, IOException, NoSessionException {
// create and upload a folder from machine A
File folder = createAndAddFolder(rootA, clientA);
// wait and clear past events
waitForNumberOfEvents(1);
listener.getEvents().clear();
// delete folder
UseCaseTestUtil.deleteFile(clientA, folder);
waitForNumberOfEvents(1);
// check event types and path
List<IFileEvent> events = listener.getEvents();
assertEventType(events, IFileDeleteEvent.class);
// verify paths
assertTrue(events.size() == 1);
IFileEvent ev = events.get(0);
assertFalse(ev.isFile());
assertTrue(ev.isFolder());
assertEqualsRelativePaths(folder, ev.getFile());
assertFalse(ev.getFile().exists());
}
示例5: testRemoteDeleteLocalExists_File_SameHashes
import org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent; //导入依赖的package包/类
@Test
public void testRemoteDeleteLocalExists_File_SameHashes() throws Exception {
remoteDatabase.put(filePath, file1);
localDatabase.put(filePath, file1);
local.put(filePath, file1);
listSync.sync(local, localDatabase, remote, remoteDatabase);
Mockito.verify(fileEventManager).onFileDelete(Matchers.any(IFileDeleteEvent.class));
Mockito.verifyNoMoreInteractions(fileEventManager);
}
示例6: testRemoteDeleteLocalExists_Folder_WithNewFile
import org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent; //导入依赖的package包/类
@Test
public void testRemoteDeleteLocalExists_Folder_WithNewFile() throws Exception {
// scenario: folder with two files. one file is new/updated and the other one unchanged
// folder was deleted in network
// expected result: new/updated file not deleted, but added. old unchanged file deleted.
// parent folder (deleted in network)
Path folderPath = Paths.get(basePath.toString(),"folder");
FileInfo folderInfo = new FileInfo(folderPath, true);
remoteDatabase.put(folderPath, folderInfo);
local.put(folderPath, folderInfo);
localDatabase.put(folderPath, folderInfo);
// file: new/updated file -> hash do not match
Path fileNewPath = folderPath.resolve("fileNew.txt");
FileInfo fileNewInfo = new FileInfo(fileNewPath, false, "hashNew");
local.put(fileNewPath, fileNewInfo);
// old unchanged file -> does not exist in network anymore, but locally
Path fileOldPath = folderPath.resolve("fileOld.txt");
FileInfo fileOldInfo = new FileInfo(fileOldPath, false, "hashOld");
remoteDatabase.put(fileOldPath, fileOldInfo);
local.put(fileOldPath, fileOldInfo);
localDatabase.put(fileOldPath, fileOldInfo);
listSync.sync(local, localDatabase, remote, remoteDatabase);
// old unchanged file -> deleted
Mockito.verify(fileEventManager, Mockito.times(1)).onFileDelete(Matchers.any(IFileDeleteEvent.class));
// new / updated file -> added
Mockito.verify(fileEventManager, Mockito.times(1)).onLocalFileCreated(fileNewPath);
Mockito.verifyNoMoreInteractions(fileEventManager);
}
示例7: onFileDelete
import org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent; //导入依赖的package包/类
@Override
@Handler
public void onFileDelete(IFileDeleteEvent fileEvent) {
System.out.println("File was deleted: " + fileEvent.getFile().getName());
// delete it at the event receiver as well
fileEvent.getFile().delete();
}
示例8: onFileDelete
import org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent; //导入依赖的package包/类
@Override
@Handler
public void onFileDelete(IFileDeleteEvent fileEvent) {
if (fileEvent.getFile().delete()) {
System.out.println("Deleted file " + fileEvent.getFile());
} else {
System.err.println("Could not delete file " + fileEvent.getFile());
}
}
示例9: onFileDelete
import org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent; //导入依赖的package包/类
@Override
@Handler
public void onFileDelete(IFileDeleteEvent fileEvent) {
delete.add(fileEvent);
if (networkManager != null) {
fileEvent.getFile().delete();
}
}
示例10: deleteLocalFile
import org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent; //导入依赖的package包/类
private void deleteLocalFile(Path file, boolean isFile) {
logger.trace("OPERATION: Remote delete file {}", file);
// delete the local file due to a remote delete
IFileDeleteEvent deleteEvent = new FileDeleteEvent(file.toFile(), isFile);
fileEventManager.onFileDelete(deleteEvent);
}
示例11: onFileDelete
import org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent; //导入依赖的package包/类
@Handler
void onFileDelete(IFileDeleteEvent fileEvent);
示例12: getDeleted
import org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent; //导入依赖的package包/类
public IFileDeleteEvent getDeleted(File file) {
return getByFile(delete, file);
}
示例13: onFileDelete
import org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent; //导入依赖的package包/类
@Override
@Handler
public void onFileDelete(IFileDeleteEvent fileEvent) {
events.add(fileEvent);
}