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.java31
1 files changed, 18 insertions, 13 deletions
diff --git a/Dozentenmodulserver/src/server/ServerHandler.java b/Dozentenmodulserver/src/server/ServerHandler.java
index bf71607a..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,7 +89,7 @@ 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 {
String pk_institution = sql.setInstitution(con, university);
@@ -93,7 +97,7 @@ public class ServerHandler implements Server.Iface {
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
@@ -216,7 +220,8 @@ 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() +"'");
@@ -227,10 +232,9 @@ public class ServerHandler implements Server.Iface {
// eingelesen?
//FileUtils.moveFile(tmpFile, new File("141.79.128.103:/srv/nfs4slx/"
// + tmpFile.getName()));
- FileUtils.moveFile(tmpFile, new File("/srv/openslx/nfs/prod/"
- + 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) {
@@ -277,9 +281,9 @@ public class ServerHandler implements Server.Iface {
@Override
public boolean updateImageData(String name, String newName, String image_path,
boolean license, boolean internet, long ram, long cpu, String id,
- String version) throws TException {
+ String version, boolean isTemplate, long filesize) throws TException {
sql.UpdateImageData(con, name, newName,image_path, license, internet, cpu, ram,
- id, version);
+ id, version, isTemplate, filesize);
return false;
}
@@ -360,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
@@ -396,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);
@@ -412,4 +416,5 @@ public class ServerHandler implements Server.Iface {
}
+
}