Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileSystem.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileSystem.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileSystem.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileSystem.java Thu Sep 14 19:26:39 2017 @@ -33,50 +33,46 @@ import org.apache.commons.vfs2.provider. * * @since 2.0 */ -public class WebdavFileSystem extends HttpFileSystem -{ +public class WebdavFileSystem extends HttpFileSystem { protected WebdavFileSystem(final GenericFileName rootName, final HttpClient client, - final FileSystemOptions fileSystemOptions) - { + final FileSystemOptions fileSystemOptions) { super(rootName, client, fileSystemOptions); } @Override - protected HttpClient getClient() - { + protected HttpClient getClient() { // make accessible return super.getClient(); } /** * Returns the capabilities of this file system. + * * @param caps The Capabilities to add. */ @Override - protected void addCapabilities(final Collection<Capability> caps) - { + protected void addCapabilities(final Collection<Capability> caps) { caps.addAll(WebdavFileProvider.capabilities); } /** - * 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. + * * @param name the FileName. * @return The created FileObject. */ @Override - protected FileObject createFile(final AbstractFileName name) - { + protected FileObject createFile(final AbstractFileName name) { return new WebdavFileObject(name, this); } /** * Return a URLStreamHandler. + * * @return The URLStreamHandler. */ - public URLStreamHandler getURLStreamHandler() - { + public URLStreamHandler getURLStreamHandler() { return new DefaultURLStreamHandler(getContext(), getFileSystemOptions()); } }
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileSystemConfigBuilder.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileSystemConfigBuilder.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileSystemConfigBuilder.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavFileSystemConfigBuilder.java Thu Sep 14 19:26:39 2017 @@ -25,14 +25,12 @@ import org.apache.commons.vfs2.provider. * * @since 2.0 */ -public final class WebdavFileSystemConfigBuilder extends HttpFileSystemConfigBuilder -{ +public final class WebdavFileSystemConfigBuilder extends HttpFileSystemConfigBuilder { private static final WebdavFileSystemConfigBuilder BUILDER = new WebdavFileSystemConfigBuilder(); private static final boolean DEFAULT_FOLLOW_REDIRECT = false; - private WebdavFileSystemConfigBuilder() - { + private WebdavFileSystemConfigBuilder() { super("webdav."); } @@ -41,63 +39,60 @@ public final class WebdavFileSystemConfi * * @return the singleton builder. */ - public static HttpFileSystemConfigBuilder getInstance() - { + public static HttpFileSystemConfigBuilder getInstance() { return BUILDER; } /** * The user name to be associated with changes to the file. + * * @param opts The FileSystem options * @param creatorName The creator name to be associated with the file. */ - public void setCreatorName(final FileSystemOptions opts, final String creatorName) - { + public void setCreatorName(final FileSystemOptions opts, final String creatorName) { setParam(opts, "creatorName", creatorName); } /** * Return the user name to be associated with changes to the file. + * * @param opts The FileSystem options * @return The creatorName. */ - public String getCreatorName(final FileSystemOptions opts) - { + public String getCreatorName(final FileSystemOptions opts) { return getString(opts, "creatorName"); } /** * Gets whether to follow redirects for the connection. * - * @param opts - * The FileSystem options. + * @param opts The FileSystem options. * @return {@code true} to follow redirects, {@code false} not to. * @see #setFollowRedirect * @since 2.1 */ @Override - public boolean getFollowRedirect(final FileSystemOptions opts) - { + public boolean getFollowRedirect(final FileSystemOptions opts) { return getBoolean(opts, KEY_FOLLOW_REDIRECT, DEFAULT_FOLLOW_REDIRECT); } /** * Whether to use versioning. + * * @param opts The FileSystem options. * @param versioning true if versioning should be enabled. */ - public void setVersioning(final FileSystemOptions opts, final boolean versioning) - { + public void setVersioning(final FileSystemOptions opts, final boolean versioning) { setParam(opts, "versioning", Boolean.valueOf(versioning)); } /** * The cookies to add to the request. + * * @param opts The FileSystem options. * @return true if versioning is enabled. */ - public boolean isVersioning(final FileSystemOptions opts) - { + public boolean isVersioning(final FileSystemOptions opts) { return getBoolean(opts, "versioning", false); } @@ -105,8 +100,7 @@ public final class WebdavFileSystemConfi * @return The Webdav FileSystem Class object. */ @Override - protected Class<? extends FileSystem> getConfigClass() - { + protected Class<? extends FileSystem> getConfigClass() { return WebdavFileSystem.class; } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavMethodRetryHandler.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavMethodRetryHandler.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavMethodRetryHandler.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/webdav/WebdavMethodRetryHandler.java Thu Sep 14 19:26:39 2017 @@ -21,7 +21,6 @@ import java.io.IOException; import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.HttpMethodRetryHandler; - /** * A retry handler which will retry a failed webdav method one time. * <p> @@ -29,22 +28,18 @@ import org.apache.commons.httpclient.Htt * * @since 2.0 */ -public final class WebdavMethodRetryHandler implements HttpMethodRetryHandler -{ +public final class WebdavMethodRetryHandler implements HttpMethodRetryHandler { private static final WebdavMethodRetryHandler INSTANCE = new WebdavMethodRetryHandler(); - private WebdavMethodRetryHandler() - { + private WebdavMethodRetryHandler() { } - public static WebdavMethodRetryHandler getInstance() - { + public static WebdavMethodRetryHandler getInstance() { return INSTANCE; } @Override - public boolean retryMethod(final HttpMethod method, final IOException exception, final int executionCount) - { + public boolean retryMethod(final HttpMethod method, final IOException exception, final int executionCount) { return executionCount < 2; } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileObject.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileObject.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileObject.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileObject.java Thu Sep 14 19:26:39 2017 @@ -47,8 +47,7 @@ public class ZipFileObject extends Abstr /** * Sets the details for this file object. * - * @param entry - * ZIP information related to this file. + * @param entry ZIP information related to this file. */ protected void setZipEntry(final ZipEntry entry) { if (this.entry != null) { @@ -71,8 +70,7 @@ public class ZipFileObject extends Abstr * compatibility. * </p> * - * @param childName - * The name of the child. + * @param childName The name of the child. */ public void attachChild(final FileName childName) { children.add(childName.getBaseName()); @@ -82,8 +80,7 @@ public class ZipFileObject extends Abstr * Determines if this file can be written to. * * @return {@code true} if this file is writable, {@code false} if not. - * @throws FileSystemException - * if an error occurs. + * @throws FileSystemException if an error occurs. */ @Override public boolean isWriteable() throws FileSystemException { Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileProvider.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileProvider.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileProvider.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileProvider.java Thu Sep 14 19:26:39 2017 @@ -32,50 +32,35 @@ import org.apache.commons.vfs2.provider. import org.apache.commons.vfs2.provider.LayeredFileName; /** - * A file system provider for ZIP files. Provides read-only file systems. + * A file system provider for ZIP files. Provides read-only file systems. */ -public class ZipFileProvider extends AbstractLayeredFileProvider -{ +public class ZipFileProvider extends AbstractLayeredFileProvider { /** The list of capabilities this provider supports */ - protected static final Collection<Capability> capabilities = - Collections.unmodifiableCollection(Arrays.asList(new Capability[] - { - Capability.GET_LAST_MODIFIED, - Capability.GET_TYPE, - Capability.LIST_CHILDREN, - Capability.READ_CONTENT, - Capability.URI, - Capability.COMPRESS, - Capability.VIRTUAL - })); + protected static final Collection<Capability> capabilities = Collections.unmodifiableCollection(Arrays + .asList(new Capability[] { Capability.GET_LAST_MODIFIED, Capability.GET_TYPE, Capability.LIST_CHILDREN, + Capability.READ_CONTENT, Capability.URI, Capability.COMPRESS, Capability.VIRTUAL })); - public ZipFileProvider() - { + public ZipFileProvider() { super(); } /** - * Creates a layered file system. This method is called if the file system - * is not cached. + * Creates a layered file system. This method is called if the file system is not cached. * * @param scheme The URI scheme. - * @param file The file to create the file system on top of. + * @param file The file to create the file system on top of. * @return The file system. */ @Override - protected FileSystem doCreateFileSystem(final String scheme, - final FileObject file, - final FileSystemOptions fileSystemOptions) - throws FileSystemException - { - final AbstractFileName rootName = - new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH, FileType.FOLDER); + protected FileSystem doCreateFileSystem(final String scheme, final FileObject file, + final FileSystemOptions fileSystemOptions) throws FileSystemException { + final AbstractFileName rootName = new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH, + FileType.FOLDER); return new ZipFileSystem(rootName, file, fileSystemOptions); } @Override - public Collection<Capability> getCapabilities() - { + public Collection<Capability> getCapabilities() { return capabilities; } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystem.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystem.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystem.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/zip/ZipFileSystem.java Thu Sep 14 19:26:39 2017 @@ -43,8 +43,7 @@ import org.apache.commons.vfs2.provider. /** * A read-only file system for ZIP and JAR files. */ -public class ZipFileSystem extends AbstractFileSystem -{ +public class ZipFileSystem extends AbstractFileSystem { private static final Log LOG = LogFactory.getLog(ZipFileSystem.class); private final File file; @@ -55,19 +54,15 @@ public class ZipFileSystem extends Abstr */ private final Map<FileName, FileObject> cache = new HashMap<>(); - public ZipFileSystem(final AbstractFileName rootName, - final FileObject parentLayer, - final FileSystemOptions fileSystemOptions) - throws FileSystemException - { + public ZipFileSystem(final AbstractFileName rootName, final FileObject parentLayer, + final FileSystemOptions fileSystemOptions) throws FileSystemException { super(rootName, parentLayer, fileSystemOptions); // Make a local copy of the file file = parentLayer.getFileSystem().replicateFile(parentLayer, Selectors.SELECT_SELF); // Open the Zip file - if (!file.exists()) - { + if (!file.exists()) { // Don't need to do anything zipFile = null; return; @@ -77,25 +72,21 @@ public class ZipFileSystem extends Abstr } @Override - public void init() throws FileSystemException - { + public void init() throws FileSystemException { super.init(); - try - { + try { // Build the index final List<ZipFileObject> strongRef = new ArrayList<>(getZipFile().size()); final Enumeration<? extends ZipEntry> entries = getZipFile().entries(); - while (entries.hasMoreElements()) - { + while (entries.hasMoreElements()) { final ZipEntry entry = entries.nextElement(); final AbstractFileName name = (AbstractFileName) getFileSystemManager().resolveName(getRootName(), - UriParser.encode(entry.getName())); + UriParser.encode(entry.getName())); // Create the file ZipFileObject fileObj; - if (entry.isDirectory() && getFileFromCache(name) != null) - { + if (entry.isDirectory() && getFileFromCache(name) != null) { fileObj = (ZipFileObject) getFileFromCache(name); fileObj.setZipEntry(entry); continue; @@ -109,14 +100,12 @@ public class ZipFileSystem extends Abstr // Make sure all ancestors exist // TODO - create these on demand ZipFileObject parent; - for (AbstractFileName parentName = (AbstractFileName) name.getParent(); - parentName != null; - fileObj = parent, parentName = (AbstractFileName) parentName.getParent()) - { + for (AbstractFileName parentName = (AbstractFileName) name + .getParent(); parentName != null; fileObj = parent, parentName = (AbstractFileName) parentName + .getParent()) { // Locate the parent parent = (ZipFileObject) getFileFromCache(parentName); - if (parent == null) - { + if (parent == null) { parent = createZipFileObject(parentName, null); putFileToCache(parent); strongRef.add(parent); @@ -127,55 +116,41 @@ public class ZipFileSystem extends Abstr parent.attachChild(fileObj.getName()); } } - } - finally - { + } finally { closeCommunicationLink(); } } - protected ZipFile getZipFile() throws FileSystemException - { - if (zipFile == null && this.file.exists()) - { + protected ZipFile getZipFile() throws FileSystemException { + if (zipFile == null && this.file.exists()) { this.zipFile = createZipFile(this.file); } return zipFile; } - protected ZipFileObject createZipFileObject(final AbstractFileName name, - final ZipEntry entry) throws FileSystemException - { + protected ZipFileObject createZipFileObject(final AbstractFileName name, final ZipEntry entry) + throws FileSystemException { return new ZipFileObject(name, entry, this, true); } - protected ZipFile createZipFile(final File file) throws FileSystemException - { - try - { + protected ZipFile createZipFile(final File file) throws FileSystemException { + try { return new ZipFile(file); - } - catch (final IOException ioe) - { + } catch (final IOException ioe) { throw new FileSystemException("vfs.provider.zip/open-zip-file.error", file, ioe); } } @Override - protected void doCloseCommunicationLink() - { + protected void doCloseCommunicationLink() { // Release the zip file - try - { - if (zipFile != null) - { + try { + if (zipFile != null) { zipFile.close(); zipFile = null; } - } - catch (final IOException e) - { + } catch (final IOException e) { // getLogger().warn("vfs.provider.zip/close-zip-file.error :" + file, e); VfsLog.warn(getLogger(), LOG, "vfs.provider.zip/close-zip-file.error :" + file, e); } @@ -185,8 +160,7 @@ public class ZipFileSystem extends Abstr * Returns the capabilities of this file system. */ @Override - protected void addCapabilities(final Collection<Capability> caps) - { + protected void addCapabilities(final Collection<Capability> caps) { caps.addAll(ZipFileProvider.capabilities); } @@ -194,8 +168,7 @@ public class ZipFileSystem extends Abstr * Creates a file object. */ @Override - protected FileObject createFile(final AbstractFileName name) throws FileSystemException - { + protected FileObject createFile(final AbstractFileName name) throws FileSystemException { // This is only called for files which do not exist in the Zip file return new ZipFileObject(name, null, this, false); } @@ -204,8 +177,7 @@ public class ZipFileSystem extends Abstr * Adds a file object to the cache. */ @Override - protected void putFileToCache(final FileObject file) - { + protected void putFileToCache(final FileObject file) { cache.put(file.getName(), file); } @@ -213,8 +185,7 @@ public class ZipFileSystem extends Abstr * Returns a cached file. */ @Override - protected FileObject getFileFromCache(final FileName name) - { + protected FileObject getFileFromCache(final FileName name) { return cache.get(name); } @@ -222,8 +193,7 @@ public class ZipFileSystem extends Abstr * remove a cached file. */ @Override - protected void removeFileFromCache(final FileName name) - { + protected void removeFileFromCache(final FileName name) { cache.remove(name); } @@ -233,10 +203,7 @@ public class ZipFileSystem extends Abstr } /** - * will be called after all file-objects closed their streams. - protected void notifyAllStreamsClosed() - { - closeCommunicationLink(); - } + * will be called after all file-objects closed their streams. protected void notifyAllStreamsClosed() { + * closeCommunicationLink(); } */ } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/AbstractSyncTask.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/AbstractSyncTask.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/AbstractSyncTask.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/AbstractSyncTask.java Thu Sep 14 19:26:39 2017 @@ -30,9 +30,8 @@ import org.apache.tools.ant.BuildExcepti import org.apache.tools.ant.Project; /** - * An abstract file synchronization task. Scans a set of source files and - * folders, and a destination folder, and performs actions on missing and - * out-of-date files. Specifically, performs actions on the following: + * An abstract file synchronization task. Scans a set of source files and folders, and a destination folder, and + * performs actions on missing and out-of-date files. Specifically, performs actions on the following: * <ul> * <li>Missing destination file. * <li>Missing source file. @@ -48,9 +47,7 @@ import org.apache.tools.ant.Project; * TODO - Handle source/dest directories as well.<br> * TODO - Allow selector to be specified for choosing which dest files to sync. */ -public abstract class AbstractSyncTask - extends VfsTask -{ +public abstract class AbstractSyncTask extends VfsTask { private final ArrayList<SourceInfo> srcFiles = new ArrayList<>(); private String destFileUrl; private String destDirUrl; @@ -61,28 +58,28 @@ public abstract class AbstractSyncTask /** * Sets the destination file. + * * @param destFile The destination file name. */ - public void setDestFile(final String destFile) - { + public void setDestFile(final String destFile) { this.destFileUrl = destFile; } /** * Sets the destination directory. + * * @param destDir The destination directory. */ - public void setDestDir(final String destDir) - { + public void setDestDir(final String destDir) { this.destDirUrl = destDir; } /** * Sets the source file. + * * @param srcFile The source file name. */ - public void setSrc(final String srcFile) - { + public void setSrc(final String srcFile) { final SourceInfo src = new SourceInfo(); src.setFile(srcFile); addConfiguredSrc(src); @@ -90,59 +87,57 @@ public abstract class AbstractSyncTask /** * Sets the source directory. + * * @param srcDir The source directory. */ - public void setSrcDir(final String srcDir) - { + public void setSrcDir(final String srcDir) { this.srcDirUrl = srcDir; } /** * Sets whether the source directory should be consider as the base directory. + * * @param srcDirIsBase true if the source directory is the base directory. */ - public void setSrcDirIsBase(final boolean srcDirIsBase) - { + public void setSrcDirIsBase(final boolean srcDirIsBase) { this.srcDirIsBase = srcDirIsBase; } /** * Sets whether we should fail if there was an error or not. + * * @param failonerror true if the operation should fail if there is an error. */ - public void setFailonerror(final boolean failonerror) - { + public void setFailonerror(final boolean failonerror) { this.failonerror = failonerror; } /** * Sets whether we should fail if there was an error or not. + * * @return true if the operation should fail if there was an error. */ - public boolean isFailonerror() - { + public boolean isFailonerror() { return failonerror; } /** * Sets the files to includes. + * * @param filesList The list of files to include. */ - public void setIncludes(final String filesList) - { + public void setIncludes(final String filesList) { this.filesList = filesList; } /** * Adds a nested <src> element. + * * @param srcInfo A nested source element. * @throws BuildException if the SourceInfo doesn't reference a file. */ - public void addConfiguredSrc(final SourceInfo srcInfo) - throws BuildException - { - if (srcInfo.file == null) - { + public void addConfiguredSrc(final SourceInfo srcInfo) throws BuildException { + if (srcInfo.file == null) { final String message = Messages.getString("vfs.tasks/sync.no-source-file.error"); throw new BuildException(message); } @@ -151,43 +146,35 @@ public abstract class AbstractSyncTask /** * Executes this task. + * * @throws BuildException if an error occurs. */ @Override - public void execute() throws BuildException - { + public void execute() throws BuildException { // Validate - if (destFileUrl == null && destDirUrl == null) - { - final String message = - Messages.getString("vfs.tasks/sync.no-destination.error"); + if (destFileUrl == null && destDirUrl == null) { + final String message = Messages.getString("vfs.tasks/sync.no-destination.error"); logOrDie(message, Project.MSG_WARN); return; } - if (destFileUrl != null && destDirUrl != null) - { - final String message = - Messages.getString("vfs.tasks/sync.too-many-destinations.error"); + if (destFileUrl != null && destDirUrl != null) { + final String message = Messages.getString("vfs.tasks/sync.too-many-destinations.error"); logOrDie(message, Project.MSG_WARN); return; } // Add the files of the includes attribute to the list - if (srcDirUrl != null && !srcDirUrl.equals(destDirUrl) && filesList != null && filesList.length() > 0) - { - if (!srcDirUrl.endsWith("/")) - { + if (srcDirUrl != null && !srcDirUrl.equals(destDirUrl) && filesList != null && filesList.length() > 0) { + if (!srcDirUrl.endsWith("/")) { srcDirUrl += "/"; } final StringTokenizer tok = new StringTokenizer(filesList, ", \t\n\r\f", false); - while (tok.hasMoreTokens()) - { + while (tok.hasMoreTokens()) { String nextFile = tok.nextToken(); // Basic compatibility with Ant fileset for directories - if (nextFile.endsWith("/**")) - { + if (nextFile.endsWith("/**")) { nextFile = nextFile.substring(0, nextFile.length() - 2); } @@ -197,39 +184,28 @@ public abstract class AbstractSyncTask } } - if (srcFiles.size() == 0) - { + if (srcFiles.size() == 0) { final String message = Messages.getString("vfs.tasks/sync.no-source-files.warn"); logOrDie(message, Project.MSG_WARN); return; } // Perform the sync - try - { - if (destFileUrl != null) - { + try { + if (destFileUrl != null) { handleSingleFile(); - } - else - { + } else { handleFiles(); } - } - catch (final BuildException e) - { + } catch (final BuildException e) { throw e; - } - catch (final Exception e) - { + } catch (final Exception e) { throw new BuildException(e.getMessage(), e); } } - protected void logOrDie(final String message, final int level) - { - if (!isFailonerror()) - { + protected void logOrDie(final String message, final int level) { + if (!isFailonerror()) { log(message, level); return; } @@ -239,83 +215,64 @@ public abstract class AbstractSyncTask /** * Copies the source files to the destination. */ - private void handleFiles() throws Exception - { + private void handleFiles() throws Exception { // Locate the destination folder, and make sure it exists final FileObject destFolder = resolveFile(destDirUrl); destFolder.createFolder(); // Locate the source files, and make sure they exist FileName srcDirName = null; - if (srcDirUrl != null) - { + if (srcDirUrl != null) { srcDirName = resolveFile(srcDirUrl).getName(); } final ArrayList<FileObject> srcs = new ArrayList<>(); - for (int i = 0; i < srcFiles.size(); i++) - { + for (int i = 0; i < srcFiles.size(); i++) { // Locate the source file, and make sure it exists final SourceInfo src = srcFiles.get(i); final FileObject srcFile = resolveFile(src.file); - if (!srcFile.exists()) - { - final String message = - Messages.getString("vfs.tasks/sync.src-file-no-exist.warn", srcFile); + if (!srcFile.exists()) { + final String message = Messages.getString("vfs.tasks/sync.src-file-no-exist.warn", srcFile); logOrDie(message, Project.MSG_WARN); - } - else - { + } else { srcs.add(srcFile); } } // Scan the source files final Set<FileObject> destFiles = new HashSet<>(); - for (int i = 0; i < srcs.size(); i++) - { + for (int i = 0; i < srcs.size(); i++) { final FileObject rootFile = srcs.get(i); final FileName rootName = rootFile.getName(); - if (rootFile.isFile()) - { + if (rootFile.isFile()) { // Build the destination file name String relName = null; - if (srcDirName == null || !srcDirIsBase) - { + if (srcDirName == null || !srcDirIsBase) { relName = rootName.getBaseName(); - } - else - { + } else { relName = srcDirName.getRelativeName(rootName); } final FileObject destFile = destFolder.resolveFile(relName, NameScope.DESCENDENT); // Do the copy handleFile(destFiles, rootFile, destFile); - } - else - { + } else { // Find matching files // If srcDirIsBase is true, select also the sub-directories - final FileObject[] files = rootFile.findFiles(srcDirIsBase - ? Selectors.SELECT_ALL : Selectors.SELECT_FILES); + final FileObject[] files = rootFile + .findFiles(srcDirIsBase ? Selectors.SELECT_ALL : Selectors.SELECT_FILES); - for (final FileObject srcFile : files) - { + for (final FileObject srcFile : files) { // Build the destination file name String relName = null; - if (srcDirName == null || !srcDirIsBase) - { + if (srcDirName == null || !srcDirIsBase) { relName = rootName.getRelativeName(srcFile.getName()); - } - else - { + } else { relName = srcDirName.getRelativeName(srcFile.getName()); } - final FileObject destFile = - destFolder.resolveFile(relName, NameScope.DESCENDENT); + final FileObject destFile = destFolder.resolveFile(relName, NameScope.DESCENDENT); // Do the copy handleFile(destFiles, srcFile, destFile); @@ -324,13 +281,10 @@ public abstract class AbstractSyncTask } // Scan the destination files for files with no source file - if (detectMissingSourceFiles()) - { + if (detectMissingSourceFiles()) { final FileObject[] allDestFiles = destFolder.findFiles(Selectors.SELECT_FILES); - for (final FileObject destFile : allDestFiles) - { - if (!destFiles.contains(destFile)) - { + for (final FileObject destFile : allDestFiles) { + if (!destFiles.contains(destFile)) { handleMissingSourceFile(destFile); } } @@ -338,22 +292,17 @@ public abstract class AbstractSyncTask } /** - * Handles a single file, checking for collisions where more than one - * source file maps to the same destination file. + * Handles a single file, checking for collisions where more than one source file maps to the same destination file. */ - private void handleFile(final Set<FileObject> destFiles, - final FileObject srcFile, - final FileObject destFile) throws Exception + private void handleFile(final Set<FileObject> destFiles, final FileObject srcFile, final FileObject destFile) + throws Exception { // Check for duplicate source files - if (destFiles.contains(destFile)) - { + if (destFiles.contains(destFile)) { final String message = Messages.getString("vfs.tasks/sync.duplicate-source-files.warn", destFile); logOrDie(message, Project.MSG_WARN); - } - else - { + } else { destFiles.add(destFile); } @@ -364,23 +313,18 @@ public abstract class AbstractSyncTask /** * Copies a single file. */ - private void handleSingleFile() throws Exception - { + private void handleSingleFile() throws Exception { // Make sure there is exactly one source file, and that it exists // and is a file. - if (srcFiles.size() > 1) - { - final String message = - Messages.getString("vfs.tasks/sync.too-many-source-files.error"); + if (srcFiles.size() > 1) { + final String message = Messages.getString("vfs.tasks/sync.too-many-source-files.error"); logOrDie(message, Project.MSG_WARN); return; } final SourceInfo src = srcFiles.get(0); final FileObject srcFile = resolveFile(src.file); - if (!srcFile.isFile()) - { - final String message = - Messages.getString("vfs.tasks/sync.source-not-file.error", srcFile); + if (!srcFile.isFile()) { + final String message = Messages.getString("vfs.tasks/sync.source-not-file.error", srcFile); logOrDie(message, Project.MSG_WARN); return; } @@ -395,18 +339,12 @@ public abstract class AbstractSyncTask /** * Handles a single source file. */ - private void handleFile(final FileObject srcFile, - final FileObject destFile) - throws Exception - { + private void handleFile(final FileObject srcFile, final FileObject destFile) throws Exception { if (!destFile.exists() - || srcFile.getContent().getLastModifiedTime() > destFile.getContent().getLastModifiedTime()) - { + || srcFile.getContent().getLastModifiedTime() > destFile.getContent().getLastModifiedTime()) { // Destination file is out-of-date handleOutOfDateFile(srcFile, destFile); - } - else - { + } else { // Destination file is up-to-date handleUpToDateFile(srcFile, destFile); } @@ -415,8 +353,7 @@ public abstract class AbstractSyncTask /** * Handles an out-of-date file. * <p> - * This is a file where the destination file - * either doesn't exist, or is older than the source file. + * This is a file where the destination file either doesn't exist, or is older than the source file. * <p> * This implementation does nothing. * @@ -424,17 +361,13 @@ public abstract class AbstractSyncTask * @param destFile The destination file. * @throws Exception Implementation can throw any Exception. */ - protected void handleOutOfDateFile(final FileObject srcFile, - final FileObject destFile) - throws Exception - { + protected void handleOutOfDateFile(final FileObject srcFile, final FileObject destFile) throws Exception { } /** * Handles an up-to-date file. * <p> - * This is where the destination file exists and is - * newer than the source file. + * This is where the destination file exists and is newer than the source file. * <p> * This implementation does nothing. * @@ -442,10 +375,7 @@ public abstract class AbstractSyncTask * @param destFile The destination file. * @throws Exception Implementation can throw any Exception. */ - protected void handleUpToDateFile(final FileObject srcFile, - final FileObject destFile) - throws Exception - { + protected void handleUpToDateFile(final FileObject srcFile, final FileObject destFile) throws Exception { } /** @@ -456,33 +386,27 @@ public abstract class AbstractSyncTask * @param destFile The existing destination file. * @throws Exception Implementation can throw any Exception. */ - protected void handleMissingSourceFile(final FileObject destFile) - throws Exception - { + protected void handleMissingSourceFile(final FileObject destFile) throws Exception { } /** - * Check if this task cares about destination files with a missing source - * file. + * Check if this task cares about destination files with a missing source file. * <p> * This implementation returns false. * * @return True if missing file is detected. */ - protected boolean detectMissingSourceFiles() - { + protected boolean detectMissingSourceFiles() { return false; } /** * Information about a source file. */ - public static class SourceInfo - { + public static class SourceInfo { private String file; - public void setFile(final String file) - { + public void setFile(final String file) { this.file = file; } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/CopyTask.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/CopyTask.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/CopyTask.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/CopyTask.java Thu Sep 14 19:26:39 2017 @@ -26,62 +26,54 @@ import org.apache.commons.vfs2.Selectors * <p> * TODO - Copy folders that do not contain files. */ -public class CopyTask - extends AbstractSyncTask -{ +public class CopyTask extends AbstractSyncTask { private boolean overwrite; private boolean preserveLastModified = true; /** * Enable/disable overwriting of up-to-date files. + * * @param overwrite true if the file should be overwritten. */ - public void setOverwrite(final boolean overwrite) - { + public void setOverwrite(final boolean overwrite) { this.overwrite = overwrite; } /** * Enable/disable preserving last modified time of copied files. + * * @param preserveLastModified true if the last modified time should be preserved. */ - public void setPreserveLastModified(final boolean preserveLastModified) - { + public void setPreserveLastModified(final boolean preserveLastModified) { this.preserveLastModified = preserveLastModified; } /** * @return the current value of overwrite */ - public boolean isOverwrite() - { + public boolean isOverwrite() { return overwrite; } /** * @return the current value of preserveLastModified */ - public boolean isPreserveLastModified() - { + public boolean isPreserveLastModified() { return preserveLastModified; } /** * Handles an out-of-date file. + * * @param srcFile The source FileObject. * @param destFile The destination FileObject. */ @Override - protected void handleOutOfDateFile(final FileObject srcFile, - final FileObject destFile) - throws FileSystemException - { + protected void handleOutOfDateFile(final FileObject srcFile, final FileObject destFile) throws FileSystemException { log("Copying " + srcFile.getPublicURIString() + " to " + destFile.getPublicURIString()); destFile.copyFrom(srcFile, Selectors.SELECT_SELF); - if (preserveLastModified - && srcFile.getFileSystem().hasCapability(Capability.GET_LAST_MODIFIED) - && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE)) - { + if (preserveLastModified && srcFile.getFileSystem().hasCapability(Capability.GET_LAST_MODIFIED) + && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE)) { final long lastModTime = srcFile.getContent().getLastModifiedTime(); destFile.getContent().setLastModifiedTime(lastModTime); } @@ -89,16 +81,13 @@ public class CopyTask /** * Handles an up-to-date file. + * * @param srcFile The source FileObject. * @param destFile The destination FileObject. */ @Override - protected void handleUpToDateFile(final FileObject srcFile, - final FileObject destFile) - throws FileSystemException - { - if (overwrite) - { + protected void handleUpToDateFile(final FileObject srcFile, final FileObject destFile) throws FileSystemException { + if (overwrite) { // Copy the file anyway handleOutOfDateFile(srcFile, destFile); } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/DeleteTask.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/DeleteTask.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/DeleteTask.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/DeleteTask.java Thu Sep 14 19:26:39 2017 @@ -27,9 +27,7 @@ import org.apache.tools.ant.BuildExcepti * <p> * TOOD - Allow selector to be specified. */ -public class DeleteTask - extends VfsTask -{ +public class DeleteTask extends VfsTask { private String file; private String srcDirUrl; private String filesList; @@ -39,68 +37,58 @@ public class DeleteTask * * @param file The name of the file. */ - public void setFile(final String file) - { + public void setFile(final String file) { this.file = file; } /** * Sets the source directory. + * * @param srcDir The source directory. */ - public void setSrcDir(final String srcDir) - { + public void setSrcDir(final String srcDir) { this.srcDirUrl = srcDir; } /** * Sets the files to include. + * * @param filesList The list of files. */ - public void setIncludes(final String filesList) - { + public void setIncludes(final String filesList) { this.filesList = filesList; } /** * Executes this task. + * * @throws BuildException if an error occurs. */ @Override - public void execute() throws BuildException - { - if ((file == null && srcDirUrl == null) || (srcDirUrl != null && filesList == null)) - { + public void execute() throws BuildException { + if ((file == null && srcDirUrl == null) || (srcDirUrl != null && filesList == null)) { final String message = Messages.getString("vfs.tasks/delete.no-source-files.error"); throw new BuildException(message); } - try - { - if (srcDirUrl != null && filesList != null) - { + try { + if (srcDirUrl != null && filesList != null) { log("Deleting " + filesList + " in the directory " + srcDirUrl); - if (!srcDirUrl.endsWith("/")) - { + if (!srcDirUrl.endsWith("/")) { srcDirUrl += "/"; } final StringTokenizer tok = new StringTokenizer(filesList, ", \t\n\r\f", false); - while (tok.hasMoreTokens()) - { + while (tok.hasMoreTokens()) { final String nextFile = tok.nextToken(); final FileObject srcFile = resolveFile(srcDirUrl + nextFile); srcFile.deleteAll(); } - } - else - { + } else { final FileObject srcFile = resolveFile(file); log("Deleting " + srcFile.getPublicURIString()); srcFile.deleteAll(); } - } - catch (final Exception e) - { + } catch (final Exception e) { throw new BuildException(e); } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/MkdirTask.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/MkdirTask.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/MkdirTask.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/MkdirTask.java Thu Sep 14 19:26:39 2017 @@ -24,9 +24,7 @@ import org.apache.tools.ant.BuildExcepti /** * An Ant task that creates a directory. */ -public class MkdirTask - extends VfsTask -{ +public class MkdirTask extends VfsTask { private String dirName; /** @@ -34,33 +32,28 @@ public class MkdirTask * * @param dir The directory name. */ - public void setDir(final String dir) - { + public void setDir(final String dir) { dirName = dir; } /** * Executes the task. + * * @throws BuildException if an exception occurs. */ @Override - public void execute() throws BuildException - { - if (dirName == null) - { + public void execute() throws BuildException { + if (dirName == null) { final String message = Messages.getString("vfs.tasks/no-directory-specified.error"); throw new BuildException(message); } - try - { + try { final FileObject dir = resolveFile(dirName); final String message = Messages.getString("vfs.tasks/mkdir.create-folder.info", dir); log(message); dir.createFolder(); - } - catch (final FileSystemException e) - { + } catch (final FileSystemException e) { throw new BuildException(e); } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/MoveTask.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/MoveTask.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/MoveTask.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/MoveTask.java Thu Sep 14 19:26:39 2017 @@ -26,17 +26,15 @@ import org.apache.commons.vfs2.Selectors * <p> * TODO - Delete matching folders. */ -public class MoveTask - extends CopyTask -{ +public class MoveTask extends CopyTask { private boolean tryRename; /** * Enable/disable move/rename of file (if possible). + * * @param tryRename true if the file should be renamed. */ - public void setTryRename(final boolean tryRename) - { + public void setTryRename(final boolean tryRename) { this.tryRename = tryRename; } @@ -44,24 +42,17 @@ public class MoveTask * Handles a single source file. */ @Override - protected void handleOutOfDateFile(final FileObject srcFile, - final FileObject destFile) - throws FileSystemException - { - if (!tryRename || !srcFile.canRenameTo(destFile)) - { + protected void handleOutOfDateFile(final FileObject srcFile, final FileObject destFile) throws FileSystemException { + if (!tryRename || !srcFile.canRenameTo(destFile)) { super.handleOutOfDateFile(srcFile, destFile); log("Deleting " + srcFile.getPublicURIString()); srcFile.delete(Selectors.SELECT_SELF); - } - else - { + } else { log("Rename " + srcFile.getPublicURIString() + " to " + destFile.getPublicURIString()); srcFile.moveTo(destFile); if (!isPreserveLastModified() - && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE)) - { + && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE)) { destFile.getContent().setLastModifiedTime(System.currentTimeMillis()); } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/ShowFileTask.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/ShowFileTask.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/ShowFileTask.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/ShowFileTask.java Thu Sep 14 19:26:39 2017 @@ -28,58 +28,51 @@ import org.apache.tools.ant.BuildExcepti /** * An Ant task that writes the details of a file to Ant's log. */ -public class ShowFileTask - extends VfsTask -{ +public class ShowFileTask extends VfsTask { private static final String INDENT = " "; private String url; private boolean showContent; private boolean recursive; - /** * The URL of the file to display. + * * @param url The url of the file. */ - public void setFile(final String url) - { + public void setFile(final String url) { this.url = url; } /** - * Shows the content. Assumes the content is text, encoded using the - * platform's default encoding. + * Shows the content. Assumes the content is text, encoded using the platform's default encoding. + * * @param showContent true if the content should be shown. */ - public void setShowContent(final boolean showContent) - { + public void setShowContent(final boolean showContent) { this.showContent = showContent; } /** * Recursively shows the descendants of the file. + * * @param recursive true if descendants should be shown. */ - public void setRecursive(final boolean recursive) - { + public void setRecursive(final boolean recursive) { this.recursive = recursive; } /** * Executes the task. + * * @throws BuildException if any exception is thrown. */ @Override - public void execute() throws BuildException - { - try - { + public void execute() throws BuildException { + try { final FileObject file = resolveFile(url); log("Details of " + file.getPublicURIString()); showFile(file, INDENT); - } - catch (final Exception e) - { + } catch (final Exception e) { throw new BuildException(e); } } @@ -87,48 +80,36 @@ public class ShowFileTask /** * Logs the details of a file. */ - private void showFile(final FileObject file, final String prefix) throws Exception - { + private void showFile(final FileObject file, final String prefix) throws Exception { // Write details final StringBuilder msg = new StringBuilder(prefix); msg.append(file.getName().getBaseName()); - if (file.exists()) - { + if (file.exists()) { msg.append(" ("); msg.append(file.getType().getName()); msg.append(")"); - } - else - { + } else { msg.append(" (unknown)"); } log(msg.toString()); - if (file.exists()) - { + if (file.exists()) { final String newPrefix = prefix + INDENT; - if (file.getType().hasContent()) - { + if (file.getType().hasContent()) { final FileContent content = file.getContent(); log(newPrefix + "Content-Length: " + content.getSize()); log(newPrefix + "Last-Modified" + new Date(content.getLastModifiedTime())); - if (showContent) - { + if (showContent) { log(newPrefix + "Content:"); logContent(file, newPrefix); } } - if (file.getType().hasChildren()) - { + if (file.getType().hasChildren()) { final FileObject[] children = file.getChildren(); - for (final FileObject child : children) - { - if (recursive) - { + for (final FileObject child : children) { + if (recursive) { showFile(child, newPrefix); - } - else - { + } else { log(newPrefix + child.getName().getBaseName()); } } @@ -139,25 +120,18 @@ public class ShowFileTask /** * Writes the content of the file to Ant log. */ - private void logContent(final FileObject file, final String prefix) - throws Exception - { + private void logContent(final FileObject file, final String prefix) throws Exception { final InputStream instr = file.getContent().getInputStream(); - try - { + try { final BufferedReader reader = new BufferedReader(new InputStreamReader(instr)); - while (true) - { + while (true) { final String line = reader.readLine(); - if (line == null) - { + if (line == null) { break; } log(prefix + line); } - } - finally - { + } finally { instr.close(); } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/SyncTask.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/SyncTask.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/SyncTask.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/SyncTask.java Thu Sep 14 19:26:39 2017 @@ -19,30 +19,23 @@ package org.apache.commons.vfs2.tasks; import org.apache.commons.vfs2.FileObject; /** - * A task that synchronises the destination folder to look exactly like - * the source folder (or folders). + * A task that synchronises the destination folder to look exactly like the source folder (or folders). */ -public class SyncTask - extends CopyTask -{ +public class SyncTask extends CopyTask { /** * Handles a destination for which there is no corresponding source file. */ @Override - protected void handleMissingSourceFile(final FileObject destFile) - throws Exception - { + protected void handleMissingSourceFile(final FileObject destFile) throws Exception { log("deleting " + destFile.getPublicURIString()); - //destFile.delete( Selectors.SELECT_SELF ); + // destFile.delete( Selectors.SELECT_SELF ); } /** - * Check if this task cares about destination files with a missing source - * file. + * Check if this task cares about destination files with a missing source file. */ @Override - protected boolean detectMissingSourceFiles() - { + protected boolean detectMissingSourceFiles() { return true; } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/VfsTask.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/VfsTask.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/VfsTask.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/tasks/VfsTask.java Thu Sep 14 19:26:39 2017 @@ -26,13 +26,10 @@ import org.apache.tools.ant.SubBuildList import org.apache.tools.ant.Task; /** - * Base class for the VFS Ant tasks. Takes care of creating a FileSystemManager, - * and for cleaning it up at the end of the build. Also provides some - * utility methods. + * Base class for the VFS Ant tasks. Takes care of creating a FileSystemManager, and for cleaning it up at the end of + * the build. Also provides some utility methods. */ -public class VfsTask - extends Task -{ +public class VfsTask extends Task { private static StandardFileSystemManager manager; /** @@ -42,11 +39,8 @@ public class VfsTask * @return resolved file object. * @throws FileSystemException If an error occurred. */ - protected FileObject resolveFile(final String uri) - throws FileSystemException - { - if (manager == null) - { + protected FileObject resolveFile(final String uri) throws FileSystemException { + if (manager == null) { final StandardFileSystemManager mngr = new StandardFileSystemManager(); mngr.setLogger(new AntLogger()); mngr.init(); @@ -59,10 +53,8 @@ public class VfsTask /** * Close the manager */ - protected void closeManager() - { - if (manager != null) - { + protected void closeManager() { + if (manager != null) { manager.close(); manager = null; } @@ -71,166 +63,135 @@ public class VfsTask /** * Closes the VFS manager when the project finishes. */ - private class CloseListener - implements SubBuildListener - { + private class CloseListener implements SubBuildListener { @Override - public void subBuildStarted(final BuildEvent buildEvent) - { + public void subBuildStarted(final BuildEvent buildEvent) { } @Override - public void subBuildFinished(final BuildEvent buildEvent) - { + public void subBuildFinished(final BuildEvent buildEvent) { closeManager(); } @Override - public void buildFinished(final BuildEvent event) - { + public void buildFinished(final BuildEvent event) { closeManager(); } @Override - public void buildStarted(final BuildEvent event) - { + public void buildStarted(final BuildEvent event) { } @Override - public void messageLogged(final BuildEvent event) - { + public void messageLogged(final BuildEvent event) { } @Override - public void targetFinished(final BuildEvent event) - { + public void targetFinished(final BuildEvent event) { } @Override - public void targetStarted(final BuildEvent event) - { + public void targetStarted(final BuildEvent event) { } @Override - public void taskFinished(final BuildEvent event) - { + public void taskFinished(final BuildEvent event) { } @Override - public void taskStarted(final BuildEvent event) - { + public void taskStarted(final BuildEvent event) { } } /** * A commons-logging wrapper for Ant logging. */ - private class AntLogger - implements Log - { + private class AntLogger implements Log { @Override - public void debug(final Object o) - { + public void debug(final Object o) { log(String.valueOf(o), Project.MSG_DEBUG); } @Override - public void debug(final Object o, final Throwable throwable) - { + public void debug(final Object o, final Throwable throwable) { debug(o); } @Override - public void error(final Object o) - { + public void error(final Object o) { log(String.valueOf(o), Project.MSG_ERR); } @Override - public void error(final Object o, final Throwable throwable) - { + public void error(final Object o, final Throwable throwable) { error(o); } @Override - public void fatal(final Object o) - { + public void fatal(final Object o) { log(String.valueOf(o), Project.MSG_ERR); } @Override - public void fatal(final Object o, final Throwable throwable) - { + public void fatal(final Object o, final Throwable throwable) { fatal(o); } @Override - public void info(final Object o) - { + public void info(final Object o) { log(String.valueOf(o), Project.MSG_INFO); } @Override - public void info(final Object o, final Throwable throwable) - { + public void info(final Object o, final Throwable throwable) { info(o); } @Override - public void trace(final Object o) - { + public void trace(final Object o) { } @Override - public void trace(final Object o, final Throwable throwable) - { + public void trace(final Object o, final Throwable throwable) { } @Override - public void warn(final Object o) - { + public void warn(final Object o) { log(String.valueOf(o), Project.MSG_WARN); } @Override - public void warn(final Object o, final Throwable throwable) - { + public void warn(final Object o, final Throwable throwable) { warn(o); } @Override - public boolean isDebugEnabled() - { + public boolean isDebugEnabled() { return true; } @Override - public boolean isErrorEnabled() - { + public boolean isErrorEnabled() { return true; } @Override - public boolean isFatalEnabled() - { + public boolean isFatalEnabled() { return true; } @Override - public boolean isInfoEnabled() - { + public boolean isInfoEnabled() { return true; } @Override - public boolean isTraceEnabled() - { + public boolean isTraceEnabled() { return false; } @Override - public boolean isWarnEnabled() - { + public boolean isWarnEnabled() { return true; } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/CombinedResources.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/CombinedResources.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/CombinedResources.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/CombinedResources.java Thu Sep 14 19:26:39 2017 @@ -26,8 +26,7 @@ import java.util.ResourceBundle; /** * @since 2.0 */ -public class CombinedResources extends ResourceBundle -{ +public class CombinedResources extends ResourceBundle { // locale.getLanguage() // locale.getCountry() // locale.getVariant() @@ -36,15 +35,12 @@ public class CombinedResources extends R private boolean inited; private final Properties properties = new Properties(); - public CombinedResources(final String resourceName) - { + public CombinedResources(final String resourceName) { this.resourceName = resourceName; } - protected void init() - { - if (inited) - { + protected void init() { + if (inited) { return; } @@ -54,23 +50,18 @@ public class CombinedResources extends R inited = true; } - protected void loadResources(final Locale locale) - { - if (locale == null) - { + protected void loadResources(final Locale locale) { + if (locale == null) { return; } - final String[] parts = new String[]{locale.getLanguage(), locale.getCountry(), locale.getVariant()}; + final String[] parts = new String[] { locale.getLanguage(), locale.getCountry(), locale.getVariant() }; final StringBuilder sb = new StringBuilder(); - for (int i = 0; i < 3; i++) - { + for (int i = 0; i < 3; i++) { sb.append(getResourceName()); - for (int j = 0; j < i; j++) - { + for (int j = 0; j < i; j++) { sb.append('_').append(parts[j]); } - if (parts[i].length() != 0) - { + if (parts[i].length() != 0) { sb.append('_').append(parts[i]); loadResources(sb.toString()); } @@ -78,58 +69,44 @@ public class CombinedResources extends R } } - protected void loadResources(String resourceName) - { + protected void loadResources(String resourceName) { ClassLoader loader = getClass().getClassLoader(); - if (loader == null) - { + if (loader == null) { loader = ClassLoader.getSystemClassLoader(); } resourceName = resourceName.replace('.', '/') + ".properties"; - try - { + try { final Enumeration<URL> resources = loader.getResources(resourceName); - while (resources.hasMoreElements()) - { + while (resources.hasMoreElements()) { final URL resource = resources.nextElement(); - try - { + try { properties.load(resource.openConnection().getInputStream()); - } - catch (final IOException ignored) - { + } catch (final IOException ignored) { /* Ignored. */ } } - } - catch (final IOException ignored) - { + } catch (final IOException ignored) { /* Ignored. */ } } - public String getResourceName() - { + public String getResourceName() { return resourceName; } @Override - public Enumeration<String> getKeys() - { - if (!inited) - { + public Enumeration<String> getKeys() { + if (!inited) { init(); } - return new Enumeration<String>() - { + return new Enumeration<String>() { @Override - public boolean hasMoreElements() - { + public boolean hasMoreElements() { return properties.keys().hasMoreElements(); } + @Override - public String nextElement() - { + public String nextElement() { // We know that our properties will only ever contain Strings return (String) properties.keys().nextElement(); } @@ -138,10 +115,8 @@ public class CombinedResources extends R } @Override - protected Object handleGetObject(final String key) - { - if (!inited) - { + protected Object handleGetObject(final String key) { + if (!inited) { init(); } return properties.get(key); Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Cryptor.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Cryptor.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Cryptor.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Cryptor.java Thu Sep 14 19:26:39 2017 @@ -19,10 +19,10 @@ package org.apache.commons.vfs2.util; /** * @since 2.0 */ -public interface Cryptor -{ +public interface Cryptor { /** * Encrypt the plain text password. + * * @param plainKey The password. * @return The encrypted password String. * @throws Exception If an error occurs. @@ -31,6 +31,7 @@ public interface Cryptor /** * Decrypts the password. + * * @param encryptedKey the encrypted password. * @return The plain text password. * @throws Exception If an error occurs. Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/CryptorFactory.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/CryptorFactory.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/CryptorFactory.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/CryptorFactory.java Thu Sep 14 19:26:39 2017 @@ -18,10 +18,10 @@ package org.apache.commons.vfs2.util; /** * Factory to create an instance of a Cryptor. + * * @since 2.0 */ -public final class CryptorFactory -{ +public final class CryptorFactory { /** * The System property name to identify the Cryptor class to be used. */ @@ -32,44 +32,37 @@ public final class CryptorFactory /** * Prevent instantiation of the class. */ - private CryptorFactory() - { + private CryptorFactory() { } /** * Allows the Cryptor class to be set programmatically. + * * @param cryptor The Cryptor. */ - public static synchronized void setCryptor(final Cryptor cryptor) - { + public static synchronized void setCryptor(final Cryptor cryptor) { instance = cryptor; } /** - * Return the Cryptor. If one has not been previously set, create it. The Cryptor class - * can be set by setting the "org.apache.commons.vfs2.cryptor" System property to the - * name of the Cryptor class. + * Return the Cryptor. If one has not been previously set, create it. The Cryptor class can be set by setting the + * "org.apache.commons.vfs2.cryptor" System property to the name of the Cryptor class. + * * @return The Cryptor. */ - public static synchronized Cryptor getCryptor() - { - if (instance != null) - { + public static synchronized Cryptor getCryptor() { + if (instance != null) { return instance; } final String cryptorClass = System.getProperty(CRYPTOR_CLASS); - if (cryptorClass != null) - { - try - { + if (cryptorClass != null) { + try { final Class<?> clazz = Class.forName(cryptorClass); instance = (Cryptor) clazz.newInstance(); return instance; - } - catch (final Exception ex) - { + } catch (final Exception ex) { throw new RuntimeException("Unable to create Cryptor " + cryptorClass, ex); } } Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/DefaultCryptor.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/DefaultCryptor.java?rev=1808381&r1=1808380&r2=1808381&view=diff ============================================================================== --- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/DefaultCryptor.java (original) +++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/DefaultCryptor.java Thu Sep 14 19:26:39 2017 @@ -22,18 +22,17 @@ import javax.crypto.spec.SecretKeySpec; /** * Allows passwords to be encrypted and decrypted. * <p> - * Warning: This uses AES128 with a fixed encryption key. - * This is only an obfuscation no cryptographic secure protection. + * Warning: This uses AES128 with a fixed encryption key. This is only an obfuscation no cryptographic secure + * protection. * * @since 2.0 */ -public class DefaultCryptor implements Cryptor -{ - private static final char[] HEX_CHARS = - {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; +public class DefaultCryptor implements Cryptor { + private static final char[] HEX_CHARS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', + 'F' }; - private static final byte[] KEY_BYTES = {0x41, 0x70, 0x61, 0x63, 0x68, 0x65, 0x43, 0x6F, 0x6D, 0x6D, - 0x6F, 0x6E, 0x73, 0x56, 0x46, 0x53}; + private static final byte[] KEY_BYTES = { 0x41, 0x70, 0x61, 0x63, 0x68, 0x65, 0x43, 0x6F, 0x6D, 0x6D, 0x6F, 0x6E, + 0x73, 0x56, 0x46, 0x53 }; private static final int INDEX_NOT_FOUND = -1; @@ -44,16 +43,15 @@ public class DefaultCryptor implements C /** * Encrypt the plain text password. * <p> - * Warning: This uses AES128 with a fixed encryption key. - * This is only an obfuscation no cryptographic secure protection. + * Warning: This uses AES128 with a fixed encryption key. This is only an obfuscation no cryptographic secure + * protection. * * @param plainKey The password. * @return The encrypted password String. * @throws Exception If an error occurs. */ @Override - public String encrypt(final String plainKey) throws Exception - { + public String encrypt(final String plainKey) throws Exception { final byte[] input = plainKey.getBytes(); final SecretKeySpec key = new SecretKeySpec(KEY_BYTES, "AES"); @@ -70,13 +68,13 @@ public class DefaultCryptor implements C /** * Decrypts the password. + * * @param encryptedKey the encrypted password. * @return The plain text password. * @throws Exception If an error occurs. */ @Override - public String decrypt(final String encryptedKey) throws Exception - { + public String decrypt(final String encryptedKey) throws Exception { final SecretKeySpec key = new SecretKeySpec(KEY_BYTES, "AES"); final Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, key); @@ -88,12 +86,10 @@ public class DefaultCryptor implements C } /** Hex-encode bytes. */ - private String encode(final byte[] bytes) - { + private String encode(final byte[] bytes) { final StringBuilder builder = new StringBuilder(); - for (final byte b : bytes) - { + for (final byte b : bytes) { builder.append(HEX_CHARS[(b >> BITS_IN_HALF_BYTE) & MASK]); builder.append(HEX_CHARS[b & MASK]); } @@ -101,41 +97,33 @@ public class DefaultCryptor implements C } /** Decodes Hey-Bytes. */ - private byte[] decode(final String str) - { + private byte[] decode(final String str) { final int length = str.length() / 2; final byte[] decoded = new byte[length]; final char[] chars = str.toCharArray(); int index = 0; - for (int i = 0; i < chars.length; ++i) - { + for (int i = 0; i < chars.length; ++i) { final int id1 = indexOf(HEX_CHARS, chars[i]); - if (id1 == -1) - { - throw new IllegalArgumentException("Character " + chars[i] + " at position " + i - + " is not a valid hexidecimal character"); + if (id1 == -1) { + throw new IllegalArgumentException( + "Character " + chars[i] + " at position " + i + " is not a valid hexidecimal character"); } final int id2 = indexOf(HEX_CHARS, chars[++i]); - if (id2 == -1) - { - throw new IllegalArgumentException("Character " + chars[i] + " at position " + i - + " is not a valid hexidecimal character"); + if (id2 == -1) { + throw new IllegalArgumentException( + "Character " + chars[i] + " at position " + i + " is not a valid hexidecimal character"); } decoded[index++] = (byte) ((id1 << BITS_IN_HALF_BYTE) | id2); } return decoded; } - private int indexOf(final char[] array, final char valueToFind) - { - if (array == null) - { + private int indexOf(final char[] array, final char valueToFind) { + if (array == null) { return INDEX_NOT_FOUND; } - for (int i = 0; i < array.length; i++) - { - if (valueToFind == array[i]) - { + for (int i = 0; i < array.length; i++) { + if (valueToFind == array[i]) { return i; } }
