incubator-lokahi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tob...@apache.org
Subject svn commit: r629916 [1/3] - in /incubator/lokahi/lokahi/trunk: conf/ database/mysql/ database/oracle/ src/java/org/apache/lokahi/core/api/server/ src/java/org/apache/lokahi/core/api/template/ src/java/org/apache/lokahi/core/common/interfaces/ src/java/...
Date Thu, 21 Feb 2008 18:44:09 GMT
Author: toback
Date: Thu Feb 21 10:43:55 2008
New Revision: 629916

URL: http://svn.apache.org/viewvc?rev=629916&view=rev
Log:
Added Templating engine code supplied by Jeff Feist in reference to https://issues.apache.org/jira/browse/LOKAHI-4

Added:
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/template/
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/template/Template.java   (with props)
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/template/TemplateModel.java   (with props)
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/TemplateEngine.java   (with props)
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/Worker.java   (with props)
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/TemplateBuilder.java   (with props)
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/TemplateDeployer.java   (with props)
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/TemplateFactory.java   (with props)
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/VelocityTemplateBuilder.java   (with props)
    incubator/lokahi/lokahi/trunk/src/www/Core/Template/
    incubator/lokahi/lokahi/trunk/src/www/Core/Template/add.vm   (with props)
    incubator/lokahi/lokahi/trunk/src/www/Core/Template/confirm.vm   (with props)
    incubator/lokahi/lokahi/trunk/src/www/Core/Template/copy.vm   (with props)
    incubator/lokahi/lokahi/trunk/src/www/Core/Template/delete.vm   (with props)
    incubator/lokahi/lokahi/trunk/src/www/Core/Template/details.vm   (with props)
    incubator/lokahi/lokahi/trunk/src/www/Core/Template/list.vm   (with props)
    incubator/lokahi/lokahi/trunk/src/www/Core/Template/menu/
    incubator/lokahi/lokahi/trunk/src/www/Core/Template/menu/global.vm   (with props)
    incubator/lokahi/lokahi/trunk/src/www/Core/Template/menu/indiv.vm   (with props)
    incubator/lokahi/lokahi/trunk/src/www/Core/Template/update.vm   (with props)
Removed:
    incubator/lokahi/lokahi/trunk/src/www/Core/File/
Modified:
    incubator/lokahi/lokahi/trunk/conf/ApplicationResources.properties
    incubator/lokahi/lokahi/trunk/conf/lokahi.properties
    incubator/lokahi/lokahi/trunk/conf/struts-config.xml
    incubator/lokahi/lokahi/trunk/conf/toolbox.xml
    incubator/lokahi/lokahi/trunk/database/mysql/procs.sql
    incubator/lokahi/lokahi/trunk/database/mysql/tables.sql
    incubator/lokahi/lokahi/trunk/database/mysql/views.sql
    incubator/lokahi/lokahi/trunk/database/oracle/procs.sql
    incubator/lokahi/lokahi/trunk/database/oracle/tables.sql
    incubator/lokahi/lokahi/trunk/database/oracle/views.sql
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/server/HardwareModel.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/Application.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/LokahiModel.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/util/TMCVelocityViewTool.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/controller/task/BuildDeployApacheConfig.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/gui/www/FileAction.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/gui/www/TMCStartupServlet.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/httpd/api/server/Apache.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/httpd/api/worker/ApacheWorker.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/httpd/api/worker/ApacheWorkerModel.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/httpd/gui/www/ApacheAction.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/tomcat/api/server/Tomcat.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/tomcat/api/worker/TomcatWorker.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/tomcat/api/worker/TomcatWorkerModel.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/tomcat/gui/www/TomcatAction.java
    incubator/lokahi/lokahi/trunk/src/www/Apache/Pool/menu/global.vm
    incubator/lokahi/lokahi/trunk/src/www/Apache/Pool/menu/indiv.vm
    incubator/lokahi/lokahi/trunk/src/www/Apache/Server/add.vm
    incubator/lokahi/lokahi/trunk/src/www/Apache/Server/details.vm
    incubator/lokahi/lokahi/trunk/src/www/Apache/Server/update.vm
    incubator/lokahi/lokahi/trunk/src/www/Apache/Worker/add.vm
    incubator/lokahi/lokahi/trunk/src/www/Apache/Worker/menu/global.vm
    incubator/lokahi/lokahi/trunk/src/www/Apache/Worker/menu/indiv.vm
    incubator/lokahi/lokahi/trunk/src/www/Apache/Worker/viewconf.vm
    incubator/lokahi/lokahi/trunk/src/www/Core/Entity/index.vm
    incubator/lokahi/lokahi/trunk/src/www/Core/Project/details.vm
    incubator/lokahi/lokahi/trunk/src/www/Tomcat/Pool/menu/global.vm
    incubator/lokahi/lokahi/trunk/src/www/Tomcat/Pool/menu/indiv.vm
    incubator/lokahi/lokahi/trunk/src/www/Tomcat/Server/add.vm
    incubator/lokahi/lokahi/trunk/src/www/Tomcat/Server/details.vm
    incubator/lokahi/lokahi/trunk/src/www/Tomcat/Server/update.vm
    incubator/lokahi/lokahi/trunk/src/www/Tomcat/Worker/menu/global.vm
    incubator/lokahi/lokahi/trunk/src/www/Tomcat/Worker/menu/indiv.vm
    incubator/lokahi/lokahi/trunk/src/www/Tomcat/Worker/viewconf.vm
    incubator/lokahi/lokahi/trunk/src/www/js/common.js
    incubator/lokahi/lokahi/trunk/src/www/layout/list2.vm
    incubator/lokahi/lokahi/trunk/src/www/layout/style.vmcss

Modified: incubator/lokahi/lokahi/trunk/conf/ApplicationResources.properties
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/conf/ApplicationResources.properties?rev=629916&r1=629915&r2=629916&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/conf/ApplicationResources.properties (original)
+++ incubator/lokahi/lokahi/trunk/conf/ApplicationResources.properties Thu Feb 21 10:43:55 2008
@@ -69,7 +69,7 @@
 function.success.AddApacheWorker=The Apache Worker was added.
 function.success.AddContext=The Context was added.
 function.success.AddEnvironment=The Environment was added.
-function.success.AddFile=The File was added.
+function.success.AddFile=The Template was added.
 function.success.AddFunction=The Function was added.
 function.success.AddHardware=The Hardware was added.
 function.success.AddHelpItem=The Help Topic was added.
@@ -94,7 +94,7 @@
 function.success.DeleteApacheWorker=The apache worker has been deleted.
 function.success.DeleteContext=The context has been deleted.
 function.success.DeleteEnvironment=The environment has been deleted.
-function.success.DeleteFile=The file has been deleted.
+function.success.DeleteFile=The template has been deleted.
 function.success.DeleteFunction=The function has been deleted.
 function.success.DeleteHardware=The hardware has been deleted.  Why would you want to do that to me?
 function.success.DeleteHelpItem=The Help Topic has been deleted.
@@ -138,7 +138,7 @@
 function.success.UpdateApacheWorker=The apache worker has been updated.
 function.success.UpdateContext=The context has been updated.
 function.success.UpdateEnvironment=The environment has been updated.
-function.success.UpdateFile=The file has been updated.
+function.success.UpdateFile=The template has been updated.
 function.success.UpdateFunction=The function has been updated.
 function.success.UpdateHardware=The hadware has been updated.
 function.success.UpdateHelpItem=The help topic has been updated.
@@ -160,4 +160,4 @@
 error.invalidFunction=The function {0} has not been found.
 
 name.notAllowed=That name is not allowed.
-login.error.notInDatabase=Login failed please try again.
\ No newline at end of file
+login.error.notInDatabase=Login failed please try again.

Modified: incubator/lokahi/lokahi/trunk/conf/lokahi.properties
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/conf/lokahi.properties?rev=629916&r1=629915&r2=629916&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/conf/lokahi.properties (original)
+++ incubator/lokahi/lokahi/trunk/conf/lokahi.properties Thu Feb 21 10:43:55 2008
@@ -58,3 +58,15 @@
 lokahi.broker.autocommit=true
 lokahi.broker.type=mysql
 
+# Config Templating support
+lokahi.template.engine=org.apache.lokahi.core.common.templating.VelocityTemplateBuilder
+# variables are a comma separated list explaining the substitutions (use \ for a new line)
+lokahi.template.variables=server root=$worker.getApplication().getServerRoot(),\
+test=$worker.getApplication().getTest(),\
+newline=$n,\
+hosting pool tool=$hpTool,\
+virtualhost tool=$vhTool,\
+velocity view tool=$view
+
+
+

Modified: incubator/lokahi/lokahi/trunk/conf/struts-config.xml
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/conf/struts-config.xml?rev=629916&r1=629915&r2=629916&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/conf/struts-config.xml (original)
+++ incubator/lokahi/lokahi/trunk/conf/struts-config.xml Thu Feb 21 10:43:55 2008
@@ -181,12 +181,13 @@
       <form-property name="startClass" type="java.lang.String"/>
       <form-property name="stdOutLog" type="java.lang.String"/>
       <form-property name="javaHome" type="java.lang.String"/>
+      <form-property name="template" type="java.lang.String[]"/>
       <form-property name="wap" type="java.lang.String" initial="false"/>
       <form-property name="methodToCall" type="java.lang.String"/>
     </form-bean>
     <form-bean name="ApacheForm" type="org.apache.struts.validator.DynaValidatorForm" dynamic="true">
       <form-property name="id" type="java.lang.String"/>
