dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14386
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4877: Generalized and moved VelocityManager from dhis-web-api to dhis-support-system
------------------------------------------------------------
revno: 4877
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-10-07 12:08:02 +0200
message:
Generalized and moved VelocityManager from dhis-web-api to dhis-support-system
added:
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/velocity/
renamed:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/VelocityManager.java => dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/velocity/VelocityManager.java
modified:
dhis-2/dhis-support/dhis-support-system/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/ResponseUtils.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ApiResource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetResource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetsResource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataValueSetsResource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitsResource.java
dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/velocity/VelocityManager.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== added directory 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/velocity'
=== renamed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/VelocityManager.java' => 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/velocity/VelocityManager.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/VelocityManager.java 2011-09-13 11:10:12 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/velocity/VelocityManager.java 2011-10-07 10:08:02 +0000
@@ -1,4 +1,31 @@
-package org.hisp.dhis.web.api.resources;
+package org.hisp.dhis.system.velocity;
+
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
import java.io.StringWriter;
@@ -9,9 +36,11 @@
public class VelocityManager
{
+ public static final String CONTEXT_KEY = "object";
+
private static final String RESOURCE_LOADER_NAME = "class";
+ private static final String VM_SUFFIX = ".vm";
private VelocityEngine velocity;
- private String templatePath = "dhis-web-api/";
public VelocityManager() throws Exception
{
@@ -31,10 +60,10 @@
if ( object != null )
{
- context.put( "object", object );
+ context.put( CONTEXT_KEY, object );
}
- velocity.getTemplate( templatePath + template + ".vm" ).merge( context, writer );
+ velocity.getTemplate( template + VM_SUFFIX ).merge( context, writer );
return writer.toString();
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-support/dhis-support-system/src/main/resources/META-INF/dhis/beans.xml 2011-06-23 14:44:17 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/resources/META-INF/dhis/beans.xml 2011-10-07 10:08:02 +0000
@@ -25,5 +25,7 @@
<property name="taskScheduler" ref="taskScheduler" />
<property name="taskExecutor" ref="taskScheduler" />
</bean>
+
+ <bean id="org.hisp.dhis.system.velocity.VelocityManager" class="org.hisp.dhis.system.velocity.VelocityManager" />
</beans>
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/ResponseUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/ResponseUtils.java 2011-09-18 14:36:11 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/ResponseUtils.java 2011-10-07 10:08:02 +0000
@@ -7,6 +7,8 @@
public class ResponseUtils
{
+ public static final String TEMPLATE_PATH = "dhis-web-api/";
+
public static ResponseBuilder response( boolean disallowCache,
String filename, boolean attachment )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ApiResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ApiResource.java 2011-09-13 11:10:12 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ApiResource.java 2011-10-07 10:08:02 +0000
@@ -10,6 +10,8 @@
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
+import org.hisp.dhis.system.velocity.VelocityManager;
+import org.hisp.dhis.web.api.ResponseUtils;
import org.springframework.beans.factory.annotation.Required;
import com.sun.jersey.api.view.ImplicitProduces;
@@ -25,7 +27,7 @@
public String getDescription()
throws ResourceNotFoundException, ParseErrorException, MethodInvocationException, IOException, Exception
{
- return velocityManager.render( null, "index" );
+ return velocityManager.render( null, ResponseUtils.TEMPLATE_PATH + "index" );
}
@Required
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetResource.java 2011-09-16 10:31:28 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetResource.java 2011-10-07 10:08:02 +0000
@@ -13,6 +13,8 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.importexport.dxf2.service.DataSetMapper;
+import org.hisp.dhis.system.velocity.VelocityManager;
+import org.hisp.dhis.web.api.ResponseUtils;
import org.hisp.dhis.web.api.UrlResourceListener;
import org.springframework.beans.factory.annotation.Required;
@@ -92,6 +94,6 @@
throw new IllegalArgumentException( "No dataset with uuid " + uuid );
}
- return velocityManager.render( dataSet, "dataSet" );
+ return velocityManager.render( dataSet, ResponseUtils.TEMPLATE_PATH + "dataSet" );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetsResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetsResource.java 2011-09-16 15:59:35 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataSetsResource.java 2011-10-07 10:08:02 +0000
@@ -20,7 +20,9 @@
import org.hisp.dhis.importexport.dxf2.model.DataSetLinks;
import org.hisp.dhis.importexport.dxf2.service.LinkBuilder;
import org.hisp.dhis.importexport.dxf2.service.LinkBuilderImpl;
+import org.hisp.dhis.system.velocity.VelocityManager;
import org.hisp.dhis.util.ContextUtils;
+import org.hisp.dhis.web.api.ResponseUtils;
import org.hisp.dhis.web.api.UrlResourceListener;
import org.springframework.beans.factory.annotation.Required;
@@ -98,6 +100,6 @@
{
DataSetLinks dataSetLinks = new DataSetLinks( linkBuilder.getLinks( dataSetService.getAllDataSets() ) );
new UrlResourceListener( uriInfo ).beforeMarshal( dataSetLinks );
- return velocityManager.render( dataSetLinks.getDataSet(), "dataSets" );
+ return velocityManager.render( dataSetLinks.getDataSet(), ResponseUtils.TEMPLATE_PATH + "dataSets" );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataValueSetsResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataValueSetsResource.java 2011-09-15 14:08:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/DataValueSetsResource.java 2011-10-07 10:08:02 +0000
@@ -13,6 +13,8 @@
import org.hisp.dhis.importexport.dxf2.model.DataValueSet;
import org.hisp.dhis.importexport.dxf2.service.DataValueSetService;
+import org.hisp.dhis.system.velocity.VelocityManager;
+import org.hisp.dhis.web.api.ResponseUtils;
import org.springframework.beans.factory.annotation.Required;
@Path( "dataValueSets" )
@@ -30,7 +32,7 @@
public String getDescription()
{
URI uri = uriInfo.getBaseUriBuilder().path( DataSetsResource.class ).build( );
- return velocityManager.render( uri, "dataValueSets" );
+ return velocityManager.render( uri, ResponseUtils.TEMPLATE_PATH + "dataValueSets" );
}
@POST
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitsResource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitsResource.java 2011-09-13 11:10:12 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/OrgUnitsResource.java 2011-10-07 10:08:02 +0000
@@ -11,6 +11,8 @@
import org.hisp.dhis.importexport.dxf2.service.LinkBuilder;
import org.hisp.dhis.importexport.dxf2.service.LinkBuilderImpl;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.system.velocity.VelocityManager;
+import org.hisp.dhis.web.api.ResponseUtils;
import org.hisp.dhis.web.api.UrlResourceListener;
import org.springframework.beans.factory.annotation.Required;
@@ -41,7 +43,7 @@
{
OrgUnitLinks orgUnitLinks = new OrgUnitLinks( linkBuilder.getLinks( organisationUnitService.getAllOrganisationUnits() ) );
new UrlResourceListener( uriInfo ).beforeMarshal( orgUnitLinks );
- return velocityManager.render( orgUnitLinks.getOrgUnit(), "orgUnits" );
+ return velocityManager.render( orgUnitLinks.getOrgUnit(), ResponseUtils.TEMPLATE_PATH + "orgUnits" );
}
@Required
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml 2011-09-21 17:22:32 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/beans.xml 2011-10-07 10:08:02 +0000
@@ -6,30 +6,30 @@
<!-- Resources -->
<bean id="org.hisp.dhis.web.api.resources.ApiResource" class="org.hisp.dhis.web.api.resources.ApiResource">
- <property name="velocityManager" ref="org.hisp.dhis.web.api.resources.VelocityManager" />
+ <property name="velocityManager" ref="org.hisp.dhis.system.velocity.VelocityManager" />
</bean>
<bean id="org.hisp.dhis.web.api.resources.DataSetsResource" class="org.hisp.dhis.web.api.resources.DataSetsResource"
scope="prototype">
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
- <property name="velocityManager" ref="org.hisp.dhis.web.api.resources.VelocityManager" />
+ <property name="velocityManager" ref="org.hisp.dhis.system.velocity.VelocityManager" />
</bean>
<bean id="org.hisp.dhis.web.api.resources.DataSetResource" class="org.hisp.dhis.web.api.resources.DataSetResource"
scope="prototype">
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
- <property name="velocityManager" ref="org.hisp.dhis.web.api.resources.VelocityManager" />
+ <property name="velocityManager" ref="org.hisp.dhis.system.velocity.VelocityManager" />
</bean>
<bean id="org.hisp.dhis.web.api.resources.DataValueSetResource" class="org.hisp.dhis.web.api.resources.DataValueSetsResource">
<property name="dataValueSetService" ref="org.hisp.dhis.importexport.dxf2.service.DataValueSetService" />
- <property name="velocityManager" ref="org.hisp.dhis.web.api.resources.VelocityManager" />
+ <property name="velocityManager" ref="org.hisp.dhis.system.velocity.VelocityManager" />
</bean>
<bean id="org.hisp.dhis.web.api.resources.OrgUnitsResource" class="org.hisp.dhis.web.api.resources.OrgUnitsResource"
scope="prototype">
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
- <property name="velocityManager" ref="org.hisp.dhis.web.api.resources.VelocityManager" />
+ <property name="velocityManager" ref="org.hisp.dhis.system.velocity.VelocityManager" />
</bean>
<bean id="org.hisp.dhis.web.api.resources.OrgUnitResource" class="org.hisp.dhis.web.api.resources.OrgUnitResource"
@@ -66,6 +66,4 @@
<property name="dataElementCategoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
</bean>
- <bean id="org.hisp.dhis.web.api.resources.VelocityManager" class="org.hisp.dhis.web.api.resources.VelocityManager" />
-
</beans>