public void start()

in bindings/servicemix-ftp/src/main/java/org/apache/servicemix/ftp/FtpPollerEndpoint.java [140:207]


	public void start() throws Exception {
        if (lockManager == null) {
            lockManager = createLockManager();
        }
        if (clientPool == null) {
            clientPool = createClientPool();
        }
        if (uri != null) {
            clientPool.setHost(uri.getHost());
            clientPool.setPort(uri.getPort());
            if (uri.getUserInfo() != null) {
                String[] infos = uri.getUserInfo().split(":");
                clientPool.setUsername(infos[0]);
                if (infos.length > 1) {
                    clientPool.setPassword(infos[1]);
                }
            }
        } 
        
        // borrow client from pool
        FTPClient ftp = borrowClient();
        String folderName = "";
        try {
            StringTokenizer strTok = null;
            if (isAutoCreateDirectory() && !ftp.changeWorkingDirectory(getWorkingPath())) {
                // it seems the folder isn't there, so create it
                strTok = new StringTokenizer(getWorkingPath(), "/");
                
                while (strTok.hasMoreTokens()) {
                    folderName += '/';
                    folderName += strTok.nextToken();
                    if (!ftp.changeWorkingDirectory(folderName)) {
                        if (ftp.makeDirectory(folderName)) {
                            // the folder now exists
                        } else {
                            // unable to create the folder
                            throw new IOException("The defined folder " + getWorkingPath() + " doesn't exist on the server and it can't be created automatically.");
                        }
                    }
                }
            }
            folderName = "";
            if (getArchivePath() != null) {
                if (isAutoCreateDirectory() && !ftp.changeWorkingDirectory(getArchivePath())) {
                    // it seems the folder isn't there, so create it
                    strTok = new StringTokenizer(getArchivePath(), "/");

                    while (strTok.hasMoreTokens()) {
                        folderName += '/';
                        folderName += strTok.nextToken();
                        if (!ftp.changeWorkingDirectory(folderName)) {
                            if (ftp.makeDirectory(folderName)) {
                                // the folder now exists
                            } else {
                                // unable to create the folder
                                throw new IOException("The defined archive folder " + getArchivePath() + " doesn't exist on the server and it can't be created automatically.");
                            }
                        }
                    }
                }
            }
        } finally {
            // give back the client
            returnClient(ftp);
        }

        super.start();
    }