summaryrefslogtreecommitdiffstats
path: root/Dozentenmodulserver/src/server/ServerHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'Dozentenmodulserver/src/server/ServerHandler.java')
-rw-r--r--Dozentenmodulserver/src/server/ServerHandler.java71
1 files changed, 34 insertions, 37 deletions
diff --git a/Dozentenmodulserver/src/server/ServerHandler.java b/Dozentenmodulserver/src/server/ServerHandler.java
index 7c93422f..95b261d3 100644
--- a/Dozentenmodulserver/src/server/ServerHandler.java
+++ b/Dozentenmodulserver/src/server/ServerHandler.java
@@ -18,19 +18,23 @@ import java.util.UUID;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
+import models.Configuration;
+
import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
+import org.ini4j.Wini;
import sql.SQL;
import util.XMLCreator;
public class ServerHandler implements Server.Iface {
-
static SQL sql = new SQL();
static Connection con = sql.getConnection();
private static Logger log = Logger.getLogger(ServerHandler.class);
+
+
@Override
public User getFtpUser() throws TException {
log.info(new Date() + " - returing FTPUser...");
@@ -38,7 +42,7 @@ public class ServerHandler implements Server.Iface {
user.setUserName(UUID.randomUUID().toString().substring(0, 8));
user.setPassword(getEncodedSha1Sum(UUID.randomUUID().toString()
.substring(0, 8)));
- user.setPath("/srv/openslx/nfs/temp");
+ user.setPath(Configuration.config.getAbsolute_path());
SQL sql = new SQL();
Connection con = sql.getConnection();
sql.writeFTPUser(con, user.getUserName(), user.getPassword());
@@ -85,15 +89,15 @@ public class ServerHandler implements Server.Iface {
public boolean writeVLdata(String imagename, String login,
String firstname, String lastname, String university, String Mail,
String Tel, String Fak, boolean license, boolean internet,
- long ram, long cpu, String imagePath) throws TException {
+ long ram, long cpu, String imagePath, boolean isTemplate ,long filesize) throws TException {
- int pk_institution = sql.setInstitution(con, university);
+ String pk_institution = sql.setInstitution(con, university);
- int pk_person = sql.setPerson(con, login, lastname, firstname, Mail,
+ String pk_person = sql.setPerson(con, login, lastname, firstname, Mail,
new Date(), pk_institution);
sql.setImageData(con, pk_person, license, internet, cpu, ram,
- imagename, imagePath);
+ imagename, imagePath,isTemplate ,filesize);
log.info(new Date() + " - written VLdata");
// TODO Auto-generated method stub
@@ -177,18 +181,18 @@ public class ServerHandler implements Server.Iface {
String imagename, String login, String firstname, String lastname,
String university, String Mail, String Tel, String Fak)
throws TException {
- int pk_image = 0;
+ String pk_image = null;
int imageversion = 0;
- int pk_institution = sql.setInstitution(con, university);
- int pk_person = sql.setPerson(con, login, lastname, firstname, Mail,
+ String pk_institution = sql.setInstitution(con, university);
+ String pk_person = sql.setPerson(con, login, lastname, firstname, Mail,
new Date(), pk_institution);
ResultSet image = sql.getImageIDandVersion(con, imagename);
try {
while (image.next()) {
- pk_image = image.getInt("GUID_imageID");
+ pk_image = image.getString("GUID_imageID");
imageversion = image.getInt("imageVersion");
}
} catch (SQLException e) {
@@ -216,28 +220,21 @@ public class ServerHandler implements Server.Iface {
}
@Override
- public boolean startFileCopy(String file) throws TException {
+ public boolean startFileCopy(String filename) throws TException {
+ String file=Configuration.config.getAbsolute_path()+"temp/"+filename;
File tmpFile = new File(file);
-
+
+ log.info(new Date() + " - Trying to move file to '/srv/openslx/nfs/prod/"+tmpFile.getName() +"'");
try {
// der übergebene Filename ist falsch - hier muss der generierte
// name geholt werden, nicht der ursprüngliche name. wo wird dieser
// eingelesen?
- FileUtils.moveFile(tmpFile, new File("141.79.128.103:/srv/nfs4slx/"
- + tmpFile.getName()));
-
- // der übergebene Filename ist falsch - hier muss der generierte
- // name geholt werden, nicht der ursprüngliche name. wo wird dieser
- // eingelesen?
- FileUtils.moveFile(tmpFile, new File("141.79.128.103:/srv/nfs4slx/"
- + tmpFile.getName()));
-
- // der übergebene Filename ist falsch - hier muss der generierte
- // name geholt werden, nicht der ursprüngliche name. wo wird dieser
- // eingelesen?
- FileUtils.moveFile(tmpFile, new File("141.79.128.103:/srv/nfs4slx/"
- + tmpFile.getName()));
+ //FileUtils.moveFile(tmpFile, new File("141.79.128.103:/srv/nfs4slx/"
+ // + tmpFile.getName()));
+ FileUtils.moveFile(tmpFile, new File(Configuration.config.getAbsolute_path()+"prod/"+filename));
+ int ret=sql.UpdateImagePath(con, filename);
+ log.info(new Date() + " - update "+ret);
log.info(new Date() + " - file moved");
} catch (IOException e) {
@@ -282,11 +279,11 @@ public class ServerHandler implements Server.Iface {
}
@Override
- public boolean updateImageData(String name, String newName,
+ public boolean updateImageData(String name, String newName, String image_path,
boolean license, boolean internet, long ram, long cpu, String id,
- String version) throws TException {
- sql.UpdateImageData(con, name, newName, license, internet, cpu, ram,
- id, version);
+ String version, boolean isTemplate, long filesize) throws TException {
+ sql.UpdateImageData(con, name, newName,image_path, license, internet, cpu, ram,
+ id, version, isTemplate, filesize);
return false;
}
@@ -330,13 +327,13 @@ public class ServerHandler implements Server.Iface {
boolean isActive, String imagename, String firstname,
String lastname, String university, String Mail, String Tel,
String Fak, String id) throws TException {
- int pk_image = 0;
+ String pk_image = "";
int imageversion = 0;
ResultSet image = sql.getImageIDandVersion(con, imagename);
try {
while (image.next()) {
- pk_image = image.getInt("GUID_imageID");
+ pk_image = image.getString("GUID_imageID");
imageversion = image.getInt("imageVersion");
}
} catch (SQLException e) {
@@ -355,9 +352,8 @@ public class ServerHandler implements Server.Iface {
e.printStackTrace();
}
- sql.updateLectureData(con, pk_image, imageversion, lastname, newName,
- desc, shortdesc, startDate, endDate, isActive, id);
- log.info(new Date() + " - Failed to execute updateLecturedata.");
+ //sql.updateLectureData(con, pk_image, imageversion, lastname, newName,
+ // desc, shortdesc, startDate, endDate, isActive, id);
return false;
}
@@ -368,7 +364,7 @@ public class ServerHandler implements Server.Iface {
String stringFile = sql.getFile(con, imageid, imageversion);
log.info(new Date() + " - File to Delete: " + stringFile);
- File tmpFile = new File(stringFile);
+ File tmpFile = new File(Configuration.config.getAbsolute_path()+stringFile);
try {
// File wird von Server gelöscht
@@ -404,7 +400,7 @@ public class ServerHandler implements Server.Iface {
String date = rs.getString("admin_createTime").replace(" ", "")
.replace("-", "").replace(":", "");
String name = rs.getString("name");
- String path = "/srv/openslx/nfs/temp/"
+ String path = Configuration.config.getAbsolute_path()+"temp/"
+ date.substring(0, date.length() - 2) + "_" + hs + "_"
+ user + "_" + name + ".xml";
File xmlFile = new File(path);
@@ -420,4 +416,5 @@ public class ServerHandler implements Server.Iface {
}
+
}