commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1024089 [2/2] - in /commons/proper/vfs/trunk: core/src/main/java/org/apache/commons/vfs/provider/ftp/ core/src/main/java/org/apache/commons/vfs/provider/ftps/ core/src/main/java/org/apache/commons/vfs/provider/sftp/ core/src/test/java/org/...
Date Tue, 19 Oct 2010 01:59:40 GMT
Modified: commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/smb/SmbFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/smb/SmbFileObject.java?rev=1024089&r1=1024088&r2=1024089&view=diff
==============================================================================
--- commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/smb/SmbFileObject.java
(original)
+++ commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/smb/SmbFileObject.java
Tue Oct 19 01:59:39 2010
@@ -75,43 +75,43 @@ public class SmbFileObject
 
         String path = smbFileName.getUriWithoutAuth();
 
-		UserAuthenticationData authData = null;
-		SmbFile file;
-		NtlmPasswordAuthentication auth;
-		try
-		{
-			authData = UserAuthenticatorUtils.authenticate(getFileSystem().getFileSystemOptions(),
SmbFileProvider.AUTHENTICATOR_TYPES);
-
-			auth = new NtlmPasswordAuthentication(
-				UserAuthenticatorUtils.toString(
-					UserAuthenticatorUtils.getData(
-						authData,
-						UserAuthenticationData.DOMAIN,
-						UserAuthenticatorUtils.toChar(smbFileName.getDomain()))),
-				UserAuthenticatorUtils.toString(
-					UserAuthenticatorUtils.getData(
-						authData,
-						UserAuthenticationData.USERNAME,
-						UserAuthenticatorUtils.toChar(smbFileName.getUserName()))),
-				UserAuthenticatorUtils.toString(
-					UserAuthenticatorUtils.getData(
-						authData,
-						UserAuthenticationData.PASSWORD,
-						UserAuthenticatorUtils.toChar(smbFileName.getPassword()))));
-
-			file = new SmbFile(path, auth);
-		}
-		finally
-		{
-			UserAuthenticatorUtils.cleanup(authData);
-		}
-
-		if (file.isDirectory() && !file.toString().endsWith("/"))
-		{
-			file = new SmbFile(path + "/", auth);
-		}
+        UserAuthenticationData authData = null;
+        SmbFile file;
+        NtlmPasswordAuthentication auth;
+        try
+        {
+            authData = UserAuthenticatorUtils.authenticate(getFileSystem().getFileSystemOptions(),
SmbFileProvider.AUTHENTICATOR_TYPES);
+
+            auth = new NtlmPasswordAuthentication(
+                UserAuthenticatorUtils.toString(
+                    UserAuthenticatorUtils.getData(
+                        authData,
+                        UserAuthenticationData.DOMAIN,
+                        UserAuthenticatorUtils.toChar(smbFileName.getDomain()))),
+                UserAuthenticatorUtils.toString(
+                    UserAuthenticatorUtils.getData(
+                        authData,
+                        UserAuthenticationData.USERNAME,
+                        UserAuthenticatorUtils.toChar(smbFileName.getUserName()))),
+                UserAuthenticatorUtils.toString(
+                    UserAuthenticatorUtils.getData(
+                        authData,
+                        UserAuthenticationData.PASSWORD,
+                        UserAuthenticatorUtils.toChar(smbFileName.getPassword()))));
+
+            file = new SmbFile(path, auth);
+        }
+        finally
+        {
+            UserAuthenticatorUtils.cleanup(authData);
+        }
+
+        if (file.isDirectory() && !file.toString().endsWith("/"))
+        {
+            file = new SmbFile(path + "/", auth);
+        }
 
