Example usage for org.apache.commons.net.ftp FTPFile getTimestamp

List of usage examples for org.apache.commons.net.ftp FTPFile getTimestamp

Introduction

In this page you can find the example usage for org.apache.commons.net.ftp FTPFile getTimestamp.

Prototype

public Calendar getTimestamp() 

Source Link

Document

Returns the file timestamp.

Usage

From source file:ch.cyberduck.core.ftp.parser.StingrayFTPEntryParserTest.java

/**
 * http://trac.cyberduck.ch/ticket/1198//from   w  w  w.  j av  a 2  s  .c  o m
 */
@Test
public void testFile() {
    FTPFile parsed;

    parsed = parser.parseFTPEntry("-r--r--r--          0     165100     165100 Aug  1 10:24 grau2.tif");
    assertNotNull(parsed);
    assertEquals("grau2.tif", parsed.getName());
    assertEquals(FTPFile.FILE_TYPE, parsed.getType());
    assertEquals(Calendar.AUGUST, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(1, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
    assertEquals(10, parsed.getTimestamp().get(Calendar.HOUR_OF_DAY));
    assertEquals(24, parsed.getTimestamp().get(Calendar.MINUTE));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION));
}

From source file:ch.cyberduck.core.ftp.parser.MicrosoftFTPEntryParserTest.java

