use of org.apache.commons.vfs2.provider.webdav.WebdavFileSystemConfigBuilder in project artisynth_core by artisynth.
the class FileCacher method setDefaultFsOptions.
public static void setDefaultFsOptions(FileSystemOptions opts) throws FileSystemException {
// SSH Defaults
// Don't check host key
// Use paths relative to root (as opposed to the user's home dir)
// 10 second timeout
SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts, "no");
SftpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, true);
SftpFileSystemConfigBuilder.getInstance().setTimeout(opts, 10000);
/**
* Allow connection to silly UBC servers who don't update their credentials
*/
TrustStrategy[] ts = { new UnsafeTrustStrategy() };
HttpFileSystemConfigBuilder httpBuilder = HttpFileSystemConfigBuilder.getInstance();
WebdavFileSystemConfigBuilder webdavBuilder = WebdavFileSystemConfigBuilder.getInstance();
// allow all SSL connections
httpBuilder.setTrustStrategies(opts, ts);
webdavBuilder.setTrustStrategies(opts, ts);
// silly deprecated UBC cipher suite
String[] ciphers = httpBuilder.getDefaultSSLCipherSuites();
ciphers = Arrays.copyOf(ciphers, ciphers.length + 1);
ciphers[ciphers.length - 1] = "SSL_RSA_WITH_RC4_128_SHA";
httpBuilder.setEnabledSSLCipherSuites(opts, ciphers);
webdavBuilder.setEnabledSSLCipherSuites(opts, ciphers);
}
use of org.apache.commons.vfs2.provider.webdav.WebdavFileSystemConfigBuilder in project commons-vfs by apache.
the class WebdavVersioningTests method testVersioning.
@Test
public void testVersioning() throws Exception {
final FileObject scratchFolder = createScratchFolder();
final FileSystemOptions opts = scratchFolder.getFileSystem().getFileSystemOptions();
final WebdavFileSystemConfigBuilder builder = (WebdavFileSystemConfigBuilder) getManager().getFileSystemConfigBuilder("webdav");
builder.setVersioning(opts, true);
final FileObject file = getManager().resolveFile(scratchFolder, "file1.txt", opts);
final FileSystemOptions newOpts = file.getFileSystem().getFileSystemOptions();
assertSame(opts, newOpts);
assertTrue(builder.isVersioning(newOpts));
assertFalse(file.exists());
file.createFile();
assertTrue(file.exists());
assertSame(FileType.FILE, file.getType());
assertTrue(file.isFile());
assertEquals(0, file.getContent().getSize());
assertTrue(file.getContent().isEmpty());
assertFalse(file.isExecutable());
assertFalse(file.isHidden());
assertTrue(file.isReadable());
assertTrue(file.isWriteable());
Map<?, ?> map = file.getContent().getAttributes();
final String name = ((URLFileName) file.getName()).getUserName();
assertTrue(map.containsKey(DeltaVConstants.CREATOR_DISPLAYNAME.toString()));
if (name != null) {
assertEquals(name, map.get(DeltaVConstants.CREATOR_DISPLAYNAME.toString()));
}
assertTrue(map.containsKey(VersionControlledResource.CHECKED_IN.toString()));
// Create the source file
final String content = "Here is some sample content for the file. Blah Blah Blah.";
try (OutputStream os = file.getContent().getOutputStream()) {
os.write(content.getBytes(StandardCharsets.UTF_8));
}
assertSameContent(content, file);
map = file.getContent().getAttributes();
assertTrue(map.containsKey(DeltaVConstants.CREATOR_DISPLAYNAME.toString()));
if (name != null) {
assertEquals(name, map.get(DeltaVConstants.CREATOR_DISPLAYNAME.toString()));
}
assertTrue(map.containsKey(VersionControlledResource.CHECKED_IN.toString()));
builder.setVersioning(opts, false);
}
use of org.apache.commons.vfs2.provider.webdav.WebdavFileSystemConfigBuilder in project commons-vfs by apache.
the class WebdavProviderTestCase method getBaseTestFolder.
/**
* Returns the base folder for tests.
*/
@Override
public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception {
String uri = getSystemTestUriOverride();
if (uri == null) {
uri = ConnectionUri;
}
final WebdavFileSystemConfigBuilder builder = (WebdavFileSystemConfigBuilder) manager.getFileSystemConfigBuilder("webdav");
final FileSystemOptions opts = new FileSystemOptions();
builder.setRootURI(opts, uri);
return manager.resolveFile(uri, opts);
}
use of org.apache.commons.vfs2.provider.webdav.WebdavFileSystemConfigBuilder in project commons-vfs by apache.
the class WebdavVersioningTests method testVersioningWithCreator.
@Test
public void testVersioningWithCreator() throws Exception {
final FileObject scratchFolder = createScratchFolder();
final FileSystemOptions opts = scratchFolder.getFileSystem().getFileSystemOptions();
final WebdavFileSystemConfigBuilder builder = (WebdavFileSystemConfigBuilder) getManager().getFileSystemConfigBuilder("webdav");
builder.setVersioning(opts, true);
builder.setCreatorName(opts, "testUser");
final FileObject file = getManager().resolveFile(scratchFolder, "file1.txt", opts);
final FileSystemOptions newOpts = file.getFileSystem().getFileSystemOptions();
assertSame(opts, newOpts);
assertTrue(builder.isVersioning(newOpts));
assertFalse(file.exists());
file.createFile();
assertTrue(file.exists());
assertSame(FileType.FILE, file.getType());
assertTrue(file.isFile());
assertEquals(0, file.getContent().getSize());
assertTrue(file.getContent().isEmpty());
assertFalse(file.isExecutable());
assertFalse(file.isHidden());
assertTrue(file.isReadable());
assertTrue(file.isWriteable());
Map<?, ?> map = file.getContent().getAttributes();
final String name = ((URLFileName) file.getName()).getUserName();
assertTrue(map.containsKey(DeltaVConstants.CREATOR_DISPLAYNAME.toString()));
assertEquals("testUser", map.get(DeltaVConstants.CREATOR_DISPLAYNAME.toString()));
if (name != null) {
assertTrue(map.containsKey(DeltaVConstants.COMMENT.toString()));
assertEquals("Modified by user " + name, map.get(DeltaVConstants.COMMENT.toString()));
}
assertTrue(map.containsKey(VersionControlledResource.CHECKED_IN.toString()));
// Create the source file
final String content = "Here is some sample content for the file. Blah Blah Blah.";
try (OutputStream os = file.getContent().getOutputStream()) {
os.write(content.getBytes(StandardCharsets.UTF_8));
}
assertSameContent(content, file);
map = file.getContent().getAttributes();
assertTrue(map.containsKey(DeltaVConstants.CREATOR_DISPLAYNAME.toString()));
assertEquals("testUser", map.get(DeltaVConstants.CREATOR_DISPLAYNAME.toString()));
if (name != null) {
assertTrue(map.containsKey(DeltaVConstants.COMMENT.toString()));
assertEquals("Modified by user " + name, map.get(DeltaVConstants.COMMENT.toString()));
}
assertTrue(map.containsKey(VersionControlledResource.CHECKED_IN.toString()));
builder.setVersioning(opts, false);
builder.setCreatorName(opts, null);
}
Aggregations