Skip to content

Commit

Permalink
renamed ClientActionPoster to PftpdService
Browse files Browse the repository at this point in the history
  • Loading branch information
wolpi committed Mar 13, 2021
1 parent da82539 commit 6c50d49
Show file tree
Hide file tree
Showing 33 changed files with 226 additions and 225 deletions.
10 changes: 5 additions & 5 deletions primitiveFTPd/src/org/primftpd/filesystem/AbstractFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.apache.sshd.common.file.SshFile;
import org.primftpd.events.ClientActionEvent;
import org.primftpd.events.ClientActionPoster;
import org.primftpd.services.PftpdService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -23,7 +23,7 @@ public abstract class AbstractFile {
protected boolean readable;
protected boolean exists;

protected final ClientActionPoster clientActionPoster;
protected final PftpdService pftpdService;

public AbstractFile(
String absPath,
Expand All @@ -33,22 +33,22 @@ public AbstractFile(
boolean readable,
boolean exists,
boolean isDirectory,
ClientActionPoster clientActionPoster) {
PftpdService pftpdService) {
this.absPath = absPath;
this.name = name;
this.lastModified = lastModified;
this.size = size;
this.readable = readable;
this.exists = exists;
this.isDirectory = isDirectory;
this.clientActionPoster = clientActionPoster;
this.pftpdService = pftpdService;
}

public abstract String getClientIp();
public abstract ClientActionEvent.Storage getClientActionStorage();

public void postClientAction(ClientActionEvent.ClientAction clientAction) {
clientActionPoster.postClientAction(
pftpdService.postClientAction(
getClientActionStorage(),
clientAction,
getClientIp(),
Expand Down
10 changes: 5 additions & 5 deletions primitiveFTPd/src/org/primftpd/filesystem/FsFile.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.primftpd.filesystem;

import org.primftpd.events.ClientActionEvent;
import org.primftpd.events.ClientActionPoster;
import org.primftpd.services.PftpdService;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
Expand All @@ -19,7 +19,7 @@ public abstract class FsFile<T> extends AbstractFile {

protected final File file;

public FsFile(File file, ClientActionPoster clientActionPoster) {
public FsFile(File file, PftpdService pftpdService) {
super(
file.getAbsolutePath(),
file.getName(),
Expand All @@ -28,12 +28,12 @@ public FsFile(File file, ClientActionPoster clientActionPoster) {
file.canRead(),
file.exists(),
file.isDirectory(),
clientActionPoster);
pftpdService);
this.file = file;
this.name = file.getName();
}

protected abstract T createFile(File file, ClientActionPoster clientActionPoster);
protected abstract T createFile(File file, PftpdService pftpdService);

@Override
public ClientActionEvent.Storage getClientActionStorage() {
Expand Down Expand Up @@ -142,7 +142,7 @@ public List<T> listFiles() {
if (filesArray != null) {
List<T> files = new ArrayList<>(filesArray.length);
for (File file : filesArray) {
files.add(createFile(file, clientActionPoster));
files.add(createFile(file, pftpdService));
}
return files;
}
Expand Down
12 changes: 6 additions & 6 deletions primitiveFTPd/src/org/primftpd/filesystem/FsFileSystemView.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.primftpd.filesystem;

import org.primftpd.events.ClientActionPoster;
import org.primftpd.services.PftpdService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -9,20 +9,20 @@
public abstract class FsFileSystemView<T extends FsFile<X>, X> {

protected final Logger logger = LoggerFactory.getLogger(getClass());
protected final ClientActionPoster clientActionPoster;
protected final PftpdService pftpdService;

protected abstract T createFile(File file, ClientActionPoster clientActionPoster);
protected abstract T createFile(File file, PftpdService pftpdService);

protected abstract String absolute(String file);

public FsFileSystemView(ClientActionPoster clientActionPoster) {
this.clientActionPoster = clientActionPoster;
public FsFileSystemView(PftpdService pftpdService) {
this.pftpdService = pftpdService;
}

public T getFile(String file) {
logger.trace("getFile({})", file);
String abs = absolute(file);
logger.trace(" getFile(abs: {})", file);
return createFile(new File(abs), clientActionPoster);
return createFile(new File(abs), pftpdService);
}
}
10 changes: 5 additions & 5 deletions primitiveFTPd/src/org/primftpd/filesystem/FsFtpFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

import org.apache.ftpserver.ftplet.FtpFile;
import org.apache.ftpserver.ftplet.User;
import org.primftpd.events.ClientActionPoster;
import org.primftpd.services.PftpdService;

public class FsFtpFile extends FsFile<FtpFile> implements FtpFile {
private final User user;

public FsFtpFile(File file, ClientActionPoster clientActionPoster, User user) {
super(file, clientActionPoster);
public FsFtpFile(File file, PftpdService pftpdService, User user) {
super(file, pftpdService);
this.user = user;
}

Expand All @@ -20,8 +20,8 @@ public String getClientIp() {
}

@Override
protected FtpFile createFile(File file, ClientActionPoster clientActionPoster) {
return new FsFtpFile(file, clientActionPoster, user);
protected FtpFile createFile(File file, PftpdService pftpdService) {
return new FsFtpFile(file, pftpdService, user);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
import org.apache.ftpserver.ftplet.FileSystemView;
import org.apache.ftpserver.ftplet.FtpException;
import org.apache.ftpserver.ftplet.User;
import org.primftpd.events.ClientActionPoster;
import org.primftpd.services.PftpdService;

public class FsFtpFileSystemView extends FsFileSystemView<FsFtpFile, FtpFile> implements FileSystemView {

private final User user;
private final File homeDir;
private FsFtpFile workingDir;

public FsFtpFileSystemView(ClientActionPoster clientActionPoster, File homeDir, User user) {
super(clientActionPoster);
public FsFtpFileSystemView(PftpdService pftpdService, File homeDir, User user) {
super(pftpdService);
this.homeDir = homeDir;
workingDir = getHomeDirectory();
this.user = user;
}

@Override
protected FsFtpFile createFile(File file, ClientActionPoster clientActionPoster) {
return new FsFtpFile(file, clientActionPoster, user);
protected FsFtpFile createFile(File file, PftpdService pftpdService) {
return new FsFtpFile(file, pftpdService, user);
}

@Override
Expand All @@ -35,7 +35,7 @@ protected String absolute(String file) {
public FsFtpFile getHomeDirectory() {
logger.trace("getHomeDirectory() -> {}", (homeDir != null ? homeDir.getAbsolutePath() : "null"));

return createFile(homeDir, clientActionPoster);
return createFile(homeDir, pftpdService);
}

public FsFtpFile getWorkingDirectory() {
Expand Down Expand Up @@ -82,7 +82,7 @@ public boolean changeWorkingDirectory(String dir) {
logger.trace("current WD '{}', new path '{}'",
currentAbsPath,
path);
workingDir = createFile(new File(path), clientActionPoster);
workingDir = createFile(new File(path), pftpdService);

return true;
}
Expand Down
12 changes: 6 additions & 6 deletions primitiveFTPd/src/org/primftpd/filesystem/FsSshFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.apache.sshd.common.Session;
import org.apache.sshd.common.file.SshFile;
import org.primftpd.events.ClientActionPoster;
import org.primftpd.services.PftpdService;

import java.io.File;
import java.io.IOException;
Expand All @@ -11,8 +11,8 @@
public class FsSshFile extends FsFile<SshFile> implements SshFile {
private final Session session;

public FsSshFile(File file, ClientActionPoster clientActionPoster, Session session) {
super(file, clientActionPoster);
public FsSshFile(File file, PftpdService pftpdService, Session session) {
super(file, pftpdService);
this.session = session;
}

Expand All @@ -22,8 +22,8 @@ public String getClientIp() {
}

@Override
protected SshFile createFile(File file, ClientActionPoster clientActionPoster) {
return new FsSshFile(file, clientActionPoster, session);
protected SshFile createFile(File file, PftpdService pftpdService) {
return new FsSshFile(file, pftpdService, session);
}

@Override
Expand All @@ -46,7 +46,7 @@ public boolean create() throws IOException {
@Override
public SshFile getParentFile() {
logger.trace("[{}] getParentFile()", name);
return new FsSshFile(file.getParentFile(), clientActionPoster, session);
return new FsSshFile(file.getParentFile(), pftpdService, session);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
import org.apache.sshd.common.file.SshFile;
import org.apache.sshd.common.Session;
import org.apache.sshd.common.file.FileSystemView;
import org.primftpd.events.ClientActionPoster;
import org.primftpd.services.PftpdService;

public class FsSshFileSystemView extends FsFileSystemView<FsSshFile, SshFile> implements FileSystemView {

private final File homeDir;
private final Session session;

public FsSshFileSystemView(ClientActionPoster clientActionPoster, File homeDir, Session session) {
super(clientActionPoster);
public FsSshFileSystemView(PftpdService pftpdService, File homeDir, Session session) {
super(pftpdService);
this.homeDir = homeDir;
this.session = session;
}

@Override
protected FsSshFile createFile(File file, ClientActionPoster clientActionPoster) {
return new FsSshFile(file, clientActionPoster, session);
protected FsSshFile createFile(File file, PftpdService pftpdService) {
return new FsSshFile(file, pftpdService, session);
}

@Override
Expand Down
16 changes: 8 additions & 8 deletions primitiveFTPd/src/org/primftpd/filesystem/QuickShareFile.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.primftpd.filesystem;

import org.primftpd.events.ClientActionEvent;
import org.primftpd.events.ClientActionPoster;
import org.primftpd.services.PftpdService;

import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
Expand All @@ -17,7 +17,7 @@ public abstract class QuickShareFile<T> extends AbstractFile {

protected File quickShareFile;

QuickShareFile(File quickShareFile, String dir, ClientActionPoster clientActionPoster) {
QuickShareFile(File quickShareFile, String dir, PftpdService pftpdService) {
// this c-tor is to be used to access fake directory
super(
dir,
Expand All @@ -27,11 +27,11 @@ public abstract class QuickShareFile<T> extends AbstractFile {
true,
true,
true,
clientActionPoster);
pftpdService);
this.quickShareFile = quickShareFile;
}

QuickShareFile(File quickShareFile, ClientActionPoster clientActionPoster) {
QuickShareFile(File quickShareFile, PftpdService pftpdService) {
// this c-tor is to be used to access actual file
super(
QuickShareFileSystemView.ROOT_PATH + quickShareFile.getName(),
Expand All @@ -41,12 +41,12 @@ public abstract class QuickShareFile<T> extends AbstractFile {
quickShareFile.canRead(),
quickShareFile.exists(),
false,
clientActionPoster);
pftpdService);
this.quickShareFile = quickShareFile;
}

abstract protected T createFile(File quickShareFile, String dir, ClientActionPoster clientActionPoster);
abstract protected T createFile(File quickShareFile, ClientActionPoster clientActionPoster);
abstract protected T createFile(File quickShareFile, String dir, PftpdService pftpdService);
abstract protected T createFile(File quickShareFile, PftpdService pftpdService);

@Override
public ClientActionEvent.Storage getClientActionStorage() {
Expand Down Expand Up @@ -93,7 +93,7 @@ public List<T> listFiles() {
logger.trace("[{}] listFiles()", name);
postClientAction(ClientActionEvent.ClientAction.LIST_DIR);

T result = createFile(quickShareFile, clientActionPoster);
T result = createFile(quickShareFile, pftpdService);
return Collections.singletonList(result);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.primftpd.filesystem;

import org.primftpd.events.ClientActionPoster;
import org.primftpd.services.PftpdService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -14,24 +14,24 @@ public abstract class QuickShareFileSystemView<T extends QuickShareFile<X>, X> {

protected final Logger logger = LoggerFactory.getLogger(getClass());
protected final File quickShareFile;
protected final ClientActionPoster clientActionPoster;
protected final PftpdService pftpdService;

QuickShareFileSystemView(File quickShareFile, ClientActionPoster clientActionPoster) {
QuickShareFileSystemView(File quickShareFile, PftpdService pftpdService) {
this.quickShareFile = quickShareFile;
this.clientActionPoster = clientActionPoster;
this.pftpdService = pftpdService;
}

abstract protected T createFile(File quickShareFile, String dir, ClientActionPoster clientActionPoster);
abstract protected T createFile(File quickShareFile, ClientActionPoster clientActionPoster);
abstract protected T createFile(File quickShareFile, String dir, PftpdService pftpdService);
abstract protected T createFile(File quickShareFile, PftpdService pftpdService);

public T getFile(String file) {
logger.trace("getFile({})", file);

T result;
if (ROOT_PATH.equals(file) || CURRENT_PATH.equals(file) || CURRENT_ROOT_PATH.equals(file)) {
result = createFile(quickShareFile, ROOT_PATH, clientActionPoster);
result = createFile(quickShareFile, ROOT_PATH, pftpdService);
} else {
result = createFile(quickShareFile, clientActionPoster);
result = createFile(quickShareFile, pftpdService);
}

return result;
Expand Down
Loading

0 comments on commit 6c50d49

Please sign in to comment.