summaryrefslogtreecommitdiffstats
path: root/Dozentenmodulserver
diff options
context:
space:
mode:
Diffstat (limited to 'Dozentenmodulserver')
-rw-r--r--Dozentenmodulserver/bin/server/BinaryListener.classbin2456 -> 2464 bytes
-rw-r--r--Dozentenmodulserver/bin/server/ServerHandler.classbin12013 -> 4044 bytes
-rw-r--r--Dozentenmodulserver/bin/server/startServer.classbin1891 -> 2057 bytes
-rw-r--r--Dozentenmodulserver/bin/sql/SQL.classbin15433 -> 15446 bytes
-rw-r--r--Dozentenmodulserver/src/server/BinaryListener.java2
-rw-r--r--Dozentenmodulserver/src/server/ServerHandler.java297
-rw-r--r--Dozentenmodulserver/src/server/startServer.java2
-rw-r--r--Dozentenmodulserver/src/sql/SQL.java4
8 files changed, 174 insertions, 131 deletions
diff --git a/Dozentenmodulserver/bin/server/BinaryListener.class b/Dozentenmodulserver/bin/server/BinaryListener.class
index d53cdc9d..4a135f2d 100644
--- a/Dozentenmodulserver/bin/server/BinaryListener.class
+++ b/Dozentenmodulserver/bin/server/BinaryListener.class
Binary files differ
diff --git a/Dozentenmodulserver/bin/server/ServerHandler.class b/Dozentenmodulserver/bin/server/ServerHandler.class
index 942de6d1..8f9b9c51 100644
--- a/Dozentenmodulserver/bin/server/ServerHandler.class
+++ b/Dozentenmodulserver/bin/server/ServerHandler.class
Binary files differ
diff --git a/Dozentenmodulserver/bin/server/startServer.class b/Dozentenmodulserver/bin/server/startServer.class
index 030b565e..14dc0861 100644
--- a/Dozentenmodulserver/bin/server/startServer.class
+++ b/Dozentenmodulserver/bin/server/startServer.class
Binary files differ
diff --git a/Dozentenmodulserver/bin/sql/SQL.class b/Dozentenmodulserver/bin/sql/SQL.class
index 4479bf2c..9310440e 100644
--- a/Dozentenmodulserver/bin/sql/SQL.class
+++ b/Dozentenmodulserver/bin/sql/SQL.class
Binary files differ
diff --git a/Dozentenmodulserver/src/server/BinaryListener.java b/Dozentenmodulserver/src/server/BinaryListener.java
index 8d592992..97793778 100644
--- a/Dozentenmodulserver/src/server/BinaryListener.java
+++ b/Dozentenmodulserver/src/server/BinaryListener.java
@@ -28,7 +28,7 @@ public class BinaryListener implements Runnable
return;
}
TServer server = new TSimpleServer( new Args( transport ).processor( processor ) );
- log.info(new Date() +" - Started Running Server");
+ log.info(new Date() +" - Started running BinaryListener");
server.serve();
}
diff --git a/Dozentenmodulserver/src/server/ServerHandler.java b/Dozentenmodulserver/src/server/ServerHandler.java
index a707954b..3bf1eddf 100644
--- a/Dozentenmodulserver/src/server/ServerHandler.java
+++ b/Dozentenmodulserver/src/server/ServerHandler.java
@@ -19,154 +19,174 @@ import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.apache.commons.io.FileUtils;
+import org.apache.log4j.Logger;
import org.apache.thrift.TException;
import sql.SQL;
import util.XMLCreator;
-
public class ServerHandler implements Server.Iface {
- static SQL sql=new SQL();
- static Connection con=sql.getConnection();
+ static SQL sql = new SQL();
+ static Connection con = sql.getConnection();
+ private static Logger log = Logger.getLogger(ServerHandler.class);
+
/**
* @param args
*/
- /*public static void main(String[] args) {
- // TODO Auto-generated method stub
-
- }*/
+ /*
+ * public static void main(String[] args) { // TODO Auto-generated method
+ * stub
+ *
+ * }
+ */
@Override
public User getFtpUser() throws TException {
- User user=new User();
+ log.info(new Date() + " - returing FTPUser...");
+ User user = new User();
user.setUserName(UUID.randomUUID().toString().substring(0, 8));
- user.setPassword(getEncodedSha1Sum(UUID.randomUUID().toString().substring(0, 8)));
+ user.setPassword(getEncodedSha1Sum(UUID.randomUUID().toString()
+ .substring(0, 8)));
user.setPath("/srv/openslx/nfs/temp");
- SQL sql=new SQL();
- Connection con=sql.getConnection();
+ SQL sql = new SQL();
+ Connection con = sql.getConnection();
sql.writeFTPUser(con, user.getUserName(), user.getPassword());
+ log.info(new Date() + " - successfully returned FTPUser");
return user;
}
-
public String getEncodedSha1Sum(String key) {
- try {
- MessageDigest md = MessageDigest.getInstance( "SHA1" );
- md.update( key.getBytes() );
- return new BigInteger(1, md.digest()).toString(16);
- }
- catch (NoSuchAlgorithmException e) {
- // handle error case to taste
- }
+ try {
+ log.info(new Date() + " - returned EncodedSha1Sum...");
+ MessageDigest md = MessageDigest.getInstance("SHA1");
+ md.update(key.getBytes());
+ log.info(new Date() + " - successfully returned EncodedSha1Sum");
+ return new BigInteger(1, md.digest()).toString(16);
+ } catch (NoSuchAlgorithmException e) {
+ // handle error case to taste
+ }
return null;
}
@Override
public long DeleteFtpUser(String user) throws TException {
int ret = sql.DeleteUser(con, user);
+ log.info(new Date() + " - deleting FTPUser");
return ret;
}
@Override
- public String getPathOfImage(String image_id, String version) throws TException {
-
+ public String getPathOfImage(String image_id, String version)
+ throws TException {
+
try {
- ResultSet rs=sql.getPathOfImage(con, image_id, version);
+ log.info(new Date() + " - returning PathOfImage...");
+ ResultSet rs = sql.getPathOfImage(con, image_id, version);
System.out.println("Path SQL erfolgreich");
rs.next();
System.out.println(rs.getString("image_path"));
+ log.info(new Date() + " - successfully returned PathOfImage: "
+ + rs.getString("image_path"));
return rs.getString("image_path");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+ log.info(new Date() + " - returning PathOfImage: null");
return null;
}
@Override
public boolean writeVLdata(String imagename, String firstname,
String lastname, String university, String Mail, String Tel,
- String Fak, boolean license, boolean internet, long ram, long cpu, String imagePath)
- throws TException {
- String login="tete";
-
- int pk_institution=sql.setInstitution(con, university);
-
- int pk_person=sql.setPerson(con, login, lastname, firstname, Mail, new Date(), pk_institution);
-
- sql.setImageData(con, pk_person, license, internet, cpu, ram, imagename, imagePath);
+ String Fak, boolean license, boolean internet, long ram, long cpu,
+ String imagePath) throws TException {
+ String login = "tete";
+
+ int pk_institution = sql.setInstitution(con, university);
+
+ int pk_person = sql.setPerson(con, login, lastname, firstname, Mail,
+ new Date(), pk_institution);
+
+ sql.setImageData(con, pk_person, license, internet, cpu, ram,
+ imagename, imagePath);
+ log.info(new Date() + " - writing VLdata");
// TODO Auto-generated method stub
return true;
}
@Override
public List<Image> getImageList() throws TException {
- ResultSet res=sql.getImageList(con);
-
+ ResultSet res = sql.getImageList(con);
+
List<Image> list = new ArrayList<Image>();
try {
-
- while(res.next())
- {
-
- list.add(new Image(res.getString("GUID_imageID"),res.getString("imageVersion"),res.getString("image_name"),res.getString("cond_hasLicenseRestriction"),res.getString("name"),res.getString("lecture"),res.getString("image_update_time"),res.getString("user")));
-
+
+ while (res.next()) {
+
+ list.add(new Image(res.getString("GUID_imageID"), res
+ .getString("imageVersion"),
+ res.getString("image_name"), res
+ .getString("cond_hasLicenseRestriction"), res
+ .getString("name"), res.getString("lecture"),
+ res.getString("image_update_time"), res
+ .getString("user")));
+
}
-
+ log.info(new Date() + " - returning ImageList: " + list.size());
return list;
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
-
+ log.info(new Date() + " - returning ImageList: " + list.size());
return null;
}
-
@Override
public List<String> getAllOS() throws TException {
- List<String> list=new ArrayList<>();
- ResultSet rs=sql.getAllOS(con);
+ List<String> list = new ArrayList<>();
+ ResultSet rs = sql.getAllOS(con);
try {
- while(rs.next())
- {
+ while (rs.next()) {
list.add(rs.getString("name"));
}
+ log.info(new Date() + " - returning AllOS: " + list.size());
return list;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
+ log.info(new Date() + " - returning AllOS: " + list.size());
return null;
}
@Override
public Map<String, String> getPersonData(String Vorname, String Nachname)
throws TException {
- Map<String,String> map=new HashMap<String, String>();
-
- ResultSet rs=sql.getPersonData(con, Vorname, Nachname);
+ Map<String, String> map = new HashMap<String, String>();
+
+ ResultSet rs = sql.getPersonData(con, Vorname, Nachname);
try {
- while(rs.next())
- {
-
+ while (rs.next()) {
+
map.put("mail", rs.getString("mail"));
map.put("Nachname", rs.getString("Nachname"));
map.put("Vorname", rs.getString("Vorname"));
map.put("Hochschule", rs.getString("name"));
-
}
+ log.info(new Date() + " - returning PersonData: " + map.size());
return map;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
+ log.info(new Date() + " - returning PersonData: " + map.size());
return null;
}
@@ -177,101 +197,115 @@ public class ServerHandler implements Server.Iface {
String university, String Mail, String Tel, String Fak)
throws TException {
int pk_image = 0;
- String login="tete";
+ String login = "tete";
int imageversion = 0;
- int pk_institution=sql.setInstitution(con, university);
- int 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");
- imageversion=image.getInt("imageVersion");
- }
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
-
- System.out.println(startDate);
- sql.setLectureData(con, pk_person, pk_image, imageversion, name, desc, shortdesc, startDate, endDate, isActive);
- XMLCreator xml=new XMLCreator(con, name);
- try {
- xml.create(name);
- System.out.println(new Date() + " - Creator beendet");
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (ParserConfigurationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (TransformerException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ int pk_institution = sql.setInstitution(con, university);
+ int 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");
+ imageversion = image.getInt("imageVersion");
}
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ System.out.println(startDate);
+ sql.setLectureData(con, pk_person, pk_image, imageversion, name, desc,
+ shortdesc, startDate, endDate, isActive);
+ XMLCreator xml = new XMLCreator(con, name);
+ try {
+ xml.create(name);
+ log.info(new Date() + " - XML created");
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ParserConfigurationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (TransformerException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
return false;
}
@Override
public boolean startFileCopy(String file) throws TException {
- File tmpFile=new File(file);
+ File tmpFile = new File(file);
- System.out.println("Vor Move" +new Date());
+ System.out.println("Vor Move" + new Date());
try {
+<<<<<<< HEAD
//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()));
+ log.info(new Date() + " - file moved");
+>>>>>>> 05f774a71379f4bb795fd5c072bfa71469e1c409
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
- System.out.println("Nach Move"+new Date());
return true;
}
-
@Override
- public Map<String, String> getImageData(String imageid, String imageversion) throws TException {
-
- ResultSet data=sql.getImageData(con, imageid, imageversion);
-
- Map<String,String> map=new HashMap<String, String>();
+ public Map<String, String> getImageData(String imageid, String imageversion)
+ throws TException {
+
+ ResultSet data = sql.getImageData(con, imageid, imageversion);
+
+ Map<String, String> map = new HashMap<String, String>();
try {
- while(data.next())
- {
- System.out.println(data.getString("cond_hasInternetRestriction")+data.getString("cond_hasLicenseRestriction")+data.getString("cond_minCPUs")+data.getString("cond_minRAM"));
- map.put("name",data.getString("image_name"));
- map.put("internet", data.getString("cond_hasInternetRestriction"));
+ while (data.next()) {
+ System.out.println(data
+ .getString("cond_hasInternetRestriction")
+ + data.getString("cond_hasLicenseRestriction")
+ + data.getString("cond_minCPUs")
+ + data.getString("cond_minRAM"));
+ map.put("name", data.getString("image_name"));
+ map.put("internet",
+ data.getString("cond_hasInternetRestriction"));
map.put("license", data.getString("cond_hasLicenseRestriction"));
map.put("cpu", data.getString("cond_minCPUs"));
map.put("ram", data.getString("cond_minRAM"));
-
+
}
System.out.println("return success");
+ log.info(new Date() + " - returning ImageData: "+map.size());
return map;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
+ log.info(new Date() + " - returning ImageData: "+map.size());
return null;
}
-
@Override
- public boolean updateImageData(String name, String newName,boolean license,
- boolean internet, long ram, long cpu,String id, String version) throws TException {
+ public boolean updateImageData(String name, String newName,
+ boolean license, boolean internet, long ram, long cpu, String id,
+ String version) throws TException {
System.out.println("Server: Vor Update");
- sql.UpdateImageData(con, name, newName ,license, internet, cpu, ram, id, version);
+ sql.UpdateImageData(con, name, newName, license, internet, cpu, ram,
+ id, version);
System.out.println("Update erfolgreich");
+ log.info(new Date() + " - updated ImageData");
return false;
}
-
@Override
public Map<String, String> getLectureData(String lecturename)
throws TException {
@@ -279,55 +313,60 @@ public class ServerHandler implements Server.Iface {
return null;
}
-
@Override
public List<Lecture> getLectureList() throws TException {
- ResultSet res=sql.getLectureList(con);
-
+ ResultSet res = sql.getLectureList(con);
+
List<Lecture> list = new ArrayList<Lecture>();
try {
-
- while(res.next())
- {
-
- list.add(new Lecture(res.getString("lectureID"), res.getString("name"), res.getString("isActive"), res.getString("startTime"), res.getString("endTime"), res.getString("lastUsed"), res.getString("description"), res.getString("image_name"), res.getString("user")));
-
- }
-
+ while (res.next()) {
+
+ list.add(new Lecture(res.getString("lectureID"), res
+ .getString("name"), res.getString("isActive"), res
+ .getString("startTime"), res.getString("endTime"), res
+ .getString("lastUsed"), res.getString("description"),
+ res.getString("image_name"), res.getString("user")));
+
+ }
+ log.info(new Date() + " - returning LectureList: "+list.size());
return list;
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
-
+ log.info(new Date() + " - returning LectureList: "+list.size());
return null;
}
+<<<<<<< HEAD
+=======
+>>>>>>> 05f774a71379f4bb795fd5c072bfa71469e1c409
@Override
public boolean updateLecturedata(String name, String newName,
String shortdesc, String desc, String startDate, String endDate,
boolean isActive, String imagename, String firstname,
String lastname, String university, String Mail, String Tel,
String Fak, String id) throws TException {
- int pk_image=0;
- int imageversion=0;
- ResultSet image=sql.getImageIDandVersion(con, imagename);
+ int pk_image = 0;
+ int imageversion = 0;
+ ResultSet image = sql.getImageIDandVersion(con, imagename);
try {
- while(image.next())
- {
- pk_image=image.getInt("GUID_imageID");
- imageversion=image.getInt("imageVersion");
+ while (image.next()) {
+ pk_image = image.getInt("GUID_imageID");
+ imageversion = image.getInt("imageVersion");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
- sql.updateLectureData(con, pk_image, imageversion, lastname, newName, desc, shortdesc, startDate, endDate, isActive, id);
+ sql.updateLectureData(con, pk_image, imageversion, lastname, newName,
+ desc, shortdesc, startDate, endDate, isActive, id);
+ log.info(new Date() + " - updated LectureData");
return false;
}
diff --git a/Dozentenmodulserver/src/server/startServer.java b/Dozentenmodulserver/src/server/startServer.java
index e1ab22c0..542c92b8 100644
--- a/Dozentenmodulserver/src/server/startServer.java
+++ b/Dozentenmodulserver/src/server/startServer.java
@@ -28,6 +28,8 @@ public class startServer {
t = new Thread(new BinaryListener());
servers.add(t);
t.start();
+ //information
+ log.info( new Date()+" - new thread created. Now "+servers.size()+" thread(s).\n" );
// Run more servers
// ...
// Wait for all servers to die
diff --git a/Dozentenmodulserver/src/sql/SQL.java b/Dozentenmodulserver/src/sql/SQL.java
index 1c34d226..daffbf0b 100644
--- a/Dozentenmodulserver/src/sql/SQL.java
+++ b/Dozentenmodulserver/src/sql/SQL.java
@@ -459,7 +459,9 @@ public class SQL {
*/
public boolean deleteImage(Connection con, String id, String version) {
-
+
+ System.out.println("delete image");
+
try {
Statement stm=con.createStatement();