Search in sources :

Example 1 with IRemoteFileInfo

use of org.eclipse.ecf.filetransfer.IRemoteFileInfo in project ecf by eclipse.

the class AbstractBrowseTestCase method verifyRemoteFiles.

/**
 * @param remoteFiles
 */
protected void verifyRemoteFiles(final IRemoteFile[] remoteFiles) {
    for (int i = 0; i < remoteFiles.length; i++) {
        final IRemoteFile first = remoteFiles[i];
        final IRemoteFileInfo firstInfo = first.getInfo();
        assertNotNull(firstInfo);
        final IFileID firstID = first.getID();
        assertNotNull(firstID);
        trace("firstID=" + firstID);
        // Now check out info
        assertNotNull(firstInfo.getName());
        assertTrue(firstInfo.getLastModified() > 0);
        trace("lastModified=" + new SimpleDateFormat().format(new Date(firstInfo.getLastModified())));
        trace("length=" + firstInfo.getLength());
        trace("isDirectory=" + firstInfo.isDirectory());
        final IRemoteFileAttributes attributes = firstInfo.getAttributes();
        assertNotNull(attributes);
        final Iterator attrNames = attributes.getAttributeKeys();
        for (; attrNames.hasNext(); ) {
            final String key = (String) attrNames.next();
            String s = "attrname=" + key;
            s += " attrvalue=" + attributes.getAttribute(key);
            trace(s);
        }
    }
}
Also used : IFileID(org.eclipse.ecf.filetransfer.identity.IFileID) IRemoteFileInfo(org.eclipse.ecf.filetransfer.IRemoteFileInfo) IRemoteFile(org.eclipse.ecf.filetransfer.IRemoteFile) Iterator(java.util.Iterator) IRemoteFileAttributes(org.eclipse.ecf.filetransfer.IRemoteFileAttributes) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 2 with IRemoteFileInfo

use of org.eclipse.ecf.filetransfer.IRemoteFileInfo in project ecf by eclipse.

the class URLRemoteFile method getInfo.

/* (non-Javadoc)
	 * @see org.eclipse.ecf.filetransfer.IRemoteFile#getInfo()
	 */
public IRemoteFileInfo getInfo() {
    return new IRemoteFileInfo() {

        public IRemoteFileAttributes getAttributes() {
            return remoteFileAttributes;
        }

        public long getLastModified() {
            return lastModified;
        }

        public long getLength() {
            return fileLength;
        }

        public String getName() {
            URL url;
            String result = null;
            try {
                url = fileID.getURL();
                String path = url.getPath();
                // $NON-NLS-1$
                int index = path.lastIndexOf("/");
                if (index == -1)
                    return path;
                result = path.substring(index + 1);
                return result;
            } catch (MalformedURLException e) {
                return fileID.getName();
            }
        }

        public boolean isDirectory() {
            try {
                // $NON-NLS-1$
                return fileID.getURL().toString().endsWith("/");
            } catch (MalformedURLException e) {
                return false;
            }
        }

        public void setAttributes(IRemoteFileAttributes attributes) {
        // Not supported
        }

        public void setLastModified(long time) {
        // not supported
        }

        public void setName(String name) {
        // not supported
        }
    };
}
Also used : MalformedURLException(java.net.MalformedURLException) IRemoteFileInfo(org.eclipse.ecf.filetransfer.IRemoteFileInfo) IRemoteFileAttributes(org.eclipse.ecf.filetransfer.IRemoteFileAttributes) URL(java.net.URL)

Example 3 with IRemoteFileInfo

use of org.eclipse.ecf.filetransfer.IRemoteFileInfo in project ecf by eclipse.

the class URLBrowseTest method verifyRemoteFilesWithoutLastModifiedAndContentLength.

protected void verifyRemoteFilesWithoutLastModifiedAndContentLength(final IRemoteFile[] remoteFiles) {
    for (int i = 0; i < remoteFiles.length; i++) {
        final IRemoteFile first = remoteFiles[i];
        final IRemoteFileInfo firstInfo = first.getInfo();
        assertNotNull(firstInfo);
        final IFileID firstID = first.getID();
        assertNotNull(firstID);
        trace("firstID=" + firstID);
        // Now check out info
        assertNotNull(firstInfo.getName());
        // TODO: should this be -1
        assertEquals(0, firstInfo.getLastModified());
        trace("length=" + firstInfo.getLength());
        trace("isDirectory=" + firstInfo.isDirectory());
        final IRemoteFileAttributes attributes = firstInfo.getAttributes();
        assertNotNull(attributes);
        final Iterator attrNames = attributes.getAttributeKeys();
        for (; attrNames.hasNext(); ) {
            final String key = (String) attrNames.next();
            String s = "attrname=" + key;
            s += " attrvalue=" + attributes.getAttribute(key);
            trace(s);
        }
    }
}
Also used : IFileID(org.eclipse.ecf.filetransfer.identity.IFileID) IRemoteFileInfo(org.eclipse.ecf.filetransfer.IRemoteFileInfo) IRemoteFile(org.eclipse.ecf.filetransfer.IRemoteFile) Iterator(java.util.Iterator) IRemoteFileAttributes(org.eclipse.ecf.filetransfer.IRemoteFileAttributes)

Aggregations

IRemoteFileAttributes (org.eclipse.ecf.filetransfer.IRemoteFileAttributes)3 IRemoteFileInfo (org.eclipse.ecf.filetransfer.IRemoteFileInfo)3 Iterator (java.util.Iterator)2 IRemoteFile (org.eclipse.ecf.filetransfer.IRemoteFile)2 IFileID (org.eclipse.ecf.filetransfer.identity.IFileID)2 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1