-      <form-property name="mainId" type="java.lang.String"/>
+      <form-property name="mainId" type="java.lang.String[]"/>
       <form-property name="name" type="java.lang.String"/>
       <form-property name="serverRoot" type="java.lang.String"/>
       <form-property name="logLocation" type="java.lang.String"/>

Modified: incubator/lokahi/lokahi/trunk/conf/toolbox.xml
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/conf/toolbox.xml?rev=629916&r1=629915&r2=629916&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/conf/toolbox.xml (original)
+++ incubator/lokahi/lokahi/trunk/conf/toolbox.xml Thu Feb 21 10:43:55 2008
@@ -79,4 +79,19 @@
     <scope>request</scope>
     <class>org.apache.lokahi.core.common.util.TMCVelocityViewTool</class>
   </tool>
+  <tool>
+    <key>hpTool</key>
+    <scope>request</scope>
+    <class>org.apache.lokahi.core.api.pool.HostingPool</class>
+  </tool>
+  <tool>
+    <key>vhTool</key>
+    <scope>request</scope>
+    <class>org.apache.lokahi.httpd.api.entity.VirtualHost</class>
+  </tool>  
+  <tool>
+    <key>contextTool</key>
+    <scope>request</scope>
+    <class>org.apache.lokahi.tomcat.api.entity.TomcatContext</class>
+  </tool>  
 </toolbox>

Modified: incubator/lokahi/lokahi/trunk/database/mysql/procs.sql
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/database/mysql/procs.sql?rev=629916&r1=629915&r2=629916&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/database/mysql/procs.sql (original)
+++ incubator/lokahi/lokahi/trunk/database/mysql/procs.sql Thu Feb 21 10:43:55 2008
@@ -382,7 +382,7 @@
 									 IN V_PIDFILE VARCHAR(300),
 									 IN V_SROOT VARCHAR(300),
 									 IN V_LOGLOC VARCHAR(300),
-									 IN V_MAINID INT
+									 IN V_MAINID VARCHAR(300)
 				     			   	)
 BEGIN
 	INSERT INTO AM_CONTAINER (CONTAINER_NAME, SYS_USER, SYS_GROUP, START_COMMAND, STOP_COMMAND, RESTART_COMMAND, FORK_WAIT, ENV_VARIBLES, PIDFILE_LOCATION, SERVER_ROOT, LOG_LOCATION, MAIN_ID)
@@ -406,7 +406,7 @@
 									 IN V_PIDFILE VARCHAR(300),
 									 IN V_SROOT VARCHAR(300),
 									 IN V_LOGLOC VARCHAR(300),
-									 IN V_MAINID INT
+									 IN V_MAINID VARCHAR(300)
 				     			   	)
 
 BEGIN
@@ -1911,7 +1911,8 @@
 									 IN V_JAVAHOME VARCHAR(40),
 									 IN V_STARTCLASS VARCHAR(40),
 									 IN V_OUTLOG VARCHAR(40),		
-									 IN V_ENTRY BLOB
+									 IN V_ENTRY BLOB,
+									 IN V_TEMPLATE_IDS VARCHAR(300)
 				     			   	 )
 				     			   	 
 BEGIN
@@ -1928,7 +1929,8 @@
 			JAVA_HOME=V_JAVAHOME,
 			START_CLASS=V_STARTCLASS,
 			STD_OUT_LOG=V_STDOUTLOG,
-			CONF_ENTRY=V_ENTRY
+			CONF_ENTRY=V_ENTRY,
+			TEMPLATE_IDS=V_TEMPLATE_IDS
 
 		WHERE CONTAINER_ID=V_ID;
 END;
@@ -1981,11 +1983,12 @@
 									 IN V_JAVAHOME VARCHAR(300),
 									 IN V_STARTCLASS VARCHAR(40),
 									 IN V_OUTLOG VARCHAR(300),									 
-									 IN V_ENTRY BLOB
+									 IN V_ENTRY BLOB,
+									 IN V_TEMPLATE_IDS VARCHAR(300)
 				     			   	 )
 BEGIN
-	INSERT INTO TM_CONTAINER (CONTAINER_NAME, BASE_LOCATION, TOMCAT_HOME, HTTP_PORT, SYS_USER, SYS_GROUP, TOMCAT_TYPE, DESCRIPTION,STD_OUT_LOG, START_CLASS, JAVA_HOME, CONF_ENTRY)
-	VALUES ( V_NAME, V_BASELOCATION, V_TOMCATHOME, V_HTTPPORT, V_SYSUSER, V_SYSGROUP, V_TT, V_DESCRIP, V_OUTLOG, V_STARTCLASS, V_JAVAHOME, V_ENTRY);
+	INSERT INTO TM_CONTAINER (CONTAINER_NAME, BASE_LOCATION, TOMCAT_HOME, HTTP_PORT, SYS_USER, SYS_GROUP, TOMCAT_TYPE, DESCRIPTION,STD_OUT_LOG, START_CLASS, JAVA_HOME, CONF_ENTRY, TEMPLATE_IDS)
+	VALUES ( V_NAME, V_BASELOCATION, V_TOMCATHOME, V_HTTPPORT, V_SYSUSER, V_SYSGROUP, V_TT, V_DESCRIP, V_OUTLOG, V_STARTCLASS, V_JAVAHOME, V_ENTRY, V_TEMPLATE_IDS);
 	SELECT LAST_INSERT_ID() INTO V_ID;
 END;
 /

Modified: incubator/lokahi/lokahi/trunk/database/mysql/tables.sql
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/database/mysql/tables.sql?rev=629916&r1=629915&r2=629916&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/database/mysql/tables.sql (original)
+++ incubator/lokahi/lokahi/trunk/database/mysql/tables.sql Thu Feb 21 10:43:55 2008
@@ -19,7 +19,7 @@
 -- SQL99
 
 DROP TABLE IF EXISTS AM_CONTAINER;/
-CREATE TABLE AM_CONTAINER (CONTAINER_ID INT(11) NOT NULL auto_increment, PRIMARY KEY (CONTAINER_ID),CONTAINER_NAME VARCHAR(100) NOT NULL,SERVER_ROOT VARCHAR(300) ,LOG_LOCATION VARCHAR(300) ,SYS_USER VARCHAR(8) ,SYS_GROUP VARCHAR(8) ,START_COMMAND VARCHAR(4000) ,STOP_COMMAND VARCHAR(4000) ,RESTART_COMMAND VARCHAR(4000) ,FORK_WAIT INT(11) ,PIDFILE_LOCATION VARCHAR(300) ,ENV_VARIBLES VARCHAR(4000) ,MAIN_ID INT(11) , KEY (MAIN_ID));/
+CREATE TABLE AM_CONTAINER (CONTAINER_ID INT(11) NOT NULL auto_increment, PRIMARY KEY (CONTAINER_ID),CONTAINER_NAME VARCHAR(100) NOT NULL,SERVER_ROOT VARCHAR(300) ,LOG_LOCATION VARCHAR(300) ,SYS_USER VARCHAR(8) ,SYS_GROUP VARCHAR(8) ,START_COMMAND VARCHAR(4000) ,STOP_COMMAND VARCHAR(4000) ,RESTART_COMMAND VARCHAR(4000) ,FORK_WAIT INT(11) ,PIDFILE_LOCATION VARCHAR(300) ,ENV_VARIBLES VARCHAR(4000) ,MAIN_ID VARCHAR(300) , KEY (MAIN_ID));/
 
 DROP TABLE IF EXISTS AM_POOL;/
 CREATE TABLE AM_POOL (POOL_ID INT(11) NOT NULL auto_increment, PRIMARY KEY (POOL_ID),POOL_NAME VARCHAR(40) NOT NULL,ENV_ID INT(11) NOT NULL, KEY (ENV_ID));/
@@ -186,7 +186,7 @@
 
 
 DROP TABLE IF EXISTS TM_CONTAINER;/
-CREATE TABLE TM_CONTAINER (CONTAINER_ID INT(11) NOT NULL auto_increment, PRIMARY KEY (CONTAINER_ID),CONTAINER_NAME VARCHAR(40) ,BASE_LOCATION VARCHAR(100) ,TOMCAT_HOME VARCHAR(100) ,HTTP_PORT INT(11) ,SYS_USER VARCHAR(8) ,SYS_GROUP VARCHAR(8) ,CONF_ENTRY BLOB ,TOMCAT_TYPE INT(11) DEFAULT 4,DESCRIPTION VARCHAR(100) ,STD_OUT_LOG VARCHAR(300) ,START_CLASS VARCHAR(40) ,JAVA_HOME VARCHAR(300) );/
+CREATE TABLE TM_CONTAINER (CONTAINER_ID INT(11) NOT NULL auto_increment, PRIMARY KEY (CONTAINER_ID),CONTAINER_NAME VARCHAR(40) ,BASE_LOCATION VARCHAR(100) ,TOMCAT_HOME VARCHAR(100) ,HTTP_PORT INT(11) ,SYS_USER VARCHAR(8) ,SYS_GROUP VARCHAR(8) ,CONF_ENTRY BLOB ,TOMCAT_TYPE INT(11) DEFAULT 4,DESCRIPTION VARCHAR(100) ,STD_OUT_LOG VARCHAR(300) ,START_CLASS VARCHAR(40) ,JAVA_HOME VARCHAR(300),TEMPLATE_IDS VARCHAR(300) );/
 
 
 DROP TABLE IF EXISTS TM_ENTITY;/
