当前位置: 首页>>代码示例>>Java>>正文


Java IFileDeleteEvent类代码示例

本文整理汇总了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));
}
 
开发者ID:PeerWasp,项目名称:PeerWasp,代码行数:24,代码来源:FileEventManager.java

示例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);
}
 
开发者ID:PeerWasp,项目名称:PeerWasp,代码行数:23,代码来源:RemoteDeleteLocalExists.java

示例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());
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:27,代码来源:FileDeleteEventsTest.java

示例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());
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:26,代码来源:FileDeleteEventsTest.java

示例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);
}
 
开发者ID:PeerWasp,项目名称:PeerWasp,代码行数:13,代码来源:RemoteDeleteLocalExists.java

示例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);
}
 
开发者ID:PeerWasp,项目名称:PeerWasp,代码行数:37,代码来源:RemoteDeleteLocalExists.java

示例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();
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:8,代码来源:EventsExample.java

示例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());
	}
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:10,代码来源:FileEventListener.java

示例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();
	}
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:9,代码来源:TestFileEventListener.java

示例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);
}
 
开发者ID:PeerWasp,项目名称:PeerWasp,代码行数:7,代码来源:ListSync.java

示例11: onFileDelete

import org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent; //导入依赖的package包/类
@Handler
void onFileDelete(IFileDeleteEvent fileEvent);
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:3,代码来源:IFileEventListener.java

示例12: getDeleted

import org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent; //导入依赖的package包/类
public IFileDeleteEvent getDeleted(File file) {
	return getByFile(delete, file);
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:4,代码来源:TestFileEventListener.java

示例13: onFileDelete

import org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent; //导入依赖的package包/类
@Override
@Handler
public void onFileDelete(IFileDeleteEvent fileEvent) {
	events.add(fileEvent);
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:6,代码来源:FileEventsTest.java


注:本文中的org.hive2hive.core.events.framework.interfaces.file.IFileDeleteEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。