本文整理汇总了Java中org.apache.ftpserver.ftplet.FtpException类的典型用法代码示例。如果您正苦于以下问题:Java FtpException类的具体用法?Java FtpException怎么用?Java FtpException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FtpException类属于org.apache.ftpserver.ftplet包,在下文中一共展示了FtpException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startFtpServer
import org.apache.ftpserver.ftplet.FtpException; //导入依赖的package包/类
/**
* ����FTP������
* @param hostip ����ip
*/
private void startFtpServer(String hostip) {
FtpServerFactory serverFactory = new FtpServerFactory();
PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
File files = new File(filename);
//���������ļ�
userManagerFactory.setFile(files);
serverFactory.setUserManager(userManagerFactory.createUserManager());
// ���ü���IP�Ͷ˿ں�
ListenerFactory factory = new ListenerFactory();
factory.setPort(PORT);
factory.setServerAddress(hostip);
// replace the default listener
serverFactory.addListener("default", factory.createListener());
// start the server
mFtpServer = serverFactory.createServer();
try {
mFtpServer.start();
Log.d(TAG, "������FTP������ ip = " + hostip);
} catch (FtpException e) {
System.out.println(e);
}
}
示例2: getWorkingDirectory
import org.apache.ftpserver.ftplet.FtpException; //导入依赖的package包/类
@Override
public FtpFile getWorkingDirectory () throws FtpException
{
if (currentPath.contains (CONTENT_DATE))
{
return new FtpContentDateFile (user, workingCol,
pathInfo.get (DATE_YEAR), pathInfo.get(DATE_MONTH),
pathInfo.get(DATE_DAY));
}
if (workingCol == null)
{
return getHomeDirectory ();
}
else
{
return new FtpCollectionFile (user, workingCol);
}
}
示例3: start
import org.apache.ftpserver.ftplet.FtpException; //导入依赖的package包/类
@PostConstruct
public void start () throws FtpException
{
if (server == null)
server = ftpServer.createFtpServer(port, passivePort, ftps);
if (server.isStopped())
{
try
{
server.start();
}
catch (Exception e)
{
LOGGER.error("Cannot start ftp server: " + e.getMessage ());
}
}
}
示例4: addUser
import org.apache.ftpserver.ftplet.FtpException; //导入依赖的package包/类
public void addUser(String name, String pass, String directory, boolean canWrite) {
BaseUser user = new BaseUser();
user.setName(name);
user.setPassword(pass);
//String root = ProjectManager.getInstance().getCurrentProject().getStoragePath() + "/" + directory;
user.setHomeDirectory(directory);
//check if user can write
if (canWrite) {
List<Authority> auths = new ArrayList<Authority>();
Authority auth = new WritePermission();
auths.add(auth);
user.setAuthorities(auths);
}
try {
um.save(user);
} catch (FtpException e) {
e.printStackTrace();
}
}
示例5: start
import org.apache.ftpserver.ftplet.FtpException; //导入依赖的package包/类
public void start() {
FtpServerFactory serverFactory = new FtpServerFactory();
ListenerFactory factory = new ListenerFactory();
factory.setPort(mPort);
// replace the default listener
serverFactory.addListener("default", factory.createListener());
serverFactory.setUserManager(um);
Map ftpLets = new HashMap<>();
ftpLets.put("ftpLet", new CallbackFTP(mCallback));
serverFactory.setFtplets(ftpLets);
// start the server
try {
server = serverFactory.createServer();
server.start();
MLog.d(TAG, "server started");
} catch (FtpException e) {
e.printStackTrace();
MLog.d(TAG, "server not started");
}
}
示例6: amqpReplyFlow
import org.apache.ftpserver.ftplet.FtpException; //导入依赖的package包/类
@Bean
IntegrationFlow amqpReplyFlow(ConnectionFactory rabbitConnectionFactory,
UserManager ftpUserManager) {
return IntegrationFlows.from(Amqp.inboundGateway(rabbitConnectionFactory, this.ftpRequests)
.messageConverter(new Jackson2JsonMessageConverter()))
.transform(String.class, new GenericTransformer<String, String>() {
@Override
public String transform(String source) {
try {
Map<String, String> map = toMap(source);
String ws = map.get("workspace");
String usr = map.get("user");
String password = UUID.randomUUID().toString();
FtpUser user = new FtpUser(ws, usr, password, true);
ftpUserManager.save(user);
String ftpUri = buildFtpConnectionString(host, port, user);
log.info("registering: workspace: " + ws + ", " + "user: " + usr + ", ftp URI: " + ftpUri);
return ftpUri;
} catch (FtpException e) {
throw new RuntimeException(e);
}
}
}).get();
}
示例7: getAllUserNames
import org.apache.ftpserver.ftplet.FtpException; //导入依赖的package包/类
@Override
public String[] getAllUserNames() throws FtpException
{
DetachedCriteria criteria = DetachedCriteria.forClass (
fr.gael.dhus.database.object.User.class);
criteria.add (Restrictions.eq ("deleted", false));
List<fr.gael.dhus.database.object.User> users = userService.getUsers (
criteria, 0, 0);
List<String> names = new LinkedList<> ();
for (fr.gael.dhus.database.object.User user : users)
{
names.add (user.getUsername ());
}
return names.toArray(new String[names.size()]);
}
示例8: before
import org.apache.ftpserver.ftplet.FtpException; //导入依赖的package包/类
@Before
public void before() throws Exception {
directory = new File(folder.newFolder(), "test-1");
directory.mkdir();
FtpServerFactory serverFactory = new FtpServerFactory();
ListenerFactory listenerFactory = new ListenerFactory();
listenerFactory.setServerAddress("127.0.0.1");
listenerFactory.setPort(21000);
serverFactory.addListener("default", listenerFactory.createListener());
serverFactory.setUserManager(new AdminUserManagerFactory(directory.getParentFile().getAbsolutePath()));
try {
ftpServer = serverFactory.createServer();
ftpServer.start();
} catch (FtpException ex) {
throw new RuntimeException(ex);
}
FtpStorageProviderFactory factory = new FtpStorageProviderFactory();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(FtpStorage.URL_PROPERTY, "ftp://admin:[email protected]:21000/" + directory.getName());
properties.put(FtpStorage.CREATE_DIRECTORY_PROPERTY, "false");
storageProvider = factory.createStorageProvider(properties);
}
示例9: before
import org.apache.ftpserver.ftplet.FtpException; //导入依赖的package包/类
@Before
public void before() throws Exception {
directory = folder.newFolder();
FtpServerFactory serverFactory = new FtpServerFactory();
ListenerFactory listenerFactory = new ListenerFactory();
listenerFactory.setServerAddress("127.0.0.1");
listenerFactory.setPort(21000);
serverFactory.addListener("default", listenerFactory.createListener());
serverFactory.setUserManager(new AdminUserManagerFactory(directory.getAbsolutePath()));
try {
ftpServer = serverFactory.createServer();
ftpServer.start();
} catch (FtpException ex) {
throw new RuntimeException(ex);
}
factory = new FtpStorageProviderFactory();
}
示例10: changeWorkingDirectory
import org.apache.ftpserver.ftplet.FtpException; //导入依赖的package包/类
@Override
public boolean changeWorkingDirectory(String dir) throws FtpException {
final String working = mPath;
String path = dir;
File fileDir = new File(path);
if (!fileDir.isAbsolute()) {
path = working + File.separator + dir;
fileDir = new File(path);
}
if (!fileDir.isDirectory())
return false;
final String absPath = fileDir.getAbsolutePath();
if (working.length() * 2 == absPath.length() && (working + working).equals(absPath))
return true;
mPath = path;
mWorking.setFile(mPath);
return true;
}
示例11: getFile
import org.apache.ftpserver.ftplet.FtpException; //导入依赖的package包/类
@Override
public FtpFile getFile(String file) throws FtpException {
final String working = mPath;
final String path;
if (file.charAt(0) == '/') {
path = file;
} else if ("./".equals(file) || ".".equals(file)) {
path = working;
} else {
path = working + "/" + file;
}
final FTPFile child;
if (mSaved.isEmpty()) {
child = new FTPFile(path, mOwner, mGroup, mStreamSize);
} else {
child = mSaved.remove(0);
child.setFile(path);
}
mChildren.add(child);
return child;
}
示例12: createFileSystemView
import org.apache.ftpserver.ftplet.FtpException; //导入依赖的package包/类
@Override
public FileSystemView createFileSystemView(User user) throws FtpException {
final String home = user.getHomeDirectory();
final String owner = user.getName();
final String group = user.getName();
final int streamSize = FTPFile.DEFAULT_SIZE;
synchronized (this) {
if (mViews.isEmpty()) {
return new FTPFileSystemView(home, owner, group, streamSize);
} else {
final FTPFileSystemView view = mViews.remove(0);
view.init(home, owner, group, streamSize);
return view;
}
}
}
示例13: setApplicationContext
import org.apache.ftpserver.ftplet.FtpException; //导入依赖的package包/类
@Override
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
this.applicationContext = applicationContext;
try {
start();
LOGGER.info("********************************************************");
LOGGER.info("*** FTP Server Created and running on port:"
+ listenPort + " ***");
LOGGER.info("********************************************************");
} catch (FtpException e) {
LOGGER.error("*** ERROR *** Unable to Start server FTP SERVER ", e);
}
}
示例14: selectNewUser
import org.apache.ftpserver.ftplet.FtpException; //导入依赖的package包/类
private String selectNewUser() {
String newUser = null;
for (int i=0; i<MAX_FTP_USERS; i++) {
try {
newUser = "user"+i;
if (! userManager.doesExist(newUser)) break;
} catch (FtpException e) {
log.error("Error reading user file from FTP server.");
return null;
}
if (i == MAX_FTP_USERS-1) {
log.error("Maximum number of users exceeded.");
return null;
}
}
return newUser;
}
示例15: setUser
import org.apache.ftpserver.ftplet.FtpException; //导入依赖的package包/类
public UserManager setUser() {
BaseUser user = new BaseUser();
user.setName(userName);
user.setPassword(password);
user.setHomeDirectory(homeDirectory);
List<Authority> authorities = new ArrayList<Authority>();
authorities.add(new WritePermission());
user.setAuthorities(authorities);
UserManager um = userManagerFactory.createUserManager();
try {
um.save(user);//Save the user to the user list on the filesystem
} catch (FtpException e1) {
log.error("FTP server startup failed " + e1.getMessage());
}
return um;
}