@@ -375,5 +375,6 @@
 #ALTER TABLE TMC_REL_HELP_TOPIC ADD (  CONSTRAINT FK_REL_HELP_ITEM_ID FOREIGN KEY (HELP_ITEM_ID) REFERENCES TMC_HELP_ITEM (HELP_ITEM_ID) ON DELETE CASCADE,  CONSTRAINT FK_SUBTOPIC_ID FOREIGN KEY (SUBTOPIC_ID) REFERENCES TMC_TOPIC (TOPIC_ID) ON DELETE CASCADE,  CONSTRAINT FK_TOPIC_ID FOREIGN KEY (TOPIC_ID) REFERENCES TMC_TOPIC (TOPIC_ID) ON DELETE CASCADE);/
 
 #ALTER TABLE TM_REL_ENTITY_PROJECT ADD (  CONSTRAINT ENTITY_ID_FK FOREIGN KEY (ENTITY_ID) REFERENCES TM_ENTITY (ENTITY_ID) ON DELETE CASCADE DISABLE,  CONSTRAINT PROJECT_ID_FK FOREIGN KEY (PROJECT_ID) REFERENCES TMC_PROJECT (PROJECT_ID) ON DELETE CASCADE DISABLE);/
+
 
 

Modified: incubator/lokahi/lokahi/trunk/database/mysql/views.sql
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/database/mysql/views.sql?rev=629916&r1=629915&r2=629916&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/database/mysql/views.sql (original)
+++ incubator/lokahi/lokahi/trunk/database/mysql/views.sql Thu Feb 21 10:43:55 2008
@@ -86,7 +86,7 @@
 (WORKER_ID, CONTAINER_ID, STATE_ID, HARDWARE_ID, CONTAINER_NAME, 
  BASE_LOCATION, TOMCAT_HOME, HTTP_PORT, SYS_USER, SYS_GROUP, 
  TOMCAT_TYPE, DESCRIPTION, CONF_ENTRY, STD_OUT_LOG, JAVA_HOME, 
- START_CLASS, HARDWARE_NAME, PHYSICAL_LOCATION, COMMENTS, INSTANCE_ID, 
+ START_CLASS, TEMPLATE_IDS, HARDWARE_NAME, PHYSICAL_LOCATION, COMMENTS, INSTANCE_ID, 
  ENV_ID, STATUS_ID, DEFAULT_IP_ID)
 AS 
 SELECT
@@ -106,6 +106,7 @@
   c.std_out_log,
   c.java_home,
   c.start_class,
+  c.template_ids,
   h.hardware_name,
   h.physical_location,
   h.comments,
@@ -115,6 +116,7 @@
   h.default_ip_id
 FROM
   ((TM_WORKER w join TM_Container c using (container_ID)) JOIN TMC_HARDWARE h using (HARDWARE_ID));/
+
 
 
 

Modified: incubator/lokahi/lokahi/trunk/database/oracle/procs.sql
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/database/oracle/procs.sql?rev=629916&r1=629915&r2=629916&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/database/oracle/procs.sql (original)
+++ incubator/lokahi/lokahi/trunk/database/oracle/procs.sql Thu Feb 21 10:43:55 2008
@@ -235,7 +235,7 @@
 									 v_pidFile	IN	VARCHAR2,
 									 v_sRoot	IN	VARCHAR2,
 									 v_logLoc	IN	VARCHAR2,
-									 v_mainId	IN	NUMBER
+									 v_mainId	IN	VARCHAR2
 				     			   	)
 AS
 BEGIN
@@ -390,7 +390,7 @@
 									 v_pidFile	IN	VARCHAR2,
 									 v_sRoot	IN	VARCHAR2,
 									 v_logLoc	IN	VARCHAR2,
-									 v_mainId	IN	NUMBER
+									 v_mainId	IN	VARCHAR2
 				     			   	)
 AS
 BEGIN
@@ -1836,13 +1836,14 @@
 									 v_javaHome		IN	VARCHAR2,
 									 v_startClass	IN	VARCHAR2,
 									 v_outLog		IN	VARCHAR2,									 
-									 v_entry		IN	BLOB
+									 v_entry		IN	BLOB,
+									 v_template_ids IN VARCHAR2
 				     			   	 )
 AS
 BEGIN
 
-	 		INSERT INTO TM_CONTAINER tc (tc.CONTAINER_ID, tc.CONTAINER_NAME, tc.BASE_LOCATION, tc.TOMCAT_HOME, tc.HTTP_PORT, tc.SYS_USER, tc.SYS_GROUP, tc.TOMCAT_TYPE, tc.DESCRIPTION,tc.STD_OUT_LOG, tc.START_CLASS, tc.JAVA_HOME, tc.CONF_ENTRY)
-		   	VALUES ( tm_tomcat4_seq.NEXTVAL, v_name, v_baseLocation, v_tomcatHome, v_httpPort, v_sysUser, v_sysGroup, v_tt, v_descrip, v_outLog, v_startClass, v_javaHome, v_entry);
+	 		INSERT INTO TM_CONTAINER tc (tc.CONTAINER_ID, tc.CONTAINER_NAME, tc.BASE_LOCATION, tc.TOMCAT_HOME, tc.HTTP_PORT, tc.SYS_USER, tc.SYS_GROUP, tc.TOMCAT_TYPE, tc.DESCRIPTION,tc.STD_OUT_LOG, tc.START_CLASS, tc.JAVA_HOME, tc.CONF_ENTRY, tc.TEMPLATE_IDS)
+		   	VALUES ( tm_tomcat4_seq.NEXTVAL, v_name, v_baseLocation, v_tomcatHome, v_httpPort, v_sysUser, v_sysGroup, v_tt, v_descrip, v_outLog, v_startClass, v_javaHome, v_entry, v_template_ids);
 			-- get the newly added id
 			v_id:=f_last_sequence_number('tm_tomcat4_seq');
 END;
@@ -1942,7 +1943,8 @@
 									 v_javaHome		IN	VARCHAR2,
 									 v_startClass	IN	VARCHAR2,
 									 v_stdOutLog	IN	VARCHAR2,
-									 v_entry		IN	BLOB
+									 v_entry		IN	BLOB,
+									 v_template_ids	IN	VARCHAR2
 				     			   	 )
 AS
 BEGIN
@@ -1958,7 +1960,8 @@
 			tc.JAVA_HOME=v_javaHome,
 			tc.START_CLASS=v_startClass,
 			tc.STD_OUT_LOG=v_stdOutLog,
-			tc.conf_entry=v_entry
+			tc.conf_entry=v_entry,
+			tc.TEMPLATE_IDS=v_template_ids
 
 		WHERE tc.CONTAINER_ID=v_id;
 END;

Modified: incubator/lokahi/lokahi/trunk/database/oracle/tables.sql
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/database/oracle/tables.sql?rev=629916&r1=629915&r2=629916&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/database/oracle/tables.sql (original)
+++ incubator/lokahi/lokahi/trunk/database/oracle/tables.sql Thu Feb 21 10:43:55 2008
@@ -17,7 +17,7 @@
 -- under the License.
 --
 
-CREATE TABLE AM_CONTAINER ( CONTAINER_ID NUMBER NOT NULL, CONTAINER_NAME VARCHAR2(100) NOT NULL, SERVER_ROOT VARCHAR2(300), LOG_LOCATION VARCHAR2(300), SYS_USER VARCHAR2(8), SYS_GROUP VARCHAR2(8), START_COMMAND VARCHAR2(4000), STOP_COMMAND VARCHAR2(4000), RESTART_COMMAND VARCHAR2(4000), FORK_WAIT NUMBER, PIDFILE_LOCATION VARCHAR2(300), ENV_VARIBLES VARCHAR2(4000), MAIN_ID NUMBER ) LOGGING NOCACHE NOPARALLEL;
+CREATE TABLE AM_CONTAINER ( CONTAINER_ID NUMBER NOT NULL, CONTAINER_NAME VARCHAR2(100) NOT NULL, SERVER_ROOT VARCHAR2(300), LOG_LOCATION VARCHAR2(300), SYS_USER VARCHAR2(8), SYS_GROUP VARCHAR2(8), START_COMMAND VARCHAR2(4000), STOP_COMMAND VARCHAR2(4000), RESTART_COMMAND VARCHAR2(4000), FORK_WAIT NUMBER, PIDFILE_LOCATION VARCHAR2(300), ENV_VARIBLES VARCHAR2(4000), MAIN_ID VARCHAR2(300) ) LOGGING NOCACHE NOPARALLEL;
 
 
 CREATE TABLE AM_POOL ( POOL_ID NUMBER NOT NULL, POOL_NAME VARCHAR2(40) NOT NULL, ENV_ID NUMBER NOT NULL ) LOGGING NOCACHE NOPARALLEL;
@@ -143,7 +143,7 @@
 CREATE TABLE TMC_USER ( FIRST_NAME VARCHAR2(30), LAST_NAME VARCHAR2(30), JOB_TITLE VARCHAR2(100), COMMENTS VARCHAR2(2000), EMAIL VARCHAR2(60), USER_ID NUMBER NOT NULL, USER_NAME VARCHAR2(30) NOT NULL, STATE_ID NUMBER DEFAULT 8, PASSWORD VARCHAR2(32) ) LOGGING NOCACHE NOPARALLEL;
 
 
