本文整理汇总了Java中net.schmizz.sshj.sftp.RemoteResourceInfo类的典型用法代码示例。如果您正苦于以下问题:Java RemoteResourceInfo类的具体用法?Java RemoteResourceInfo怎么用?Java RemoteResourceInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RemoteResourceInfo类属于net.schmizz.sshj.sftp包,在下文中一共展示了RemoteResourceInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testAcceptWithLimitNotReached
import net.schmizz.sshj.sftp.RemoteResourceInfo; //导入依赖的package包/类
@Test
public void testAcceptWithLimitNotReached() throws Exception {
// given
RemoteResourceInfo resource1 = createRemoteResourceInfo(2L);
RemoteResourceInfo resource2 = createRemoteResourceInfo(1L);
int resourceMaxCount = 2;
// when
LastUpdatedRemoteResourceFilter resourceFilter = new LastUpdatedRemoteResourceFilter(resourceMaxCount);
resourceFilter.accept(resource1);
resourceFilter.accept(resource2);
Collection<RemoteResourceInfo> remoteResourceInfos = resourceFilter.getRemoteResourceInfos();
// then
Assert.assertEquals(2, remoteResourceInfos.size());
Iterator<RemoteResourceInfo> resourceIterator = remoteResourceInfos.iterator();
Assert.assertTrue(resource2 == resourceIterator.next());
Assert.assertTrue(resource1 == resourceIterator.next());
}
开发者ID:fbaligand,项目名称:lognavigator,代码行数:21,代码来源:LastUpdatedRemoteResourceFilterTest.java
示例2: testAcceptWithLimitReached
import net.schmizz.sshj.sftp.RemoteResourceInfo; //导入依赖的package包/类
@Test
public void testAcceptWithLimitReached() throws Exception {
// given
RemoteResourceInfo resource1 = createRemoteResourceInfo(1L);
RemoteResourceInfo resource2 = createRemoteResourceInfo(2L);
RemoteResourceInfo resource3 = createRemoteResourceInfo(3L);
int resourceMaxCount = 2;
// when
LastUpdatedRemoteResourceFilter resourceFilter = new LastUpdatedRemoteResourceFilter(resourceMaxCount);
resourceFilter.accept(resource1);
resourceFilter.accept(resource2);
resourceFilter.accept(resource3);
Collection<RemoteResourceInfo> remoteResourceInfos = resourceFilter.getRemoteResourceInfos();
// then
Assert.assertEquals(2, remoteResourceInfos.size());
Iterator<RemoteResourceInfo> resourceIterator = remoteResourceInfos.iterator();
Assert.assertTrue(resource2 == resourceIterator.next());
Assert.assertTrue(resource3 == resourceIterator.next());
}
开发者ID:fbaligand,项目名称:lognavigator,代码行数:23,代码来源:LastUpdatedRemoteResourceFilterTest.java
示例3: testCompare
import net.schmizz.sshj.sftp.RemoteResourceInfo; //导入依赖的package包/类
@Test
public void testCompare() throws Exception {
// given
RemoteResourceInfo resource1 = createRemoteResourceInfo(2L);
RemoteResourceInfo resource2 = createRemoteResourceInfo(1L);
int resourceMaxCount = 2;
// when
LastUpdatedRemoteResourceFilter resourceFilter = new LastUpdatedRemoteResourceFilter(resourceMaxCount);
int result = resourceFilter.compare(resource1, resource2);
// then
final int greaterThanReturn = 1;
Assert.assertEquals(greaterThanReturn, result);
}
开发者ID:fbaligand,项目名称:lognavigator,代码行数:17,代码来源:LastUpdatedRemoteResourceFilterTest.java
示例4: listChildrenNamesByFilter
import net.schmizz.sshj.sftp.RemoteResourceInfo; //导入依赖的package包/类
private List<String> listChildrenNamesByFilter(String remotePath, RemoteResourceFilter remoteFolderResourceFilter) throws IOException {
try (SFTPClient sftpClient = sshClient.newSFTPClient()) {
List<String> children = new ArrayList<>();
List<RemoteResourceInfo> childrenInfos = sftpClient.ls(remotePath, remoteFolderResourceFilter);
childrenInfos.stream().forEach((childInfo) -> {
children.add(childInfo.getName());
});
return children;
}
}
开发者ID:sparsick,项目名称:comparison-java-ssh-libs,代码行数:11,代码来源:SshJClient.java
示例5: listFiles
import net.schmizz.sshj.sftp.RemoteResourceInfo; //导入依赖的package包/类
@Test
public void listFiles() throws IOException, NoSuchProviderException, NoSuchAlgorithmException {
sftpHome.newFile("fred.txt");
List<RemoteResourceInfo> files;
final SSHClient ssh = new SSHClient();
ssh.addHostKeyVerifier(SecurityUtils.getFingerprint(subject.getHostsPublicKey()));
ssh.connect("localhost", subject.getPort());
try {
ssh.authPublickey("this_is_ignored", new KeyPairWrapper(
KeyPairGenerator.getInstance("DSA", "SUN").generateKeyPair()));
final SFTPClient sftp = ssh.newSFTPClient();
try {
files = sftp.ls("/");
} finally {
sftp.close();
}
} finally {
ssh.disconnect();
}
assertThat(files.size(), is(1));
assertThat(files.get(0).getName(), is("fred.txt"));
}
开发者ID:mlk,项目名称:AssortmentOfJUnitRules,代码行数:28,代码来源:TestSftpRule.java
示例6: getRecord
import net.schmizz.sshj.sftp.RemoteResourceInfo; //导入依赖的package包/类
@Nonnull
private Record getRecord(@Nonnull RemoteResourceInfo info) {
if (info.getAttributes().getType() == FileMode.Type.SYMLINK) {
return Unchecked.get(() -> getRecord(info.getPath()));
}
long time = info.getAttributes().getMtime() * 1000;
long size = info.getAttributes().getSize();
return new Record(uri, RecordPath.from(info.getParent(), info.getName()), time, size, info.isDirectory());
}
开发者ID:lithiumtech,项目名称:flow,代码行数:11,代码来源:SshjFiler.java
示例7: listFilesUsingNativeSystem
import net.schmizz.sshj.sftp.RemoteResourceInfo; //导入依赖的package包/类
@Override
protected Set<FileInfo> listFilesUsingNativeSystem(LogAccessConfig logAccessConfig, String subPath) throws LogAccessException {
// Get ssh client
SSHClient sshClient = sshClientThreadLocal.get();
// Define target directory
String targetPath = logAccessConfig.getDirectory();
if (subPath != null) {
targetPath += "/" + subPath;
}
// List files and directories (keep only the 'fileListMaxCount' last modified resources)
SFTPClient sftpClient = null;
Collection<RemoteResourceInfo> remoteResourceInfos;
try {
sftpClient = sshClient.newSFTPClient();
LastUpdatedRemoteResourceFilter remoteResourcefilter = new LastUpdatedRemoteResourceFilter(configService.getFileListMaxCount());
sftpClient.ls(targetPath, remoteResourcefilter);
remoteResourceInfos = remoteResourcefilter.getRemoteResourceInfos();
}
catch (IOException e) {
throw new LogAccessException("Error when listing files and directories on " + logAccessConfig, e);
}
finally {
IOUtils.closeQuietly(sftpClient, sshClient);
}
// Extract meta-informations
Set<FileInfo> fileInfos = new TreeSet<FileInfo>();
for (RemoteResourceInfo remoteResourceInfo : remoteResourceInfos) {
FileInfo fileInfo = new FileInfo();
fileInfo.setFileName(remoteResourceInfo.getName());
fileInfo.setRelativePath(remoteResourceInfo.getPath().substring(logAccessConfig.getDirectory().length() + 1).replace('\\', '/'));
fileInfo.setDirectory(remoteResourceInfo.isDirectory());
fileInfo.setLastModified(new Date(remoteResourceInfo.getAttributes().getMtime() * 1000L));
fileInfo.setFileSize(remoteResourceInfo.isDirectory() ? 0L : remoteResourceInfo.getAttributes().getSize());
fileInfo.setLogAccessType(LogAccessType.SSH);
fileInfos.add(fileInfo);
}
// Return meta-informations about files and folders
return fileInfos;
}
开发者ID:fbaligand,项目名称:lognavigator,代码行数:45,代码来源:SshLogAccessService.java
示例8: accept
import net.schmizz.sshj.sftp.RemoteResourceInfo; //导入依赖的package包/类
/**
* Stores the resource in remoteResourceInfos set (which is sorted by mtime).
* Keeps only the 'resourceMaxCount' last modified resources in remoteResourceInfos.
* Always return false, so that no resource is stored in client list (the real filtered result list is stored in this instance, in 'remoteResourceInfos')
*/
@Override
public boolean accept(RemoteResourceInfo resource) {
remoteResourceInfos.add(resource);
if (remoteResourceInfos.size() > resourceMaxCount) {
remoteResourceInfos.remove(remoteResourceInfos.first());
}
return false;
}
开发者ID:fbaligand,项目名称:lognavigator,代码行数:14,代码来源:LastUpdatedRemoteResourceFilter.java
示例9: compare
import net.schmizz.sshj.sftp.RemoteResourceInfo; //导入依赖的package包/类
/**
* Comparator method which sorts by mtime ascending
*/
@Override
public int compare(RemoteResourceInfo o1, RemoteResourceInfo o2) {
if (o1 == o2) {
return 0;
}
else {
long diff = o1.getAttributes().getMtime() - o2.getAttributes().getMtime();
return (diff >= 0) ? 1 : -1;
}
}
开发者ID:fbaligand,项目名称:lognavigator,代码行数:14,代码来源:LastUpdatedRemoteResourceFilter.java
示例10: getFilesInPath
import net.schmizz.sshj.sftp.RemoteResourceInfo; //导入依赖的package包/类
public ArrayList< String > getFilesInPath( String path )
{
ArrayList< String > ret = new ArrayList< String >();
SSHClient client = new SSHClient();
client.addHostKeyVerifier(new PromiscuousVerifier());
try {
client.connect(hostName);
client.authPassword(userName, userPass);
SFTPClient sftp = client.newSFTPClient();
List< RemoteResourceInfo > files = sftp.ls( path );
for( RemoteResourceInfo file: files )
{
ret.add( file.getPath() );
}
sftp.close();
client.disconnect();
} catch( Exception e ) {
logger.error( e.toString() );
}
return ret;
}
开发者ID:prateek,项目名称:ssh-spool-source,代码行数:28,代码来源:SshClientJ.java
示例11: listChildrenFolderNames
import net.schmizz.sshj.sftp.RemoteResourceInfo; //导入依赖的package包/类
@Override
public List<String> listChildrenFolderNames(String remotePath) throws IOException {
return listChildrenNamesByFilter(remotePath, RemoteResourceInfo::isDirectory);
}
开发者ID:sparsick,项目名称:comparison-java-ssh-libs,代码行数:5,代码来源:SshJClient.java
示例12: listChildrenFileNames
import net.schmizz.sshj.sftp.RemoteResourceInfo; //导入依赖的package包/类
@Override
public List<String> listChildrenFileNames(String remotePath) throws IOException {
return listChildrenNamesByFilter(remotePath, RemoteResourceInfo::isRegularFile);
}
开发者ID:sparsick,项目名称:comparison-java-ssh-libs,代码行数:5,代码来源:SshJClient.java
示例13: LastUpdatedRemoteResourceFilter
import net.schmizz.sshj.sftp.RemoteResourceInfo; //导入依赖的package包/类
public LastUpdatedRemoteResourceFilter(int resourceMaxCount) {
this.resourceMaxCount = resourceMaxCount;
this.remoteResourceInfos = new TreeSet<RemoteResourceInfo>(this);
}
开发者ID:fbaligand,项目名称:lognavigator,代码行数:5,代码来源:LastUpdatedRemoteResourceFilter.java
示例14: getRemoteResourceInfos
import net.schmizz.sshj.sftp.RemoteResourceInfo; //导入依赖的package包/类
/**
* Return the 'resourceMaxCount' last modified resources filtered
*/
public Collection<RemoteResourceInfo> getRemoteResourceInfos() {
return remoteResourceInfos;
}
开发者ID:fbaligand,项目名称:lognavigator,代码行数:7,代码来源:LastUpdatedRemoteResourceFilter.java
示例15: createRemoteResourceInfo
import net.schmizz.sshj.sftp.RemoteResourceInfo; //导入依赖的package包/类
private RemoteResourceInfo createRemoteResourceInfo(long mtime) {
PathComponents comps = new PathComponents("parent", "name" + mtime, "/");
FileAttributes attrs = new FileAttributes(0, 0, 0, 0, null, 0L, mtime, new HashMap<String, String>());
return new RemoteResourceInfo(comps, attrs);
}
开发者ID:fbaligand,项目名称:lognavigator,代码行数:6,代码来源:LastUpdatedRemoteResourceFilterTest.java
注:本文中的net.schmizz.sshj.sftp.RemoteResourceInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论