-		return file;
+        return file;
     }
 
     /**

Modified: commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/smb/SmbFileProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/smb/SmbFileProvider.java?rev=1024089&r1=1024088&r2=1024089&view=diff
==============================================================================
--- commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/smb/SmbFileProvider.java
(original)
+++ commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/smb/SmbFileProvider.java
Tue Oct 19 01:59:39 2010
@@ -55,12 +55,12 @@ public class SmbFileProvider
         Capability.RANDOM_ACCESS_WRITE
     }));
 
-	public final static UserAuthenticationData.Type[] AUTHENTICATOR_TYPES = new UserAuthenticationData.Type[]
-		{
-			UserAuthenticationData.USERNAME, UserAuthenticationData.PASSWORD, UserAuthenticationData.DOMAIN
-		};
+    public final static UserAuthenticationData.Type[] AUTHENTICATOR_TYPES = new UserAuthenticationData.Type[]
+        {
+            UserAuthenticationData.USERNAME, UserAuthenticationData.PASSWORD, UserAuthenticationData.DOMAIN
+        };
 
-	public SmbFileProvider()
+    public SmbFileProvider()
     {
         super();
         setFileNameParser(SmbFileNameParser.getInstance());

Modified: commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/smb/SmbFileRandomAccessContent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/smb/SmbFileRandomAccessContent.java?rev=1024089&r1=1024088&r2=1024089&view=diff
==============================================================================
--- commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/smb/SmbFileRandomAccessContent.java
(original)
+++ commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/smb/SmbFileRandomAccessContent.java
Tue Oct 19 01:59:39 2010
@@ -74,16 +74,16 @@ class SmbFileRandomAccessContent extends
                     return raf.read(b, off, len);
                 }
 
-				public int available() throws IOException
-				{
-					long available = raf.length() - raf.getFilePointer();
-					if (available > Integer.MAX_VALUE)
-					{
-						return Integer.MAX_VALUE;
-					}
+                public int available() throws IOException
+                {
+                    long available = raf.length() - raf.getFilePointer();
+                    if (available > Integer.MAX_VALUE)
+                    {
+                        return Integer.MAX_VALUE;
+                    }
 
-					return (int) available;
-				}
+                    return (int) available;
+                }
             };
         }
         catch (MalformedURLException e)

Modified: commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/util/FileObjectDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/util/FileObjectDataSource.java?rev=1024089&r1=1024088&r2=1024089&view=diff
==============================================================================
--- commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/util/FileObjectDataSource.java
(original)
+++ commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/util/FileObjectDataSource.java
Tue Oct 19 01:59:39 2010
@@ -29,37 +29,37 @@ import java.io.OutputStream;
  */
 public class FileObjectDataSource implements DataSource
 {
-	private final FileObject fo;
+    private final FileObject fo;
 
-	public FileObjectDataSource(FileObject fo)
-	{
-		this.fo = fo;
-	}
+    public FileObjectDataSource(FileObject fo)
+    {
+        this.fo = fo;
+    }
 
-	public InputStream getInputStream() throws IOException
-	{
-		return fo.getContent().getInputStream();
-	}
+    public InputStream getInputStream() throws IOException
+    {
+        return fo.getContent().getInputStream();
+    }
 
-	public OutputStream getOutputStream() throws IOException
-	{
-		return fo.getContent().getOutputStream();
-	}
+    public OutputStream getOutputStream() throws IOException
+    {
+        return fo.getContent().getOutputStream();
+    }
 
-	public String getContentType()
-	{
-		try
-		{
-			return fo.getContent().getContentInfo().getContentType();
-		}
-		catch (FileSystemException e)
-		{
-			throw new RuntimeException(e);
-		}
-	}
+    public String getContentType()
+    {
+        try
+        {
+            return fo.getContent().getContentInfo().getContentType();
+        }
+        catch (FileSystemException e)
+        {
+            throw new RuntimeException(e);
+        }
+    }
 
-	public String getName()
-	{
-		return fo.getName().getBaseName();
-	}
+    public String getName()
+    {
+        return fo.getName().getBaseName();
+    }
 }

