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

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

Introduction

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

Prototype

public String getName() 

Source Link

Document

Return the name of the file.

Usage

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

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

    // #3119/*from  w  w w. j  a  v  a  2  s . co  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 testDirectoryBeginningWithNumber() throws Exception {
    FTPFile parsed = parser.parseFTPEntry("12-03-96  06:38AM       <DIR>          123xyz");
    assertNotNull(parsed);//from   www.  j a  va2  s  .co  m
    assertEquals("name", "123xyz", parsed.getName());
}

From source file:dhz.skz.citaci.weblogger.zerospan.WebloggerZeroSpanCitacBean.java

public void pokupiZeroSpanSaPostaje(IzvorPodataka izvor, Postaja p) {
    this.izvor = izvor;
    this.postaja = p;
    Date zadnji = getZadnjiZS(izvor, p);

    if (imaZS(izvor, p)) {

        try {/*from w  w  w  . j  av  a2  s  . co m*/
            Map<ProgramMjerenja, NizZeroSpanPodataka> tmp = getMapaZeroSpanNizova(p, izvor, zadnji);
            ftp.connect(new URI(izvor.getUri()));

            WlZeroSpanDatotekaParser citac = new WlZeroSpanDatotekaParser(timeZone);
            citac.setZadnjiPodatak(zadnji);
            citac.setNizKanala(tmp);

            WlZeroSpanFileFilter fns = new WlZeroSpanFileFilter(p.getNazivPostaje(), zadnji, timeZone);
            for (FTPFile file : ftp.getFileList(fns)) {
                log.log(Level.INFO, "Zero/span datoteka :{0}", file.getName());
                try (InputStream ifs = ftp.getFileStream(file)) {
                    citac.parse(ifs);
                } catch (Exception ex) { // kakva god da se iznimka dogodi, nastavljamo
                    log.log(Level.SEVERE, null, ex);
                } finally {
                    ftp.zavrsi();
                }
            }
            obradiISpremiNizove(tmp);
        } catch (FtpKlijentException | URISyntaxException ex) {
            log.log(Level.SEVERE, null, ex);
        } finally {
            ftp.disconnect();
        }
    }
}

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

/**
 * #1996/*from   w w w  .j a v a 2  s  .c  o  m*/
 */
@Test
public void testDateYearParser() {
    FTPFile parsed;

    parsed = parser.parseFTPEntry("- [RWCEAFMS] wtubbs 24038 May 05 17:57 CIMSscheduler_log_May02_4.txt");
    assertNotNull(parsed);
    assertEquals(parsed.getName(), "CIMSscheduler_log_May02_4.txt");
    assertEquals(FTPFile.FILE_TYPE, parsed.getType());
    assertEquals("wtubbs", parsed.getUser());
    assertEquals(24038, parsed.getSize());
    assertEquals(Calendar.MAY, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(5, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));

    parsed = parser.parseFTPEntry("- [RWCEAFMS] wtubbs 9965 May 01 18:15 CIMSscheduler_log_May01.txt");
    assertNotNull(parsed);
    assertEquals(parsed.getName(), "CIMSscheduler_log_May01.txt");
    assertEquals(FTPFile.FILE_TYPE, parsed.getType());
    assertEquals("wtubbs", parsed.getUser());
    assertEquals(9965, parsed.getSize());
    assertEquals(Calendar.MAY, parsed.getTimestamp().get(Calendar.MONTH));
    assertEquals(1, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH));
}

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

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

    // #5437/*from www .  ja va  2s .c  o  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:jcr.FTPParser.java

private void parse(String workingDirectory) throws RepositoryException, IOException, Exception {
    Node node = JcrUtils.getOrCreateByPath(jcrServerNodePath + workingDirectory, null, session);
    String encoded = new String(workingDirectory.getBytes("UTF-8"), "ISO-8859-1");
    FTPFile[] files = client.listFiles(encoded);
    logger.log(Level.INFO, "Parse {0} item in directory: {1}", new Object[] { files.length, workingDirectory });
    for (FTPFile file : files) {
        if (file.isDirectory()) {
            parse(workingDirectory + "/" + file.getName());
        } else {//from  www .  ja va 2  s.c  o  m
            String remote = workingDirectory + "/" + file.getName();
            if (remote.endsWith(".md5") || remote.endsWith(".md5sum")) {
                parseChecksumFile(remote);
            } else if (remote.endsWith(".tgz.desc") || remote.endsWith(".zip.desc")) {
                parseDescriptorFile(remote);
            } else {
                parseFile(remote, file.getSize());
            }
        }
    }
}

From source file:au.org.intersect.dms.wn.transports.impl.FtpConnection.java

@Override
public FileInfo getInfo(String path) throws IOException {
    if (PathUtils.isRoot(path)) {
        return FileInfo.createRootFileInfo();
    }// w w  w . j  a  v  a 2 s. c  o  m
    String parentPath = PathUtils.getParent(path);
    String namePart = PathUtils.getName(path);
    changeWorkingDirectory(parentPath);
    for (FTPFile file : client.listFiles()) {
        if (file.getName().equals(namePart)) {
            return makeFileInfo(parentPath, file);
        }
    }
    throw new PathNotFoundException("Couldn't retrieve information for '" + path + "'");
}

From source file:dhz.skz.citaci.weblogger.WebloggerCitacBean.java

private void pokupiMjerenjaSaPostaje(IzvorPodataka izvor, Postaja p) {
    Date zadnji = getZadnjiPodatak(izvor, p);
    try {//from  w  w w . j a v a2 s. co  m
        Map<ProgramMjerenja, NizPodataka> tmp = getMapaNizova(p, izvor, zadnji);
        ftp.connect(new URI(izvor.getUri()));

        WlDatotekaParser citac = new WlDatotekaParser(timeZone);
        citac.setZadnjiPodatak(zadnji);
        citac.setNizKanala(tmp);

        WlFileFilter fns = new WlFileFilter(p.getNazivPostaje(), zadnji, timeZone);
        for (FTPFile file : ftp.getFileList(fns)) {
            log.log(Level.INFO, "Datoteka :{0}", file.getName());
            try (InputStream ifs = ftp.getFileStream(file)) {
                citac.parse(ifs);
            } catch (Exception ex) { // kakva god da se iznimka dogodi, nastavljamo
                log.log(Level.SEVERE, null, ex);
            } finally {
                ftp.zavrsi();
            }
        }
        obradiISpremiNizove(tmp);
    } catch (FtpKlijentException | URISyntaxException ex) {
        log.log(Level.SEVERE, null, ex);
    } finally {
        ftp.disconnect();
    }
}

From source file:ftpclientgui.FTPListItemAdapter.java

@Override
public FileListItem getFileListItem(FTPFile adaptee) {
    FileListItemTypes t = null;//from   w w w. j ava 2  s.c om
    if (adaptee.isDirectory()) {
        t = FileListItemTypes.DIRECTORY;
    } else if (adaptee.isFile()) {
        t = FileListItemTypes.FILE;
    }
    return new FileListItem(adaptee.getName(), t);
}

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

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

    //#1213/*from  ww w  .  j av a 2  s. c  om*/
    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));
}