-CREATE TABLE TM_CONTAINER ( CONTAINER_ID NUMBER NOT NULL, CONTAINER_NAME VARCHAR2(40), BASE_LOCATION VARCHAR2(100), TOMCAT_HOME VARCHAR2(100), HTTP_PORT NUMBER, SYS_USER VARCHAR2(8), SYS_GROUP VARCHAR2(8), CONF_ENTRY BLOB, TOMCAT_TYPE NUMBER DEFAULT 4, DESCRIPTION VARCHAR2(100), STD_OUT_LOG VARCHAR2(300), START_CLASS VARCHAR2(40), JAVA_HOME VARCHAR2(300) ) LOGGING NOCACHE NOPARALLEL;
+CREATE TABLE TM_CONTAINER ( CONTAINER_ID NUMBER NOT NULL, CONTAINER_NAME VARCHAR2(40), BASE_LOCATION VARCHAR2(100), TOMCAT_HOME VARCHAR2(100), HTTP_PORT NUMBER, SYS_USER VARCHAR2(8), SYS_GROUP VARCHAR2(8), CONF_ENTRY BLOB, TOMCAT_TYPE NUMBER DEFAULT 4, DESCRIPTION VARCHAR2(100), STD_OUT_LOG VARCHAR2(300), START_CLASS VARCHAR2(40), JAVA_HOME VARCHAR2(300), TEMPLATE_IDS VARCHAR(300) ) LOGGING NOCACHE NOPARALLEL;
 
 
 CREATE TABLE TM_ENTITY ( ENTITY_ID NUMBER NOT NULL, ENTITY_NAME VARCHAR2(60) NOT NULL, DOC_BASE VARCHAR2(500) NOT NULL, ENTITY_STATE_ID NUMBER NOT NULL, ENV_ID NUMBER NOT NULL, TOMCAT_POOL_ID NUMBER, ENTITY_DEFIN VARCHAR2(4000), EX_PROJECT_ID NUMBER DEFAULT 0 ) LOGGING NOCACHE NOPARALLEL;
@@ -326,5 +326,6 @@
 ALTER TABLE TMC_REL_HELP_TOPIC ADD (  CONSTRAINT FK_REL_HELP_ITEM_ID FOREIGN KEY (HELP_ITEM_ID) REFERENCES TMC_HELP_ITEM (HELP_ITEM_ID) ON DELETE CASCADE,  CONSTRAINT FK_SUBTOPIC_ID FOREIGN KEY (SUBTOPIC_ID) REFERENCES TMC_TOPIC (TOPIC_ID) ON DELETE CASCADE,  CONSTRAINT FK_TOPIC_ID FOREIGN KEY (TOPIC_ID) REFERENCES TMC_TOPIC (TOPIC_ID) ON DELETE CASCADE);
 
 ALTER TABLE TM_REL_ENTITY_PROJECT ADD (  CONSTRAINT ENTITY_ID_FK FOREIGN KEY (ENTITY_ID) REFERENCES TM_ENTITY (ENTITY_ID) ON DELETE CASCADE DISABLE,  CONSTRAINT PROJECT_ID_FK FOREIGN KEY (PROJECT_ID) REFERENCES TMC_PROJECT (PROJECT_ID) ON DELETE CASCADE DISABLE);
+
 
 

Modified: incubator/lokahi/lokahi/trunk/database/oracle/views.sql
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/database/oracle/views.sql?rev=629916&r1=629915&r2=629916&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/database/oracle/views.sql (original)
+++ incubator/lokahi/lokahi/trunk/database/oracle/views.sql Thu Feb 21 10:43:55 2008
@@ -86,7 +86,7 @@
 (WORKER_ID, CONTAINER_ID, STATE_ID, HARDWARE_ID, CONTAINER_NAME, 
  BASE_LOCATION, TOMCAT_HOME, HTTP_PORT, SYS_USER, SYS_GROUP, 
  TOMCAT_TYPE, DESCRIPTION, CONF_ENTRY, STD_OUT_LOG, JAVA_HOME, 
- START_CLASS, HARDWARE_NAME, PHYSICAL_LOCATION, COMMENTS, INSTANCE_ID, 
+ START_CLASS, TEMPLATE_IDS, HARDWARE_NAME, PHYSICAL_LOCATION, COMMENTS, INSTANCE_ID, 
  ENV_ID, STATUS_ID, DEFAULT_IP_ID)
 AS 
 SELECT
@@ -106,6 +106,7 @@
   c.std_out_log,
   c.java_home,
   c.start_class,
+  c.template_ids,
   h.hardware_name,
   h.physical_location,
   h.comments,
@@ -115,5 +116,6 @@
   h.default_ip_id
 FROM
   ((TM_WORKER w join TM_Container c using (container_ID)) JOIN TMC_HARDWARE h using (HARDWARE_ID));
+
 
 

Modified: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/server/HardwareModel.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/server/HardwareModel.java?rev=629916&r1=629915&r2=629916&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/server/HardwareModel.java (original)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/server/HardwareModel.java Thu Feb 21 10:43:55 2008
@@ -100,44 +100,11 @@
     JobPool.update(jp);
   }
 
-  public void deployJvmConf(User u, Collection<Hardware> c, JobPool jobPool) throws SQLException, IOException {
-    for (final Hardware h : c) {
-      this.deployJvmConf(u, h, jobPool);
-    }
-  }
-
-  public void deployJvmConf(User u, Hardware h, JobPool jobPool) throws SQLException, IOException {
-    Function f = Function.getFunction("PutFile");
-    Job j = new Job("./jvm.conf", h, f, jobPool);
-    j.setResult(this.buildJvmConf(h));
-    j = Job.store(j);
-    j = new Job(j, "", h, Function.getFunction("UpdateTomcat"), jobPool);
-    Job.store(j);
-  }
-
-  public String buildJvmConf(Hardware h) throws SQLException {
-    Collection<TomcatWorker> c = TomcatWorker.getTomcatWorkers(h, false);
-    StringBuffer ret = new StringBuffer();
-    for (final TomcatWorker tw : c) {
-      Tomcat t = tw.getTomcat();
-      if (t != null)
-        ret.append(t.buildJvmconfEntry());
-    }
-    return ret.toString();
-  }
-
   public void addHardware(User u, String hardwareName, String physicalLocation, String comments, int instanceId, int envId, int statusId, String defaultIp, String... ips) throws AuthorizationException, TMCIllegalArgumentException, SQLException, IOException {
     Hardware h = new Hardware(); //todo finish this
     this.addHardware(u, h);
   }
 
-//  public void addHardware(User u, Hardware h) throws AuthorizationException, TMCIllegalArgumentException, SQLException, IOException {
-//    Function f = Function.getFunction("AddHardware");
-//    this.jpInit(f, u, h.getName());
-//    if (!u.isAllowed(f)) throw new AuthorizationException("User " + u.getName() + " Not allowed to " + f.getName());
-//    this.addHardware(jp, h);
-//  }
-
   public void addHardware(JobPool jp, Hardware h) throws AuthorizationException, TMCIllegalArgumentException, SQLException, IOException {
 
   }
@@ -173,7 +140,7 @@
   }
 
   /**
-   * @return
+   * @return A collection of all of the hardware
    * @throws SQLException
    * @deprecated
    */
@@ -189,6 +156,7 @@
     return Hardware.getHardware(id, true);
   }
 }
+
 
 
 

