Merge "Issue #1638 Fixed Velocity templates for windows build" into development

Former-commit-id: cab8a23ebd [formerly f3fbae64b3] [formerly cab8a23ebd [formerly f3fbae64b3] [formerly d14dfe215c [formerly 640eb368b7026651de34db2154fb955930d65040]]]
Former-commit-id: d14dfe215c
Former-commit-id: 74df582fac [formerly 0191c8bff0]
Former-commit-id: 7cae3e296e
This commit is contained in:
Nate Jensen 2013-03-15 13:49:56 -05:00 committed by Gerrit Code Review
commit 9bd1f201e3
3 changed files with 36 additions and 35 deletions

View file

@ -466,15 +466,14 @@ public abstract class PluginDataObject extends PersistableDataObject implements
} }
/** /**
* Used to determine if a given subclass exposes the IDecoderGettable * TODO: Rework non-PointDataContainer plots and remove
* interface. Normally if the class does implement the interface then a
* reference to "this" is returned. Otherwise a null reference indicates
* that the interface is not implemented.
* *
* @return The IDecoderGettable interface implementation. Null reference if * @return
* not implemented.
*/ */
public abstract IDecoderGettable getDecoderGettable(); @Deprecated
public IDecoderGettable getDecoderGettable() {
return null;
}
public void setDataURI(String dataURI) { public void setDataURI(String dataURI) {
this.dataURI = dataURI; this.dataURI = dataURI;
@ -549,4 +548,4 @@ public abstract class PluginDataObject extends PersistableDataObject implements
return result; return result;
} }
} }

View file

@ -86,14 +86,10 @@ public class VelocityManager {
if (engine == null) { if (engine == null) {
engine = new VelocityEngine(); engine = new VelocityEngine();
Properties p = new Properties(); Properties p = new Properties();
String scriptDir = globalTemplateDir.getAbsolutePath();
String rootsToCheck = scriptDir;
for (File root : File.listRoots()) {
rootsToCheck += "," + root.getAbsolutePath();
}
p.setProperty("file.resource.loader.class", p.setProperty("file.resource.loader.class",
VelocityTemplateLoader.class.getName()); VelocityTemplateLoader.class.getName());
p.setProperty("file.resource.loader.path", rootsToCheck); p.setProperty("file.resource.loader.path",
globalTemplateDir.getAbsolutePath());
p.setProperty("velocimacro.permissions.allowInline", "true"); p.setProperty("velocimacro.permissions.allowInline", "true");
p.setProperty( p.setProperty(
"velocimacro.permissions.allow.inline.to.replace.global", "velocimacro.permissions.allow.inline.to.replace.global",

View file

@ -23,6 +23,9 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.collections.ExtendedProperties; import org.apache.commons.collections.ExtendedProperties;
import org.apache.velocity.exception.ResourceNotFoundException; import org.apache.velocity.exception.ResourceNotFoundException;
@ -42,7 +45,7 @@ import org.apache.velocity.runtime.resource.loader.FileResourceLoader;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 04/17/2008 1088 chammack Initial Creation. * 04/17/2008 1088 chammack Initial Creation.
* 06/01/2012 DR 14555 D. Friedman Support new version of Velocity. * 06/01/2012 DR 14555 D. Friedman Support new version of Velocity.
* 03/12/2013 1638 njensen Move to new plugin and rename * 03/12/2013 1638 njensen Move to new plugin and rename
* *
* *
* </pre> * </pre>
@ -53,7 +56,7 @@ import org.apache.velocity.runtime.resource.loader.FileResourceLoader;
public class VelocityTemplateLoader extends FileResourceLoader { public class VelocityTemplateLoader extends FileResourceLoader {
private String path; private List<String> paths = new ArrayList<String>();
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -63,8 +66,7 @@ public class VelocityTemplateLoader extends FileResourceLoader {
*/ */
@Override @Override
public long getLastModified(Resource resource) { public long getLastModified(Resource resource) {
File file = new File(resource.getName()); return resolvePath(resource.getName()).lastModified();
return file.lastModified();
} }
/* /*
@ -74,11 +76,10 @@ public class VelocityTemplateLoader extends FileResourceLoader {
* getResourceStream(java.lang.String) * getResourceStream(java.lang.String)
*/ */
@Override @Override
public InputStream getResourceStream(String arg0) public InputStream getResourceStream(String resource)
throws ResourceNotFoundException { throws ResourceNotFoundException {
try { try {
FileInputStream fis = new FileInputStream(resolvePath(arg0)); return new FileInputStream(resolvePath(resource));
return fis;
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw new ResourceNotFoundException(e); throw new ResourceNotFoundException(e);
} }
@ -92,8 +93,8 @@ public class VelocityTemplateLoader extends FileResourceLoader {
* .apache.commons.collections.ExtendedProperties) * .apache.commons.collections.ExtendedProperties)
*/ */
@Override @Override
public void init(ExtendedProperties arg0) { public void init(ExtendedProperties props) {
this.path = arg0.getString("path"); this.paths.addAll(Arrays.asList(props.getStringArray("path")));
} }
/* /*
@ -103,24 +104,29 @@ public class VelocityTemplateLoader extends FileResourceLoader {
* isSourceModified(org.apache.velocity.runtime.resource.Resource) * isSourceModified(org.apache.velocity.runtime.resource.Resource)
*/ */
@Override @Override
public boolean isSourceModified(Resource arg0) { public boolean isSourceModified(Resource rsc) {
File file = new File(arg0.getName()); File file = resolvePath(rsc.getName());
return (file.lastModified() != arg0.getLastModified()); return (file.lastModified() != rsc.getLastModified());
} }
@Override @Override
public boolean resourceExists(String name) { public boolean resourceExists(String name) {
File f = new File(resolvePath(name)); return resolvePath(name).exists();
return f.isFile();
} }
private String resolvePath(String arg0) { private File resolvePath(String path) {
String dir = null; File file = new File(path);
if (arg0.startsWith(File.separator) || arg0.charAt(1) == ':') // Win32 if (file.isAbsolute()) {
dir = arg0; // Absolute path, always use
else return file;
dir = this.path + File.separator + arg0; }
return dir; for (String p : paths) {
File tmpFile = new File(p, path);
if (tmpFile.exists()) {
return tmpFile;
}
}
return file;
} }
} }