本文整理汇总了Java中org.apache.ftpserver.ftplet.FtpRequest类的典型用法代码示例。如果您正苦于以下问题:Java FtpRequest类的具体用法?Java FtpRequest怎么用?Java FtpRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FtpRequest类属于org.apache.ftpserver.ftplet包,在下文中一共展示了FtpRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: translateMessage
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的package包/类
/**
* Returns the translated message.
*
* @param session
* the FTP session for which a reply is to be sent
* @param request
* the FTP request object
* @param context
* the FTP server context
* @param code
* the reply code
* @param subId
* the ID of the sub message
* @param basicMsg
* the basic message
* @return the translated message
*/
public static String translateMessage(FtpIoSession session,
FtpRequest request, FtpServerContext context, int code, String subId,
String basicMsg) {
MessageResource resource = context.getMessageResource();
String lang = session.getLanguage();
String msg = null;
if (resource != null) {
msg = resource.getMessage(code, subId, lang);
}
if (msg == null) {
msg = "";
}
msg = replaceVariables(session, request, context, code, basicMsg, msg);
return msg;
}
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:35,代码来源:FtpReplyTranslator.java
示例2: execute
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的package包/类
/**
* Execute command
*/
public void execute(final FtpIoSession session,
final FtpServerContext context, final FtpRequest request)
throws IOException {
// reset state variables
session.resetState();
// get server system info
String systemName = System.getProperty("os.name");
if (systemName == null) {
systemName = "UNKNOWN";
} else {
systemName = systemName.toUpperCase();
systemName = systemName.replace(' ', '-');
}
// print server system info
session.write(LocalizedFtpReply.translate(session, request, context,
FtpReply.REPLY_215_NAME_SYSTEM_TYPE, "SYST", systemName));
}
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:23,代码来源:SYST.java
示例3: execute
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的package包/类
/**
* Execute command.
*/
public void execute(final FtpIoSession session,
final FtpServerContext context, final FtpRequest request)
throws IOException {
// reset state variables
session.resetState();
// print global help
if (!request.hasArgument()) {
session.write(LocalizedFtpReply.translate(session, request, context,
FtpReply.REPLY_214_HELP_MESSAGE, null, null));
return;
}
// print command specific help if available
String ftpCmd = request.getArgument().toUpperCase();
MessageResource resource = context.getMessageResource();
if (resource.getMessage(FtpReply.REPLY_214_HELP_MESSAGE, ftpCmd,
session.getLanguage()) == null) {
ftpCmd = null;
}
session.write(LocalizedFtpReply.translate(session, request, context,
FtpReply.REPLY_214_HELP_MESSAGE, ftpCmd, null));
}
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:28,代码来源:HELP.java
示例4: afterCommand
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的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
示例5: beforeCommand
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的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
示例6: testExceptionDuringDeleteStart
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的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
示例7: testExceptionDuringDeleteEnd
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的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
示例8: testExceptionDuringMkdirStart
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的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
示例9: testExceptionDuringRmdirStart
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的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
示例10: testExceptionDuringRenameStart
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的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
示例11: testExceptionDuringDownloadStart
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的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
示例12: testExceptionDuringDownloadEnd
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的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
示例13: testExceptionDuringAppendStart
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的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
示例14: testExceptionDuringAppendEnd
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的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
示例15: testExceptionDuringUploadStart
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的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
示例16: testExceptionDuringUploadEnd
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的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
示例17: testExceptionDuringUploadUniqueStart
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的package包/类
public void testExceptionDuringUploadUniqueStart() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
@Override
public FtpletResult onUploadUniqueStart(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.storeUniqueFile(TEST_FILE1.getName(),
new ByteArrayInputStream(TESTDATA)));
assertEquals(ROOT_DIR.listFiles().length, 0);
}
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:19,代码来源:FtpLetReturnSkipTest.java
示例18: testExceptionDuringUploadUniqueEnd
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的package包/类
public void testExceptionDuringUploadUniqueEnd() throws Exception {
MockFtplet.callback = new MockFtpletCallback() {
@Override
public FtpletResult onUploadUniqueEnd(FtpSession session,
FtpRequest request) throws FtpException, IOException {
throwException();
return mockReturnValue;
}
};
client.login(ADMIN_USERNAME, ADMIN_PASSWORD);
assertTrue(client.storeUniqueFile(new ByteArrayInputStream(TESTDATA)));
TestUtil.assertFileEqual(TESTDATA, ROOT_DIR.listFiles()[0]);
}
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:17,代码来源:FtpLetReturnSkipTest.java
示例19: testLogin
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的package包/类
public void testLogin() throws Exception {
final LinkedBlockingQueue<User> loggedInUser = new LinkedBlockingQueue<User>();
MockFtplet.callback = new MockFtpletCallback() {
public FtpletResult onLogin(FtpSession session, FtpRequest request)
throws FtpException, IOException {
loggedInUser.add(session.getUser());
return super.onLogin(session, request);
}
};
MockFtpletCallback.returnValue = FtpletResult.DEFAULT;
assertTrue(client.login(ADMIN_USERNAME, ADMIN_PASSWORD));
assertNotNull(loggedInUser.poll(2000, TimeUnit.MILLISECONDS));
}
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:19,代码来源:FtpLetReturnDefaultTest.java
示例20: onUploadEnd
import org.apache.ftpserver.ftplet.FtpRequest; //导入依赖的package包/类
@Override
public FtpletResult onUploadEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {
if (LOG.isDebugEnabled()) {
LOG.debug("Processing request: " + request);
}
if (request.hasArgument() && request.getArgument().startsWith(watchPath)) {
Path path = Paths.get(rootPath, request.getArgument()).toAbsolutePath();
// top directory is "camera" directory inside is the camera name
if (path.getNameCount() > 1) {
Path cameraDirectory = path.getParent();
String fileName = path.getFileName().toString();
if (LOG.isDebugEnabled()) {
LOG.debug("Request matches watched path '" + watchPath + "', camera directory: '" + cameraDirectory + "' fileName: '" + fileName);
}
SecurityEvent event = new SecurityEvent();
event.setFilePath(path);
event.setType(Type.cameraMotionDetected);
event.setSource(Camera.parse(cameraDirectory.getFileName().toString()));
getSecurityController().handle(event);
} else {
LOG.debug("Request path does not contain subdirectory for camera name, skipping...");
}
}
return super.onUploadEnd(session, request);
}
开发者ID:PoJD,项目名称:hawa,代码行数:29,代码来源:CameraUploadFtplet.java
注:本文中的org.apache.ftpserver.ftplet.FtpRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论