Skip to content

Commit 860516b

Browse files
author
NoteFox
committed
revied Comments and corrected
1 parent 575db20 commit 860516b

3 files changed

Lines changed: 146 additions & 11 deletions

File tree

Log.txt

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
1-
2020-05-08 at 15:06:08 CEST | given Data: MapNamenoname | Date: insert | coords:
1+
2020-05-12 at 11:46:53 MESZ | given Data: MapNamenoname | Date: insert | coords:
22
x = 13.005 | y = 15.123
33
x = 13.005 | y = 15.123
44
x = 13.005 | y = 15.123
55
x = 13.005 | y = 15.123
66
x = 13.005 | y = 15.123
77

8-
2020-05-08 at 15:06:08 CEST | fixing coordinates
9-
2020-05-08 at 15:06:08 CEST | mapname: noname
10-
2020-05-08 at 15:06:08 CEST | new Request found
11-
2020-05-08 at 15:06:08 CEST | Downloading mapName = noname | Date = insert | Coordinates = [LClasses.Coords;@9a1b15
12-
2020-05-08 at 15:06:08 CEST | running: [Ljava.lang.String;@45989562
8+
2020-05-12 at 11:46:53 MESZ | fixing coordinates
9+
2020-05-12 at 11:46:53 MESZ | mapname: noname
10+
2020-05-12 at 11:46:53 MESZ | new Request found
11+
2020-05-12 at 11:46:53 MESZ | Downloading mapName = noname | Date = insert | Coordinates = [LClasses.Coords;@3f65f1a4
12+
2020-05-12 at 11:46:53 MESZ | running: [Ljava.lang.String;@7a67682c
13+
2020-05-12 at 11:48:13 MESZ | given Data: MapNamemapname | Date: insert | coords:
14+
x = 13.005 | y = 15.123
15+
x = 13.005 | y = 15.123
16+
x = 13.005 | y = 15.123
17+
x = 13.005 | y = 15.123
18+
x = 13.005 | y = 15.123
19+
20+
2020-05-12 at 11:48:13 MESZ | fixing coordinates
21+
2020-05-12 at 11:48:13 MESZ | mapname: mapname
22+
2020-05-12 at 11:49:21 MESZ | given Data: MapNamemapnamme | Date: insert | coords:
23+
x = 13.005 | y = 15.123
24+
x = 13.005 | y = 15.123
25+
x = 13.005 | y = 15.123
26+
x = 13.005 | y = 15.123
27+
x = 13.005 | y = 15.123
28+
29+
2020-05-12 at 11:49:21 MESZ | fixing coordinates
30+
2020-05-12 at 11:49:21 MESZ | mapname: mapnamme
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*package Server;
2+
3+
public class FTPService {
4+
FtpServerFactory serverFactory = new FtpServerFactory();
5+
ListenerFactory factory = new ListenerFactory();
6+
factory.setPort(1234);// set the port of the listener (choose your desired port, not 1234)
7+
serverFactory.addListener("default", factory.createListener());
8+
PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
9+
userManagerFactory.setFile(new File("/home/blablah/myusers.properties"));//choose any. We're telling the FTP-server where to read its user list
10+
userManagerFactory.setPasswordEncryptor(new PasswordEncryptor()
11+
{//We store clear-text passwords in this example
12+
13+
@Override
14+
public String encrypt(String password) {
15+
return password;
16+
}
17+
18+
@Override
19+
public boolean matches(String passwordToCheck, String storedPassword) {
20+
return passwordToCheck.equals(storedPassword);
21+
}
22+
});
23+
//Let's add a user, since our myusers.properties file is empty on our first test run
24+
BaseUser user = new BaseUser();
25+
user.setName("test");
26+
user.setPassword("test");
27+
user.setHomeDirectory("/home/blablah");
28+
List<Authority> authorities = new ArrayList<Authority>();
29+
authorities.add(new WritePermission());
30+
user.setAuthorities(authorities);
31+
UserManager um = userManagerFactory.createUserManager();
32+
try
33+
{
34+
um.save(user);//Save the user to the user list on the filesystem
35+
}
36+
catch (FtpException e1)
37+
{
38+
//Deal with exception as you need
39+
}
40+
serverFactory.setUserManager(um);
41+
Map<String, Ftplet> m = new HashMap<String, Ftplet>();
42+
m.put("miaFtplet", new Ftplet()
43+
{
44+
45+
@Override
46+
public void init(FtpletContext ftpletContext) throws FtpException {
47+
//System.out.println("init");
48+
//System.out.println("Thread #" + Thread.currentThread().getId());
49+
}
50+
51+
@Override
52+
public void destroy() {
53+
//System.out.println("destroy");
54+
//System.out.println("Thread #" + Thread.currentThread().getId());
55+
}
56+
57+
@Override
58+
public FtpletResult beforeCommand(FtpSession session, FtpRequest request) throws FtpException, IOException
59+
{
60+
//System.out.println("beforeCommand " + session.getUserArgument() + " : " + session.toString() + " | " + request.getArgument() + " : " + request.getCommand() + " : " + request.getRequestLine());
61+
//System.out.println("Thread #" + Thread.currentThread().getId());
62+
63+
//do something
64+
return FtpletResult.DEFAULT;//...or return accordingly
65+
}
66+
67+
@Override
68+
public FtpletResult afterCommand(FtpSession session, FtpRequest request, FtpReply reply) throws FtpException, IOException
69+
{
70+
//System.out.println("afterCommand " + session.getUserArgument() + " : " + session.toString() + " | " + request.getArgument() + " : " + request.getCommand() + " : " + request.getRequestLine() + " | " + reply.getMessage() + " : " + reply.toString());
71+
//System.out.println("Thread #" + Thread.currentThread().getId());
72+
73+
//do something
74+
return FtpletResult.DEFAULT;//...or return accordingly
75+
}
76+
77+
@Override
78+
public FtpletResult onConnect(FtpSession session) throws FtpException, IOException
79+
{
80+
//System.out.println("onConnect " + session.getUserArgument() + " : " + session.toString());
81+
//System.out.println("Thread #" + Thread.currentThread().getId());
82+
83+
//do something
84+
return FtpletResult.DEFAULT;//...or return accordingly
85+
}
86+
87+
@Override
88+
public FtpletResult onDisconnect(FtpSession session) throws FtpException, IOException
89+
{
90+
//System.out.println("onDisconnect " + session.getUserArgument() + " : " + session.toString());
91+
//System.out.println("Thread #" + Thread.currentThread().getId());
92+
93+
//do something
94+
return FtpletResult.DEFAULT;//...or return accordingly
95+
}
96+
});
97+
serverFactory.setFtplets(m);
98+
//Map<String, Ftplet> mappa = serverFactory.getFtplets();
99+
//System.out.println(mappa.size());
100+
//System.out.println("Thread #" + Thread.currentThread().getId());
101+
//System.out.println(mappa.toString());
102+
FtpServer server = serverFactory.createServer();
103+
try
104+
{
105+
server.start();//Your FTP server starts listening for incoming FTP-connections, using the configuration options previously set
106+
}
107+
catch (FtpException ex)
108+
{
109+
//Deal with exception as you need
110+
}
111+
}
112+
*/

src/main/java/Server/SpringClass.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import Classes.CommandReturn;
44
import Classes.Coords;
55
import Classes.QueueRequest;
6+
import ch.qos.logback.core.encoder.EchoEncoder;
67
import org.springframework.boot.SpringApplication;
78
import org.springframework.boot.autoconfigure.SpringBootApplication;
89
import org.springframework.web.bind.annotation.GetMapping;
@@ -57,7 +58,7 @@ public String status() {
5758
return sb.toString();
5859
}
5960

60-
// 192.168.178.35:8080/request?coords=13.005,15.123_13.005,15.123_13.005,15.123_13.005,15.123_13.005,15.123
61+
// 192.168.178.35:8080/request?name=mapname&coords=13.005,15.123_13.005,15.123_13.005,15.123_13.005,15.123_13.005,15.123&date=11-09-97
6162
@GetMapping("/request")
6263
public String request(@RequestParam(value = "name", defaultValue = "noname") String mapname,
6364
@RequestParam(value = "coords") String coords,
@@ -81,10 +82,14 @@ public String request(@RequestParam(value = "name", defaultValue = "noname") Str
8182
float x;
8283
float y;
8384

84-
for (String s : coordsS) {
85-
x = Float.parseFloat(s.split(",")[0]);
86-
y = Float.parseFloat(s.split(",")[1]);
87-
coordinates.add(new Coords(x, y));
85+
try {
86+
for (String s : coordsS) {
87+
x = Float.parseFloat(s.split(",")[0]);
88+
y = Float.parseFloat(s.split(",")[1]);
89+
coordinates.add(new Coords(x, y));
90+
}
91+
} catch (Exception e) {
92+
serviceInstance.log(e.toString());
8893
}
8994

9095
q = new QueueRequest(coordinates, date, mapname);

0 commit comments

Comments
 (0)