• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FtpSession类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testExceptionDuringDownloadEnd

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

    TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);

    client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    assertTrue(client.retrieveFile(TEST_FILE1.getName(), baos));

    TestUtil.assertArraysEqual(TESTDATA, baos.toByteArray());
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:19,代码来源:FtpLetReturnSkipTest.java


示例17: testExceptionDuringAppendStart

import org.apache.ftpserver.ftplet.FtpSession; //导入依赖的package包/类
public void testExceptionDuringAppendStart() throws Exception {
    MockFtplet.callback = new MockFtpletCallback() {
        @Override
        public FtpletResult onAppendStart(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);
    assertFalse(client.appendFile(TEST_FILE1.getName(),
            new ByteArrayInputStream(TESTDATA)));

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


示例18: testExceptionDuringAppendEnd

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

    TestUtil.writeDataToFile(TEST_FILE1, TESTDATA);

    client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
    assertTrue(client.appendFile(TEST_FILE1.getName(),
            new ByteArrayInputStream(TESTDATA)));

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


示例19: testExceptionDuringUploadStart

import org.apache.ftpserver.ftplet.FtpSession; //导入依赖的package包/类
public void testExceptionDuringUploadStart() throws Exception {
    MockFtplet.callback = new MockFtpletCallback() {
        @Override
        public FtpletResult onUploadStart(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.storeFile(TEST_FILE1.getName(),
            new ByteArrayInputStream(TESTDATA)));

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


示例20: testExceptionDuringUploadEnd

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

    client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
    assertTrue(client.storeFile(TEST_FILE1.getName(),
            new ByteArrayInputStream(TESTDATA)));

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WebEndpointProperties类代码示例发布时间:2022-05-22
下一篇:
Java OAuthToken类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap