From beb57fe92e628b3ffadb1b02f2bcf909b0fb2dc9 Mon Sep 17 00:00:00 2001 From: Willem Cazander Date: Mon, 7 May 2012 16:29:20 +0200 Subject: [PATCH] Added start of demo data of tech demo --- .../src/main/demo/csv/csv-vasc.xml | 45 ++++++++ .../src/main/demo/csv/meta-people.csv | 10 ++ .../src/main/demo/csv/meta-project.csv | 4 + .../src/main/demo/csv/meta-todo.csv | 0 .../src/main/demo/ldap/ldap-example.ldif | 13 +++ .../src/main/demo/ldap/ldap-vasc.xml | 95 +++++++++++++++ .../src/main/demo/postgres/pg-data.sql | 0 .../src/main/demo/postgres/pg-schema.sql | 0 .../src/main/demo/postgres/pg-vasc.xml | 39 +++++++ .../src/main/files/auto-readme.txt | 1 + .../src/main/files/readme.txt | 6 + .../vasc/demo/tech/ui/TomcatManager.java | 108 ++++++++++++++++++ 12 files changed, 321 insertions(+) create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/csv/csv-vasc.xml create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/csv/meta-people.csv create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/csv/meta-project.csv create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/csv/meta-todo.csv create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/ldap/ldap-example.ldif create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/ldap/ldap-vasc.xml create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/postgres/pg-data.sql create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/postgres/pg-schema.sql create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/postgres/pg-vasc.xml create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/files/auto-readme.txt create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/files/readme.txt create mode 100644 vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/src/main/java/net/forwardfire/vasc/demo/tech/ui/TomcatManager.java diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/csv/csv-vasc.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/csv/csv-vasc.xml new file mode 100644 index 0000000..b33ba1f --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/csv/csv-vasc.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/csv/meta-people.csv b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/csv/meta-people.csv new file mode 100644 index 0000000..ba6fa4f --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/csv/meta-people.csv @@ -0,0 +1,10 @@ +id,name,gender,age,function +1,"mike",male,18,manager +2,"michael",male,19,manager-co +3,"peter",male,18,devop +4,"bob",male,17,devver +5,"barbara, barb",female,18,devver +6,"charlotte",female,18,devver +7,"hillary",female,20,tester +8,"vera",female,17,tester +9,"carrie",female,17,sales \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/csv/meta-project.csv b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/csv/meta-project.csv new file mode 100644 index 0000000..bb69050 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/csv/meta-project.csv @@ -0,0 +1,4 @@ +id,name,description +1,"fix-website","Move all pages to plain text so it is printable when there is no power." +2,"refactor-HJY","Make function HJY abstract and use generic logic to improve total cpu lag on system" +3,"custum-graph","Big custumer foobar want really this killer graph woobly line point stuff." diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/csv/meta-todo.csv b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/csv/meta-todo.csv new file mode 100644 index 0000000..e69de29 diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/ldap/ldap-example.ldif b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/ldap/ldap-example.ldif new file mode 100644 index 0000000..993d16a --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/ldap/ldap-example.ldif @@ -0,0 +1,13 @@ + + + +dn: cn=Mirjan Broek,os=Amsterdam,ou=user,o=forwardfire,c=net +objectClass: inetOrgPerson +cn: Mirjan Broek +description: Prime Contractors +mail: mirjan.broek@demo.vasc.forwardfire.net +postalAddress: 233 Mobbs Circuit$Vermont VIC +postalCode: 3133 +sn: Broek +telephoneNumber: 622 7619 +title: Secretary diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/ldap/ldap-vasc.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/ldap/ldap-vasc.xml new file mode 100644 index 0000000..cd6cff2 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/ldap/ldap-vasc.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/postgres/pg-data.sql b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/postgres/pg-data.sql new file mode 100644 index 0000000..e69de29 diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/postgres/pg-schema.sql b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/postgres/pg-schema.sql new file mode 100644 index 0000000..e69de29 diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/postgres/pg-vasc.xml b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/postgres/pg-vasc.xml new file mode 100644 index 0000000..7219765 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/demo/postgres/pg-vasc.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/files/auto-readme.txt b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/files/auto-readme.txt new file mode 100644 index 0000000..1262c52 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/files/auto-readme.txt @@ -0,0 +1 @@ +All *.xml in this dir are automaticly started. \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/files/readme.txt b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/files/readme.txt new file mode 100644 index 0000000..5805e3e --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-build/src/main/files/readme.txt @@ -0,0 +1,6 @@ + +Readme for Vasc Tech Demo application. + +To start: + +execute: run.sh or run.bat \ No newline at end of file diff --git a/vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/src/main/java/net/forwardfire/vasc/demo/tech/ui/TomcatManager.java b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/src/main/java/net/forwardfire/vasc/demo/tech/ui/TomcatManager.java new file mode 100644 index 0000000..989f9b9 --- /dev/null +++ b/vasc-demo/vasc-demo-tech/vasc-demo-tech-ui/src/main/java/net/forwardfire/vasc/demo/tech/ui/TomcatManager.java @@ -0,0 +1,108 @@ +package net.forwardfire.vasc.demo.tech.ui; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.util.Enumeration; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.logging.Logger; + +import net.forwardfire.vasc.core.VascController; + +import org.apache.catalina.startup.Tomcat; + +public class TomcatManager { + + private Logger logger = null; + private Tomcat tomcat = null; + private VascController vascController = null; + + public TomcatManager() { + logger = Logger.getLogger(TomcatManager.class.getName()); + } + + public void start() throws Exception { + Tomcat tomcat = new Tomcat(); + + String webPort = System.getenv("PORT"); + if(webPort == null || webPort.isEmpty()) { + webPort = "8899"; + } + tomcat.setPort(Integer.valueOf(webPort)); + + if (System.getProperty("java.class.path").contains("classes")) { + String webappPathLocation = "../vasc-demo-tech-web/src/main/webapp/"; + String deployPath = new File(webappPathLocation).getAbsolutePath(); + logger.info("Deploy demo app from workspace path: "+deployPath); + tomcat.addWebapp("/demo",deployPath); + } else { + + File techWarFile = null; + for (File file:new File("lib").listFiles()) { + if (file.getName().endsWith("war")) { + techWarFile = file; + break; + } + } + if (techWarFile==null) { + throw new NullPointerException("Could not locate war file in lib directory."); + } + File destDir = new File("tomcat.wars"+File.separator+techWarFile.getName()); + if (destDir.exists()==false) { + destDir.mkdirs(); + JarFile jar = new JarFile(techWarFile); + Enumeration jars = jar.entries(); + while (jars.hasMoreElements()) { + java.util.jar.JarEntry file = jars.nextElement(); + java.io.File f = new java.io.File(destDir+File.separator+file.getName()); + if (file.isDirectory()) { + f.mkdir(); + continue; + } + InputStream is = jar.getInputStream(file); + FileOutputStream fos = new FileOutputStream(f); + while (is.available() > 0) { + fos.write(is.read()); // slow copy + } + fos.close(); + is.close(); + } + } + String deployPath = destDir.getAbsolutePath(); + logger.info("Deploy war path: "+deployPath); + tomcat.addWebapp("/demo",deployPath); + } + + instance = this; + + tomcat.start(); + } + + public void stop() throws Exception { + if (tomcat==null) { + return; + } + tomcat.stop(); + instance = null; + } + + static private TomcatManager instance = null; + static public TomcatManager getInstance() { + return instance; // hackje to rm mvn 1-1 dep with ui + } + + /** + * @return the vascController + */ + public VascController getVascController() { + return vascController; + } + + /** + * @param vascController the vascController to set + */ + public void setVascController(VascController vascController) { + this.vascController = vascController; + } +}