Search in sources :

Example 6 with AFTPClient

use of lucee.runtime.net.ftp.AFTPClient in project Lucee by lucee.

the class Ftp method doEndTag.

@Override
public int doEndTag() throws PageException {
    pool = ((PageContextImpl) pageContext).getFTPPool();
    AFTPClient client = null;
    // retries
    do {
        try {
            if (action.equals("open"))
                client = actionOpen();
            else if (action.equals("close"))
                client = actionClose();
            else if (action.equals("changedir"))
                client = actionChangeDir();
            else if (action.equals("createdir"))
                client = actionCreateDir();
            else if (action.equals("listdir"))
                client = actionListDir();
            else if (action.equals("removedir"))
                client = actionRemoveDir();
            else if (action.equals("getfile"))
                client = actionGetFile();
            else if (action.equals("putfile"))
                client = actionPutFile();
            else if (action.equals("rename"))
                client = actionRename();
            else if (action.equals("remove"))
                client = actionRemove();
            else if (action.equals("getcurrentdir"))
                client = actionGetCurrentDir();
            else if (action.equals("getcurrenturl"))
                client = actionGetCurrentURL();
            else if (action.equals("existsdir"))
                client = actionExistsDir();
            else if (action.equals("existsfile"))
                client = actionExistsFile();
            else if (action.equals("exists"))
                client = actionExists();
            else
                throw new ApplicationException("attribute action has an invalid value [" + action + "]", "valid values are [open,close,listDir,createDir,removeDir,changeDir,getCurrentDir," + "getCurrentURL,existsFile,existsDir,exists,getFile,putFile,rename,remove]");
        } catch (IOException ioe) {
            if (count++ < retrycount)
                continue;
            throw Caster.toPageException(ioe);
        }
        if (client == null || !checkCompletion(client))
            break;
    } while (true);
    return EVAL_PAGE;
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) AFTPClient(lucee.runtime.net.ftp.AFTPClient) IOException(java.io.IOException)

Example 7 with AFTPClient

use of lucee.runtime.net.ftp.AFTPClient in project Lucee by lucee.

the class Ftp method actionRemove.

/**
 * removes a file on the server
 * @return FTPCLient
 * @throws IOException
 * @throws PageException
 */
private AFTPClient actionRemove() throws IOException, PageException {
    required("item", item);
    AFTPClient client = getClient();
    client.deleteFile(item);
    writeCfftp(client);
    return client;
}
Also used : AFTPClient(lucee.runtime.net.ftp.AFTPClient)

Example 8 with AFTPClient

use of lucee.runtime.net.ftp.AFTPClient in project Lucee by lucee.

the class Ftp method actionCreateDir.

/**
 * create a remote directory
 * @return FTPCLient
 * @throws IOException
 * @throws PageException
 */
private AFTPClient actionCreateDir() throws IOException, PageException {
    required("directory", directory);
    AFTPClient client = getClient();
    client.makeDirectory(directory);
    writeCfftp(client);
    return client;
}
Also used : AFTPClient(lucee.runtime.net.ftp.AFTPClient)

Example 9 with AFTPClient

use of lucee.runtime.net.ftp.AFTPClient in project Lucee by lucee.

the class Ftp method actionClose.

/**
 * close a existing ftp connection
 * @return FTPCLient
 * @throws PageException
 */
private AFTPClient actionClose() throws PageException {
    FTPConnection conn = _createConnection();
    AFTPClient client = pool.remove(conn);
    Struct cfftp = writeCfftp(client);
    cfftp.setEL("succeeded", Caster.toBoolean(client != null));
    return client;
}
Also used : AFTPClient(lucee.runtime.net.ftp.AFTPClient) FTPConnection(lucee.runtime.net.ftp.FTPConnection) Struct(lucee.runtime.type.Struct)

Example 10 with AFTPClient

use of lucee.runtime.net.ftp.AFTPClient in project Lucee by lucee.

the class Ftp method actionExistsDir.

/**
 * check if a directory exists or not
 * @return FTPCLient
 * @throws PageException
 * @throws IOException
 */
private AFTPClient actionExistsDir() throws PageException, IOException {
    required("directory", directory);
    AFTPClient client = getClient();
    boolean res = existsDir(client, directory);
    Struct cfftp = writeCfftp(client);
    cfftp.setEL(RETURN_VALUE, Caster.toBoolean(res));
    cfftp.setEL(SUCCEEDED, Boolean.TRUE);
    stoponerror = false;
    return client;
}
Also used : AFTPClient(lucee.runtime.net.ftp.AFTPClient) Struct(lucee.runtime.type.Struct)

Aggregations

AFTPClient (lucee.runtime.net.ftp.AFTPClient)16 Struct (lucee.runtime.type.Struct)6 FTPFile (org.apache.commons.net.ftp.FTPFile)3 Resource (lucee.commons.io.res.Resource)2 ApplicationException (lucee.runtime.exp.ApplicationException)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 FTPConnection (lucee.runtime.net.ftp.FTPConnection)1