diff options
Diffstat (limited to 'Dozentenmodulserver/src')
| -rw-r--r-- | Dozentenmodulserver/src/server/Server.java | 198 | ||||
| -rw-r--r-- | Dozentenmodulserver/src/server/ServerHandler.java | 16 | ||||
| -rw-r--r-- | Dozentenmodulserver/src/sql/SQL.java | 46 |
3 files changed, 185 insertions, 75 deletions
diff --git a/Dozentenmodulserver/src/server/Server.java b/Dozentenmodulserver/src/server/Server.java index 91afb099..7382e965 100644 --- a/Dozentenmodulserver/src/server/Server.java +++ b/Dozentenmodulserver/src/server/Server.java @@ -58,7 +58,7 @@ public class Server { public Map<String,String> getImageData(String imageid, String imageversion) throws org.apache.thrift.TException; - public boolean updateImageData(String name, String newName, boolean license, boolean internet, long ram, long cpu, String id, String version) throws org.apache.thrift.TException; + public boolean updateImageData(String name, String newName, String image_path, boolean license, boolean internet, long ram, long cpu, String id, String version) throws org.apache.thrift.TException; public Map<String,String> getLectureData(String lecturename) throws org.apache.thrift.TException; @@ -98,7 +98,7 @@ public class Server { public void getImageData(String imageid, String imageversion, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; - public void updateImageData(String name, String newName, boolean license, boolean internet, long ram, long cpu, String id, String version, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void updateImageData(String name, String newName, String image_path, boolean license, boolean internet, long ram, long cpu, String id, String version, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void getLectureData(String lecturename, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; @@ -411,17 +411,18 @@ public class Server { throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getImageData failed: unknown result"); } - public boolean updateImageData(String name, String newName, boolean license, boolean internet, long ram, long cpu, String id, String version) throws org.apache.thrift.TException + public boolean updateImageData(String name, String newName, String image_path, boolean license, boolean internet, long ram, long cpu, String id, String version) throws org.apache.thrift.TException { - send_updateImageData(name, newName, license, internet, ram, cpu, id, version); + send_updateImageData(name, newName, image_path, license, internet, ram, cpu, id, version); return recv_updateImageData(); } - public void send_updateImageData(String name, String newName, boolean license, boolean internet, long ram, long cpu, String id, String version) throws org.apache.thrift.TException + public void send_updateImageData(String name, String newName, String image_path, boolean license, boolean internet, long ram, long cpu, String id, String version) throws org.apache.thrift.TException { updateImageData_args args = new updateImageData_args(); args.setName(name); args.setNewName(newName); + args.setImage_path(image_path); args.setLicense(license); args.setInternet(internet); args.setRam(ram); @@ -1040,9 +1041,9 @@ public class Server { } } - public void updateImageData(String name, String newName, boolean license, boolean internet, long ram, long cpu, String id, String version, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + public void updateImageData(String name, String newName, String image_path, boolean license, boolean internet, long ram, long cpu, String id, String version, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); - updateImageData_call method_call = new updateImageData_call(name, newName, license, internet, ram, cpu, id, version, resultHandler, this, ___protocolFactory, ___transport); + updateImageData_call method_call = new updateImageData_call(name, newName, image_path, license, internet, ram, cpu, id, version, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } @@ -1050,16 +1051,18 @@ public class Server { public static class updateImageData_call extends org.apache.thrift.async.TAsyncMethodCall { private String name; private String newName; + private String image_path; private boolean license; private boolean internet; private long ram; private long cpu; private String id; private String version; - public updateImageData_call(String name, String newName, boolean license, boolean internet, long ram, long cpu, String id, String version, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + public updateImageData_call(String name, String newName, String image_path, boolean license, boolean internet, long ram, long cpu, String id, String version, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.name = name; this.newName = newName; + this.image_path = image_path; this.license = license; this.internet = internet; this.ram = ram; @@ -1073,6 +1076,7 @@ public class Server { updateImageData_args args = new updateImageData_args(); args.setName(name); args.setNewName(newName); + args.setImage_path(image_path); args.setLicense(license); args.setInternet(internet); args.setRam(ram); @@ -1615,7 +1619,7 @@ public class Server { public updateImageData_result getResult(I iface, updateImageData_args args) throws org.apache.thrift.TException { updateImageData_result result = new updateImageData_result(); - result.success = iface.updateImageData(args.name, args.newName, args.license, args.internet, args.ram, args.cpu, args.id, args.version); + result.success = iface.updateImageData(args.name, args.newName, args.image_path, args.license, args.internet, args.ram, args.cpu, args.id, args.version); result.setSuccessIsSet(true); return result; } @@ -2393,7 +2397,7 @@ public class Server { } public void start(I iface, updateImageData_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws TException { - iface.updateImageData(args.name, args.newName, args.license, args.internet, args.ram, args.cpu, args.id, args.version,resultHandler); + iface.updateImageData(args.name, args.newName, args.image_path, args.license, args.internet, args.ram, args.cpu, args.id, args.version,resultHandler); } } @@ -13115,12 +13119,13 @@ public class Server { private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)-1); private static final org.apache.thrift.protocol.TField NEW_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("newName", org.apache.thrift.protocol.TType.STRING, (short)-2); - private static final org.apache.thrift.protocol.TField LICENSE_FIELD_DESC = new org.apache.thrift.protocol.TField("license", org.apache.thrift.protocol.TType.BOOL, (short)-3); - private static final org.apache.thrift.protocol.TField INTERNET_FIELD_DESC = new org.apache.thrift.protocol.TField("internet", org.apache.thrift.protocol.TType.BOOL, (short)-4); - private static final org.apache.thrift.protocol.TField RAM_FIELD_DESC = new org.apache.thrift.protocol.TField("ram", org.apache.thrift.protocol.TType.I64, (short)-5); - private static final org.apache.thrift.protocol.TField CPU_FIELD_DESC = new org.apache.thrift.protocol.TField("cpu", org.apache.thrift.protocol.TType.I64, (short)-6); - private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.STRING, (short)-7); - private static final org.apache.thrift.protocol.TField VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("version", org.apache.thrift.protocol.TType.STRING, (short)-8); + private static final org.apache.thrift.protocol.TField IMAGE_PATH_FIELD_DESC = new org.apache.thrift.protocol.TField("image_path", org.apache.thrift.protocol.TType.STRING, (short)-3); + private static final org.apache.thrift.protocol.TField LICENSE_FIELD_DESC = new org.apache.thrift.protocol.TField("license", org.apache.thrift.protocol.TType.BOOL, (short)-4); + private static final org.apache.thrift.protocol.TField INTERNET_FIELD_DESC = new org.apache.thrift.protocol.TField("internet", org.apache.thrift.protocol.TType.BOOL, (short)-5); + private static final org.apache.thrift.protocol.TField RAM_FIELD_DESC = new org.apache.thrift.protocol.TField("ram", org.apache.thrift.protocol.TType.I64, (short)-6); + private static final org.apache.thrift.protocol.TField CPU_FIELD_DESC = new org.apache.thrift.protocol.TField("cpu", org.apache.thrift.protocol.TType.I64, (short)-7); + private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.STRING, (short)-8); + private static final org.apache.thrift.protocol.TField VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("version", org.apache.thrift.protocol.TType.STRING, (short)-9); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { @@ -13130,6 +13135,7 @@ public class Server { public String name; // required public String newName; // required + public String image_path; // required public boolean license; // required public boolean internet; // required public long ram; // required @@ -13141,12 +13147,13 @@ public class Server { public enum _Fields implements org.apache.thrift.TFieldIdEnum { NAME((short)-1, "name"), NEW_NAME((short)-2, "newName"), - LICENSE((short)-3, "license"), - INTERNET((short)-4, "internet"), - RAM((short)-5, "ram"), - CPU((short)-6, "cpu"), - ID((short)-7, "id"), - VERSION((short)-8, "version"); + IMAGE_PATH((short)-3, "image_path"), + LICENSE((short)-4, "license"), + INTERNET((short)-5, "internet"), + RAM((short)-6, "ram"), + CPU((short)-7, "cpu"), + ID((short)-8, "id"), + VERSION((short)-9, "version"); private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); @@ -13165,17 +13172,19 @@ public class Server { return NAME; case -2: // NEW_NAME return NEW_NAME; - case -3: // LICENSE + case -3: // IMAGE_PATH + return IMAGE_PATH; + case -4: // LICENSE return LICENSE; - case -4: // INTERNET + case -5: // INTERNET return INTERNET; - case -5: // RAM + case -6: // RAM return RAM; - case -6: // CPU + case -7: // CPU return CPU; - case -7: // ID + case -8: // ID return ID; - case -8: // VERSION + case -9: // VERSION return VERSION; default: return null; @@ -13229,6 +13238,8 @@ public class Server { new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.NEW_NAME, new org.apache.thrift.meta_data.FieldMetaData("newName", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.IMAGE_PATH, new org.apache.thrift.meta_data.FieldMetaData("image_path", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.LICENSE, new org.apache.thrift.meta_data.FieldMetaData("license", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); tmpMap.put(_Fields.INTERNET, new org.apache.thrift.meta_data.FieldMetaData("internet", org.apache.thrift.TFieldRequirementType.DEFAULT, @@ -13251,6 +13262,7 @@ public class Server { public updateImageData_args( String name, String newName, + String image_path, boolean license, boolean internet, long ram, @@ -13261,6 +13273,7 @@ public class Server { this(); this.name = name; this.newName = newName; + this.image_path = image_path; this.license = license; setLicenseIsSet(true); this.internet = internet; @@ -13284,6 +13297,9 @@ public class Server { if (other.isSetNewName()) { this.newName = other.newName; } + if (other.isSetImage_path()) { + this.image_path = other.image_path; + } this.license = other.license; this.internet = other.internet; this.ram = other.ram; @@ -13304,6 +13320,7 @@ public class Server { public void clear() { this.name = null; this.newName = null; + this.image_path = null; setLicenseIsSet(false); this.license = false; setInternetIsSet(false); @@ -13364,6 +13381,30 @@ public class Server { } } + public String getImage_path() { + return this.image_path; + } + + public updateImageData_args setImage_path(String image_path) { + this.image_path = image_path; + return this; + } + + public void unsetImage_path() { + this.image_path = null; + } + + /** Returns true if field image_path is set (has been assigned a value) and false otherwise */ + public boolean isSetImage_path() { + return this.image_path != null; + } + + public void setImage_pathIsSet(boolean value) { + if (!value) { + this.image_path = null; + } + } + public boolean isLicense() { return this.license; } @@ -13522,6 +13563,14 @@ public class Server { } break; + case IMAGE_PATH: + if (value == null) { + unsetImage_path(); + } else { + setImage_path((String)value); + } + break; + case LICENSE: if (value == null) { unsetLicense(); @@ -13581,6 +13630,9 @@ public class Server { case NEW_NAME: return getNewName(); + case IMAGE_PATH: + return getImage_path(); + case LICENSE: return Boolean.valueOf(isLicense()); @@ -13614,6 +13666,8 @@ public class Server { return isSetName(); case NEW_NAME: return isSetNewName(); + case IMAGE_PATH: + return isSetImage_path(); case LICENSE: return isSetLicense(); case INTERNET: @@ -13661,6 +13715,15 @@ public class Server { return false; } + boolean this_present_image_path = true && this.isSetImage_path(); + boolean that_present_image_path = true && that.isSetImage_path(); + if (this_present_image_path || that_present_image_path) { + if (!(this_present_image_path && that_present_image_path)) + return false; + if (!this.image_path.equals(that.image_path)) + return false; + } + boolean this_present_license = true; boolean that_present_license = true; if (this_present_license || that_present_license) { @@ -13751,6 +13814,16 @@ public class Server { return lastComparison; } } + lastComparison = Boolean.valueOf(isSetImage_path()).compareTo(other.isSetImage_path()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetImage_path()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.image_path, other.image_path); + if (lastComparison != 0) { + return lastComparison; + } + } lastComparison = Boolean.valueOf(isSetLicense()).compareTo(other.isSetLicense()); if (lastComparison != 0) { return lastComparison; @@ -13847,6 +13920,14 @@ public class Server { } first = false; if (!first) sb.append(", "); + sb.append("image_path:"); + if (this.image_path == null) { + sb.append("null"); + } else { + sb.append(this.image_path); + } + first = false; + if (!first) sb.append(", "); sb.append("license:"); sb.append(this.license); first = false; @@ -13939,7 +14020,15 @@ public class Server { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case -3: // LICENSE + case -3: // IMAGE_PATH + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.image_path = iprot.readString(); + struct.setImage_pathIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case -4: // LICENSE if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { struct.license = iprot.readBool(); struct.setLicenseIsSet(true); @@ -13947,7 +14036,7 @@ public class Server { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case -4: // INTERNET + case -5: // INTERNET if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { struct.internet = iprot.readBool(); struct.setInternetIsSet(true); @@ -13955,7 +14044,7 @@ public class Server { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case -5: // RAM + case -6: // RAM if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.ram = iprot.readI64(); struct.setRamIsSet(true); @@ -13963,7 +14052,7 @@ public class Server { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case -6: // CPU + case -7: // CPU if (schemeField.type == org.apache.thrift.protocol.TType.I64) { struct.cpu = iprot.readI64(); struct.setCpuIsSet(true); @@ -13971,7 +14060,7 @@ public class Server { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case -7: // ID + case -8: // ID if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.id = iprot.readString(); struct.setIdIsSet(true); @@ -13979,7 +14068,7 @@ public class Server { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case -8: // VERSION + case -9: // VERSION if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.version = iprot.readString(); struct.setVersionIsSet(true); @@ -14024,6 +14113,11 @@ public class Server { oprot.writeFieldBegin(LICENSE_FIELD_DESC); oprot.writeBool(struct.license); oprot.writeFieldEnd(); + if (struct.image_path != null) { + oprot.writeFieldBegin(IMAGE_PATH_FIELD_DESC); + oprot.writeString(struct.image_path); + oprot.writeFieldEnd(); + } if (struct.newName != null) { oprot.writeFieldBegin(NEW_NAME_FIELD_DESC); oprot.writeString(struct.newName); @@ -14058,31 +14152,37 @@ public class Server { if (struct.isSetNewName()) { optionals.set(1); } - if (struct.isSetLicense()) { + if (struct.isSetImage_path()) { optionals.set(2); } - if (struct.isSetInternet()) { + if (struct.isSetLicense()) { optionals.set(3); } - if (struct.isSetRam()) { + if (struct.isSetInternet()) { optionals.set(4); } - if (struct.isSetCpu()) { + if (struct.isSetRam()) { optionals.set(5); } - if (struct.isSetId()) { + if (struct.isSetCpu()) { optionals.set(6); } - if (struct.isSetVersion()) { + if (struct.isSetId()) { optionals.set(7); } - oprot.writeBitSet(optionals, 8); + if (struct.isSetVersion()) { + optionals.set(8); + } + oprot.writeBitSet(optionals, 9); if (struct.isSetName()) { oprot.writeString(struct.name); } if (struct.isSetNewName()) { oprot.writeString(struct.newName); } + if (struct.isSetImage_path()) { + oprot.writeString(struct.image_path); + } if (struct.isSetLicense()) { oprot.writeBool(struct.license); } @@ -14106,7 +14206,7 @@ public class Server { @Override public void read(org.apache.thrift.protocol.TProtocol prot, updateImageData_args struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(8); + BitSet incoming = iprot.readBitSet(9); if (incoming.get(0)) { struct.name = iprot.readString(); struct.setNameIsSet(true); @@ -14116,26 +14216,30 @@ public class Server { struct.setNewNameIsSet(true); } if (incoming.get(2)) { + struct.image_path = iprot.readString(); + struct.setImage_pathIsSet(true); + } + if (incoming.get(3)) { struct.license = iprot.readBool(); struct.setLicenseIsSet(true); } - if (incoming.get(3)) { + if (incoming.get(4)) { struct.internet = iprot.readBool(); struct.setInternetIsSet(true); } - if (incoming.get(4)) { + if (incoming.get(5)) { struct.ram = iprot.readI64(); struct.setRamIsSet(true); } - if (incoming.get(5)) { + if (incoming.get(6)) { struct.cpu = iprot.readI64(); struct.setCpuIsSet(true); } - if (incoming.get(6)) { + if (incoming.get(7)) { struct.id = iprot.readString(); struct.setIdIsSet(true); } - if (incoming.get(7)) { + if (incoming.get(8)) { struct.version = iprot.readString(); struct.setVersionIsSet(true); } diff --git a/Dozentenmodulserver/src/server/ServerHandler.java b/Dozentenmodulserver/src/server/ServerHandler.java index 7c93422f..67514c39 100644 --- a/Dozentenmodulserver/src/server/ServerHandler.java +++ b/Dozentenmodulserver/src/server/ServerHandler.java @@ -87,9 +87,9 @@ public class ServerHandler implements Server.Iface { String Tel, String Fak, boolean license, boolean internet, long ram, long cpu, String imagePath) 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, @@ -177,18 +177,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) { @@ -282,10 +282,10 @@ 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, + sql.UpdateImageData(con, name, newName,image_path, license, internet, cpu, ram, id, version); return false; } diff --git a/Dozentenmodulserver/src/sql/SQL.java b/Dozentenmodulserver/src/sql/SQL.java index 52cbefb9..a5eeb83e 100644 --- a/Dozentenmodulserver/src/sql/SQL.java +++ b/Dozentenmodulserver/src/sql/SQL.java @@ -6,6 +6,8 @@ import java.text.DateFormat; import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
+import java.util.UUID;
+
import org.apache.log4j.Logger;
import server.BinaryListener;
@@ -114,7 +116,7 @@ public class SQL { return null;
}
- public int setInstitution(Connection con, String university) {
+ public String setInstitution(Connection con, String university) {
try {
Statement stm = con.createStatement();
@@ -122,8 +124,8 @@ public class SQL { .executeQuery("SELECT * FROM bwLehrpool.m_institution where name like'"
+ university + "';");
if (ret.next() == false) {
- Random rand = new Random();
- int id = rand.nextInt();
+
+ String id = UUID.randomUUID().toString();
stm.executeUpdate("INSERT INTO `bwLehrpool`.`m_institution`(`institutionID`,`name`)VALUES('"
+ id + "','" + university + "');");
con.commit();
@@ -131,9 +133,9 @@ public class SQL { .executeQuery("SELECT institutionID FROM bwLehrpool.m_institution WHERE name like '"
+ university + "';");
rs.next();
- return rs.getInt("institutionID");
+ return rs.getString("institutionID");
} else {
- return ret.getInt("institutionID");
+ return ret.getString("institutionID");
}
} catch (SQLException e) {
@@ -141,11 +143,11 @@ public class SQL { log.info(new Date() + " - Failed to setInstitution.");
e.printStackTrace();
}
- return -1;
+ return "-1";
}
- public int setPerson(Connection con, String login, String lastname,
- String firstname, String mail, Date lastlogin, int Institution) {
+ public String setPerson(Connection con, String login, String lastname,
+ String firstname, String mail, Date lastlogin, String Institution) {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
try {
Statement stm = con.createStatement();
@@ -156,9 +158,10 @@ public class SQL { + "' and Vorname like '"
+ firstname
+ "';");
+
if (ret.next() == false) {
- Random rand = new Random();
- int id = rand.nextInt();
+
+ String id = UUID.randomUUID().toString();
stm.executeUpdate("INSERT INTO `bwLehrpool`.`m_user`(`userID`,`loginName`,`nachname`,`vorname`,`mail`,`lastLogin`,`institution`)VALUES('"
+ id
+ "','"
@@ -182,9 +185,10 @@ public class SQL { + firstname
+ "';");
rs.next();
- return rs.getInt("userID");
+ return rs.getString("userID");
} else {
- return ret.getInt("userID");
+ ret.first();
+ return ret.getString("userID");
}
} catch (SQLException e) {
@@ -192,10 +196,10 @@ public class SQL { log.info(new Date() + " - Failed to setPerson.");
e.printStackTrace();
}
- return -1;
+ return "-1";
}
- public boolean setImageData(Connection con, int pk_person, boolean license,
+ public boolean setImageData(Connection con, String pk_person, boolean license,
boolean internet, long cpu, long ram, String imagename,
String imagePath) {
@@ -212,8 +216,8 @@ public class SQL { try {
Statement stm = con.createStatement();
- Random random = new Random();
- int uid = random.nextInt();
+
+ 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('"
+ uid // GUID_imageID
+ "',1,'" // imageVersion
@@ -316,7 +320,7 @@ public class SQL { return null;
}
- public int setLectureData(Connection con, int pk_person, int pk_image,
+ public int setLectureData(Connection con, String pk_person, String pk_image,
int imageversion, String name, String desc, String shortdesc,
String start, String end, boolean isactive) {
@@ -328,8 +332,8 @@ public class SQL { }
try {
Statement stm = con.createStatement();
- Random random = new Random();
- int uid = random.nextInt();
+
+ String uid = UUID.randomUUID().toString();
stm.executeUpdate("INSERT INTO `bwLehrpool`.`m_VLData_lecture`(`lectureID`,`name`,`isActive`,`startTime`,`endTime`,`lastUsed`,`shortDescription`,`description`,`imageID`,`imageVersion`,`admin_createTime`,`admin_changeTime`,`admin_owner`,`admin_change_by`)VALUES('"
+ uid
+ "','"
@@ -398,7 +402,7 @@ public class SQL { return null;
}
- public int UpdateImageData(Connection con, String name, String newName,
+ public int UpdateImageData(Connection con, String name, String newName,String image_path,
boolean license, boolean internet, long cpu, long ram, String id,
String version) {
try {
@@ -420,6 +424,8 @@ public class SQL { + newVersion
+ "',`image_name` = '"
+ newName
+ + "',`image_path` = '"
+ + image_path
+ "',`image_update_time` = '"
+ formatter.format(new Date())
+ "',`rec_change_time` = '"
|