Added: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/template/Template.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/template/Template.java?rev=629916&view=auto
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/template/Template.java (added)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/template/Template.java Thu Feb 21 10:43:55 2008
@@ -0,0 +1,288 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+package org.apache.lokahi.core.api.template;
+
+import org.apache.log4j.Logger;
+import org.apache.lokahi.core.common.database.BrokerFactory;
+import org.apache.lokahi.core.common.interfaces.Entity;
+import org.apache.lokahi.core.common.interfaces.TMCBroker;
+import org.apache.lokahi.core.common.interfaces.TMCDao;
+import org.apache.lokahi.core.common.util.PropertiesFile;
+
+import java.sql.Blob;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+
+/**
+ * @author The Apache Incubated Lokahi project - http://incubator.apache.org/lokahi/
+ * @version $Id$
+ */
+public class Template extends TMCDao<Template> implements Entity {
+  static final Logger logger = Logger.getLogger(Template.class);
+  private static final TMCBroker<Template> broker = new BrokerFactory<Template>().getBroker();
+  private int pk;
+  private String name;
+  private String content;
+  private String descriptor;
+  private String path;
+
+  public Template() {
+	  // create a new empty template
+  }
+
+  public Template(String name, String content, String discriptor, String path) {
+    this.name = name;
+    this.content = content;
+    this.descriptor = discriptor;
+    this.path = path;
+  }
+
+  public Template(int pk, String name, String discriptor, String path, Blob content) throws SQLException {
+    this.pk = pk;
+    this.name = name;
+    this.descriptor = discriptor;
+    this.path = path;
+    if (content != null)
+      this.setContent(content.getBytes(1, (int) content.length()));
+  }
+
+  public int getPk() {
+    return this.pk;
+  }
+
+  public void setPk(int pk) {
+    this.pk = pk;
+  }
+
+  public String getName() {
+    return this.name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getContent() {
+    if (this.content == null) {
+      this.content = "";
+    }
+    return this.content;
+  }
+
+  public void setContent(byte[] content) {
+    if (content != null) {
+      this.content = new String(content);
+    } else {
+      if (logger.isDebugEnabled()) {
+        logger.debug("content=" + content);
+      }
+      this.content = "";
+    }
+  }
+
+  public void setContent(String content) {
+    this.content = content;
+  }
+
+  public String getDescriptor() {
+    return this.descriptor;
+  }
+
+  public void setDescriptor(String discriptor) {
+    this.descriptor = discriptor;
+  }
+
+  public String getPath() {
+    return this.path;
+  }
+
+  public void setPath(String path) {
+    this.path = path;
+  }
+
+  public Template fillObject(ResultSet r) throws SQLException {
+    return new Template(r.getInt("FILE_ID"), r.getString("FILE_NAME"), r.getString("FILE_DESCRIPTOR"), r.getString("FILE_PATH"), r.getBlob("FILE_CONTENT"));
+  }
+
+  static Template store(Template t) throws SQLException {
+	Template ret = null;
+    try {
+      t.setPk(broker.save("core.file.store", t.getName(), t.getDescriptor(), t.getPath()));
+      if (logger.isDebugEnabled()) {
+        logger.debug("t=" + t);
+      }
+      if (storeBlob(t.getPk(), t.getContent())) {
+        ret = t;
+      }
+    } catch (SQLException e) {
+        logger.error("Exception: " + e.getMessage());
+      throw e;
+    }
+    if (logger.isDebugEnabled()) {
+      logger.debug("Returning " + ret);
+    }
+    return ret;
+  }
+
+  static boolean update(Template t) throws SQLException {
+    boolean ret = false;
+    try {
+      broker.update("core.file.update", t.getPk(), t.getName(), t.getDescriptor(), t.getPath());
+      if (logger.isDebugEnabled()) {
+        logger.debug("t=" + t);
+      }
+      if (storeBlob(t.getPk(), t.getContent())) {
+        ret = true;
+      }
+    } catch (SQLException e) {
+        logger.error("Exception: " + e.getMessage());
+      throw e;
+    }
+    if (logger.isDebugEnabled()) {
+      logger.debug("Returning " + ret);
+    }
+    return ret;
+  }
+
+  private static boolean storeBlob(int id, String toStore) throws SQLException {
+    boolean ret = false;
+    try {
+        if ("oracle".equals(PropertiesFile.getConstantValue("lokahi.broker.type")))
+            storeBlobOracleImpl(id, toStore);
+        else
+            storeBlobStdImpl(id, toStore);
+      ret = true;
+    } catch (SQLException e) {
+        logger.error("Exception: " + e.getMessage());
+      throw e;
+    }
+    return ret;
+  }
+
+  private static void storeBlobOracleImpl(int id, String toStore) throws SQLException {
+      broker.useSQL("core.file.prep.blob", id);
+      if (toStore == null) toStore = "";
+      byte[] blobBytes = toStore.getBytes();
+      broker.blobHack("core.file.content.lock", "core.file.content.update", id, blobBytes);
+  }
+
+  private static void storeBlobStdImpl(int id, String toStore) throws SQLException {
+      if (toStore == null) toStore = "";
+      byte[] blobBytes = toStore.getBytes();
+      broker.useSQL("core.file.prep.blob", id ,blobBytes);
+  }
+
+  static boolean delete(Template f) throws SQLException {
+    return broker.delete("core.file.delete", f.getPk());
+  }
+
+  public Template get(int id) throws SQLException {
+    return broker.getObject(Template.class, "core.file.by.id", false, id);
+  }
+
+  /**
+   * @param id
+   *
+   * @return A template with the given id or null if it isn't found
+   * @throws SQLException
+   * @deprecated
+   */
+  public static Template getTemplate(int id) throws SQLException {
+	Template t;
+    try {
+      t = broker.getObject(Template.class, "core.file.by.id", false, id);
+    } catch (SQLException e) {
+        logger.error("SQLException: " + e.getMessage());
+      throw e;
+    }
+    return t;
+  }
+
+  public static Collection<Template> getTemplates() throws SQLException {
+    Collection<Template> c;
+    try {
+      c = broker.getObjects(Template.class, false, "core.file.all");
+    } catch (SQLException e) {
+      if (logger.isInfoEnabled()) {
+        logger.info("Exception: " + e.getMessage());
+      }
+      throw e;
+    }
+    return c;
+  }
+
+  public StringBuilder buildShortXMLRepresentation() {
+    LinkedHashMap<String, String> map = new LinkedHashMap<String, String>(3, 1);
+    map.put("id", Integer.toString(this.getPk()));
+    map.put("name", this.getName());
+    map.put("href", PropertiesFile.getConstantValue("rest.servlet.url") + "template/" + this.getPk() + '/');
+    return elementBuilder("template", map);
+  }
+
+  public StringBuilder buildXMLRepresention() {
+    StringBuilder ret = new StringBuilder();
+    ret.append("<template>\n");
+    ret.append(elementBuilder("id", Integer.toString(this.getPk())));
+    ret.append(elementBuilder("name", this.getName()));
+    ret.append(elementBuilder("content", this.getContent()));
+    ret.append(elementBuilder("descriptor", this.getDescriptor()));
+    ret.append(elementBuilder("path", this.getPath()));
+    ret.append("</template>\n");
+    return ret;
+  }
+
+  public String toString() {
+    final StringBuffer buf = new StringBuffer();
+    buf.append("Template");
+    buf.append("{pk=").append(this.pk);
+    buf.append(",name=").append(this.name);
+    buf.append(",content=").append(this.content);
+    buf.append(",descriptor=").append(this.descriptor);
+    buf.append(",path=").append(this.path);
+    buf.append('}');
+    return buf.toString();
+  }
+
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (!(o instanceof Template)) return false;
+
+    final Template template = (Template) o;
+
+    if (this.pk != template.pk) return false;
+    if (this.descriptor != null ? !this.descriptor.equals(template.descriptor) : template.descriptor != null) return false;
+    if (this.name != null ? !this.name.equals(template.name) : template.name != null) return false;
+    if (this.path != null ? !this.path.equals(template.path) : template.path != null) return false;
+
+    return true;
+  }
+
+  public int hashCode() {
+    int result;
+    result = this.pk;
+    result = 29 * result + (this.name != null ? this.name.hashCode() : 0);
+    result = 29 * result + (this.descriptor != null ? this.descriptor.hashCode() : 0);
+    result = 29 * result + (this.path != null ? this.path.hashCode() : 0);
+    return result;
+  }
+}
+
+

Propchange: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/template/Template.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/template/TemplateModel.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/template/TemplateModel.java?rev=629916&view=auto
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/template/TemplateModel.java (added)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/template/TemplateModel.java Thu Feb 21 10:43:55 2008
@@ -0,0 +1,96 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+package org.apache.lokahi.core.api.template;
+
+import org.apache.lokahi.core.api.function.Function;
+import org.apache.lokahi.core.api.jobpool.JobPool;
+import org.apache.lokahi.core.api.state.State;
+import org.apache.lokahi.core.api.user.User;
+import org.apache.lokahi.core.common.collection.TMCSet;
+import org.apache.lokahi.core.common.exception.AuthorizationException;
+import org.apache.lokahi.core.common.exception.TMCIllegalArgumentException;
+import org.apache.lokahi.core.common.interfaces.LokahiModel;
+
+import java.sql.SQLException;
+import java.util.Collection;
+
+/**
+ * @author The Apache Incubated Lokahi project - http://incubator.apache.org/lokahi/
+ * @version $Id$
+ */
+public class TemplateModel extends LokahiModel<Template> {
+
+  public void addFile(User u, Template template, Function f) throws AuthorizationException, SQLException {
+    this.jpInit(f, u, template.getName());
+    if (u.isAllowed(f) && "AddFile".equals(f.getCommand())) {
+    	Template.store(template);
+    } else {
+      throw new AuthorizationException("User " + u.getName() + " Not allowed to " + f.getName());
+    }
+    this.jp.setState(State.COMPLETE);
+    JobPool.update(this.jp);
+  }
+
+  public void deleteFile(User u, Template template, Function f) throws SQLException, AuthorizationException, TMCIllegalArgumentException {
+    if (template == null || template.getPk() < 1) throw new TMCIllegalArgumentException("File can not be null");
+    this.jpInit(f, u, template.getName());
+    if (u.isAllowed(f) && "DeleteFile".equals(f.getCommand())) {
+    	Template.delete(template);
+    } else {
+      throw new AuthorizationException("User " + u.getName() + " Not allowed to " + f.getName());
+    }
+    this.jp.setState(State.COMPLETE);
+    JobPool.update(this.jp);
+  }
+
+  public void deleteFile(User u, Collection<Template> templates, Function f) throws AuthorizationException, TMCIllegalArgumentException, SQLException {
+    for (Template template : templates) this.deleteFile(u, template, f);
+  }  //todo fix the quick hack so that we only create one jobpool for the list of files we want to delete.
+
+  public void updateFile(User u, Template template, Function f) throws AuthorizationException, TMCIllegalArgumentException, SQLException {
+    this.jpInit(f, u, template.getName());
+    if (u.isAllowed(f) && "UpdateFile".equals(f.getCommand())) {
+      if (template.getPk() >= 1 && template.getName() != null && !"".equals(template.getName())) {
+    	  Template.update(template);
+      } else {
+        throw new TMCIllegalArgumentException("Template can not be null");
+      }
+    } else {
+      throw new AuthorizationException("User " + u.getName() + " Not allowed to " + f.getName());
+    }
+    this.jp.setState(State.COMPLETE);
+    JobPool.update(this.jp);
+  }
+
+  public Template viewTemplate(int id) throws SQLException {
+    return Template.getTemplate(id);
+  }
+
+  public Collection<Template> viewTemplates() throws SQLException {
+    return Template.getTemplates();
+  }
+
+  public Collection<Template> getObjects() throws SQLException {
+    return new TMCSet<Template>(this.viewTemplates());
+  }
+
+  public Template getObject(int id) throws SQLException {
+    return this.viewTemplate(id);
+  }
+}

Propchange: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/template/TemplateModel.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/Application.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/Application.java?rev=629916&r1=629915&r2=629916&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/Application.java (original)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/Application.java Thu Feb 21 10:43:55 2008
@@ -18,6 +18,11 @@
 */
 package org.apache.lokahi.core.common.interfaces;
 
+import java.util.Collection;
+
+import org.apache.lokahi.core.api.template.Template;
+
+
 /**
  * @author The Apache Incubated Lokahi project - http://incubator.apache.org/lokahi/
  * @version $Id$
@@ -30,8 +35,13 @@
   public abstract String getSysUser();
 
   public abstract String getSysGroup();
-
+  
+  public abstract Collection<Template> getTemplates();
+  
+  public abstract String getServerLocation();
+  
 }
+
 
 
 

Modified: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/LokahiModel.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/LokahiModel.java?rev=629916&r1=629915&r2=629916&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/LokahiModel.java (original)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/LokahiModel.java Thu Feb 21 10:43:55 2008
@@ -24,11 +24,15 @@
 import org.apache.lokahi.core.api.project.Project;
 import org.apache.lokahi.core.api.state.State;
 import org.apache.lokahi.core.api.user.User;
+import org.apache.lokahi.core.common.database.BrokerFactory;
 import org.apache.lokahi.core.common.exception.AlreadyExistException;
 import org.apache.lokahi.core.common.exception.AuthorizationException;
 import org.apache.lokahi.core.common.exception.TMCException;
 import org.apache.lokahi.core.common.exception.TMCIllegalArgumentException;
 import org.apache.lokahi.core.common.exception.UnsupportedParameterException;
+import org.apache.lokahi.core.common.templating.TemplateBuilder;
+import org.apache.lokahi.core.common.templating.TemplateFactory;
+import org.apache.lokahi.httpd.api.worker.ApacheWorker;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -44,7 +48,8 @@
  */
 public abstract class LokahiModel<T extends Restable> {
   protected static final Logger logger = Logger.getLogger(LokahiModel.class);
-
+  protected static final TemplateEngine templateEngine = new TemplateFactory().getEngine();
+  
   protected static ThreadPoolExecutor tpe = new ThreadPoolExecutor(5, 20, 300, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(25));
 
   public abstract Collection<T> getObjects() throws SQLException;
@@ -133,6 +138,7 @@
   }
 
 }
+
 
 
 

Added: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/TemplateEngine.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/TemplateEngine.java?rev=629916&view=auto
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/TemplateEngine.java (added)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/TemplateEngine.java Thu Feb 21 10:43:55 2008
@@ -0,0 +1,26 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+* 
+*   http://www.apache.org/licenses/LICENSE-2.0
+* 
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+package org.apache.lokahi.core.common.interfaces;
+
+import java.util.Collection;
+
+public interface TemplateEngine {
+	Collection<String> buildConfs(Object param);
+	String buildConf(Object... params);
+}

Propchange: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/TemplateEngine.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/Worker.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/Worker.java?rev=629916&view=auto
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/Worker.java (added)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/Worker.java Thu Feb 21 10:43:55 2008
@@ -0,0 +1,30 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+* 
+*   http://www.apache.org/licenses/LICENSE-2.0
+* 
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+package org.apache.lokahi.core.common.interfaces;
+
+import org.apache.lokahi.core.api.server.Hardware;
+
+/**
+ * @author The Apache Incubated Lokahi project - http://incubator.apache.org/lokahi/
+ * @version $Id$
+ */
+public interface Worker {
+	public Application getApplication();
+	public Hardware getHardware();
+}

Propchange: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/interfaces/Worker.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/TemplateBuilder.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/TemplateBuilder.java?rev=629916&view=auto
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/TemplateBuilder.java (added)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/TemplateBuilder.java Thu Feb 21 10:43:55 2008
@@ -0,0 +1,81 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+package org.apache.lokahi.core.common.templating;
+
+import java.util.Collection;
+
+import org.apache.log4j.Logger;
+import org.apache.lokahi.core.common.interfaces.TemplateEngine;
+
+/**
+ * TemplateBuilder
+ * Builds a configuration file from a template
+ * @author The Apache Incubated Lokahi project - http://incubator.apache.org/lokahi/
+ * @version $Id$
+ */
+public class TemplateBuilder implements TemplateEngine {
+	static final Logger logger = Logger.getLogger(TemplateBuilder.class);
+	public final static String DEFAULT_ENGINE_IMPLEMENTATION = "org.apache.lokahi.core.common.templating.VelocityTemplateBuilder";
+
+	private static String masterEngineClassName = DEFAULT_ENGINE_IMPLEMENTATION;
+
+	private TemplateEngine masterEngine;
+
+	/**
+	 * Create a new Template builder.
+	 * This instantiates a new template builder with the class name of masterEngineClassName
+	 */
+	public TemplateBuilder() {
+		super();
+		if (logger.isDebugEnabled()) {
+			logger.debug("Instantiate a '"+masterEngineClassName+"' template builder.");
+		}
+		try {
+			masterEngine = (TemplateEngine) Class.forName(masterEngineClassName).newInstance();
+		} catch (InstantiationException e) {
+			e.printStackTrace();
+		} catch (IllegalAccessException e) {
+			e.printStackTrace();
+		} catch (ClassNotFoundException e) {
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * Sets the master engine class name
+	 * @param masterEngineClassName - The class name of the templating engine to use
+	 */
+	public static void setMasterEngineClassName(String masterEngineClassName) {
+		TemplateBuilder.masterEngineClassName = masterEngineClassName;
+	}
+
+	/**
+	 * Builds a collection of configuration files from templates
+	 */
+	public Collection<String> buildConfs(Object param) {
+		return masterEngine.buildConfs(param);
+	}
+
+	/**
+	 * Builds a single configuration file from a template
+	 */
+	public String buildConf(Object... params) {
+		return masterEngine.buildConf(params);
+	}
+}
\ No newline at end of file

Propchange: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/TemplateBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/TemplateDeployer.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/TemplateDeployer.java?rev=629916&view=auto
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/TemplateDeployer.java (added)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/TemplateDeployer.java Thu Feb 21 10:43:55 2008
@@ -0,0 +1,86 @@
++/*
++* Licensed to the Apache Software Foundation (ASF) under one
++* or more contributor license agreements.  See the NOTICE file
++* distributed with this work for additional information
++* regarding copyright ownership.  The ASF licenses this file
++* to you under the Apache License, Version 2.0 (the
++* "License"); you may not use this file except in compliance
++* with the License.  You may obtain a copy of the License at
++*
++*   http://www.apache.org/licenses/LICENSE-2.0
++*
++* Unless required by applicable law or agreed to in writing,
++* software distributed under the License is distributed on an
++* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
++* KIND, either express or implied.  See the License for the
++* specific language governing permissions and limitations
++* under the License.
++*/
++package org.apache.lokahi.core.common.templating;
++
++import java.io.IOException;
++import java.sql.SQLException;
++
++import org.apache.log4j.Logger;
++import org.apache.lokahi.core.api.function.Function;
++import org.apache.lokahi.core.api.job.Job;
++import org.apache.lokahi.core.api.jobpool.JobPool;
++import org.apache.lokahi.core.api.template.Template;
++import org.apache.lokahi.core.common.interfaces.TemplateEngine;
++import org.apache.lokahi.core.common.interfaces.Worker;
++
++/**
++ * TemplateDeployer
++ * Deploys configuration files based on templates
++ * @author The Apache Incubated Lokahi project - http://incubator.apache.org/lokahi/
++ * @version $Id$
++ */
++public class TemplateDeployer implements Runnable {
++	public static final Logger logger = Logger.getLogger(TemplateDeployer.class);
++	protected static final TemplateEngine templateEngine = new TemplateFactory().getEngine();
++
++	private final Worker worker;
++	private final JobPool jp;
++	private final boolean graceful;
++	private final Job prereq;
++
++	public TemplateDeployer(Worker worker, JobPool jobPool, boolean shouldGraceful) {
++		this.worker = worker;
++		this.graceful = shouldGraceful;
++		this.jp = jobPool;
++		this.prereq = null;
++	}
++
++	public TemplateDeployer(Job j, Worker worker, JobPool jobPool, boolean shouldGraceful) {
++		this.worker = worker;
++		this.graceful = shouldGraceful;
++		this.jp = jobPool;
++		this.prereq = j;
++	}
++
++	/**
++	 * Gets all of the template files from the worker and deploys them
++	 * 	 The path and file name are read from the template
++	 */
++	public void run() {
++	    try {
++	      Function f = Function.getFunction("PutFile");
++	      Job j = new Job();
++	      for (Object temp : this.worker.getApplication().getTemplates()) {
++	    	  Template template = (Template) temp;
++	    	  j = new Job(this.prereq, template.getPath() + template.getDescriptor(), this.worker.getHardware(), f, this.jp);
++	    	  String conf = templateEngine.buildConf(this.worker, template.getPk());
++		      j.setResult(conf);
++		      j = Job.store(j);
++	      }
++	      if (j != null && this.graceful) {
++	    	  j = new Job(j, this.worker.getApplication().getServerLocation(), this.worker.getHardware(), Function.getFunction("GracefulApache"), this.jp);
++	    	  Job.store(j);
++	      }
++	    } catch (SQLException e) {
++	        logger.error("SQLException: " + e.getMessage());
++	    } catch (IOException e) {
++	        logger.error("SQLException: " + e.getMessage());
++	    }
++	  }
++}
\ No newline at end of file

Propchange: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/TemplateDeployer.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/TemplateFactory.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/TemplateFactory.java?rev=629916&view=auto
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/TemplateFactory.java (added)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/TemplateFactory.java Thu Feb 21 10:43:55 2008
@@ -0,0 +1,41 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+package org.apache.lokahi.core.common.templating;
+
+import org.apache.log4j.Logger;
+import org.apache.lokahi.core.common.interfaces.TemplateEngine;
+
+/**
+ * TemplateFactory
+ * Gets a new template builder based on the engine that is provided
+ * @author The Apache Incubated Lokahi project - http://incubator.apache.org/lokahi/
+ * @version $Id$
+ */
+public class TemplateFactory {
+	static final Logger logger = Logger.getLogger(TemplateFactory.class);
+
+	public TemplateFactory() {
+	}
+
+	  public TemplateEngine getEngine() {
+		    return new TemplateBuilder();
+		  }
+
+
+}
\ No newline at end of file

Propchange: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/TemplateFactory.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/VelocityTemplateBuilder.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/VelocityTemplateBuilder.java?rev=629916&view=auto
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/VelocityTemplateBuilder.java (added)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/VelocityTemplateBuilder.java Thu Feb 21 10:43:55 2008
@@ -0,0 +1,110 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+package org.apache.lokahi.core.common.templating;
+
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.log4j.Logger;
+import org.apache.lokahi.core.api.pool.HostingPool;
+import org.apache.lokahi.core.api.template.Template;
+import org.apache.lokahi.core.common.interfaces.TemplateEngine;
+import org.apache.lokahi.core.common.interfaces.Worker;
+import org.apache.lokahi.core.common.util.TMCVelocityViewTool;
+import org.apache.lokahi.httpd.api.entity.VirtualHost;
+import org.apache.lokahi.tomcat.api.entity.TomcatContext;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.Velocity;
+
+/**
+ * VelocityTemplateBuilder
+ * Builds configuration files based on a velocity template
+ * @author The Apache Incubated Lokahi project - http://incubator.apache.org/lokahi/
+ * @version $Id$
+ */
+public class VelocityTemplateBuilder implements TemplateEngine {
+	static final Logger logger = Logger.getLogger(VelocityTemplateBuilder.class);
+
+	/**
+	 * Builds a collection of configuration files from the workers templates
+	 * @param worker - The worker whose configuration files will be built
+	 * @return A collection of the built configuration files
+	 */
+	public Collection<String> buildConfs(Object worker) {
+		Collection<String> confFiles = new ArrayList<String>();
+		StringWriter w = new StringWriter();
+		try {
+			Collection<Template> confTemplates = ((Worker) worker).getApplication().getTemplates();
+			for (Template confTemplate : confTemplates) {
+				String confFile = confTemplate.getContent();
+
+				Velocity.init();
+				VelocityContext context = new VelocityContext();
+				context.put("worker", worker); // replace the $worker with the actual worker
+				context.put("hpTool", new HostingPool());
+				context.put("vhTool", new VirtualHost());
+				context.put("contextTool", new TomcatContext());
+				context.put("view", new TMCVelocityViewTool());
+				context.put("n", '\n');
+				Velocity.evaluate(context, w, confTemplate.getName(), confFile);
+				confFiles.add(w.toString());
+			}
+		} catch (Exception e) {
+			logger.error("Exception building the cofig file: " + e.getMessage());
+		}
+	    return confFiles;
+	}
+
+	/**
+	 * Builds a configuration file from a worker and its template
+	 * @param params - An array of parameters: The worker and the template ID
+	 * @return A built configuration file
+	 */
+	public String buildConf(Object[] params) {
+		Worker worker = (Worker) params[0];
+		int id = (Integer)params[1];
+		String builtConfFile = "";
+		StringWriter w = new StringWriter();
+		try {
+			Collection<Template> confTemplates = worker.getApplication().getTemplates();
+			for (Template confTemplate : confTemplates) {
+				if (confTemplate.getPk() == id) {
+					String confFile = confTemplate.getContent();
+
+					Velocity.init();
+					VelocityContext context = new VelocityContext();
+					context.put("worker", worker); // replace the $worker with the actual worker
+					context.put("hpTool", new HostingPool());
+					context.put("vhTool", new VirtualHost());
+					context.put("contextTool", new TomcatContext());
+					context.put("view", new TMCVelocityViewTool());
+					context.put("n", '\n');
+					Velocity.evaluate(context, w, confTemplate.getName(), confFile);
+					builtConfFile = w.toString();
+					break;
+				}
+			}
+		} catch (Exception e) {
+			logger.error("Exception building the cofig file: " + e.getMessage());
+		}
+	    return builtConfFile;
+	}
+
+}

Propchange: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/templating/VelocityTemplateBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/util/TMCVelocityViewTool.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/util/TMCVelocityViewTool.java?rev=629916&r1=629915&r2=629916&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/util/TMCVelocityViewTool.java (original)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/common/util/TMCVelocityViewTool.java Thu Feb 21 10:43:55 2008
@@ -30,8 +30,10 @@
 import org.apache.lokahi.core.api.project.Project;
 import org.apache.lokahi.core.api.server.Hardware;
 import org.apache.lokahi.core.api.state.State;
+import org.apache.lokahi.core.api.template.Template;
 import org.apache.lokahi.core.api.user.User;
 import org.apache.lokahi.core.common.collection.TMCCollectionImpl;
+import org.apache.lokahi.core.common.interfaces.Collectable;
 import org.apache.lokahi.httpd.api.entity.VirtualHost;
 import org.apache.lokahi.httpd.api.pool.ApachePool;
 import org.apache.lokahi.httpd.api.server.Apache;
@@ -44,6 +46,7 @@
 import java.sql.SQLException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
 import java.util.TreeMap;
@@ -63,9 +66,7 @@
     try {
       c = Project.getProjects(name.trim() + '%');
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c;
   }
@@ -76,9 +77,7 @@
     try {
       c = Project.getProjects('%' + name.trim());
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c;
   }
@@ -89,9 +88,7 @@
     try {
       c = Project.getProjects('%' + name.trim() + '%');
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c;
   }
@@ -102,9 +99,7 @@
     try {
       c = Project.getProjects(name.trim());
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c;
   }
@@ -134,9 +129,7 @@
     try {
       jp = JobPool.getJobPool(id);
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return jp;
   }
@@ -147,9 +140,7 @@
     try {
       jp = JobPool.getJobPool(Integer.parseInt(id));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return jp;
   }
@@ -160,9 +151,7 @@
     try {
       c.addAll(HostingPool.getHostingPools());
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -172,9 +161,7 @@
     try {
       c.addAll(HostingPool.getHostingPools(ap, true));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -184,9 +171,7 @@
     try {
       c.addAll(HostingPool.getHostingPools(tp, true));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -198,9 +183,7 @@
       try {
         hp = HostingPool.getHostingPool(Integer.parseInt(id), true);
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("SQLException: " + e.getMessage());
       }
     }
     return hp;
@@ -212,9 +195,7 @@
     try {
       c.addAll(HostingPool.getHostingPools(name, true));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -225,9 +206,7 @@
     try {
       c.addAll(ApachePool.getApachePools());
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -237,9 +216,7 @@
     try {
       c.addAll(ApachePool.getApachePools(aw));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -250,9 +227,7 @@
     try {
       c.addAll(ApachePool.getApachePools(name));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -264,9 +239,7 @@
       try {
         ap = ApachePool.getApachePool(Integer.parseInt(id));
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("SQLException: " + e.getMessage());
       }
     }
     return ap;
@@ -277,9 +250,7 @@
     try {
       c.addAll(Function.getFunctions());
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -314,9 +285,7 @@
     try {
       c.addAll(TomcatPool.getTomcatPools());
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -326,9 +295,7 @@
     try {
       c.addAll(TomcatPool.getTomcatPools(tw));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -339,9 +306,7 @@
     try {
       c.addAll(TomcatPool.getTomcatPools(name));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -353,9 +318,7 @@
       try {
         tp = TomcatPool.getTomcatPool(Integer.parseInt(id));
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("SQLException: " + e.getMessage());
       }
     }
     return tp;
@@ -367,9 +330,7 @@
     try {
       c.addAll(Tomcat.getTomcats());
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -380,9 +341,7 @@
     try {
       c.addAll(Tomcat.getTomcats(name, true));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -394,9 +353,7 @@
       try {
         tc = Tomcat.getTomcat(Integer.parseInt(id), true);
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("SQLException: " + e.getMessage());
       }
     }
     return tc;
@@ -408,9 +365,7 @@
     try {
       c.addAll(TomcatWorker.getTomcatWorkers(false));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -420,9 +375,7 @@
     try {
       c.addAll(TomcatWorker.getTomcatWorkers(t, false));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("SQLException: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -433,9 +386,7 @@
     try {
       c.addAll(TomcatWorker.getTomcatWorkers(name, false));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -447,9 +398,7 @@
       try {
         tc = TomcatWorker.getTomcatWorker(Integer.parseInt(id), false);
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("Exception: " + e.getMessage());
       }
     } else {
       if (logger.isDebugEnabled()) {
@@ -469,9 +418,7 @@
       try {
         h = Hardware.getHardware(Integer.parseInt(id), true);
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("Exception: " + e.getMessage());
       }
     }
     return h;
@@ -483,9 +430,7 @@
     try {
       c.addAll(Hardware.getHardwares());
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -496,9 +441,7 @@
     try {
       c.addAll(Hardware.getHardwares(name, true));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -509,9 +452,7 @@
     try {
       c.addAll(Apache.getApaches());
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -522,9 +463,7 @@
     try {
       c.addAll(Apache.getApaches(name, true));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -536,9 +475,7 @@
       try {
         ap = Apache.getApache(Integer.parseInt(id), true);
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("Exception: " + e.getMessage());
       }
     }
     return ap;
@@ -550,9 +487,7 @@
     try {
       c.addAll(ApacheWorker.getApacheWorkers(false));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -563,9 +498,7 @@
     try {
       c.addAll(ApacheWorker.getApacheWorkers(name, false));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -577,9 +510,7 @@
       try {
         ap = ApacheWorker.getApacheWorker(Integer.parseInt(id), false);
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("Exception: " + e.getMessage());
       }
     }
     return ap;
@@ -613,9 +544,7 @@
         c = ((TMCCollectionImpl<Environment>) c).orderByName().values();
       }
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     if (logger.isDebugEnabled()) {
       logger.debug("Returning " + c);
@@ -630,9 +559,7 @@
       try {
         e = Environment.getEnviroment(Integer.parseInt(id), true);
       } catch (SQLException e1) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e1.getMessage());
-        }
+          logger.error("Exception: " + e1.getMessage());
       }
     }
     return e;
@@ -647,9 +574,7 @@
         c = ((TMCCollectionImpl<Instance>) c).orderByName().values();
       }
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     return c;
   }
@@ -661,9 +586,7 @@
       try {
         i = Instance.getInstance(Integer.parseInt(id), true);
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("Exception: " + e.getMessage());
       }
     }
     return i;
@@ -678,9 +601,7 @@
         c = ((TMCCollectionImpl<File>) c).orderByName().values();
       }
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     return c;
   }
@@ -692,23 +613,46 @@
       try {
         file = File.getFile(Integer.parseInt(id));
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("Exception: " + e.getMessage());
       }
     }
     return file;
   }
 
   /** @deprecated  */
+  public Collection<Template> getTemplates() {
+    Collection<Template> c = null;
+    try {
+      c = Template.getTemplates();
+      if (c instanceof TMCCollectionImpl) {
+        c = ((TMCCollectionImpl<Template>) c).orderByName().values();
+      }
+    } catch (SQLException e) {
+        logger.error("SQLException: " + e.getMessage());
+    }
+    return c;
+  }
+
+  /** @deprecated  */
+  public Template getTemplate(String id) {
+	Template template = null;
+    if (!"".equals(id)) {
+      try {
+    	  template = Template.getTemplate(Integer.parseInt(id));
+      } catch (SQLException e) {
+          logger.error("SQLException: " + e.getMessage());
+      }
+    }
+    return template;
+  }
+  
+  /** @deprecated  */
   public Collection<User> getUsers() {
     TMCCollectionImpl<User> c = new TMCCollectionImpl<User>();
     try {
       c.addAll(User.getAllUsers());
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -719,9 +663,7 @@
     try {
       c = User.getAllUsers();
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     TreeMap<String, User> tm = new TreeMap<String, User>();
     if (c != null) {
@@ -739,9 +681,7 @@
       try {
         user = User.getUser(Integer.parseInt(id));
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("Exception: " + e.getMessage());
       }
     }
     return user;
@@ -756,9 +696,7 @@
         c = ((TMCCollectionImpl<Ip>) c).orderByName().values();
       }
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     return c;
   }
@@ -770,9 +708,7 @@
       try {
         i = Ip.getIp(Integer.parseInt(id), true);
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("Exception: " + e.getMessage());
       }
     }
     return i;
@@ -784,9 +720,7 @@
     try {
       c.addAll(VirtualHost.getVirtualHosts());
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -797,9 +731,7 @@
     try {
       c.addAll(VirtualHost.getVirtualHosts(name));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     return c.orderByName().values();
   }
@@ -811,9 +743,7 @@
       try {
         vh = VirtualHost.getVirtualHost(Integer.parseInt(id));
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("Exception: " + e.getMessage());
       }
     }
     return vh;
@@ -829,9 +759,7 @@
         tm.put(tc.getName() + " - " + tc.getTomcatPool().getName(), tc);
       }
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     return tm.values();
   }
@@ -846,9 +774,7 @@
         tm.put(tc.getName() + " - " + tc.getTomcatPool().getName(), tc);
       }
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     return tm.values();
   }
@@ -860,9 +786,7 @@
       try {
         tc = TomcatContext.getTomcatContext(Integer.parseInt(id));
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("Exception: " + e.getMessage());
       }
     }
     return tc;
@@ -875,9 +799,7 @@
       try {
         ret.addAll(VirtualHost.getVirtualHosts(aw));
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("Exception: " + e.getMessage());
       }
     return ret;
   }
@@ -891,9 +813,7 @@
           ret.addAll(VirtualHost.getVirtualHosts(hp));
         }
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("Exception: " + e.getMessage());
       }
     return ret;
   }
