Issue #1638 fix velocity on windows

Change-Id: Iacac3c6a76c5d05840606c301fa640b607cb741a

Former-commit-id: 5e545cc9c4 [formerly 863d4cf3df] [formerly 5e545cc9c4 [formerly 863d4cf3df] [formerly cbf0343d72 [formerly bfd5c809b8fd40aacd199c4ccb8bbdbea972e13b]]]
Former-commit-id: cbf0343d72
Former-commit-id: 35d0187e3d [formerly b00ccd2b77]
Former-commit-id: d8197235fe
This commit is contained in:
Nate Jensen 2013-03-12 16:04:59 -05:00
parent 833d616ab5
commit 52139d5bcf
13 changed files with 201 additions and 11 deletions

View file

@ -92,6 +92,7 @@ Import-Package: com.raytheon.uf.common.alertmonitor,
com.raytheon.uf.common.time.adapter,
com.raytheon.uf.common.time.util,
com.raytheon.uf.common.topo,
com.raytheon.uf.common.velocity,
org.apache.log4j,
org.apache.log4j.spi
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

View file

@ -44,7 +44,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.uf.common.util.velocity.VelocityManager;
import com.raytheon.uf.common.velocity.VelocityManager;
import com.raytheon.uf.viz.core.Activator;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.localization.LocalizationManager;

View file

@ -48,6 +48,7 @@ Import-Package: com.raytheon.edex.colormap,
com.raytheon.uf.common.serialization,
com.raytheon.uf.common.time,
com.raytheon.uf.common.util,
com.raytheon.uf.common.velocity,
com.raytheon.uf.edex.core,
com.raytheon.uf.edex.core.props,
com.raytheon.uf.edex.database,

View file

@ -25,7 +25,7 @@ import java.util.HashMap;
import java.util.Map;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.util.velocity.VelocityManager;
import com.raytheon.uf.common.velocity.VelocityManager;
import com.raytheon.uf.edex.core.props.EnvProperties;
import com.raytheon.uf.edex.core.props.PropertiesFactory;

View file

@ -124,7 +124,7 @@
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.junit"
download-size="0"
@ -308,7 +308,7 @@
download-size="0"
install-size="0"
version="0.0.0"/>
<plugin
id="org.jep.linux32"
os="linux"
@ -361,4 +361,11 @@
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.common.velocity"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>

View file

@ -8,13 +8,11 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.junit;bundle-version="1.0.0",
org.apache.commons.beanutils;bundle-version="1.8.3",
com.raytheon.uf.common.status;bundle-version="1.12.1174",
org.apache.commons.lang;bundle-version="2.3.0",
org.apache.velocity;bundle-version="1.7.0"
org.apache.commons.lang;bundle-version="2.3.0"
Export-Package: com.raytheon.uf.common.util,
com.raytheon.uf.common.util.algorithm,
com.raytheon.uf.common.util.cache,
com.raytheon.uf.common.util.header,
com.raytheon.uf.common.util.mapping,
com.raytheon.uf.common.util.registry,
com.raytheon.uf.common.util.session,
com.raytheon.uf.common.util.velocity
com.raytheon.uf.common.util.session

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.common.velocity</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,8 @@
#Tue Mar 12 15:42:20 CDT 2013
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,11 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Velocity
Bundle-SymbolicName: com.raytheon.uf.common.velocity
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.apache.velocity;bundle-version="1.7.0",
com.raytheon.uf.common.util
Import-Package: org.apache.commons.collections
Export-Package: com.raytheon.uf.common.velocity

View file

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.util.velocity;
package com.raytheon.uf.common.velocity;
import java.io.File;
import java.io.StringWriter;
@ -29,7 +29,6 @@ import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.runtime.resource.loader.FileResourceLoader;
import com.raytheon.uf.common.util.FileUtil;
@ -93,7 +92,7 @@ public class VelocityManager {
rootsToCheck += "," + root.getAbsolutePath();
}
p.setProperty("file.resource.loader.class",
FileResourceLoader.class.getName());
VelocityTemplateLoader.class.getName());
p.setProperty("file.resource.loader.path", rootsToCheck);
p.setProperty("velocimacro.permissions.allowInline", "true");
p.setProperty(

View file

@ -0,0 +1,126 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.velocity;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import org.apache.commons.collections.ExtendedProperties;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.resource.Resource;
import org.apache.velocity.runtime.resource.loader.FileResourceLoader;
/**
* Provides a velocity file loading strategy that allows absolute path-based
* script loading.
*
* Traditional velocity file loader requires all scripts to be in a single
* declared directory.
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 04/17/2008 1088 chammack Initial Creation.
* 06/01/2012 DR 14555 D. Friedman Support new version of Velocity.
* 03/12/2013 1638 njensen Move to new plugin and rename
*
*
* </pre>
*
* @author chammack
* @version 1.0
*/
public class VelocityTemplateLoader extends FileResourceLoader {
private String path;
/*
* (non-Javadoc)
*
* @see org.apache.velocity.runtime.resource.loader.FileResourceLoader#
* getLastModified(org.apache.velocity.runtime.resource.Resource)
*/
@Override
public long getLastModified(Resource resource) {
File file = new File(resource.getName());
return file.lastModified();
}
/*
* (non-Javadoc)
*
* @see org.apache.velocity.runtime.resource.loader.FileResourceLoader#
* getResourceStream(java.lang.String)
*/
@Override
public InputStream getResourceStream(String arg0)
throws ResourceNotFoundException {
try {
FileInputStream fis = new FileInputStream(resolvePath(arg0));
return fis;
} catch (FileNotFoundException e) {
throw new ResourceNotFoundException(e);
}
}
/*
* (non-Javadoc)
*
* @see
* org.apache.velocity.runtime.resource.loader.FileResourceLoader#init(org
* .apache.commons.collections.ExtendedProperties)
*/
@Override
public void init(ExtendedProperties arg0) {
this.path = arg0.getString("path");
}
/*
* (non-Javadoc)
*
* @see org.apache.velocity.runtime.resource.loader.FileResourceLoader#
* isSourceModified(org.apache.velocity.runtime.resource.Resource)
*/
@Override
public boolean isSourceModified(Resource arg0) {
File file = new File(arg0.getName());
return (file.lastModified() != arg0.getLastModified());
}
@Override
public boolean resourceExists(String name) {
File f = new File(resolvePath(name));
return f.isFile();
}
private String resolvePath(String arg0) {
String dir = null;
if (arg0.startsWith(File.separator) || arg0.charAt(1) == ':') // Win32
dir = arg0;
else
dir = this.path + File.separator + arg0;
return dir;
}
}