当前位置: 首页>>代码示例>>Java>>正文


Java FtpSession类代码示例

本文整理汇总了Java中org.apache.ftpserver.ftplet.FtpSession的典型用法代码示例。如果您正苦于以下问题:Java FtpSession类的具体用法?Java FtpSession怎么用?Java FtpSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FtpSession类属于org.apache.ftpserver.ftplet包,在下文中一共展示了FtpSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transferFromClient

import org.apache.ftpserver.ftplet.FtpSession; //导入依赖的package包/类
public final long transferFromClient(FtpSession session,
        final OutputStream out) throws IOException {
    TransferRateRequest transferRateRequest = new TransferRateRequest();
    transferRateRequest = (TransferRateRequest) session.getUser()
            .authorize(transferRateRequest);
    int maxRate = 0;
    if (transferRateRequest != null) {
        maxRate = transferRateRequest.getMaxUploadRate();
    }

    InputStream is = getDataInputStream();
    try {
        return transfer(session, false, is, out, maxRate);
    } finally {
        IoUtils.close(is);
    }
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:18,代码来源:IODataConnection.java

示例2: transferToClient

import org.apache.ftpserver.ftplet.FtpSession; //导入依赖的package包/类
public final long transferToClient(FtpSession session, final InputStream in)
        throws IOException {
    TransferRateRequest transferRateRequest = new TransferRateRequest();
    transferRateRequest = (TransferRateRequest) session.getUser()
            .authorize(transferRateRequest);
    int maxRate = 0;
    if (transferRateRequest != null) {
        maxRate = transferRateRequest.getMaxDownloadRate();
    }

    OutputStream out = getDataOutputStream();
    try {
        return transfer(session, true, in, out, maxRate);
    } finally {
        IoUtils.close(out);
    }
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:18,代码来源:IODataConnection.java

示例3: onConnect

import org.apache.ftpserver.ftplet.FtpSession; //导入依赖的package包/类
/**
 * Call ftplet onConnect.
 */
public FtpletResult onConnect(FtpSession session) throws FtpException,
        IOException {
    FtpletResult retVal = FtpletResult.DEFAULT;
    for (Entry<String, Ftplet> entry : ftplets.entrySet()) {
        retVal = entry.getValue().onConnect(session);
        if (retVal == null) {
            retVal = FtpletResult.DEFAULT;
        }

        // proceed only if the return value is FtpletResult.DEFAULT
        if (retVal != FtpletResult.DEFAULT) {
            break;
        }
    }
    return retVal;
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:20,代码来源:DefaultFtpletContainer.java

示例4: onDisconnect

import org.apache.ftpserver.ftplet.FtpSession; //导入依赖的package包/类
/**
 * Call ftplet onDisconnect.
 */
public FtpletResult onDisconnect(FtpSession session) throws FtpException,
        IOException {
    FtpletResult retVal = FtpletResult.DEFAULT;
    for (Entry<String, Ftplet> entry : ftplets.entrySet()) {

        retVal = entry.getValue().onDisconnect(session);
        if (retVal == null) {
            retVal = FtpletResult.DEFAULT;
        }

        // proceed only if the return value is FtpletResult.DEFAULT
        if (retVal != FtpletResult.DEFAULT) {
            break;
        }
    }
    return retVal;
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:21,代码来源:DefaultFtpletContainer.java

示例5: afterCommand

import org.apache.ftpserver.ftplet.FtpSession; //导入依赖的package包/类
public FtpletResult afterCommand(FtpSession session, FtpRequest request, FtpReply reply)
        throws FtpException, IOException {
    FtpletResult retVal = FtpletResult.DEFAULT;
    for (Entry<String, Ftplet> entry : ftplets.entrySet()) {

        retVal = entry.getValue().afterCommand(session, request, reply);
        if (retVal == null) {
            retVal = FtpletResult.DEFAULT;
        }

        // proceed only if the return value is FtpletResult.DEFAULT
        if (retVal != FtpletResult.DEFAULT) {
            break;
        }
    }
    return retVal;
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:18,代码来源:DefaultFtpletContainer.java

示例6: beforeCommand

import org.apache.ftpserver.ftplet.FtpSession; //导入依赖的package包/类
public FtpletResult beforeCommand(FtpSession session, FtpRequest request)
        throws FtpException, IOException {
    FtpletResult retVal = FtpletResult.DEFAULT;
    for (Entry<String, Ftplet> entry : ftplets.entrySet()) {

        retVal = entry.getValue().beforeCommand(session, request);
        if (retVal == null) {
            retVal = FtpletResult.DEFAULT;
        }

        // proceed only if the return value is FtpletResult.DEFAULT
        if (retVal != FtpletResult.DEFAULT) {
            break;
        }
    }
    return retVal;
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:18,代码来源:DefaultFtpletContainer.java

示例7: testExceptionDuringDeleteStart

import org.apache.ftpserver.ftplet.FtpSession; //导入依赖的package包/类
public void testExceptionDuringDeleteStart() throws Exception {
    MockFtplet.callback = new MockFtpletCallback() {
        @Override
        public FtpletResult onDeleteStart(FtpSession session,
                FtpRequest request) throws FtpException, IOException {

            session.write(new DefaultFtpReply(
                    FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN,
                    "foo"));
            throwException();
            return mockReturnValue;
        }
    };

    TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);

    client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
    assertFalse(client.deleteFile(TEST_FILE1.getName()));

    assertTrue(TEST_FILE1.exists());
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:22,代码来源:FtpLetReturnSkipTest.java

示例8: testExceptionDuringDeleteEnd

import org.apache.ftpserver.ftplet.FtpSession; //导入依赖的package包/类
public void testExceptionDuringDeleteEnd() throws Exception {
    MockFtplet.callback = new MockFtpletCallback() {
        @Override
        public FtpletResult onDeleteEnd(FtpSession session, FtpRequest request)
                throws FtpException, IOException {
            throwException();
            return mockReturnValue;
        }
    };

    TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);

    client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
    assertTrue(client.deleteFile(TEST_FILE1.getName()));

    assertFalse(TEST_FILE1.exists());
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:18,代码来源:FtpLetReturnSkipTest.java

示例9: testExceptionDuringMkdirStart

import org.apache.ftpserver.ftplet.FtpSession; //导入依赖的package包/类
public void testExceptionDuringMkdirStart() throws Exception {
    MockFtplet.callback = new MockFtpletCallback() {
        @Override
        public FtpletResult onMkdirStart(FtpSession session,
                FtpRequest request) throws FtpException, IOException {

            session.write(new DefaultFtpReply(
                    FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "foo"));
            throwException();
            return mockReturnValue;
        }
    };

    client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
    assertFalse(client.makeDirectory(TEST_DIR1.getName()));

    assertFalse(TEST_DIR1.exists());
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:19,代码来源:FtpLetReturnSkipTest.java

示例10: testExceptionDuringRmdirStart

import org.apache.ftpserver.ftplet.FtpSession; //导入依赖的package包/类
public void testExceptionDuringRmdirStart() throws Exception {
    MockFtplet.callback = new MockFtpletCallback() {
        @Override
        public FtpletResult onRmdirStart(FtpSession session,
                FtpRequest request) throws FtpException, IOException {
            session.write(new DefaultFtpReply(
                    FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN,
                    "foo"));

            throwException();
            return mockReturnValue;
        }
    };

    TEST_DIR1.mkdirs();

    client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
    assertFalse(client.removeDirectory(TEST_DIR1.getName()));

    assertTrue(TEST_DIR1.exists());
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:22,代码来源:FtpLetReturnSkipTest.java

示例11: testExceptionDuringRmdirEnd

import org.apache.ftpserver.ftplet.FtpSession; //导入依赖的package包/类
public void testExceptionDuringRmdirEnd() throws Exception {
    MockFtplet.callback = new MockFtpletCallback() {
        @Override
        public FtpletResult onRmdirEnd(FtpSession session, FtpRequest request)
                throws FtpException, IOException {
            throwException();
            return mockReturnValue;
        }
    };

    TEST_DIR1.mkdirs();

    client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
    assertTrue(client.removeDirectory(TEST_DIR1.getName()));

    assertFalse(TEST_DIR1.exists());
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:18,代码来源:FtpLetReturnSkipTest.java

示例12: testExceptionDuringSite

import org.apache.ftpserver.ftplet.FtpSession; //导入依赖的package包/类
public void testExceptionDuringSite() throws Exception {
    MockFtplet.callback = new MockFtpletCallback() {
        @Override
        public FtpletResult onSite(FtpSession session, FtpRequest request)
                throws FtpException, IOException {
            session
            .write(new DefaultFtpReply(
                    FtpReply.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED,
                    "foo"));
            
            throwException();
            return mockReturnValue;
        }
    };

    client.login(ADMIN_USERNAME, ADMIN_PASSWORD);

    client.site("HELP");
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:20,代码来源:FtpLetReturnSkipTest.java

示例13: testExceptionDuringRenameStart

import org.apache.ftpserver.ftplet.FtpSession; //导入依赖的package包/类
public void testExceptionDuringRenameStart() throws Exception {
    MockFtplet.callback = new MockFtpletCallback() {
        @Override
        public FtpletResult onRenameStart(FtpSession session,
                FtpRequest request) throws FtpException, IOException {
            session
                    .write(new DefaultFtpReply(
                            FtpReply.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED,
                            "foo"));

            throwException();
            return mockReturnValue;
        }
    };

    TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);

    client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
    assertFalse(client.rename(TEST_FILE1.getName(), TEST_FILE2.getName()));

    assertTrue(TEST_FILE1.exists());
    assertFalse(TEST_FILE2.exists());
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:24,代码来源:FtpLetReturnSkipTest.java

示例14: testExceptionDuringRenameEnd

import org.apache.ftpserver.ftplet.FtpSession; //导入依赖的package包/类
public void testExceptionDuringRenameEnd() throws Exception {
    MockFtplet.callback = new MockFtpletCallback() {
        @Override
        public FtpletResult onRenameEnd(FtpSession session, FtpRequest request)
                throws FtpException, IOException {
            throwException();
            return mockReturnValue;
        }
    };

    TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);

    client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
    assertTrue(client.rename(TEST_FILE1.getName(), TEST_FILE2.getName()));

    assertFalse(TEST_FILE1.exists());
    assertTrue(TEST_FILE2.exists());

}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:20,代码来源:FtpLetReturnSkipTest.java

示例15: testExceptionDuringDownloadStart

import org.apache.ftpserver.ftplet.FtpSession; //导入依赖的package包/类
public void testExceptionDuringDownloadStart() throws Exception {
    MockFtplet.callback = new MockFtpletCallback() {
        @Override
        public FtpletResult onDownloadStart(FtpSession session,
                FtpRequest request) throws FtpException, IOException {
            session.write(new DefaultFtpReply(
                    FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "foo"));

            throwException();
            return mockReturnValue;
        }
    };

    TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);

    client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
    client.retrieveFileStream(TEST_FILE1.getName());

    assertTrue(FTPReply.isNegativePermanent(client.getReplyCode()));
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:21,代码来源:FtpLetReturnSkipTest.java


注:本文中的org.apache.ftpserver.ftplet.FtpSession类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。