Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/StandardFileSystemManager.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/StandardFileSystemManager.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/StandardFileSystemManager.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/StandardFileSystemManager.java Thu Sep 14 19:26:39 2017 @@ -36,16 +36,13 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; /** - * A {@link org.apache.commons.vfs2.FileSystemManager} that configures itself - * from an XML (Default: providers.xml) configuration file. + * A {@link org.apache.commons.vfs2.FileSystemManager} that configures itself from an XML (Default: providers.xml) + * configuration file. * <p> - * Certain providers are only loaded and available if the dependent library is in your - * classpath. You have to configure your debugging facility to log "debug" messages to see - * if a provider was skipped due to "unresolved externals". + * Certain providers are only loaded and available if the dependent library is in your classpath. You have to configure + * your debugging facility to log "debug" messages to see if a provider was skipped due to "unresolved externals". */ -public class StandardFileSystemManager - extends DefaultFileSystemManager -{ +public class StandardFileSystemManager extends DefaultFileSystemManager { private static final String CONFIG_RESOURCE = "providers.xml"; private static final String PLUGIN_CONFIG_RESOURCE = "META-INF/vfs-providers.xml"; @@ -57,14 +54,10 @@ public class StandardFileSystemManager * * @param configUri The URI for this manager. */ - public void setConfiguration(final String configUri) - { - try - { + public void setConfiguration(final String configUri) { + try { setConfiguration(new URL(configUri)); - } - catch (final MalformedURLException e) - { + } catch (final MalformedURLException e) { getLogger().warn(e.getLocalizedMessage(), e); } } @@ -74,19 +67,16 @@ public class StandardFileSystemManager * * @param configUri The URI forthis manager. */ - public void setConfiguration(final URL configUri) - { + public void setConfiguration(final URL configUri) { this.configUri = configUri; } /** - * Sets the ClassLoader to use to load the providers. - * Default is to use the ClassLoader that loaded this class. + * Sets the ClassLoader to use to load the providers. Default is to use the ClassLoader that loaded this class. * * @param classLoader The ClassLoader. */ - public void setClassLoader(final ClassLoader classLoader) - { + public void setClassLoader(final ClassLoader classLoader) { this.classLoader = classLoader; } @@ -96,19 +86,16 @@ public class StandardFileSystemManager * @throws FileSystemException if an error occurs. */ @Override - public void init() throws FileSystemException - { + public void init() throws FileSystemException { // Set the replicator and temporary file store (use the same component) final DefaultFileReplicator replicator = createDefaultFileReplicator(); setReplicator(new PrivilegedFileReplicator(replicator)); setTemporaryFileStore(replicator); - if (configUri == null) - { + if (configUri == null) { // Use default config final URL url = getClass().getResource(CONFIG_RESOURCE); - if (url == null) - { + if (url == null) { throw new FileSystemException("vfs.impl/find-config-file.error", CONFIG_RESOURCE); } configUri = url; @@ -128,43 +115,34 @@ public class StandardFileSystemManager * * @throws FileSystemException if an error occurs. */ - protected void configurePlugins() throws FileSystemException - { + protected void configurePlugins() throws FileSystemException { Enumeration<URL> enumResources; - try - { + try { enumResources = loadResources(PLUGIN_CONFIG_RESOURCE); - } - catch (final IOException e) - { + } catch (final IOException e) { throw new FileSystemException(e); } - while (enumResources.hasMoreElements()) - { + while (enumResources.hasMoreElements()) { final URL url = enumResources.nextElement(); configure(url); } } - private ClassLoader findClassLoader() - { - if (classLoader != null) - { + private ClassLoader findClassLoader() { + if (classLoader != null) { return classLoader; } ClassLoader cl = Thread.currentThread().getContextClassLoader(); - if (cl == null) - { + if (cl == null) { cl = getClass().getClassLoader(); } return cl; } - protected DefaultFileReplicator createDefaultFileReplicator() - { + protected DefaultFileReplicator createDefaultFileReplicator() { return new DefaultFileReplicator(); } @@ -174,11 +152,9 @@ public class StandardFileSystemManager * @param configUri The URI of the configuration. * @throws FileSystemException if an error occus. */ - private void configure(final URL configUri) throws FileSystemException - { + private void configure(final URL configUri) throws FileSystemException { InputStream configStream = null; - try - { + try { // Load up the config // TODO - validate final DocumentBuilder builder = createDocumentBuilder(); @@ -186,21 +162,13 @@ public class StandardFileSystemManager final Element config = builder.parse(configStream).getDocumentElement(); configure(config); - } - catch (final Exception e) - { + } catch (final Exception e) { throw new FileSystemException("vfs.impl/load-config.error", configUri.toString(), e); - } - finally - { - if (configStream != null) - { - try - { + } finally { + if (configStream != null) { + try { configStream.close(); - } - catch (final IOException e) - { + } catch (final IOException e) { getLogger().warn(e.getLocalizedMessage(), e); } } @@ -215,11 +183,8 @@ public class StandardFileSystemManager * @throws FileSystemException if an error occurs. */ @SuppressWarnings("unused") - private void configure(final String configUri, final InputStream configStream) - throws FileSystemException - { - try - { + private void configure(final String configUri, final InputStream configStream) throws FileSystemException { + try { // Load up the config // TODO - validate final DocumentBuilder builder = createDocumentBuilder(); @@ -227,9 +192,7 @@ public class StandardFileSystemManager configure(config); - } - catch (final Exception e) - { + } catch (final Exception e) { throw new FileSystemException("vfs.impl/load-config.error", configUri, e); } } @@ -240,13 +203,12 @@ public class StandardFileSystemManager * @return A DocumentBuilder for the configuration. * @throws ParserConfigurationException if an error occurs. */ - private DocumentBuilder createDocumentBuilder() throws ParserConfigurationException - { + private DocumentBuilder createDocumentBuilder() throws ParserConfigurationException { final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setIgnoringElementContentWhitespace(true); factory.setIgnoringComments(true); factory.setExpandEntityReferences(true); - return factory.newDocumentBuilder(); + return factory.newDocumentBuilder(); } /** @@ -255,45 +217,39 @@ public class StandardFileSystemManager * @param config The configuration Element. * @throws FileSystemException if an error occurs. */ - private void configure(final Element config) throws FileSystemException - { + private void configure(final Element config) throws FileSystemException { // Add the providers final NodeList providers = config.getElementsByTagName("provider"); final int count = providers.getLength(); - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { final Element provider = (Element) providers.item(i); addProvider(provider, false); } // Add the operation providers final NodeList operationProviders = config.getElementsByTagName("operationProvider"); - for (int i = 0; i < operationProviders.getLength(); i++) - { + for (int i = 0; i < operationProviders.getLength(); i++) { final Element operationProvider = (Element) operationProviders.item(i); addOperationProvider(operationProvider); } // Add the default provider final NodeList defProviders = config.getElementsByTagName("default-provider"); - if (defProviders.getLength() > 0) - { + if (defProviders.getLength() > 0) { final Element provider = (Element) defProviders.item(0); addProvider(provider, true); } // Add the mime-type maps final NodeList mimeTypes = config.getElementsByTagName("mime-type-map"); - for (int i = 0; i < mimeTypes.getLength(); i++) - { + for (int i = 0; i < mimeTypes.getLength(); i++) { final Element map = (Element) mimeTypes.item(i); addMimeTypeMap(map); } // Add the extension maps final NodeList extensions = config.getElementsByTagName("extension-map"); - for (int i = 0; i < extensions.getLength(); i++) - { + for (int i = 0; i < extensions.getLength(); i++) { final Element map = (Element) extensions.item(i); addExtensionMap(map); } @@ -304,12 +260,10 @@ public class StandardFileSystemManager * * @param map containing the Elements. */ - private void addExtensionMap(final Element map) - { + private void addExtensionMap(final Element map) { final String extension = map.getAttribute("extension"); final String scheme = map.getAttribute("scheme"); - if (scheme != null && scheme.length() > 0) - { + if (scheme != null && scheme.length() > 0) { addExtensionMap(extension, scheme); } } @@ -319,8 +273,7 @@ public class StandardFileSystemManager * * @param map containing the Elements. */ - private void addMimeTypeMap(final Element map) - { + private void addMimeTypeMap(final Element map) { final String mimeType = map.getAttribute("mime-type"); final String scheme = map.getAttribute("scheme"); addMimeTypeMap(mimeType, scheme); @@ -333,19 +286,15 @@ public class StandardFileSystemManager * @param isDefault true if the default should be used. * @throws FileSystemException if an error occurs. */ - private void addProvider(final Element providerDef, final boolean isDefault) - throws FileSystemException - { + private void addProvider(final Element providerDef, final boolean isDefault) throws FileSystemException { final String classname = providerDef.getAttribute("class-name"); // Make sure all required schemes are available final String[] requiredSchemes = getRequiredSchemes(providerDef); - for (final String requiredScheme : requiredSchemes) - { - if (!hasProvider(requiredScheme)) - { - final String msg = Messages.getString("vfs.impl/skipping-provider-scheme.debug", - classname, requiredScheme); + for (final String requiredScheme : requiredSchemes) { + if (!hasProvider(requiredScheme)) { + final String msg = Messages.getString("vfs.impl/skipping-provider-scheme.debug", classname, + requiredScheme); VfsLog.debug(getLogger(), getLogger(), msg); return; } @@ -353,12 +302,9 @@ public class StandardFileSystemManager // Make sure all required classes are in classpath final String[] requiredClasses = getRequiredClasses(providerDef); - for (final String requiredClass : requiredClasses) - { - if (!findClass(requiredClass)) - { - final String msg = Messages.getString("vfs.impl/skipping-provider.debug", - classname, requiredClass); + for (final String requiredClass : requiredClasses) { + if (!findClass(requiredClass)) { + final String msg = Messages.getString("vfs.impl/skipping-provider.debug", classname, requiredClass); VfsLog.debug(getLogger(), getLogger(), msg); return; } @@ -367,14 +313,12 @@ public class StandardFileSystemManager // Create and register the provider final FileProvider provider = (FileProvider) createInstance(classname); final String[] schemas = getSchemas(providerDef); - if (schemas.length > 0) - { + if (schemas.length > 0) { addProvider(schemas, provider); } // Set as default, if required - if (isDefault) - { + if (isDefault) { setDefaultProvider(provider); } } @@ -382,16 +326,13 @@ public class StandardFileSystemManager /** * Adds a operationProvider from a operationProvider definition. */ - private void addOperationProvider(final Element providerDef) throws FileSystemException - { + private void addOperationProvider(final Element providerDef) throws FileSystemException { final String classname = providerDef.getAttribute("class-name"); // Attach only to available schemas final String[] schemas = getSchemas(providerDef); - for (final String schema : schemas) - { - if (hasProvider(schema)) - { + for (final String schema : schemas) { + if (hasProvider(schema)) { final FileOperationProvider operationProvider = (FileOperationProvider) createInstance(classname); addOperationProvider(schema, operationProvider); } @@ -401,15 +342,11 @@ public class StandardFileSystemManager /** * Tests if a class is available. */ - private boolean findClass(final String className) - { - try - { + private boolean findClass(final String className) { + try { loadClass(className); return true; - } - catch (final ClassNotFoundException e) - { + } catch (final ClassNotFoundException e) { return false; } } @@ -417,17 +354,14 @@ public class StandardFileSystemManager /** * Extracts the required classes from a provider definition. */ - private String[] getRequiredClasses(final Element providerDef) - { + private String[] getRequiredClasses(final Element providerDef) { final ArrayList<String> classes = new ArrayList<>(); final NodeList deps = providerDef.getElementsByTagName("if-available"); final int count = deps.getLength(); - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { final Element dep = (Element) deps.item(i); final String className = dep.getAttribute("class-name"); - if (className != null && className.length() > 0) - { + if (className != null && className.length() > 0) { classes.add(className); } } @@ -437,17 +371,14 @@ public class StandardFileSystemManager /** * Extracts the required schemes from a provider definition. */ - private String[] getRequiredSchemes(final Element providerDef) - { + private String[] getRequiredSchemes(final Element providerDef) { final ArrayList<String> schemes = new ArrayList<>(); final NodeList deps = providerDef.getElementsByTagName("if-available"); final int count = deps.getLength(); - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { final Element dep = (Element) deps.item(i); final String scheme = dep.getAttribute("scheme"); - if (scheme != null && scheme.length() > 0) - { + if (scheme != null && scheme.length() > 0) { schemes.add(scheme); } } @@ -457,13 +388,11 @@ public class StandardFileSystemManager /** * Extracts the schema names from a provider definition. */ - private String[] getSchemas(final Element provider) - { + private String[] getSchemas(final Element provider) { final ArrayList<String> schemas = new ArrayList<>(); final NodeList schemaElements = provider.getElementsByTagName("scheme"); final int count = schemaElements.getLength(); - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { final Element scheme = (Element) schemaElements.item(i); schemas.add(scheme.getAttribute("name")); } @@ -473,47 +402,38 @@ public class StandardFileSystemManager /** * Creates a provider. */ - private Object createInstance(final String className) - throws FileSystemException - { - try - { + private Object createInstance(final String className) throws FileSystemException { + try { final Class<?> clazz = loadClass(className); return clazz.newInstance(); - } - catch (final Exception e) - { + } catch (final Exception e) { throw new FileSystemException("vfs.impl/create-provider.error", className, e); } } /** * Load a class from different class loaders. + * * @throws ClassNotFoundException if last {@code loadClass} failed. * @see #findClassLoader() */ - private Class< ? > loadClass(final String className) throws ClassNotFoundException - { - try - { + private Class<?> loadClass(final String className) throws ClassNotFoundException { + try { return findClassLoader().loadClass(className); - } - catch (final ClassNotFoundException e) - { + } catch (final ClassNotFoundException e) { return getClass().getClassLoader().loadClass(className); } } /** * Resolve resources from different class loaders. + * * @throws IOException if {@code getResource} failed. * @see #findClassLoader() */ - private Enumeration<URL> loadResources(final String name) throws IOException - { + private Enumeration<URL> loadResources(final String name) throws IOException { Enumeration<URL> res = findClassLoader().getResources(name); - if (res == null || !res.hasMoreElements()) - { + if (res == null || !res.hasMoreElements()) { res = getClass().getClassLoader().getResources(name); } return res;
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/SynchronizedFileObject.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/SynchronizedFileObject.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/SynchronizedFileObject.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/SynchronizedFileObject.java Thu Sep 14 19:26:39 2017 @@ -28,217 +28,169 @@ import org.apache.commons.vfs2.NameScope /** * This decorator synchronize all access to the FileObject. */ -public class SynchronizedFileObject extends DecoratedFileObject -{ - public SynchronizedFileObject(final FileObject fileObject) - { +public class SynchronizedFileObject extends DecoratedFileObject { + public SynchronizedFileObject(final FileObject fileObject) { super(fileObject); } @Override - public void close() throws FileSystemException - { - synchronized (this) - { + public void close() throws FileSystemException { + synchronized (this) { super.close(); } } @Override - public void copyFrom(final FileObject srcFile, final FileSelector selector) throws FileSystemException - { - synchronized (this) - { + public void copyFrom(final FileObject srcFile, final FileSelector selector) throws FileSystemException { + synchronized (this) { super.copyFrom(srcFile, selector); } } @Override - public void createFile() throws FileSystemException - { - synchronized (this) - { + public void createFile() throws FileSystemException { + synchronized (this) { super.createFile(); } } @Override - public void createFolder() throws FileSystemException - { - synchronized (this) - { + public void createFolder() throws FileSystemException { + synchronized (this) { super.createFolder(); } } @Override - public boolean delete() throws FileSystemException - { - synchronized (this) - { + public boolean delete() throws FileSystemException { + synchronized (this) { return super.delete(); } } @Override - public int delete(final FileSelector selector) throws FileSystemException - { - synchronized (this) - { + public int delete(final FileSelector selector) throws FileSystemException { + synchronized (this) { return super.delete(selector); } } @Override - public boolean exists() throws FileSystemException - { - synchronized (this) - { + public boolean exists() throws FileSystemException { + synchronized (this) { return super.exists(); } } @Override public void findFiles(final FileSelector selector, final boolean depthwise, final List<FileObject> selected) - throws FileSystemException - { - synchronized (this) - { + throws FileSystemException { + synchronized (this) { super.findFiles(selector, depthwise, selected); } } @Override - public FileObject[] findFiles(final FileSelector selector) throws FileSystemException - { - synchronized (this) - { + public FileObject[] findFiles(final FileSelector selector) throws FileSystemException { + synchronized (this) { return super.findFiles(selector); } } @Override - public FileObject getChild(final String name) throws FileSystemException - { - synchronized (this) - { + public FileObject getChild(final String name) throws FileSystemException { + synchronized (this) { return super.getChild(name); } } @Override - public FileObject[] getChildren() throws FileSystemException - { - synchronized (this) - { + public FileObject[] getChildren() throws FileSystemException { + synchronized (this) { return super.getChildren(); } } @Override - public FileContent getContent() throws FileSystemException - { - synchronized (this) - { + public FileContent getContent() throws FileSystemException { + synchronized (this) { return super.getContent(); } } @Override - public FileType getType() throws FileSystemException - { - synchronized (this) - { + public FileType getType() throws FileSystemException { + synchronized (this) { return super.getType(); } } @Override - public boolean isHidden() throws FileSystemException - { - synchronized (this) - { + public boolean isHidden() throws FileSystemException { + synchronized (this) { return super.isHidden(); } } @Override - public boolean isReadable() throws FileSystemException - { - synchronized (this) - { + public boolean isReadable() throws FileSystemException { + synchronized (this) { return super.isReadable(); } } @Override - public boolean isWriteable() throws FileSystemException - { - synchronized (this) - { + public boolean isWriteable() throws FileSystemException { + synchronized (this) { return super.isWriteable(); } } @Override - public boolean isExecutable() throws FileSystemException - { - synchronized (this) - { + public boolean isExecutable() throws FileSystemException { + synchronized (this) { return super.isExecutable(); } } @Override - public boolean setReadable(final boolean readable, final boolean ownerOnly) throws FileSystemException - { - synchronized (this) - { + public boolean setReadable(final boolean readable, final boolean ownerOnly) throws FileSystemException { + synchronized (this) { return super.setReadable(readable, ownerOnly); } } @Override - public boolean setWritable(final boolean writable, final boolean ownerOnly) throws FileSystemException - { - synchronized (this) - { + public boolean setWritable(final boolean writable, final boolean ownerOnly) throws FileSystemException { + synchronized (this) { return super.setWritable(writable, ownerOnly); } } @Override - public boolean setExecutable(final boolean executable, final boolean ownerOnly) throws FileSystemException - { - synchronized (this) - { + public boolean setExecutable(final boolean executable, final boolean ownerOnly) throws FileSystemException { + synchronized (this) { return super.setExecutable(executable, ownerOnly); } } @Override - public void moveTo(final FileObject destFile) throws FileSystemException - { - synchronized (this) - { + public void moveTo(final FileObject destFile) throws FileSystemException { + synchronized (this) { super.moveTo(destFile); } } @Override - public FileObject resolveFile(final String name, final NameScope scope) throws FileSystemException - { - synchronized (this) - { + public FileObject resolveFile(final String name, final NameScope scope) throws FileSystemException { + synchronized (this) { return super.resolveFile(name, scope); } } @Override - public FileObject resolveFile(final String path) throws FileSystemException - { - synchronized (this) - { + public FileObject resolveFile(final String path) throws FileSystemException { + synchronized (this) { return super.resolveFile(path); } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/URLStreamHandlerProxy.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/URLStreamHandlerProxy.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/URLStreamHandlerProxy.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/URLStreamHandlerProxy.java Thu Sep 14 19:26:39 2017 @@ -25,34 +25,22 @@ import java.net.URLStreamHandler; /** * A proxy for URLs that are supported by the standard stream handler factory. */ -class URLStreamHandlerProxy - extends URLStreamHandler -{ +class URLStreamHandlerProxy extends URLStreamHandler { @Override - protected URLConnection openConnection(final URL url) - throws IOException - { + protected URLConnection openConnection(final URL url) throws IOException { final URL proxyURL = new URL(url.toExternalForm()); return proxyURL.openConnection(); } @Override - protected void parseURL(final URL u, - final String spec, - final int start, - final int limit) - { - try - { + protected void parseURL(final URL u, final String spec, final int start, final int limit) { + try { final URL url = new URL(u, spec); - setURL(u, url.getProtocol(), url.getHost(), - url.getPort(), url.getAuthority(), url.getUserInfo(), - url.getFile(), url.getQuery(), url.getRef()); - } - catch (final MalformedURLException mue) - { - //We retrow this as a simple runtime exception. - //It is retrown in URL as a MalformedURLException anyway. + setURL(u, url.getProtocol(), url.getHost(), url.getPort(), url.getAuthority(), url.getUserInfo(), + url.getFile(), url.getQuery(), url.getRef()); + } catch (final MalformedURLException mue) { + // We retrow this as a simple runtime exception. + // It is retrown in URL as a MalformedURLException anyway. throw new RuntimeException(mue.getMessage()); } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/VFSClassLoader.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/VFSClassLoader.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/VFSClassLoader.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/VFSClassLoader.java Thu Sep 14 19:26:39 2017 @@ -37,84 +37,65 @@ import org.apache.commons.vfs2.FileSyste import org.apache.commons.vfs2.FileSystemManager; import org.apache.commons.vfs2.NameScope; - /** * A class loader that can load classes and resources from a search path. * <p> - * The search path can consist of VFS FileObjects referring both to folders - * and JAR files. Any FileObject of type FileType.FILE is assumed to be a JAR and - * is opened by creating a layered file system with the "jar" scheme. + * The search path can consist of VFS FileObjects referring both to folders and JAR files. Any FileObject of type + * FileType.FILE is assumed to be a JAR and is opened by creating a layered file system with the "jar" scheme. * <p> * TODO - Test this with signed Jars and a SecurityManager. * * @see FileSystemManager#createFileSystem */ -public class VFSClassLoader extends SecureClassLoader -{ +public class VFSClassLoader extends SecureClassLoader { private final ArrayList<FileObject> resources = new ArrayList<>(); /** * Constructors a new VFSClassLoader for the given file. * - * @param file the file to load the classes and resources from. - * @param manager the FileManager to use when trying create a layered Jar file - * system. + * @param file the file to load the classes and resources from. + * @param manager the FileManager to use when trying create a layered Jar file system. * @throws FileSystemException if an error occurs. */ - public VFSClassLoader(final FileObject file, - final FileSystemManager manager) - throws FileSystemException - { - this(new FileObject[]{file}, manager, null); + public VFSClassLoader(final FileObject file, final FileSystemManager manager) throws FileSystemException { + this(new FileObject[] { file }, manager, null); } /** * Constructors a new VFSClassLoader for the given file. * - * @param file the file to load the classes and resources from. - * @param manager the FileManager to use when trying create a layered Jar file - * system. - * @param parent the parent class loader for delegation. + * @param file the file to load the classes and resources from. + * @param manager the FileManager to use when trying create a layered Jar file system. + * @param parent the parent class loader for delegation. * @throws FileSystemException if an error occurs. */ - public VFSClassLoader(final FileObject file, - final FileSystemManager manager, - final ClassLoader parent) - throws FileSystemException - { - this(new FileObject[]{file}, manager, parent); + public VFSClassLoader(final FileObject file, final FileSystemManager manager, final ClassLoader parent) + throws FileSystemException { + this(new FileObject[] { file }, manager, parent); } /** - * Constructors a new VFSClassLoader for the given files. The files will - * be searched in the order specified. + * Constructors a new VFSClassLoader for the given files. The files will be searched in the order specified. * - * @param files the files to load the classes and resources from. - * @param manager the FileManager to use when trying create a layered Jar file - * system. + * @param files the files to load the classes and resources from. + * @param manager the FileManager to use when trying create a layered Jar file system. * @throws FileSystemException if an error occurs. */ - public VFSClassLoader(final FileObject[] files, - final FileSystemManager manager) - throws FileSystemException - { + public VFSClassLoader(final FileObject[] files, final FileSystemManager manager) throws FileSystemException { this(files, manager, null); } /** - * Constructors a new VFSClassLoader for the given FileObjects. - * The FileObjects will be searched in the order specified. + * Constructors a new VFSClassLoader for the given FileObjects. The FileObjects will be searched in the order + * specified. * - * @param files the FileObjects to load the classes and resources from. - * @param manager the FileManager to use when trying create a layered Jar file - * system. - * @param parent the parent class loader for delegation. + * @param files the FileObjects to load the classes and resources from. + * @param manager the FileManager to use when trying create a layered Jar file system. + * @param parent the parent class loader for delegation. * @throws FileSystemException if an error occurs. */ - public VFSClassLoader(final FileObject[] files, - final FileSystemManager manager, - final ClassLoader parent) throws FileSystemException - { + public VFSClassLoader(final FileObject[] files, final FileSystemManager manager, final ClassLoader parent) + throws FileSystemException { super(parent); addFileObjects(manager, files); } @@ -125,33 +106,26 @@ public class VFSClassLoader extends Secu * @return An array of FileObjects. * @since 2.0 */ - public FileObject[] getFileObjects() - { + public FileObject[] getFileObjects() { return resources.toArray(new FileObject[resources.size()]); } /** - * Appends the specified FileObjects to the list of FileObjects to search - * for classes and resources. + * Appends the specified FileObjects to the list of FileObjects to search for classes and resources. * * @param manager The FileSystemManager. * @param files the FileObjects to append to the search path. * @throws FileSystemException if an error occurs. */ - private void addFileObjects(final FileSystemManager manager, - final FileObject[] files) throws FileSystemException - { - for (FileObject file : files) - { - if (!file.exists()) - { + private void addFileObjects(final FileSystemManager manager, final FileObject[] files) throws FileSystemException { + for (FileObject file : files) { + if (!file.exists()) { // Does not exist - skip continue; } // TODO - use federation instead - if (manager.canCreateFileSystem(file)) - { + if (manager.canCreateFileSystem(file)) { // Use contents of the file file = manager.createFileSystem(file); } @@ -161,26 +135,20 @@ public class VFSClassLoader extends Secu } /** - * Finds and loads the class with the specified name from the search - * path. + * Finds and loads the class with the specified name from the search path. * * @throws ClassNotFoundException if the class is not found. */ @Override - protected Class<?> findClass(final String name) throws ClassNotFoundException - { - try - { + protected Class<?> findClass(final String name) throws ClassNotFoundException { + try { final String path = name.replace('.', '/').concat(".class"); final Resource res = loadResource(path); - if (res == null) - { + if (res == null) { throw new ClassNotFoundException(name); } return defineClass(name, res); - } - catch (final IOException ioe) - { + } catch (final IOException ioe) { throw new ClassNotFoundException(name, ioe); } } @@ -188,40 +156,28 @@ public class VFSClassLoader extends Secu /** * Loads and verifies the class with name and located with res. */ - private Class<?> defineClass(final String name, final Resource res) - throws IOException - { + private Class<?> defineClass(final String name, final Resource res) throws IOException { final URL url = res.getCodeSourceURL(); final String pkgName = res.getPackageName(); - if (pkgName != null) - { + if (pkgName != null) { final Package pkg = getPackage(pkgName); - if (pkg != null) - { - if (pkg.isSealed()) - { - if (!pkg.isSealed(url)) - { + if (pkg != null) { + if (pkg.isSealed()) { + if (!pkg.isSealed(url)) { throw new FileSystemException("vfs.impl/pkg-sealed-other-url", pkgName); } - } - else - { - if (isSealed(res)) - { + } else { + if (isSealed(res)) { throw new FileSystemException("vfs.impl/pkg-sealing-unsealed", pkgName); } } - } - else - { + } else { definePackage(pkgName, res); } } final byte[] bytes = res.getBytes(); - final Certificate[] certs = - res.getFileObject().getContent().getCertificates(); + final Certificate[] certs = res.getFileObject().getContent().getCertificates(); final CodeSource cs = new CodeSource(url, certs); return defineClass(name, bytes, 0, bytes.length, cs); } @@ -229,9 +185,7 @@ public class VFSClassLoader extends Secu /** * Returns true if the we should seal the package where res resides. */ - private boolean isSealed(final Resource res) - throws FileSystemException - { + private boolean isSealed(final Resource res) throws FileSystemException { final String sealed = res.getPackageAttribute(Attributes.Name.SEALED); return "true".equalsIgnoreCase(sealed); } @@ -239,10 +193,7 @@ public class VFSClassLoader extends Secu /** * Reads attributes for the package and defines it. */ - private Package definePackage(final String name, - final Resource res) - throws FileSystemException - { + private Package definePackage(final String name, final Resource res) throws FileSystemException { // TODO - check for MANIFEST_ATTRIBUTES capability first final String specTitle = res.getPackageAttribute(Name.SPECIFICATION_TITLE); final String specVendor = res.getPackageAttribute(Attributes.Name.SPECIFICATION_VENDOR); @@ -252,40 +203,32 @@ public class VFSClassLoader extends Secu final String implVersion = res.getPackageAttribute(Name.IMPLEMENTATION_VERSION); final URL sealBase; - if (isSealed(res)) - { + if (isSealed(res)) { sealBase = res.getCodeSourceURL(); - } - else - { + } else { sealBase = null; } - return definePackage(name, specTitle, specVersion, specVendor, - implTitle, implVersion, implVendor, sealBase); + return definePackage(name, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, sealBase); } /** - * Calls super.getPermissions both for the code source and also - * adds the permissions granted to the parent layers. + * Calls super.getPermissions both for the code source and also adds the permissions granted to the parent layers. + * * @param cs the CodeSource. * @return The PermissionCollections. */ @Override - protected PermissionCollection getPermissions(final CodeSource cs) - { - try - { + protected PermissionCollection getPermissions(final CodeSource cs) { + try { final String url = cs.getLocation().toString(); final FileObject file = lookupFileObject(url); - if (file == null) - { + if (file == null) { return super.getPermissions(cs); } final FileObject parentLayer = file.getFileSystem().getParentLayer(); - if (parentLayer == null) - { + if (parentLayer == null) { return super.getPermissions(cs); } @@ -293,52 +236,39 @@ public class VFSClassLoader extends Secu PermissionCollection permCollect = super.getPermissions(cs); copyPermissions(permCollect, combi); - for (FileObject parent = parentLayer; - parent != null; - parent = parent.getFileSystem().getParentLayer()) - { - final CodeSource parentcs = - new CodeSource(parent.getURL(), - parent.getContent().getCertificates()); + for (FileObject parent = parentLayer; parent != null; parent = parent.getFileSystem().getParentLayer()) { + final CodeSource parentcs = new CodeSource(parent.getURL(), parent.getContent().getCertificates()); permCollect = super.getPermissions(parentcs); copyPermissions(permCollect, combi); } return combi; - } - catch (final FileSystemException fse) - { + } catch (final FileSystemException fse) { throw new SecurityException(fse.getMessage()); } } /** * Copies the permissions from src to dest. + * * @param src The source PermissionCollection. * @param dest The destination PermissionCollection. */ - protected void copyPermissions(final PermissionCollection src, - final PermissionCollection dest) - { - for (final Enumeration<Permission> elem = src.elements(); elem.hasMoreElements();) - { + protected void copyPermissions(final PermissionCollection src, final PermissionCollection dest) { + for (final Enumeration<Permission> elem = src.elements(); elem.hasMoreElements();) { final Permission permission = elem.nextElement(); dest.add(permission); } } /** - * Does a reverse lookup to find the FileObject when we only have the - * URL. + * Does a reverse lookup to find the FileObject when we only have the URL. */ - private FileObject lookupFileObject(final String name) - { + private FileObject lookupFileObject(final String name) { final Iterator<FileObject> it = resources.iterator(); - while (it.hasNext()) - { + while (it.hasNext()) { final FileObject object = it.next(); - if (name.equals(object.getName().getURI())) - { + if (name.equals(object.getName().getURI())) { return object; } } @@ -346,50 +276,40 @@ public class VFSClassLoader extends Secu } /** - * Finds the resource with the specified name from the search path. - * This returns null if the resource is not found. + * Finds the resource with the specified name from the search path. This returns null if the resource is not found. + * * @param name The resource name. * @return The URL that matches the resource. */ @Override - protected URL findResource(final String name) - { - try - { + protected URL findResource(final String name) { + try { final Resource res = loadResource(name); - if (res != null) - { + if (res != null) { return res.getURL(); } return null; - } - catch (final Exception ignored) - { + } catch (final Exception ignored) { return null; // TODO: report? } } /** - * Returns an Enumeration of all the resources in the search path - * with the specified name. + * Returns an Enumeration of all the resources in the search path with the specified name. * <p> - * Gets called from {@link ClassLoader#getResources(String)} after - * parent class loader was questioned. + * Gets called from {@link ClassLoader#getResources(String)} after parent class loader was questioned. * * @param name The resources to find. * @return An Enumeration of the resources associated with the name. * @throws FileSystemException if an error occurs. */ @Override - protected Enumeration<URL> findResources(final String name) throws IOException - { + protected Enumeration<URL> findResources(final String name) throws IOException { final List<URL> result = new ArrayList<>(2); - for (final FileObject baseFile : resources) - { + for (final FileObject baseFile : resources) { final FileObject file = baseFile.resolveFile(name, NameScope.DESCENDENT_OR_SELF); - if (file.exists()) - { + if (file.exists()) { result.add(new Resource(name, baseFile, file).getURL()); } } @@ -398,19 +318,16 @@ public class VFSClassLoader extends Secu } /** - * Searches through the search path of for the first class or resource - * with specified name. + * Searches through the search path of for the first class or resource with specified name. + * * @param name The resource to load. * @return The Resource. * @throws FileSystemException if an error occurs. */ - private Resource loadResource(final String name) throws FileSystemException - { - for (final FileObject baseFile : resources) - { + private Resource loadResource(final String name) throws FileSystemException { + for (final FileObject baseFile : resources) { final FileObject file = baseFile.resolveFile(name, NameScope.DESCENDENT_OR_SELF); - if (file.exists()) - { + if (file.exists()) { return new Resource(name, baseFile, file); } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/VirtualFileName.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/VirtualFileName.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/VirtualFileName.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/VirtualFileName.java Thu Sep 14 19:26:39 2017 @@ -23,22 +23,18 @@ import org.apache.commons.vfs2.provider. /** * A simple Filename to hold the scheme for to be created virtual filesytsem. */ -public class VirtualFileName extends AbstractFileName -{ - public VirtualFileName(final String scheme, final String absPath, final FileType type) - { +public class VirtualFileName extends AbstractFileName { + public VirtualFileName(final String scheme, final String absPath, final FileType type) { super(scheme, absPath, type); } @Override - public FileName createName(final String absPath, final FileType type) - { + public FileName createName(final String absPath, final FileType type) { return new VirtualFileName(getScheme(), absPath, type); } @Override - protected void appendRootUri(final StringBuilder buffer, final boolean addPassword) - { + protected void appendRootUri(final StringBuilder buffer, final boolean addPassword) { buffer.append(getScheme()); } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/VirtualFileProvider.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/VirtualFileProvider.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/VirtualFileProvider.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/VirtualFileProvider.java Thu Sep 14 19:26:39 2017 @@ -25,12 +25,10 @@ import org.apache.commons.vfs2.provider. import org.apache.commons.vfs2.provider.AbstractFileSystem; import org.apache.commons.vfs2.provider.AbstractVfsContainer; - /** * A virtual filesystem provider. */ -public class VirtualFileProvider extends AbstractVfsContainer -{ +public class VirtualFileProvider extends AbstractVfsContainer { /** * Creates a virtual file system, with the supplied file as its root. * @@ -38,10 +36,9 @@ public class VirtualFileProvider extends * @return A FileObject in the FileSystem. * @throws FileSystemException if an error occurs. */ - public FileObject createFileSystem(final FileObject rootFile) throws FileSystemException - { - final AbstractFileName rootName = (AbstractFileName) - getContext().getFileSystemManager().resolveName(rootFile.getName(), FileName.ROOT_PATH); + public FileObject createFileSystem(final FileObject rootFile) throws FileSystemException { + final AbstractFileName rootName = (AbstractFileName) getContext().getFileSystemManager() + .resolveName(rootFile.getName(), FileName.ROOT_PATH); final VirtualFileSystem fs = new VirtualFileSystem(rootName, rootFile.getFileSystem().getFileSystemOptions()); addComponent(fs); fs.addJunction(FileName.ROOT_PATH, rootFile); @@ -55,25 +52,21 @@ public class VirtualFileProvider extends * @return A FileObject in the FileSystem. * @throws FileSystemException if an error occurs. */ - public FileObject createFileSystem(final String rootUri) throws FileSystemException - { - final AbstractFileName rootName = - new VirtualFileName(rootUri, FileName.ROOT_PATH, FileType.FOLDER); + public FileObject createFileSystem(final String rootUri) throws FileSystemException { + final AbstractFileName rootName = new VirtualFileName(rootUri, FileName.ROOT_PATH, FileType.FOLDER); final VirtualFileSystem fs = new VirtualFileSystem(rootName, null); addComponent(fs); return fs.getRoot(); } /** - * Close a VirtualFileSystem by removing it from the - * {@code #components} list of this provider. + * Close a VirtualFileSystem by removing it from the {@code #components} list of this provider. * <p> * This gets called from DefaultFileManager#_closeFileSystem. * * @param filesystem the file system remembered by this provider. */ - void closeFileSystem(final FileSystem filesystem) - { + void closeFileSystem(final FileSystem filesystem) { final AbstractFileSystem fs = (AbstractFileSystem) filesystem; removeComponent(fs); Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/VirtualFileSystem.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/VirtualFileSystem.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/VirtualFileSystem.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/impl/VirtualFileSystem.java Thu Sep 14 19:26:39 2017 @@ -32,17 +32,14 @@ import org.apache.commons.vfs2.provider. import org.apache.commons.vfs2.provider.DelegateFileObject; /** - * A logical file system, made up of set of junctions, or links, to files from - * other file systems. + * A logical file system, made up of set of junctions, or links, to files from other file systems. * <p> * TODO - Handle nested junctions. */ -public class VirtualFileSystem extends AbstractFileSystem -{ +public class VirtualFileSystem extends AbstractFileSystem { private final Map<FileName, FileObject> junctions = new HashMap<>(); - public VirtualFileSystem(final AbstractFileName rootName, final FileSystemOptions fileSystemOptions) - { + public VirtualFileSystem(final AbstractFileName rootName, final FileSystemOptions fileSystemOptions) { super(rootName, null, fileSystemOptions); } @@ -50,8 +47,7 @@ public class VirtualFileSystem extends A * Adds the capabilities of this file system. */ @Override - protected void addCapabilities(final Collection<Capability> caps) - { + protected void addCapabilities(final Collection<Capability> caps) { // TODO - this isn't really true caps.add(Capability.ATTRIBUTES); caps.add(Capability.CREATE); @@ -69,24 +65,19 @@ public class VirtualFileSystem extends A } /** - * Creates a file object. This method is called only if the requested - * file is not cached. + * Creates a file object. This method is called only if the requested file is not cached. */ @Override - protected FileObject createFile(final AbstractFileName name) throws Exception - { + protected FileObject createFile(final AbstractFileName name) throws Exception { // Find the file that the name points to final FileName junctionPoint = getJunctionForFile(name); final FileObject file; - if (junctionPoint != null) - { + if (junctionPoint != null) { // Resolve the real file final FileObject junctionFile = junctions.get(junctionPoint); final String relName = junctionPoint.getRelativeName(name); file = junctionFile.resolveFile(relName, NameScope.DESCENDENT_OR_SELF); - } - else - { + } else { file = null; } @@ -96,50 +87,41 @@ public class VirtualFileSystem extends A /** * Adds a junction to this file system. + * * @param junctionPoint The location of the junction. * @param targetFile The target file to base the junction on. * @throws FileSystemException if an error occurs. */ @Override - public void addJunction(final String junctionPoint, - final FileObject targetFile) - throws FileSystemException - { + public void addJunction(final String junctionPoint, final FileObject targetFile) throws FileSystemException { final FileName junctionName = getFileSystemManager().resolveName(getRootName(), junctionPoint); // Check for nested junction - these are not supported yet - if (getJunctionForFile(junctionName) != null) - { + if (getJunctionForFile(junctionName) != null) { throw new FileSystemException("vfs.impl/nested-junction.error", junctionName); } - try - { + try { // Add to junction table junctions.put(junctionName, targetFile); // Attach to file final DelegateFileObject junctionFile = (DelegateFileObject) getFileFromCache(junctionName); - if (junctionFile != null) - { + if (junctionFile != null) { junctionFile.setFile(targetFile); } // Create ancestors of junction point FileName childName = junctionName; boolean done = false; - for (AbstractFileName parentName = (AbstractFileName) childName.getParent(); - !done && parentName != null; - childName = parentName, parentName = (AbstractFileName) parentName.getParent()) - { + for (AbstractFileName parentName = (AbstractFileName) childName.getParent(); !done + && parentName != null; childName = parentName, parentName = (AbstractFileName) parentName + .getParent()) { DelegateFileObject file = (DelegateFileObject) getFileFromCache(parentName); - if (file == null) - { + if (file == null) { file = new DelegateFileObject(parentName, this, null); putFileToCache(file); - } - else - { + } else { done = file.exists(); } @@ -148,22 +130,19 @@ public class VirtualFileSystem extends A } // TODO - attach all cached children of the junction point to their real file - } - catch (final Exception e) - { + } catch (final Exception e) { throw new FileSystemException("vfs.impl/create-junction.error", junctionName, e); } } /** * Removes a junction from this file system. + * * @param junctionPoint The junction to remove. * @throws FileSystemException if an error occurs. */ @Override - public void removeJunction(final String junctionPoint) - throws FileSystemException - { + public void removeJunction(final String junctionPoint) throws FileSystemException { final FileName junctionName = getFileSystemManager().resolveName(getRootName(), junctionPoint); junctions.remove(junctionName); @@ -173,22 +152,19 @@ public class VirtualFileSystem extends A /** * Locates the junction point for the junction containing the given file. + * * @param name The FileName. * @return the FileName where the junction occurs. */ - private FileName getJunctionForFile(final FileName name) - { - if (junctions.containsKey(name)) - { + private FileName getJunctionForFile(final FileName name) { + if (junctions.containsKey(name)) { // The name points to the junction point directly return name; } // Find matching junction - for (final FileName junctionPoint : junctions.keySet()) - { - if (junctionPoint.isDescendent(name)) - { + for (final FileName junctionPoint : junctions.keySet()) { + if (junctionPoint.isDescendent(name)) { return junctionPoint; } } @@ -198,8 +174,7 @@ public class VirtualFileSystem extends A } @Override - public void close() - { + public void close() { super.close(); junctions.clear(); } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/AbstractFileOperation.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/AbstractFileOperation.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/AbstractFileOperation.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/AbstractFileOperation.java Thu Sep 14 19:26:39 2017 @@ -22,8 +22,7 @@ import org.apache.commons.vfs2.FileObjec * * @since 0.1 */ -public abstract class AbstractFileOperation implements FileOperation -{ +public abstract class AbstractFileOperation implements FileOperation { /** * FileObject which the FileOperation is operate on. */ @@ -32,16 +31,14 @@ public abstract class AbstractFileOperat /** * @param file The FileObject. */ - public AbstractFileOperation(final FileObject file) - { + public AbstractFileOperation(final FileObject file) { fileObject = file; } /** * @return an instance of FileObject which this FileOperation is operate on. */ - protected FileObject getFileObject() - { + protected FileObject getFileObject() { return fileObject; } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/AbstractFileOperationProvider.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/AbstractFileOperationProvider.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/AbstractFileOperationProvider.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/AbstractFileOperationProvider.java Thu Sep 14 19:26:39 2017 @@ -23,74 +23,55 @@ import java.util.Iterator; import org.apache.commons.vfs2.FileObject; import org.apache.commons.vfs2.FileSystemException; - /** * * @since 0.1 */ -public abstract class AbstractFileOperationProvider implements FileOperationProvider -{ +public abstract class AbstractFileOperationProvider implements FileOperationProvider { /** - * Available operations. Operations could be registered for different schemes. - * Some operations can work only for "file" scheme, other - for "svnhttp(s)", - * "svn", "svnssh", but not for "file", etc. The Map has scheme as a key and - * Collection of operations that are available for that scheme. + * Available operations. Operations could be registered for different schemes. Some operations can work only for + * "file" scheme, other - for "svnhttp(s)", "svn", "svnssh", but not for "file", etc. The Map has scheme as a key + * and Collection of operations that are available for that scheme. */ - private final Collection<Class<? extends FileOperation>> operations = - new ArrayList<>(); + private final Collection<Class<? extends FileOperation>> operations = new ArrayList<>(); /** - * Gather available operations for the specified FileObject and put them into - * specified operationsList. + * Gather available operations for the specified FileObject and put them into specified operationsList. * - * @param operationsList - * the list of available operations for the specified FileObject. - * The operationList contains classes of available operations, e.g. - * Class objects. - * @param file - * the FileObject for which we want to get the list of available - * operations. + * @param operationsList the list of available operations for the specified FileObject. The operationList contains + * classes of available operations, e.g. Class objects. + * @param file the FileObject for which we want to get the list of available operations. * @throws FileSystemException if list of operations cannot be retrieved. */ @Override public final void collectOperations(final Collection<Class<? extends FileOperation>> operationsList, - final FileObject file) throws FileSystemException - { + final FileObject file) throws FileSystemException { doCollectOperations(operations, operationsList, file); } /** - * Gather available operations for the specified FileObject and put them into - * specified operationsList. + * Gather available operations for the specified FileObject and put them into specified operationsList. * - * @param availableOperations - * the list of available operations for the specified FileObject. - * @param resultList - * List to be filled with applicable operations. - * @param file - * the FileObject for which we want to get the list of available - * operations. + * @param availableOperations the list of available operations for the specified FileObject. + * @param resultList List to be filled with applicable operations. + * @param file the FileObject for which we want to get the list of available operations. * @throws FileSystemException if list of operations cannot be retrieved. * @see #collectOperations(Collection operationsList, FileObject file) */ - protected abstract void doCollectOperations( - final Collection<Class<? extends FileOperation>> availableOperations, - final Collection<Class<? extends FileOperation>> resultList, - final FileObject file) throws FileSystemException; + protected abstract void doCollectOperations(final Collection<Class<? extends FileOperation>> availableOperations, + final Collection<Class<? extends FileOperation>> resultList, final FileObject file) + throws FileSystemException; /** - * @param file - * the FileObject for which we need a operation. - * @param operationClass - * the Class which instance we are needed. + * @param file the FileObject for which we need a operation. + * @param operationClass the Class which instance we are needed. * @return the required operation instance. * @throws FileSystemException if operation cannot be retrieved. */ @Override public final FileOperation getOperation(final FileObject file, final Class<? extends FileOperation> operationClass) - throws FileSystemException - { + throws FileSystemException { final Class<? extends FileOperation> implementation = lookupOperation(operationClass); final FileOperation operationInstance = instantiateOperation(file, implementation); @@ -117,29 +98,24 @@ public abstract class AbstractFileOperat * @throws FileSystemException if operationClass is not a known FileOperation interface. */ protected final Class<? extends FileOperation> lookupOperation(final Class<? extends FileOperation> operationClass) - throws FileSystemException - { + throws FileSystemException { // check validity of passed class - if (!FileOperation.class.isAssignableFrom(operationClass)) - { + if (!FileOperation.class.isAssignableFrom(operationClass)) { throw new FileSystemException("vfs.operation/wrong-type.error", operationClass); } // find appropriate class Class<? extends FileOperation> foundClass = null; final Iterator<Class<? extends FileOperation>> iterator = operations.iterator(); - while (iterator.hasNext()) - { + while (iterator.hasNext()) { final Class<? extends FileOperation> operation = iterator.next(); - if (operationClass.isAssignableFrom(operation)) - { + if (operationClass.isAssignableFrom(operation)) { foundClass = operation; break; } } - if (foundClass == null) - { + if (foundClass == null) { throw new FileSystemException("vfs.operation/not-found.error", operationClass); } @@ -152,12 +128,9 @@ public abstract class AbstractFileOperat * @param operationClass a class implementing FileOperation. * @throws FileSystemException if instances of the class cannot be assigned to FileOperation. */ - protected final void addOperation(final Class<? extends FileOperation> operationClass) - throws FileSystemException - { + protected final void addOperation(final Class<? extends FileOperation> operationClass) throws FileSystemException { // check validity of passed class - if (!FileOperation.class.isAssignableFrom(operationClass)) - { + if (!FileOperation.class.isAssignableFrom(operationClass)) { throw new FileSystemException("vfs.operation/cant-register.error", operationClass); } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/DefaultFileOperations.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/DefaultFileOperations.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/DefaultFileOperations.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/DefaultFileOperations.java Thu Sep 14 19:26:39 2017 @@ -27,8 +27,7 @@ import org.apache.commons.vfs2.FileSyste * * @since 0.1 */ -public class DefaultFileOperations implements FileOperations -{ +public class DefaultFileOperations implements FileOperations { /** */ private final FileSystemManager fsmanager; @@ -41,8 +40,7 @@ public class DefaultFileOperations imple * * @param file The file. */ - public DefaultFileOperations(final FileObject file) - { + public DefaultFileOperations(final FileObject file) { fileObject = file; fsmanager = file.getFileSystem().getFileSystemManager(); @@ -53,29 +51,24 @@ public class DefaultFileOperations imple * @throws FileSystemException If an error occurs. */ @Override - public Class<? extends FileOperation>[] getOperations() throws FileSystemException - { + public Class<? extends FileOperation>[] getOperations() throws FileSystemException { final String scheme = fileObject.getURL().getProtocol(); - final FileOperationProvider[] providers = fsmanager - .getOperationProviders(scheme); + final FileOperationProvider[] providers = fsmanager.getOperationProviders(scheme); - if (providers == null) - { + if (providers == null) { return null; } final List<Class<? extends FileOperation>> operations = new ArrayList<>(); - for (final FileOperationProvider provider : providers) - { + for (final FileOperationProvider provider : providers) { provider.collectOperations(operations, fileObject); } @SuppressWarnings("unchecked") - final - Class<? extends FileOperation>[] array = - (Class<? extends FileOperation>[]) operations.toArray(new Class<?>[] {}); + final Class<? extends FileOperation>[] array = (Class<? extends FileOperation>[]) operations + .toArray(new Class<?>[] {}); return array; } @@ -85,36 +78,27 @@ public class DefaultFileOperations imple * @throws FileSystemException if an error occurs. */ @Override - public FileOperation getOperation(final Class<? extends FileOperation> operationClass) - throws FileSystemException - { + public FileOperation getOperation(final Class<? extends FileOperation> operationClass) throws FileSystemException { final String scheme = fileObject.getURL().getProtocol(); - final FileOperationProvider[] providers = fsmanager - .getOperationProviders(scheme); + final FileOperationProvider[] providers = fsmanager.getOperationProviders(scheme); - if (providers == null) - { - throw new FileSystemException( - "vfs.operation/operation-not-supported.error", operationClass); + if (providers == null) { + throw new FileSystemException("vfs.operation/operation-not-supported.error", operationClass); } FileOperation resultOperation = null; - for (final FileOperationProvider provider : providers) - { + for (final FileOperationProvider provider : providers) { resultOperation = provider.getOperation(fileObject, operationClass); - if (resultOperation != null) - { + if (resultOperation != null) { break; } } - if (resultOperation == null) - { - throw new FileSystemException( - "vfs.operation/operation-not-supported.error", operationClass); + if (resultOperation == null) { + throw new FileSystemException("vfs.operation/operation-not-supported.error", operationClass); } return resultOperation; @@ -122,24 +106,19 @@ public class DefaultFileOperations imple /** * @param operationClass the operation's class. - * @return true if the operation of specified class is supported for current - * FileObject and false otherwise. + * @return true if the operation of specified class is supported for current FileObject and false otherwise. * * @throws FileSystemException if an error occurs. */ @Override - public boolean hasOperation(final Class<? extends FileOperation> operationClass) throws FileSystemException - { + public boolean hasOperation(final Class<? extends FileOperation> operationClass) throws FileSystemException { final Class<? extends FileOperation>[] operations = getOperations(); - if (operations == null) - { + if (operations == null) { return false; } - for (final Class<? extends FileOperation> operation : operations) - { - if (operationClass.isAssignableFrom(operation)) - { + for (final Class<? extends FileOperation> operation : operations) { + if (operationClass.isAssignableFrom(operation)) { return true; } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/FileOperation.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/FileOperation.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/FileOperation.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/FileOperation.java Thu Sep 14 19:26:39 2017 @@ -20,34 +20,29 @@ import org.apache.commons.vfs2.FileSyste /** * <p> - * A FileOperation is an object that brings an extra function to a FileObject. - * The VFS provides the basic functionality to deal with FileObject's. That is - * create, delete, rename, copy, and so on functions. However, if you are working with - * FileSystem and its files are, for example, under Version Control System (VCS) - * you might want to get an access to the versioning framework and to be able to - * manage your files regarding VCS (e.g. commit them, update, get logs, etc.). - * Such type of extended functionality is provided by FileOperation. + * A FileOperation is an object that brings an extra function to a FileObject. The VFS provides the basic functionality + * to deal with FileObject's. That is create, delete, rename, copy, and so on functions. However, if you are working + * with FileSystem and its files are, for example, under Version Control System (VCS) you might want to get an access to + * the versioning framework and to be able to manage your files regarding VCS (e.g. commit them, update, get logs, + * etc.). Such type of extended functionality is provided by FileOperation. * </p> * <p> - * The FileOperation interface is a genetic interface that should not be - * implemented directly. It rather should be extended by other interfaces that - * provide some concrete functions. + * The FileOperation interface is a genetic interface that should not be implemented directly. It rather should be + * extended by other interfaces that provide some concrete functions. * </p> * <p> * FileOperation is provided by * - * @see FileOperationProvider Especially the FileOperationProvider is responsible - * for looking up and instantiating any concrete FileOperation. + * @see FileOperationProvider Especially the FileOperationProvider is responsible for looking up and instantiating any + * concrete FileOperation. * </p> * * @since 0.1 */ -public interface FileOperation -{ +public interface FileOperation { /** - * Performs necessary actions that are related to the concrete - * implementation of a FileOperation. + * Performs necessary actions that are related to the concrete implementation of a FileOperation. * * @throws FileSystemException if an error occurs */ Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/FileOperationProvider.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/FileOperationProvider.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/FileOperationProvider.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/FileOperationProvider.java Thu Sep 14 19:26:39 2017 @@ -26,23 +26,16 @@ import org.apache.commons.vfs2.FileSyste * * @since 0.1 */ -public interface FileOperationProvider -{ +public interface FileOperationProvider { /** - * Gather available operations for the specified FileObject and put them into - * specified operationsList. + * Gather available operations for the specified FileObject and put them into specified operationsList. * - * @param operationsList - * the list of available operations for the specified FileObject. - * The operationList contains classes of available operations, e.g. - * Class objects. - * @param file - * the FileObject for which we want to get the list of available - * operations. + * @param operationsList the list of available operations for the specified FileObject. The operationList contains + * classes of available operations, e.g. Class objects. + * @param file the FileObject for which we want to get the list of available operations. * - * @throws FileSystemException - * if list of operations cannot be retrieved. + * @throws FileSystemException if list of operations cannot be retrieved. */ void collectOperations(final Collection<Class<? extends FileOperation>> operationsList, final FileObject file) throws FileSystemException; @@ -50,14 +43,11 @@ public interface FileOperationProvider /** * Get implementation for a given FileObject and FileOperation interface. * - * @param file - * the FileObject for which we need a operation. - * @param operationClass - * the Class which instance we are needed. + * @param file the FileObject for which we need a operation. + * @param operationClass the Class which instance we are needed. * @return the required operation instance. * - * @throws FileSystemException - * if operation cannot be retrieved. + * @throws FileSystemException if operation cannot be retrieved. */ FileOperation getOperation(final FileObject file, final Class<? extends FileOperation> operationClass) throws FileSystemException; Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/FileOperations.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/FileOperations.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/FileOperations.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/FileOperations.java Thu Sep 14 19:26:39 2017 @@ -25,8 +25,7 @@ import org.apache.commons.vfs2.FileSyste * * @since 0.1 */ -public interface FileOperations -{ +public interface FileOperations { /** * @return all operations associated with the fileObject * @throws FileSystemException if an error occurs. Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsAdd.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsAdd.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsAdd.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsAdd.java Thu Sep 14 19:26:39 2017 @@ -22,8 +22,7 @@ import org.apache.commons.vfs2.operation * * @since 0.1 */ -public interface VcsAdd extends FileOperation -{ +public interface VcsAdd extends FileOperation { /** * * @param makedir true if directories should be created, false otherwise. Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsCheckout.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsCheckout.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsCheckout.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsCheckout.java Thu Sep 14 19:26:39 2017 @@ -23,8 +23,7 @@ import org.apache.commons.vfs2.operation * * @since 0.1 */ -public interface VcsCheckout extends FileOperation -{ +public interface VcsCheckout extends FileOperation { /** * * @param revision The revision number. @@ -44,10 +43,8 @@ public interface VcsCheckout extends Fil void setTargetDirectory(final FileObject targetDir); /** - * @param export - * if true, administrative .svn directoies will not be created on - * the retrieved tree. The checkout operation in this case is - * equivalent to export function. + * @param export if true, administrative .svn directoies will not be created on the retrieved tree. The checkout + * operation in this case is equivalent to export function. */ void setExport(final boolean export); } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsCommit.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsCommit.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsCommit.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsCommit.java Thu Sep 14 19:26:39 2017 @@ -22,8 +22,7 @@ import org.apache.commons.vfs2.operation * * @since 0.1 */ -public interface VcsCommit extends FileOperation -{ +public interface VcsCommit extends FileOperation { /** * Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsCommitListener.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsCommitListener.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsCommitListener.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsCommitListener.java Thu Sep 14 19:26:39 2017 @@ -20,8 +20,7 @@ package org.apache.commons.vfs2.operatio * * @since 0.1 */ -public interface VcsCommitListener -{ +public interface VcsCommitListener { /** * * @param path The path. Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsDelete.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsDelete.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsDelete.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/operations/vcs/VcsDelete.java Thu Sep 14 19:26:39 2017 @@ -22,8 +22,7 @@ import org.apache.commons.vfs2.operation * * @since 0.1 */ -public interface VcsDelete extends FileOperation -{ +public interface VcsDelete extends FileOperation { /** * * @param force true if the delete should be unconditional.
