dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13892
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4573: Replaced deprecated method
------------------------------------------------------------
revno: 4573
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-09-12 16:39:31 +0200
message:
Replaced deprecated method
modified:
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/VelocityProcessor.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
=== 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-12 08:29:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ApiResource.java 2011-09-12 14:39:31 +0000
@@ -6,9 +6,7 @@
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
@@ -20,9 +18,6 @@
@ImplicitProduces( MediaType.TEXT_HTML )
public class ApiResource
{
- @Context
- UriInfo uriInfo;
-
private VelocityManager velocityManager;
public void setVelocityManager( VelocityManager velocityManager )
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/VelocityProcessor.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/VelocityProcessor.java 2011-09-12 08:29:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/VelocityProcessor.java 2011-09-12 14:39:31 +0000
@@ -5,6 +5,8 @@
import java.io.OutputStreamWriter;
import java.io.Writer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
@@ -22,6 +24,8 @@
public class VelocityProcessor
implements ViewProcessor<Template>
{
+ private static final Log log = LogFactory.getLog( VelocityProcessor.class );
+
private static final String RESOURCE_LOADER_NAME = "class";
private VelocityEngine velocity = new VelocityEngine();
@@ -42,10 +46,11 @@
final VelocityContext context = new VelocityContext();
if ( o != null )
+ {
context.put( "object", o );
+ }
velocity.getTemplate( templatePrefix + template + ".vm" ).merge( context, writer );
-
}
@Override
@@ -53,9 +58,9 @@
{
String templatePath = templatePrefix + name + ".vm";
- if ( !velocity.templateExists( templatePath ) )
+ if ( !velocity.resourceExists( templatePath ) )
{
- System.out.println("Couldn't find " + templatePath);
+ log.warn( "Template could not be found: " + templatePath );
return null;
}
try
@@ -64,7 +69,7 @@
}
catch ( Exception e )
{
- // TODO: handle
+ // TODO handle
return null;
}
}
@@ -76,6 +81,7 @@
final VelocityContext context = new VelocityContext();
Object model = viewable.getModel();
+
if (model != null)
{
context.put( "object", model );