protected FileSystemOptions getFileSystemOptions() throws FileSystemException { FileSystemOptions opts = new FileSystemOptions(); return opts; }
@Test public void testEqualsHashCodeAndCompareTo() { final JUnitConfigBuilder builder = JUnitConfigBuilder.getInstance(); final FileSystemOptions expected = new FileSystemOptions(); builder.setId(expected, "Test"); final FileSystemOptions actual = new FileSystemOptions(); builder.setId(actual, "Test"); Assert.assertEquals(expected, actual); Assert.assertEquals(0, actual.compareTo(expected)); Assert.assertEquals(expected.hashCode(), actual.hashCode()); builder.setNames(expected, new String[] { "A", "B", "C" }); Assert.assertNotEquals(expected, actual); Assert.assertEquals(-1, actual.compareTo(expected)); Assert.assertNotEquals(expected.hashCode(), actual.hashCode()); builder.setNames(actual, new String[] { "A", "B", "C" }); Assert.assertEquals(expected, actual); Assert.assertEquals(0, actual.compareTo(expected)); Assert.assertEquals(expected.hashCode(), actual.hashCode()); }
final FileSystemOptions fileSystemOptions = new FileSystemOptions(); final SftpFileSystemConfigBuilder builder = SftpFileSystemConfigBuilder.getInstance(); builder.setStrictHostKeyChecking(fileSystemOptions, "no"); final FileSystemOptions proxyOptions = (FileSystemOptions) fileSystemOptions.clone();
@Override public int compareTo(final FileSystemKey o) { @SuppressWarnings("unchecked") // Keys must implement comparable, and be comparable to themselves final Comparable<Comparable<?>> comparable = (Comparable<Comparable<?>>) key; final int ret = comparable.compareTo(o.key); if (ret != 0) { // other filesystem return ret; } return fileSystemOptions.compareTo(o.fileSystemOptions); }
/** * Check if option exists. * * @param opts file system options to work with * @param name the name to look up in {@code opts} * @return true if opts have the named parameter * * @since 1.0 */ protected boolean hasParam(final FileSystemOptions opts, final String name) { return opts != null && opts.hasOption(getConfigClass(), name); }
/** * Set named parameter. * * @param opts the file system options to modify * @param name set option with this name * @param value object value to set * * @since 1.0 */ protected void setParam(final FileSystemOptions opts, final String name, final Object value) { opts.setOption(getConfigClass(), name, value); }
/** * Get named parameter. * * @param opts file system options to work with * @param name get option with this name * @return the named option or null * * @since 1.0 */ protected Object getParam(final FileSystemOptions opts, final String name) { if (opts == null) { return null; } return opts.getOption(getConfigClass(), name); }
@Test public void testEqualsHashCodeAndCompareTo() { final JUnitConfigBuilder builder = JUnitConfigBuilder.getInstance(); final FileSystemOptions expected = new FileSystemOptions(); builder.setId(expected, "Test"); final FileSystemOptions actual = new FileSystemOptions(); builder.setId(actual, "Test"); Assert.assertEquals(expected, actual); Assert.assertEquals(0, actual.compareTo(expected)); Assert.assertEquals(expected.hashCode(), actual.hashCode()); builder.setNames(expected, new String[] { "A", "B", "C" }); Assert.assertNotEquals(expected, actual); Assert.assertEquals(-1, actual.compareTo(expected)); Assert.assertNotEquals(expected.hashCode(), actual.hashCode()); builder.setNames(actual, new String[] { "A", "B", "C" }); Assert.assertEquals(expected, actual); Assert.assertEquals(0, actual.compareTo(expected)); Assert.assertEquals(expected.hashCode(), actual.hashCode()); }
final FileSystemOptions fileSystemOptions = new FileSystemOptions(); final SftpFileSystemConfigBuilder builder = SftpFileSystemConfigBuilder.getInstance(); builder.setStrictHostKeyChecking(fileSystemOptions, "no"); final FileSystemOptions proxyOptions = (FileSystemOptions) fileSystemOptions.clone();
@Override public int compareTo(final FileSystemKey o) { @SuppressWarnings("unchecked") // Keys must implement comparable, and be comparable to themselves final Comparable<Comparable<?>> comparable = (Comparable<Comparable<?>>) key; final int ret = comparable.compareTo(o.key); if (ret != 0) { // other filesystem return ret; } return fileSystemOptions.compareTo(o.fileSystemOptions); }
/** * Check if option exists. * * @param opts file system options to work with * @param name the name to look up in {@code opts} * @return true if opts have the named parameter * * @since 1.0 */ protected boolean hasParam(final FileSystemOptions opts, final String name) { return opts != null && opts.hasOption(getConfigClass(), name); }
/** * Set named parameter. * * @param opts the file system options to modify * @param name set option with this name * @param value object value to set * * @since 1.0 */ protected void setParam(final FileSystemOptions opts, final String name, final Object value) { opts.setOption(getConfigClass(), name, value); }
/** * Get named parameter. * * @param opts file system options to work with * @param name get option with this name * @return the named option or null * * @since 1.0 */ protected Object getParam(final FileSystemOptions opts, final String name) { if (opts == null) { return null; } return opts.getOption(getConfigClass(), name); }
FileSystemOptions fsOptions = new FileSystemOptions(); SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(fsOptions, "no"); FileSystemManager fsManager = VFS.getManager(); String uri = "sftp://user:password@host:port/absolute-path"; FileObject fo = fsManager.resolveFile(uri, fsOptions);
@Override public int compareTo(final FileSystemKey o) { @SuppressWarnings("unchecked") // Keys must implement comparable, and be comparable to themselves final Comparable<Comparable<?>> comparable = (Comparable<Comparable<?>>) key; final int ret = comparable.compareTo(o.key); if (ret != 0) { // other filesystem return ret; } return fileSystemOptions.compareTo(o.fileSystemOptions); }
/** * Check if option exists. * * @param opts file system options to work with * @param name the name to look up in {@code opts} * @return true if opts have the named parameter * * @since 1.0 */ protected boolean hasParam(final FileSystemOptions opts, final String name) { return opts != null && opts.hasOption(getConfigClass(), name); }
/** * Set named parameter. * * @param opts the file system options to modify * @param name set option with this name * @param value object value to set * * @since 1.0 */ protected void setParam(final FileSystemOptions opts, final String name, final Object value) { opts.setOption(getConfigClass(), name, value); }
/** * Get named parameter. * * @param opts file system options to work with * @param name get option with this name * @return the named option or null * * @since 1.0 */ protected Object getParam(final FileSystemOptions opts, final String name) { if (opts == null) { return null; } return opts.getOption(getConfigClass(), name); }
private static FileSystemOptions buildFsOptions( VariableSpace varSpace, FileSystemOptions sourceOptions, String vfsFilename, String scheme ) throws IOException { if ( varSpace == null || vfsFilename == null ) { // We cannot extract settings from a non-existant variable space return null; } IKettleFileSystemConfigBuilder configBuilder = KettleFileSystemConfigBuilderFactory.getConfigBuilder( varSpace, scheme ); FileSystemOptions fsOptions = ( sourceOptions == null ) ? new FileSystemOptions() : sourceOptions; String[] varList = varSpace.listVariables(); for ( String var : varList ) { if ( var.startsWith( "vfs." ) ) { String param = configBuilder.parseParameterName( var, scheme ); String varScheme = KettleGenericFileSystemConfigBuilder.extractScheme( var ); if ( param != null ) { if ( varScheme == null || varScheme.equals( "sftp" ) || varScheme.equals( scheme ) ) { configBuilder.setParameter( fsOptions, param, varSpace.getVariable( var ), var, vfsFilename ); } } else { throw new IOException( "FileSystemConfigBuilder could not parse parameter: " + var ); } } } return fsOptions; }
@Override public int compareTo(final FileSystemKey o) { @SuppressWarnings("unchecked") // Keys must implement comparable, and be comparable to themselves final Comparable<Comparable<?>> comparable = (Comparable<Comparable<?>>) key; final int ret = comparable.compareTo(o.key); if (ret != 0) { // other filesystem return ret; } return fileSystemOptions.compareTo(o.fileSystemOptions); } }