@@ -904,9 +824,7 @@
       try {
         ret.addAll(VirtualHost.getVirtualHosts(hp));
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("Exception: " + e.getMessage());
       }
     return ret;
   }
@@ -917,9 +835,7 @@
       try {
         ret.addAll(TomcatContext.getTomcatContexts(tw));
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("Exception: " + e.getMessage());
       }
     return ret;
   }
@@ -930,9 +846,7 @@
       try {
         ret.addAll(TomcatContext.getTomcatContexts(tp));
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("Exception: " + e.getMessage());
       }
     return ret;
   }
@@ -944,9 +858,7 @@
         if (hp != null && hp.getTomcatPool() != null)
           ret.addAll(TomcatContext.getTomcatContexts(hp.getTomcatPool()));
       } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
+          logger.error("Exception: " + e.getMessage());
       }
     return ret;
   }
@@ -956,9 +868,7 @@
     try {
       ret.addAll(TomcatWorker.getTomcatWorkers(h, false));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     return ret;
   }
@@ -968,9 +878,7 @@
     try {
       ret.addAll(ApacheWorker.getApacheWorkers(h, false));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     return ret;
   }
@@ -980,9 +888,7 @@
     try {
       ret.addAll(ApacheWorker.getApacheWorkers(a, false));
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.info("Exception: " + e.getMessage());
-      }
+        logger.error("Exception: " + e.getMessage());
     }
     return ret;
   }
@@ -1016,15 +922,24 @@
       }
       ret = JobPool.getJobPools(u, start, end, filter, functions);
     } catch (SQLException e) {
-      if (logger.isInfoEnabled()) {
-        logger.debug("SQLException:" + e);
-      }
+        logger.error("SQLException:" + e);
     } catch (ParseException e) {
-      if (logger.isInfoEnabled()) {
-        logger.debug("ParseException:" + e);
-      }
+        logger.error("ParseException:" + e);
     }
     return ret;
   }
-
+  
+  public Collection<String> getTemplateVariables() {
+	  Collection<String> templateVariablesCol = new ArrayList<String>();
+	  String templateVariables = PropertiesFile.getConstantValue("lokahi.template.variables");
+	  for (String templateVariable : templateVariables.split(",")) {
+		  templateVariablesCol.add(templateVariable);
+	  }
+	  return templateVariablesCol;
+  }
+  
+  public Collection<Ip> getNewIpCollection() {
+	  return new TMCCollectionImpl<Ip>();
+  }
+  
 }

Modified: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/controller/task/BuildDeployApacheConfig.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/controller/task/BuildDeployApacheConfig.java?rev=629916&r1=629915&r2=629916&view=diff
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/controller/task/BuildDeployApacheConfig.java (original)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/controller/task/BuildDeployApacheConfig.java Thu Feb 21 10:43:55 2008
@@ -60,7 +60,7 @@
       Function f = Function.getFunction("PutFile");
       ApacheWorkerModel awm = new ApacheWorkerModel();
       Job j = new Job(prereq, aw.getApache().getServerRoot() + "/conf/" + PropertiesFile.getConstantValue("ApacheConfFile"), aw.getHardware(), f, jp);
-      j.setResult(awm.buildConf(aw));
+      j.setResult(awm.buildConf(aw, 1));
       j = Job.store(j);
       j = new Job(j, aw.getApache().getServerRoot() + "/conf/" + PropertiesFile.getConstantValue("WorkersProperties"), aw.getHardware(), f, jp);
       j.setResult(awm.buildWorkerProperties(aw));



Mime
View raw message