diff --git a/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF index 1b21b95dfe..93deaa6520 100644 --- a/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.core/META-INF/MANIFEST.MF @@ -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 diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/catalog/ScriptCreator.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/catalog/ScriptCreator.java index 0242ae4853..f625725d23 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/catalog/ScriptCreator.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/catalog/ScriptCreator.java @@ -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; diff --git a/edexOsgi/com.raytheon.edex.uengine/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.edex.uengine/META-INF/MANIFEST.MF index 81f767dbbd..6a486587c4 100644 --- a/edexOsgi/com.raytheon.edex.uengine/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.edex.uengine/META-INF/MANIFEST.MF @@ -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, diff --git a/edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/web/ScriptTestDriver.java b/edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/web/ScriptTestDriver.java index b34966d018..2b96eb5312 100644 --- a/edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/web/ScriptTestDriver.java +++ b/edexOsgi/com.raytheon.edex.uengine/src/com/raytheon/edex/uengine/web/ScriptTestDriver.java @@ -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; diff --git a/edexOsgi/com.raytheon.uf.common.base.feature/feature.xml b/edexOsgi/com.raytheon.uf.common.base.feature/feature.xml index 412c2adebc..2a4d7989f7 100644 --- a/edexOsgi/com.raytheon.uf.common.base.feature/feature.xml +++ b/edexOsgi/com.raytheon.uf.common.base.feature/feature.xml @@ -124,7 +124,7 @@ install-size="0" version="0.0.0" unpack="false"/> - + - + + + diff --git a/edexOsgi/com.raytheon.uf.common.util/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.util/META-INF/MANIFEST.MF index 846d88fae2..f21072c209 100644 --- a/edexOsgi/com.raytheon.uf.common.util/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.util/META-INF/MANIFEST.MF @@ -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 diff --git a/edexOsgi/com.raytheon.uf.common.velocity/.classpath b/edexOsgi/com.raytheon.uf.common.velocity/.classpath new file mode 100644 index 0000000000..ad32c83a78 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.velocity/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.common.velocity/.project b/edexOsgi/com.raytheon.uf.common.velocity/.project new file mode 100644 index 0000000000..7accc5d249 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.velocity/.project @@ -0,0 +1,28 @@ + + + com.raytheon.uf.common.velocity + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/edexOsgi/com.raytheon.uf.common.velocity/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.common.velocity/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..75ea8a9bbb --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.velocity/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/edexOsgi/com.raytheon.uf.common.velocity/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.velocity/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..2e37736cfd --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.velocity/META-INF/MANIFEST.MF @@ -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 diff --git a/edexOsgi/com.raytheon.uf.common.velocity/build.properties b/edexOsgi/com.raytheon.uf.common.velocity/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.velocity/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/velocity/VelocityManager.java b/edexOsgi/com.raytheon.uf.common.velocity/src/com/raytheon/uf/common/velocity/VelocityManager.java similarity index 96% rename from edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/velocity/VelocityManager.java rename to edexOsgi/com.raytheon.uf.common.velocity/src/com/raytheon/uf/common/velocity/VelocityManager.java index 3572f65bf7..e219b8fae5 100644 --- a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/velocity/VelocityManager.java +++ b/edexOsgi/com.raytheon.uf.common.velocity/src/com/raytheon/uf/common/velocity/VelocityManager.java @@ -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( diff --git a/edexOsgi/com.raytheon.uf.common.velocity/src/com/raytheon/uf/common/velocity/VelocityTemplateLoader.java b/edexOsgi/com.raytheon.uf.common.velocity/src/com/raytheon/uf/common/velocity/VelocityTemplateLoader.java new file mode 100644 index 0000000000..c2ada1c989 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.velocity/src/com/raytheon/uf/common/velocity/VelocityTemplateLoader.java @@ -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. + * + *
+ * 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
+ * 
+ * 
+ * 
+ * + * @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; + } + +}