@Test
public void testParse() throws Exception {
    FTPFile parsed;

    // #3701/*ww  w  .j  a  v  a  2  s  . c om*/
    parsed = parser.parseFTPEntry("12-04-06  12:43PM                65335 fon1.kucuk.jpg");
    assertNotNull(parsed);
    assertEquals("fon1.kucuk.jpg", parsed.getName());
    assertEquals(FTPFile.FILE_TYPE, parsed.getType());
    assertEquals(65335, parsed.getSize());
    assertEquals(2006, parsed.getTimestamp().get(Calendar.YEAR));
    assertEquals(Calendar.DECEMBER, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(4, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
}

From source file:com.streamsets.pipeline.stage.origin.remote.FTPRemoteDownloadSourceDelegate.java

private long getModTime(FileObject fileObject) throws FileSystemException {
    long modTime = fileObject.getContent().getLastModifiedTime();
    if (supportsMDTM) {
        FtpClient ftpClient = null;/*from  w  w w.  ja v a  2s  . c om*/
        FtpFileSystem ftpFileSystem = (FtpFileSystem) remoteDir.getFileSystem();
        try {
            ftpClient = ftpFileSystem.getClient();
            FTPClient rawFtpClient = (FTPClient) getFtpClient.invoke(ftpClient);
            String path = fileObject.getName().getPath();
            if (conf.userDirIsRoot && path.startsWith("/")) {
                // Remove the leading slash to turn it into a proper relative path
                path = path.substring(1);
            }
            FTPFile ftpFile = rawFtpClient.mdtmFile(path);
            if (ftpFile != null) {
                modTime = ftpFile.getTimestamp().getTimeInMillis();
            }
        } catch (Exception e) {
            LOG.trace("Ignoring Exception from MDTM command and falling back to basic timestamp", e);
        } finally {
            if (ftpClient != null) {
                ftpFileSystem.putClient(ftpClient);
            }
        }
    }
    return modTime;
}

From source file:ch.cyberduck.core.ftp.parser.StingrayFTPEntryParserTest.java

/**
 * http://trac.cyberduck.ch/ticket/1198//from   w  w  w  .jav  a2s . c  o m
 */
@Test
public void testFolder() {
    FTPFile parsed;

    parsed = parser.parseFTPEntry("dr--r--r--                folder          0 Aug  1 10:18 TestCyberduck");
    assertNotNull(parsed);
    assertEquals("TestCyberduck", parsed.getName());
    assertEquals(FTPFile.DIRECTORY_TYPE, parsed.getType());
    assertEquals(Calendar.AUGUST, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(1, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
    assertEquals(10, parsed.getTimestamp().get(Calendar.HOUR_OF_DAY));
    assertEquals(18, parsed.getTimestamp().get(Calendar.MINUTE));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION));
}

From source file:ch.cyberduck.core.ftp.parser.OpensolarisFTPEntryParserTest.java

@Test
public void testParse() throws Exception {
    FTPFile parsed;

    // #3689/*from  w w  w. j  a  v  a2s.c o m*/
    parsed = parser.parseFTPEntry("drwxr-xr-x+  5 niels    staff          7 Sep  6 13:46 data");
    assertNotNull(parsed);
    assertEquals(parsed.getName(), "data");
    assertEquals(FTPFile.DIRECTORY_TYPE, parsed.getType());
    assertEquals(7, parsed.getSize());
    assertEquals(Calendar.SEPTEMBER, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(6, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION));
}

From source file:com.esri.gpt.control.webharvest.client.waf.FtpFileIterator.java

/**
 * Creates new resource.//from ww w. j  av a  2  s  . c o  m
 * @param file file
 * @return resource
 */
protected Resource newResource(FTPFile file) {
    if (file.isDirectory()) {
        return new FtpFolder(iterationContext, getFtpClient(), criteria, folder + "/" + file.getName());
    } else if (file.isFile() && file.getName().toLowerCase().endsWith(".xml")) {
        if (criteria == null || criteria.getFromDate() == null || file.getTimestamp() == null
                || (criteria.getFromDate() != null && file.getTimestamp() != null
                        && file.getTimestamp().after(criteria.getFromDate()))) {
            return new FtpFile(iterationContext, getFtpClient(), folder + "/" + file.getName());
        }
    }
    return null;
}

From source file:ch.cyberduck.core.ftp.parser.vsFTPdEntryParserTest.java

@Test
public void testParse() throws Exception {
    FTPFile parsed;

    // #5437/* ww  w.j a  v  a 2  s . co  m*/
    parsed = parser.parseFTPEntry("-rw-r--r--    1 3642     3643          106 Nov 15 22:20 index.html");
    assertNotNull(parsed);
    assertEquals("index.html", parsed.getName());
    assertEquals(FTPFile.FILE_TYPE, parsed.getType());
    assertEquals(106, parsed.getSize());
    assertEquals(Calendar.NOVEMBER, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(15, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
}

From source file:ch.cyberduck.core.ftp.parser.FilezillaFTPEntryParserTest.java

@Test
public void testParse() throws Exception {
    FTPFile parsed;

    // #3119// ww  w . j a v a2 s  .  c  o m
    parsed = parser.parseFTPEntry("-rw-r--r-- 1 ftp ftp         100847 Sep 10  2004 octfront2.jpg");
    assertNotNull(parsed);
    assertEquals("octfront2.jpg", parsed.getName());
    assertEquals(FTPFile.FILE_TYPE, parsed.getType());
    assertEquals(100847, parsed.getSize());
    assertEquals(Calendar.SEPTEMBER, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(10, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
}

From source file:ch.cyberduck.core.ftp.parser.NTFTPEntryParserTest.java

@Test
public void testElectic() throws Exception {
    FTPFile parsed = parser
            .parseFTPEntry("09-04-06  11:28AM                  149 gearkommandon with spaces.txt");
    assertNotNull(parsed);/*from w  ww.jav  a  2s.c o  m*/
    assertEquals("gearkommandon with spaces.txt", parsed.getName());
    assertEquals(FTPFile.FILE_TYPE, parsed.getType());
    assertEquals(Calendar.SEPTEMBER, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(4, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
    assertEquals(2006, parsed.getTimestamp().get(Calendar.YEAR));
}

From source file:ch.cyberduck.core.ftp.parser.TrellixFTPEntryParserTest.java

@Test
public void testParse() throws Exception {
    FTPFile parsed;

    //#1213//w  w w .  jav  a2 s  .  co  m
    parsed = parser.parseFTPEntry("-rw-r--r--  FTP  User       10439 Apr 20 05:29 ASCheckbox_2_0.zip");
    assertNotNull(parsed);
    assertEquals("ASCheckbox_2_0.zip", parsed.getName());
    assertEquals(FTPFile.FILE_TYPE, parsed.getType());
    assertEquals(10439, parsed.getSize());
    assertEquals(Calendar.APRIL, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(20, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION));
    assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION));
    assertFalse(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION));
}