本文整理汇总了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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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");
}
示例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());
}
示例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());
}
示例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()));
}