Modified: commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/util/SharedRandomContentInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/util/SharedRandomContentInputStream.java?rev=1024089&r1=1024088&r2=1024089&view=diff
==============================================================================
--- commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/util/SharedRandomContentInputStream.java
(original)
+++ commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/util/SharedRandomContentInputStream.java
Tue Oct 19 01:59:39 2010
@@ -36,190 +36,190 @@ import java.util.Set;
  */
 public class SharedRandomContentInputStream extends BufferedInputStream implements SharedInputStream
 {
-	private final Set createdStreams;
-	private final FileObject fo;
-	private final long fileStart;
-	private final long fileEnd;
-
-	private long pos;
-	private long resetCount;
-
-	private SharedRandomContentInputStream(final Set createdStreams, final FileObject fo, final
long fileStart, final long fileEnd, final InputStream is) throws FileSystemException
-	{
-		super(is);
-
-		if (!fo.getFileSystem().hasCapability(Capability.RANDOM_ACCESS_READ))
-		{
-			throw new FileSystemException("vfs.util/missing-capability.error", Capability.RANDOM_ACCESS_READ);
-		}
-		
-		this.fo = fo;
-		this.fileStart = fileStart;
-		this.fileEnd = fileEnd;
-		this.createdStreams = createdStreams;
-
-		synchronized(createdStreams)
-		{
-			createdStreams.add(this);
-		}
-	}
-
-	public SharedRandomContentInputStream(final FileObject fo) throws FileSystemException
-	{
-		this(new HashSet(), fo, 0, -1, fo.getContent().getInputStream());
-	}
-
-
-	public synchronized int read() throws IOException
-	{
-		if (checkEnd())
-		{
-			return -1;
-		}
-		int r = super.read();
-		pos++;
-		resetCount++;
-		return r;
-	}
-
-	public synchronized int read(byte b[], int off, int len) throws IOException
-	{
-		if (checkEnd())
-		{
-			return -1;
-		}
-
-		if (fileEnd > -1 && calcFilePosition(len) > fileEnd)
-		{
-			// we can not read past our end
-			len = (int) (fileEnd - getFilePosition());
-		}
-
-		int nread = super.read(b, off, len);
-		pos+=nread;
-		resetCount+=nread;
-		return nread;
-	}
-
-	public synchronized long skip(long n) throws IOException
-	{
-		if (checkEnd())
-		{
-			return -1;
-		}
-
-		if (fileEnd > -1 && calcFilePosition(n) > fileEnd)
-		{
-			// we can not skip past our end
-			n = fileEnd - getFilePosition();
-		}
-
-		long nskip = super.skip(n);
-		pos+=nskip;
-		resetCount+=nskip;
-		return nskip;
-	}
-
-	/*
-	public synchronized int available() throws IOException
-	{
-		long realFileEnd = fileEnd;
-		if (realFileEnd < 0)
-		{
-			realFileEnd = fo.getContent().getSize();
-		}
-		if (realFileEnd < 0)
-		{
-			// we cant determine if there is really something available
-			return 8192;
-		}
-
-		long available = realFileEnd - (fileStart + pos);
-		if (available > Integer.MAX_VALUE)
-		{
-			return Integer.MAX_VALUE;
-		}
-
-		return (int) available;
-	}
-	*/
-
-	private boolean checkEnd()
-	{
-		return fileEnd > -1 && (getFilePosition() >= fileEnd);
-	}
-
-	protected long getFilePosition()
-	{
-		return fileStart + pos;
-	}
-
-	protected long calcFilePosition(long nadd)
-	{
-		return getFilePosition()+nadd;
-	}
-
-	public synchronized void mark(int readlimit)
-	{
-		super.mark(readlimit);
-		resetCount = 0;
-	}
-
-	public synchronized void reset() throws IOException
-	{
-		super.reset();
-		pos-=resetCount;
-		resetCount=0;
-	}
-
-	public long getPosition()
-	{
-		return pos;
-	}
-
-
-	public void close() throws IOException
-	{
-		super.close();
-
-		synchronized(createdStreams)
-		{
-			createdStreams.remove(this);
-		}
-	}
-
-	public InputStream newStream(long start, long end)
-	{
-		try
-		{
-			long newFileStart = this.fileStart+start;
-			long newFileEnd = end<0?this.fileEnd:this.fileStart+end;
-
-			RandomAccessContent rac = fo.getContent().getRandomAccessContent(RandomAccessMode.READ);
-			rac.seek(newFileStart);
-			return new SharedRandomContentInputStream(
-				createdStreams,
-				fo,
-				newFileStart,
-				newFileEnd,
-				rac.getInputStream());
-		}
-		catch (IOException e)
-		{
-			throw new RuntimeException(e);
-		}
-	}
-
-	public void closeAll() throws IOException
-	{
-		synchronized(createdStreams)
-		{
-			SharedRandomContentInputStream[] streams = new SharedRandomContentInputStream[createdStreams.size()];
-			createdStreams.toArray(streams);
-			for (int i = 0; i<streams.length; i++)
-			{
-				streams[i].close();
-			}
-		}
-	}
+    private final Set createdStreams;
+    private final FileObject fo;
+    private final long fileStart;
+    private final long fileEnd;
+
+    private long pos;
+    private long resetCount;
+
+    private SharedRandomContentInputStream(final Set createdStreams, final FileObject fo,
final long fileStart, final long fileEnd, final InputStream is) throws FileSystemException
+    {
+        super(is);
+
+        if (!fo.getFileSystem().hasCapability(Capability.RANDOM_ACCESS_READ))
+        {
+            throw new FileSystemException("vfs.util/missing-capability.error", Capability.RANDOM_ACCESS_READ);
+        }
+        
+        this.fo = fo;
+        this.fileStart = fileStart;
+        this.fileEnd = fileEnd;
+        this.createdStreams = createdStreams;
+
+        synchronized(createdStreams)
+        {
+            createdStreams.add(this);
+        }
+    }
+
+    public SharedRandomContentInputStream(final FileObject fo) throws FileSystemException
+    {
+        this(new HashSet(), fo, 0, -1, fo.getContent().getInputStream());
+    }
+
+
+    public synchronized int read() throws IOException
+    {
+        if (checkEnd())
+        {
+            return -1;
+        }
+        int r = super.read();
+        pos++;
+        resetCount++;
+        return r;
+    }
+
+    public synchronized int read(byte b[], int off, int len) throws IOException
+    {
+        if (checkEnd())
+        {
+            return -1;
+        }
+
+        if (fileEnd > -1 && calcFilePosition(len) > fileEnd)
+        {
+            // we can not read past our end
+            len = (int) (fileEnd - getFilePosition());
+        }
+
+        int nread = super.read(b, off, len);
+        pos+=nread;
+        resetCount+=nread;
+        return nread;
+    }
+
+    public synchronized long skip(long n) throws IOException
+    {
+        if (checkEnd())
+        {
+            return -1;
+        }
+
+        if (fileEnd > -1 && calcFilePosition(n) > fileEnd)
+        {
+            // we can not skip past our end
+            n = fileEnd - getFilePosition();
+        }
+
+        long nskip = super.skip(n);
+        pos+=nskip;
+        resetCount+=nskip;
+        return nskip;
+    }
+
+    /*
+    public synchronized int available() throws IOException
+    {
+        long realFileEnd = fileEnd;
+        if (realFileEnd < 0)
+        {
+            realFileEnd = fo.getContent().getSize();
+        }
+        if (realFileEnd < 0)
+        {
+            // we cant determine if there is really something available
+            return 8192;
+        }
+
+        long available = realFileEnd - (fileStart + pos);
+        if (available > Integer.MAX_VALUE)
+        {
+            return Integer.MAX_VALUE;
+        }
+
+        return (int) available;
+    }
+    */
+
+    private boolean checkEnd()
+    {
+        return fileEnd > -1 && (getFilePosition() >= fileEnd);
+    }
+
+    protected long getFilePosition()
+    {
+        return fileStart + pos;
+    }
+
+    protected long calcFilePosition(long nadd)
+    {
+        return getFilePosition()+nadd;
+    }
+
+    public synchronized void mark(int readlimit)
+    {
+        super.mark(readlimit);
+        resetCount = 0;
+    }
+
+    public synchronized void reset() throws IOException
+    {
+        super.reset();
+        pos-=resetCount;
+        resetCount=0;
+    }
+
+    public long getPosition()
+    {
+        return pos;
+    }
+
+
+    public void close() throws IOException
+    {
+        super.close();
+
+        synchronized(createdStreams)
+        {
+            createdStreams.remove(this);
+        }
+    }
+
+    public InputStream newStream(long start, long end)
+    {
+        try
+        {
+            long newFileStart = this.fileStart+start;
+            long newFileEnd = end<0?this.fileEnd:this.fileStart+end;
+
+            RandomAccessContent rac = fo.getContent().getRandomAccessContent(RandomAccessMode.READ);
+            rac.seek(newFileStart);
+            return new SharedRandomContentInputStream(
+                createdStreams,
+                fo,
+                newFileStart,
+                newFileEnd,
+                rac.getInputStream());
+        }
+        catch (IOException e)
+        {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public void closeAll() throws IOException
+    {
+        synchronized(createdStreams)
+        {
+            SharedRandomContentInputStream[] streams = new SharedRandomContentInputStream[createdStreams.size()];
+            createdStreams.toArray(streams);
+            for (int i = 0; i<streams.length; i++)
+            {
+                streams[i].close();
+            }
+        }
+    }
 }



Mime
View raw message