summaryrefslogtreecommitdiffstats
path: root/Dozentenmodulserver/src/sql/SQL.java
diff options
context:
space:
mode:
authorunknown2014-05-08 12:46:57 +0200
committerunknown2014-05-08 12:46:57 +0200
commitc6b8f14dd17839b78c753999f2f73b7dfdc8d745 (patch)
tree60eca56f67a56aa901638ccaccd11b43a453a554 /Dozentenmodulserver/src/sql/SQL.java
parentMinimale Änderungen für Move-Vorgang (diff)
downloadtutor-module-c6b8f14dd17839b78c753999f2f73b7dfdc8d745.tar.gz
tutor-module-c6b8f14dd17839b78c753999f2f73b7dfdc8d745.tar.xz
tutor-module-c6b8f14dd17839b78c753999f2f73b7dfdc8d745.zip
-Kopieren von Temp zu Prod inkl. änderung des Pfades in SQL-DB
-Dateigröße zur DB hinzugefügt
Diffstat (limited to 'Dozentenmodulserver/src/sql/SQL.java')
-rw-r--r--Dozentenmodulserver/src/sql/SQL.java39
1 files changed, 33 insertions, 6 deletions
diff --git a/Dozentenmodulserver/src/sql/SQL.java b/Dozentenmodulserver/src/sql/SQL.java
index 36aadd89..69843988 100644
--- a/Dozentenmodulserver/src/sql/SQL.java
+++ b/Dozentenmodulserver/src/sql/SQL.java
@@ -8,6 +8,8 @@ import java.util.Date;
import java.util.Random;
import java.util.UUID;
+import models.Configuration;
+
import org.apache.log4j.Logger;
import server.BinaryListener;
@@ -25,7 +27,7 @@ public class SQL {
}
try {
Connection con = DriverManager
- .getConnection("jdbc:mysql://127.0.0.1/bwLehrpool?user=root&password=slx-ng-open");
+ .getConnection("jdbc:mysql://"+Configuration.config.getSql_connection()+"?user="+Configuration.config.getSql_user()+"&password="+Configuration.config.getSql_pass()+"");
con.setAutoCommit(false);
log.info(new Date() + " - Connection returned to Client.");
return con;
@@ -47,7 +49,7 @@ public class SQL {
+ user
+ "',SHA1('"
+ pass
- + "'),'10001','12345','/srv/openslx/nfs/temp');");
+ + "'),'10001','12345','"+Configuration.config.getAbsolute_path()+"temp/');");
con.commit();
log.info(new Date() + " - created FTPUser " + user + " : " + pass
+ ".");
@@ -201,7 +203,7 @@ public class SQL {
public boolean setImageData(Connection con, String pk_person, boolean license,
boolean internet, long cpu, long ram, String imagename,
- String imagePath) {
+ String imagePath, boolean isTemplate, long filesize) {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
@@ -218,7 +220,7 @@ public class SQL {
Statement stm = con.createStatement();
String uid = UUID.randomUUID().toString();
- stm.executeUpdate("INSERT INTO `bwLehrpool`.`m_VLData_imageInfo`(`GUID_imageID`,`imageVersion`,`image_name`,`image_path`,`image_lastCall`,`image_create_time`,`image_update_time`,`image_owner`,`image_change_by`,`rec_create_time`,`rec_change_time`,`rec_owner`,`rec_change_by`,`content_operatingSystem`,`status_isCompressed`,`status_isSecure`,`status_isOptimzed`,`status_isValid`,`status_isReady`,`status_isDeleted`,`status_isLastOfficialVersion`,`cond_hasLicenseRestriction`,`cond_hasInternetRestriction`,`cond_minRAM`,`cond_minCPUs`)VALUES('"
+ stm.executeUpdate("INSERT INTO `bwLehrpool`.`m_VLData_imageInfo`(`GUID_imageID`,`imageVersion`,`image_name`,`image_path`,`image_lastCall`,`image_create_time`,`image_update_time`,`image_owner`,`image_change_by`,`rec_create_time`,`rec_change_time`,`rec_owner`,`rec_change_by`,`content_operatingSystem`,`status_isCompressed`,`status_isSecure`,`status_isOptimzed`,`status_isValid`,`status_isReady`,`status_isDeleted`,`status_isLastOfficialVersion`,`cond_hasLicenseRestriction`,`cond_hasInternetRestriction`,`cond_minRAM`,`cond_minCPUs`,`image_isTemplate`,`image_filesize`)VALUES('"
+ uid // GUID_imageID
+ "',1,'" // imageVersion
+ imagename // image_name
@@ -244,6 +246,8 @@ public class SQL {
+ "','" + internet_bol // cond_hasInternetRestriction
+ "','" + ram // cond_minRAM
+ "','" + cpu // cond_minCPUs
+ + "','" + isTemplate //image_isTemplate
+ + "','" + filesize //image_filesize
+ "');");
con.commit();
@@ -390,7 +394,6 @@ public class SQL {
public ResultSet getImageData(Connection con, String id, String version) {
try {
Statement stm = con.createStatement();
- System.out.println("Test");
return stm
.executeQuery("SELECT image_name,cond_hasInternetRestriction,cond_hasLicenseRestriction, cond_minCPUs, cond_minRAM FROM bwLehrpool.m_VLData_imageInfo where GUID_imageID = '"
+ id + "' and imageVersion = '" + version + "' ;");
@@ -404,7 +407,7 @@ public class SQL {
public int UpdateImageData(Connection con, String name, String newName,String image_path,
boolean license, boolean internet, long cpu, long ram, String id,
- String version) {
+ String version, boolean isTemplate, long filesize) {
try {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Statement stm = con.createStatement();
@@ -438,6 +441,10 @@ public class SQL {
+ ram
+ "',`cond_minCPUs` = '"
+ cpu
+ + "',`image_isTemplate` = '"
+ + isTemplate
+ + "',`image_filesize` = '"
+ + filesize
+ "' WHERE `GUID_imageID` = '"
+ id
+ "' AND `imageVersion` = '" + version + "';");
@@ -599,4 +606,24 @@ public class SQL {
return null;
}
+
+ public int UpdateImagePath(Connection con, String name) {
+ try {
+
+ Statement stm = con.createStatement();
+ String image_path="prod/"+name;
+
+ stm.executeUpdate("UPDATE `bwLehrpool`.`m_VLData_imageInfo` SET `image_path` = '"
+ + image_path
+ + "' WHERE `image_path` = '"
+ + "temp/"+name + "';");
+ con.commit();
+ return 0;
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ log.info(new Date() + " - Failed to UpdateImageData.");
+ e.printStackTrace();
+ }
+ return -1;
+ }
}