summaryrefslogtreecommitdiffstats
path: root/Dozentenmodulserver
diff options
context:
space:
mode:
authorunknown2014-04-04 16:42:54 +0200
committerunknown2014-04-04 16:42:54 +0200
commit4acab74e19b08290b4e8b9a8c7171885c222aee5 (patch)
treec7f46a3a4addf1181b88ce897bc9b4eadf111927 /Dozentenmodulserver
parentMerge branch 'master' of git.openslx.org:openslx-ng/tutor-module (diff)
downloadtutor-module-4acab74e19b08290b4e8b9a8c7171885c222aee5.tar.gz
tutor-module-4acab74e19b08290b4e8b9a8c7171885c222aee5.tar.xz
tutor-module-4acab74e19b08290b4e8b9a8c7171885c222aee5.zip
Diverse Bugfixes und neue Grafik
Diffstat (limited to 'Dozentenmodulserver')
-rw-r--r--Dozentenmodulserver/bin/util/XMLCreator.classbin6252 -> 6292 bytes
-rw-r--r--Dozentenmodulserver/src/util/XMLCreator.java192
2 files changed, 92 insertions, 100 deletions
diff --git a/Dozentenmodulserver/bin/util/XMLCreator.class b/Dozentenmodulserver/bin/util/XMLCreator.class
index 579a4cd4..025904a6 100644
--- a/Dozentenmodulserver/bin/util/XMLCreator.class
+++ b/Dozentenmodulserver/bin/util/XMLCreator.class
Binary files differ
diff --git a/Dozentenmodulserver/src/util/XMLCreator.java b/Dozentenmodulserver/src/util/XMLCreator.java
index 0efb2465..8a8bd701 100644
--- a/Dozentenmodulserver/src/util/XMLCreator.java
+++ b/Dozentenmodulserver/src/util/XMLCreator.java
@@ -1,4 +1,5 @@
package util;
+
import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -18,196 +19,187 @@ import org.w3c.dom.Comment;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-
public class XMLCreator {
+ /*
+ * This class offers methods to create XML files for the (old) version of
+ * managing VMware *.vmdks
+ */
- /* This class offers methods to create XML files for the (old) version of managing VMware *.vmdks */
-
-
-
private Connection con = null;
private Statement st = null;
private ResultSet rs = null;
private String vmName;
private String filePath = "/srv/openslx/nfs/temp/";
-
-
- //phone param not existing
+
+ // phone param not existing
private String query = "SELECT m_VLData_imageInfo.image_path ,vorname, nachname, mail, shortdescription, description, m_operatingSystem.name as os, m_VLData_lecture.admin_changeTime as time "
- + "FROM bwLehrpool.m_VLData_lecture, bwLehrpool.m_VLData_imageInfo, bwLehrpool.m_user, bwLehrpool.m_operatingSystem "
- + "WHERE m_user.userID = m_VLData_lecture.admin_owner "
- + "AND m_VLData_imageInfo.GUID_imageID = m_VLData_lecture.imageID "
- + "AND m_VLData_imageInfo.content_operatingSystem = m_operatingSystem.operatingSystemID "
- + "AND m_VLData_lecture.name = ";
-
-
-
- public XMLCreator(Connection con)
- {
+ + "FROM bwLehrpool.m_VLData_lecture, bwLehrpool.m_VLData_imageInfo, bwLehrpool.m_user, bwLehrpool.m_operatingSystem "
+ + "WHERE m_user.userID = m_VLData_lecture.admin_owner "
+ + "AND m_VLData_imageInfo.GUID_imageID = m_VLData_lecture.imageID "
+ + "AND m_VLData_imageInfo.content_operatingSystem = m_operatingSystem.operatingSystemID "
+ + "AND m_VLData_lecture.name = ";
+
+ public XMLCreator(Connection con) {
this.con = con;
- }
-
- public XMLCreator(Connection con, String vmName)
- {
+ }
+
+ public XMLCreator(Connection con, String vmName) {
this.con = con;
this.vmName = vmName;
}
-
-
- public boolean create() throws SQLException, ParserConfigurationException, TransformerException
- {
-
- //System.out.println(query);
-
- if(con == null || vmName == null)
- {
+
+ public boolean create() throws SQLException, ParserConfigurationException,
+ TransformerException {
+
+ // System.out.println(query);
+
+ if (con == null || vmName == null) {
return false;
}
query += "'" + this.vmName + "';";
-
+
boolean success = startCreation();
-
- if(success)
- {
+
+ if (success) {
return true;
}
-
+
return false;
-
+
}
-
- //overload method for dynamic setting of param vmName instead of static context above
- public boolean create(String vmName) throws SQLException, ParserConfigurationException, TransformerException
- {
- //System.out.println(query);
-
- if(con == null || vmName == null)
- {
+
+ // overload method for dynamic setting of param vmName instead of static
+ // context above
+ public boolean create(String vmName) throws SQLException,
+ ParserConfigurationException, TransformerException {
+ // System.out.println(query);
+
+ if (con == null || vmName == null) {
return false;
}
query += "'" + vmName + "';";
-
+
boolean success = startCreation();
-
- if(success)
- {
+
+ if (success) {
return true;
}
return false;
}
-
-
- private boolean startCreation() throws SQLException, ParserConfigurationException, TransformerException
- {
- //get needed data from database
- st = con.createStatement();
+
+ private boolean startCreation() throws SQLException,
+ ParserConfigurationException, TransformerException {
+ // get needed data from database
+ st = con.createStatement();
rs = st.executeQuery(query);
rs.next();
-
- //factory
- DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+
+ // factory
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory
+ .newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
-
+
// root elements - dynamic content
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement("settings");
doc.appendChild(rootElement);
-
+
Element entry = doc.createElement("eintrag");
rootElement.appendChild(entry);
-
+
Element prio = doc.createElement("priority");
entry.appendChild(prio);
prio.setAttribute("param", "0");
-
+
Comment fComment = doc.createComment("Diesen Abschnitt ergänzen");
entry.appendChild(fComment);
-
+
Element imgName = doc.createElement("image_name");
entry.appendChild(imgName);
- String imagePath=rs.getString("image_path").substring(rs.getString("image_path").lastIndexOf("/"));
-
+ String imagePath = rs.getString("image_path").substring(
+ rs.getString("image_path").lastIndexOf("/"));
+
imgName.setAttribute("param", imagePath);
-
+
Element creator = doc.createElement("creator");
entry.appendChild(creator);
- creator.setAttribute("param", (rs.getString("vorname") + " " + rs.getString("nachname")));
-
+ creator.setAttribute("param",
+ (rs.getString("vorname") + " " + rs.getString("nachname")));
+
Element email = doc.createElement("email");
entry.appendChild(email);
email.setAttribute("param", rs.getString("mail"));
-
- //TODO check whether necessary
+
+ // TODO check whether necessary
Element phone = doc.createElement("phone");
entry.appendChild(phone);
phone.setAttribute("param", "");
-
+
Element shortDesc = doc.createElement("short_description");
entry.appendChild(shortDesc);
shortDesc.setAttribute("param", rs.getString("shortdescription"));
-
- //TODO append latest change date and time
+
+ // TODO append latest change date and time
Element longDesc = doc.createElement("long_description");
entry.appendChild(longDesc);
- longDesc.setAttribute("param", rs.getString("description") + " last update: " + rs.getString("time"));
-
+ longDesc.setAttribute("param", rs.getString("description")
+ + " last update: " + rs.getString("time"));
+
Element os = doc.createElement("os");
entry.appendChild(os);
os.setAttribute("param", rs.getString("os"));
-
+
Comment sComment = doc.createComment("Diesen Abschnitt ergänzen");
entry.appendChild(sComment);
-
-
- //static content following - second part of xml descriptor
-
-
+
+ // static content following - second part of xml descriptor
+
Element netwParam = doc.createElement("network");
entry.appendChild(netwParam);
netwParam.setAttribute("param", "nat");
-
+
Element netcParam = doc.createElement("netcard");
entry.appendChild(netcParam);
netcParam.setAttribute("param", "e1000");
-
-
+
Element vm = doc.createElement("virtualmachine");
entry.appendChild(vm);
vm.setAttribute("param", "vmware");
-
- //TODO Fallunterscheidung
+
+ // TODO Fallunterscheidung
Element icon = doc.createElement("icon");
entry.appendChild(icon);
icon.setAttribute("param", "windows");
-
+
Element active = doc.createElement("active");
entry.appendChild(active);
active.setAttribute("param", "true");
-
+
Element pools = doc.createElement("pools");
entry.appendChild(pools);
pools.setAttribute("param", "default");
-
+
Element enable3d = doc.createElement("enable3d");
entry.appendChild(enable3d);
enable3d.setAttribute("param", "true");
-
-
-
- //write virtual document to file
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
+
+ // write virtual document to file
+ TransformerFactory transformerFactory = TransformerFactory
+ .newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
-
- StreamResult result = new StreamResult(new File(filePath+imagePath.replace("vmdk", "xml"))); //see filepath at top of class
+
+ StreamResult result = new StreamResult(new File(filePath
+ + imagePath.replace("vmdk", "xml"))); // see filepath at top of
+ // class
transformer.transform(source, result);
-
- //cleanup
+
+ // cleanup
rs.close();
st.close();
-
- //return
+
+ // return
return true;
}
}