summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/imagemaster/db
diff options
context:
space:
mode:
authorNils Schwabe2014-06-16 17:42:51 +0200
committerNils Schwabe2014-06-16 17:42:51 +0200
commit09a0f7f6184b680c7e208104d7e8fcacde27a00d (patch)
treeb0ce867cdcb9319e9b69da1419f8c7b427442854 /src/main/java/org/openslx/imagemaster/db
parentStarted to implement download of images (diff)
downloadmasterserver-09a0f7f6184b680c7e208104d7e8fcacde27a00d.tar.gz
masterserver-09a0f7f6184b680c7e208104d7e8fcacde27a00d.tar.xz
masterserver-09a0f7f6184b680c7e208104d7e8fcacde27a00d.zip
Add FtpUsers are now in sync with DB
Diffstat (limited to 'src/main/java/org/openslx/imagemaster/db')
-rw-r--r--src/main/java/org/openslx/imagemaster/db/DbFtpUser.java21
-rw-r--r--src/main/java/org/openslx/imagemaster/db/DbImage.java5
2 files changed, 17 insertions, 9 deletions
diff --git a/src/main/java/org/openslx/imagemaster/db/DbFtpUser.java b/src/main/java/org/openslx/imagemaster/db/DbFtpUser.java
index ea8a79f..088109e 100644
--- a/src/main/java/org/openslx/imagemaster/db/DbFtpUser.java
+++ b/src/main/java/org/openslx/imagemaster/db/DbFtpUser.java
@@ -1,5 +1,6 @@
package org.openslx.imagemaster.db;
+import java.sql.Timestamp;
import java.util.List;
@@ -9,28 +10,38 @@ public class DbFtpUser
public final String password;
public final String mode;
public final String filename;
+ public final String sessionId;
+ public final Timestamp timestamp;
- public DbFtpUser(String username, String password, String mode, String filename)
+ public DbFtpUser(String username, String password, String mode, String filename, String sessionId, Timestamp timestamp)
{
this.username = username;
this.password = password;
this.mode = mode;
this.filename = filename;
+ this.sessionId = sessionId;
+ this.timestamp = timestamp;
}
public static List<DbFtpUser> getAllUsers()
{
- return MySQL.findAll( DbFtpUser.class, "SELECT username, password, mode, filename from ftpUser" );
+ return MySQL.findAll( DbFtpUser.class, "SELECT username, password, mode, filename, sessionid, timestamp from ftpUser" );
}
public static void addUser(DbFtpUser user)
{
- MySQL.update( "INSERT INTO ftpUser username, password, mode, filename VALUES (? , ?, ?, ?)",
- user.username, user.password, user.mode, user.filename);
+ MySQL.update( "INSERT INTO ftpUser (username, password, mode, filename, sessionid, timestamp) VALUES (?, ?, ?, ?, ?, ?)",
+ user.username, user.password, user.mode, user.filename, user.sessionId, user.timestamp);
}
public static DbFtpUser getUserByName(String username)
{
- return MySQL.findUniqueOrNull( DbFtpUser.class, "SELECT username, password, mode, filename FROM ftpUser WHERE username=?", username );
+ return MySQL.findUniqueOrNull( DbFtpUser.class, "SELECT username, password, mode, filename, sessionid, timestamp FROM ftpUser WHERE username=?", username );
+ }
+
+ public static boolean removeUserByName(String username)
+ {
+ int result = MySQL.update( "DELETE FROM ftpUser WHERE username=? LIMIT 1", username );
+ return result == 1;
}
}
diff --git a/src/main/java/org/openslx/imagemaster/db/DbImage.java b/src/main/java/org/openslx/imagemaster/db/DbImage.java
index 2cf3922..59701e4 100644
--- a/src/main/java/org/openslx/imagemaster/db/DbImage.java
+++ b/src/main/java/org/openslx/imagemaster/db/DbImage.java
@@ -24,7 +24,6 @@ public class DbImage
public final String longDescription;
public final Timestamp timestamp;
public final String ftpUser;
- public final String ftpPassword;
public final long fileSize;
@@ -44,14 +43,13 @@ public class DbImage
this.longDescription = null;
this.timestamp = new Timestamp( 0 );
this.ftpUser = null;
- this.ftpPassword = null;
this.fileSize = 0;
}
public DbImage(String UUID, int imageVersion, String imageName, String imagePath,
Timestamp imageCreateTime, Timestamp imageUpdateTime, int imageOwner, String contentOperatingSystem,
boolean isValid, boolean isDeleted, String shortDescription, String longDescription,
- Timestamp timestamp, String ftpUser, String ftpPassword, long fileSize)
+ Timestamp timestamp, String ftpUser, long fileSize)
{
this.UUID = UUID;
this.imageVersion = imageVersion;
@@ -67,7 +65,6 @@ public class DbImage
this.longDescription = longDescription;
this.timestamp = timestamp;
this.ftpUser = ftpUser;
- this.ftpPassword = ftpPassword;
this.fileSize = fileSize;
}